Intel® Fortran Compiler 17.0 Developer Guide and Reference
Inquiry Intrinsic Function (Generic): Returns the association status of its pointer argument or indicates whether the pointer is associated with the target.
result = ASSOCIATED (pointer [, target])
pointer |
(Input) Must be a pointer. It can be of any data type. The pointer association status must be defined. |
target |
(Input; optional) Must be a pointer or target. If it is a pointer, the pointer association status must be defined. |
The result is a scalar of type default logical. The setting of compiler options specifying integer size can affect this function.
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.)
REAL C (:), D(:), E(5)
POINTER C, D
TARGET E
LOGICAL STATUS
C => E ! pointer assignment
D => E ! pointer assignment
STATUS = ASSOCIATED(C) ! returns TRUE; C is associated
STATUS = ASSOCIATED(C, E) ! returns TRUE; C is associated with E
STATUS = ASSOCIATED (C, D) ! returns TRUE; C and D are associated
! with the same target
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