HP Fortran Programmer's Reference (September 2007)

Arrays
Array declarations
Chapter 3 61
INTEGER, PARAMETER :: buffsize = 0
REAL :: buffer (1: buffsize)
! buffer has explicit shape, but no elements and is zero-sized
.
.
.
END SUBROUTINE sort
Assumed-shape arrays
An assumed-shape array is a dummy argument that assumes the shape of the
corresponding actual argument. It must not have the POINTER attribute. Each dimension of
an assumed-shape array has the form:
[
lower-bound
] :
where
lower-bound
is a specification expression. The default for
lower-bound
is 1.
The actual argument and the corresponding dummy argument may have different bounds for
each dimension. An assumed-shape array subscript may extend from the specified
lower-bound
to an upper bound that is equal to
lower-bound
plus the extent in that
dimension of the actual argument minus one.
The following code segment illustrates different declarations of assumed-shape arrays.
SUBROUTINE initialize (a,b,c,n)
! examples of assumed-shape arrays
INTEGER :: n
INTEGER :: a(:)
! the array a is a rank-one assumed-shape array, it takes its
! shape and size from the corresponding actual argument; its
! lower bound is 1 regardless of the lower bound defined for
! the actual argument
COMPLEX :: b(ABS(n):)
! a rank-one assumed-shape array, the lower bound is ABS(n) and
! the upper bound will be the lower bound plus the extent of
! the corresponding actual argument minus one
REAL, DIMENSION(:,:,:,:,:) :: c
! an assumed-shape array with 5 dimensions; the lower bound for
! each dimension is 1
.
.
.
END SUBROUTINE initialize