Disassociates a pointer from a target.
Syntax
NULLIFY (pointer-object-list) |
- pointer-object-list
is a comma-separated list of variable names and
derived-type components.
Description
The NULLIFY
statement disassociates a pointer from any target. A NULLIFY
statement is also used to change the status of a pointer from undefined
to disassociated.
Examples
The following example shows the declaration and use of a variable
with the pointer attribute:
REAL, TARGET :: value ! value can be target REAL, POINTER :: pt ! for the pointer pt.pt => value ! Associate pt with value NULLIFY (pt) ! Disassociate pt ! ASSOCIATED intrinsic is valid in next statement if (and only ! if) pt has been previously allocated, assigned (as above), or ! nullified (as above) IF (.NOT.ASSOCIATED(pt)) pt => x |
The next example shows how a derived type can be used in list
processing applications:
TYPE list_node INTEGER value TYPE (list_node), POINTER :: next END TYPE list_node TYPE (list_node), POINTER :: list ALLOCATE (list) ! Create new list node list % value = 28 ! Initialize data field NULLIFY (list % next) ! Nullify pointer to the next node |
Related statements
ALLOCATE,
DEALLOCATE, POINTER,
and TARGET
Related concepts
For information about pointers, see “Pointers”.