ASSOCIATED (pointer [,target])
Class: Inquiry function - Generic
Returns the association status of its pointer argument or indicates
whether the pointer is associated with the target. The pointer
must not have an undefined association status.
The "target" can be a pointer or target.
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 integer size compiler options 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 PTR 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