next up previous contents
Next: Dynamic Targets Up: Pointers and Targets Previous: Example: Array swapping   Contents

Status of a Pointer

Pointer Status:

For example, the declaration


leaves PtoR in undefined association status. We can bind the pointer to a target


which changes the pointer status to associated. Finally, we can break the association with the target (without setting PtoR to point to a different target) by
nullify(PtoR)
PtoR has now the ``Null'' values, and its status is disassociated.

The association status may be tested using the logical intrinsic function

associated(PtoR)
which returns .TRUE. if the pointer is associated, .FALSE. if not associated, or undefined if the pointer itself is undefined (because of this, it is a good idea to NULLIFY all pointers right after the declarations).

We can test the target of the pointer,

associated(PtoR,x)
which returns .TRUE. if the pointer is defined and associated to the specific target x, and .FALSE. otherwise.

The function is useful to avoid deallocation errors

if ( associated(PtoA) ) deallocate(PtoA, STAT=ierr)


next up previous contents
Next: Dynamic Targets Up: Pointers and Targets Previous: Example: Array swapping   Contents
Adrian Sandu 2001-08-26