# 6.3 NULLIFY Statement

The NULLIFY statement disassociates a pointer from its target. It takes the following form:

  NULLIFY (pointer-object [, pointer-object]...)
  pointer-object
  Is a structure component or the name of a variable; it must be a pointer (have the POINTER attribute).

Rules and Behavior

The initial association status of a pointer is undefined. You can use NULLIFY to initialize an undefined pointer, giving it disassociated status. Then the pointer can be tested using the intrinsic function ASSOCIATED.

Examples

The following is an example of the NULLIFY statement:

    REAL, TARGET  :: TAR(0:50)
    REAL, POINTER :: PTR_A(:), PTR_B(:)
    PTR_A => TAR
    PTR_B => TAR
    ...
    NULLIFY(PTR_A)

After these statements are executed, PTR_A will have disassociated status, while PTR_B will continue to be associated with variable TAR.

For More Information:

- On the POINTER attribute, see Section 5.15.
- On pointer assignment, see Section 4.2.3.
- On the ASSOCIATED intrinsic function, see Section 9.3.16.
- On the NULL intrinsic function, which can also be used to disassociate a pointer, see Section 9.3.111.

Previous Page Next Page Table of Contents