Visible to Intel only — GUID: GUID-638CE46F-977E-42BB-B1E4-852C7753ED82
Visible to Intel only — GUID: GUID-638CE46F-977E-42BB-B1E4-852C7753ED82
NULLIFY
Statement: Disassociates a pointer from a target.
NULLIFY (pointer-object[,pointer-object]...)
pointer-object |
Is a structure component, the name of a variable, or the name of a procedure pointer. It must have the POINTER attribute. Each pointer-object may not depend on the value, bounds or association of another pointer object in the same NULLIFY statement. |
Description
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.
When a polymorphic pointer is nullified, its dynamic type becomes its declared type.
Example
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.
The following shows another example:
! POINTER2.F90 Pointing at a Pointer and Target
!DIR$ FIXEDFORMLINESIZE:80
REAL, POINTER :: arrow1 (:)
REAL, POINTER :: arrow2 (:)
REAL, ALLOCATABLE, TARGET :: bullseye (:)
ALLOCATE (bullseye (7))
bullseye = 1.
bullseye (1:7:2) = 10.
WRITE (*,'(/1x,a,7f8.0)') 'target ',bullseye
arrow1 => bullseye
WRITE (*,'(/1x,a,7f8.0)') 'pointer',arrow1
arrow2 => arrow1
IF (ASSOCIATED(arrow2)) WRITE (*,'(/a/)') ' ARROW2 is pointed.'
WRITE (*,'(1x,a,7f8.0)') 'pointer',arrow2
NULLIFY (arrow2)
IF (.NOT.ASSOCIATED(arrow2)) WRITE (*,'(/a/)') ' ARROW2 is not pointed.'
WRITE (*,'( 1x,a,7f8.0)') 'pointer',arrow1
WRITE (*,'(/1x,a,7f8.0)') 'target ',bullseye
END