HP Fortran Programmer's Reference (September 2007)

HP Fortran statements
ALLOCATE
Chapter 10278
The ALLOCATE and DEALLOCATE statements and pointer variables of type node make it
possible to allocate space for nodes in such a tree structure, traverse it as required, and then
recover the space when it is no longer needed.
TYPE node
REAL val
TYPE(node), POINTER :: left, right ! Pointer components
END TYPE node
TYPE(node) top
ALLOCATE (top % left, top % right)
In the final example, two CHARACTER arrays, para and key, are declared with the POINTER
attribute. para is allocated space; key is made to point at a section of para.
! Pointers to char arrays
CHARACTER, POINTER :: para(:), key(:)
CALL init_k_m(k, m)
ALLOCATE (para(1000))
key => para (k : k + m)
Related statements
ALLOCATABLE (statement and attribute), DEALLOCATE, NULLIFY, and POINTER (statement and
attribute)
Related concepts
For related information, see the following:
The descriptions of the ALLOCATED and ASSOCIATED intrinsics in Chapter 11, “Intrinsic
procedures,” on page 501
“Pointers” on page 131