02.07.2013 Views

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

NULLIFY<br />

Disassociates a pointer from a target.<br />

Syntax<br />

NULLIFY (pointer-object-list)<br />

pointer-object-list<br />

Description<br />

<strong>HP</strong> <strong>Fortran</strong> statements<br />

NULLIFY<br />

is a comma-separated list of variable names and derived-type components.<br />

The NULLIFY statement disassociates a pointer from any target. A NULLIFY statement is also<br />

used to change the status of a pointer from undefined to disassociated.<br />

Examples<br />

The following example shows the declaration and use of a variable with the pointer attribute:<br />

REAL, TARGET :: value ! value can be target<br />

REAL, POINTER :: pt ! for the pointer<br />

pt.pt => value ! Associate pt with value<br />

NULLIFY (pt) ! Disassociate pt<br />

! ASSOCIATED intrinsic is valid in next statement if (and only<br />

! if) pt has been previously allocated, assigned (as above), or<br />

! nullified (as above)<br />

IF (.NOT.ASSOCIATED(pt)) pt => x<br />

The next example shows how a derived type can be used in list processing applications:<br />

TYPE list_node<br />

INTEGER value<br />

TYPE (list_node), POINTER :: next<br />

END TYPE list_node<br />

TYPE (list_node), POINTER :: list<br />

ALLOCATE (list) ! Create new list node<br />

list % value = 28 ! Initialize data field<br />

NULLIFY (list % next) ! Nullify pointer to the next node<br />

Related statements<br />

ALLOCATE, DEALLOCATE, POINTER, andTARGET<br />

Chapter 10 371

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!