This is G o o g l e's cache of http://www.man.ac.uk/hpctec/courses/Fortran90/Fortran90_48.html.
G o o g l e's cache is the snapshot that we took of the page as we crawled the web.
The page may have changed since that time. Click here for the current page without highlighting.


Google is not affiliated with the authors of this page nor responsible for its content.
These search terms have been highlighted: fortran90 pointer undefined 

5.4 Pointer Association Status [Next: Dynamic Storage] [Prev: Pointer Assignments] [Up]: Pointer Variables] [Top: Fortran90]

5 Pointer Variables


5.4 Pointer Association Status

Every pointer has one of the following three association states:

  1. Undefined - when it is initially specified in a type declaration statement.

  2. Null (disassociated) - when it is nullified by a NULLIFY statement.

  3. Associated - when it points to a target.

A pointer may be explicitly disassociated from its target and set to point at `nothing' by executing a NULLIFY statement, whose general form is

NULLIFY(list of pointers)
The intrinsic function ASSOCIATED can be used to test the association status of a pointer with one argument or with two:

ASSOCIATED(p, [,t])
When t is absent, it returns the logical value .TRUE. if the pointer p is currently associated with a target and .FALSE. otherwise. If t is present and is a target variable, it returns .TRUE. if the pointer p is associated with t and .FALSE. otherwise. The second argument t may itself be a pointer, in which case it returns .TRUE. if both pointers are associated to the same target or disassociated and .FALSE. otherwise.

There is one restriction concerning the use of this function, that is the pointer argument must not have an undefined pointer association status. Therefore, it is recommended that a pointer should always be either associated with a target immediately after its declaration, or nullified by the NULLIFY statement to ensure its null status.

The following code shows the status of pointers at different stages:

REAL, POINTER :: p, q                         ! undefined association status
REAL, TARGET :: t = 3.4 
p => t                        ! p points to t1
q => t                        ! q also points to t1
PRINT *, "After p => t, ASSOCIATED(p) = ", ASSOCIATED(p)     ! .T.
PRINT *, "ASSOCIATED(p, q) = ", ASSOCIATED(p, q)             ! .T.
NULLIFY(p)
PRINT *, "After NULLIFY(p), ASSOCIATED(p) = ", ASSOCIATED(p) ! .F.
PRINT *, "ASSOCIATED(p, q) = ", ASSOCIATED(p, q)             ! .F.
...
p => t                        ! p points to t2
NULLIFY(p, q)
Note that the disassociation of p did not affect q even though they were both pointing at the same object. After being nullified, p can be associated again either with the same or different object later. The last line just illustrates that a NULLIFY statement can have more than one pointer argument.


[Next: Dynamic Storage] [Prev: Pointer Assignments] [Up]: Pointer Variables] [Top: Fortran90]

MAN-T&EC - Fortran90 - last modified: 04 AUG 95 - hpc-staff@mcc.ac.uk
Generated with CERN WebMaker