HP Fortran Programmer's Reference (September 2007)

Data types and data objects
Pointers
Chapter 5134
! is explicit to the caller. Internal procedures have an
! explicit interface. If this were an external procedure,
! its interface would have to be declared in an interface
! block to be explicit.
SUBROUTINE get_ptr_sts
IF (ASSOCIATED(ptr, tgt)) THEN
PRINT *, " Pointer is associated with target."
ELSE
PRINT *, " Pointer is disassociated from target."
END IF
END SUBROUTINE get_ptr_sts
END PROGRAM main
Here are the command lines to compile and execute the program, along with the output from
a sample run:
$ f90 ptr_sts.f90
$ a.out
Initial status of pointer:
Pointer is disassociated from target.
Status after pointer assignment:
Pointer is associated with target.
Contents of target by reference to pointer: -2.2 -1.1
Contents of target after assignment to pointer: 1.1 2.2
Status after pointer is nullified:
Pointer is disassociated from target.
Status after pointer is allocated:
Pointer is allocated.
Contents of array pointer: 3.3 4.4 5.5 6.6 7.7
Status after array pointer is deallocated:
Pointer is deallocated.