11.07.2015 Views

Fortran 90 Handbook

Fortran 90 Handbook

Fortran 90 Handbook

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

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

6X is not available for use in the program until it has been allocated space by anALLOCATE statement. X must be declared with a deferred-shape arrayspecification and the ALLOCATABLE attribute.6.5.1.2 Allocation of PointersWhen an object with the POINTER attribute is allocated, space is created, andthe pointer is associated with that space, which becomes the pointer target. Areference to the pointer name can be used to define or access its target. Thetarget may be an array or a scalar. Additional pointers may become associatedwith the same target by pointer assignment (described in Section 7.5.3). Apointer target may be an array with the ALLOCATABLE attribute if the arrayalso has the TARGET attribute. Allocation of a pointer creates an object thatimplicitly has the TARGET attribute. It is not an error to allocate a pointer thatis currently associated with a target. In this case, a new pointer target is createdand the previous association of the pointer is lost. If there was no other way toaccess the previous target, it becomes inaccessible. The ASSOCIATED intrinsicfunction may be used to query the association status of a pointer if theassociation status of the pointer is defined. The ASSOCIATED function (A.13)also may be used to inquire whether a pointer is associated with a target orwhether two pointers are associated with the same target.Pointers can be used in many ways; an important usage is the creation oflinked lists. For example,TYPE NODEINTEGER :: VALUETYPE (NODE), POINTER :: NEXTEND TYPE NODETYPE(NODE), POINTER :: LIST. . .ALLOCATE (LIST)LIST % VALUE = 17ALLOCATE (LIST % NEXT)The first two executable statements create a node pointed to by LIST and putthe value 17 in the VALUE component of the node. The third statement createsa second node pointed to by the NEXT component of the first node.218 <strong>Fortran</strong> <strong>90</strong> <strong>Handbook</strong>Copyright © 1992 J. Adams, W. Brainerd, J. Martin, B. Smith, and J. Wagener

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

Saved successfully!

Ooh no, something went wrong!