5 Pointer Variables
NULLIFYstatement, whose general form is
NULLIFY(list of pointers)The intrinsic function
ASSOCIATEDcan 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
NULLIFYstatement can have more than one pointer argument.
MAN-T&EC - Fortran90 - last modified: 04 AUG 95 - firstname.lastname@example.org Generated with CERN WebMaker