LF Fortran 95



The ASSOCIATED function indicates whether a pointer is associated or disassociated. It may also test a pointer for association with a particular target.


ASSOCIATED (pointer[, target])

Required Arguments

pointer is an INTENT(IN) variable with the pointer attribute whose association status is either associated or disassociated. The association status of pointer must not be undefined.

Optional Arguments

target is INTENT(IN) and must have either the pointer or target attribute. If it is a pointer, its pointer association status must not be undefined.


The result is of type default LOGICAL.

When target is absent, the result is true if pointer is currently associated with a target. If pointer is disassociated, the result is false.

When target is present, the result is true if pointer is currently associated with target. The result is false if pointer is disassociated or associated with a different target.

If target has the pointer attribute, the result is true if both pointer and target are currently associated with the same target. If either pointer or target is disassociated, or if they are associated with different targets, the result is false.


real,pointer :: a(:) real,allocatable, target :: b(:) write (*,*) associated(a) ! pointer disassociated by default allocate(a(4)) ! a is associated write (*,*) associated(a) deallocate(a) ! a is disassociated write (*,*) associated(a) allocate(b(5)) a => b ! a is associated with b write (*,*) associated(a,b) deallocate(b) ! careful, a is undefined!!! a => null() ! a is disassociated write(*,*) associated(a)