Description: | Returns the association status of its pointer argument or indicates whether the pointer is associated with the target. | ||
Class: | Inquiry function; Generic | ||
Arguments: | POINTER | Must be a pointer (of any data type). | |
TARGET (opt) | Must be a pointer or target. | ||
The pointer (in POINTER or TARGET) must not have an association status that is undefined. | |||
Results: | The
result is a scalar of type default logical.
If only POINTER appears, the result is true if it is currently associated with a target; otherwise, the result is false. If TARGET also appears and is a target, the result is true if POINTER is currently associated with TARGET; otherwise, the result is false. If TARGET is a pointer, the result is true if both POINTER and TARGET are currently associated with the same target; otherwise, the result is false. (If either POINTER or TARGET is disassociated, the result is false.) The setting of compiler options specifying integer size can affect this function. |
Examples
Consider the following:
REAL, TARGET, DIMENSION (0:50) :: TAR
REAL, POINTER, DIMENSION (:) :: PTR
PTR => TAR
PRINT *, ASSOCIATED (PTR, TAR) ! Returns the value true
The subscript range for PTR is 0:50. Consider the following pointer assignment statements:
(1) PTR => TAR (:)
(2) PTR => TAR (0:50)
(3) PTR => TAR (0:49)
For statements 1 and 2, ASSOCIATED (PTR, TAR) is true because TAR has not changed (the subscript range for PTR in both cases is 1:51, following the rules for deferred-shape arrays). For statement 3, ASSOCIATED (PTR, TAR) is false because the upper bound of TAR has changed.
Consider the following:
REAL, POINTER, DIMENSION (:) :: PTR2, PTR3
ALLOCATE (PTR2 (0:15))
PTR3 => PTR2
PRINT *, ASSOCIATED (PTR2, PTR3) ! Returns the value true
...
NULLIFY (PTR2)
NULLIFY (PTR3)
PRINT *, ASSOCIATED (PTR2, PTR3) ! Returns the value false