ASSOCIATED

Inquiry Intrinsic Function (Generic): Returns the association status of its pointer argument or indicates whether the pointer is associated with the target.

Syntax

result = ASSOCIATED (pointer [, target])

pointer
(Input) Must be a pointer (of any data type).

target
(Optional; input) 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 option /integer_size can affect this function.

Compatibility

CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB

See Also: ALLOCATED, POINTER, TARGET

Example

REAL C (:), D(:), E(5)
POINTER C, D
ARGET 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