HP Fortran Programmer's Reference (September 2007)

Arrays
Array declarations
Chapter 3 63
Deferred-shape arrays
A deferred-shape array has either the POINTER attribute or the ALLOCATABLE attribute. Its
shape is not specified until the array is pointer assigned or allocated. Although a
deferred-shape array can have the same form as an assumed-shape array, the two are
different. The assumed-shape array is a dummy argument and must not have the POINTER
attribute.
The array specification for a deferred-shape array has the form:
: [ , : ] ...
The specification for a deferred-shape array defines its rank but not the bounds. The bounds
are defined either when the array is allocated or when an array pointer becomes associated
with a target.
Array pointers and allocatable arrays are described in the following sections.
Array pointers
An array pointer is a deferred-shape array with the POINTER attribute. Its bounds and
shape are defined only when the array is associated with a target in a pointer assignment
statement or in an ALLOCATE statement. An array pointer must not be referenced until it is
associated.
Following are example declarations of array pointers:
! p1 is declared as a pointer to a rank-one
! array of type real; p1 is not associated with any target
REAL, POINTER, DIMENSION(:) :: p1
! p2 is a pointer to an integer array of rank-two;
! it must be associated with a target before it can be referenced
INTEGER, POINTER :: p2(:,:)
! err is a pointer to a rank-3 array of type err_type
TYPE err_type
INTEGER :: class
REAL :: code
END TYPE err_type
TYPE(err_type), POINTER, DIMENSION(:,:,:) :: err
! The next statement is ILLEGAL: pointers cannot have an
! explicit shape.
INTEGER, POINTER :: p3(n)
For information about associating an array pointer with a target, see “Pointers” on page 131.
For information about the POINTER attribute and ALLOCATE statement, see Chapter 10, “HP
Fortran Statements.”