HP Fortran Programmer's Reference (September 2007)

Arrays
Array declarations
Chapter 360
For a given dimension, the values of
lower-bound
and
upper-bound
define the range of the
array in that dimension. Usually,
lower-bound
is less than
upper-bound
; if
lower-bound
is
the same as
upper-bound
, then the dimension contains only one element; if it is greater, then
the dimension contains no elements, the extent of the dimension is zero, and the array is
zero-sized.
The simplest form is represented by an array declaration in which the name of the array is
not a dummy argument and all bounds are constant expressions, as in the following example:
INTEGER :: a(100,4,5)
This form of array may have the SAVE attribute and may be declared in any program unit.
Other forms of the explicit-shape array include:
•Anautomatic array: An array that is declared in a subprogram but is not a dummy
argument and has at least one nonconstant bound. Automatic arrays may be declared in a
subroutine or function, but may not have the SAVE attribute nor be initialized.
Character strings can also be declared as automatic data objects; see “Character strings
as automatic data objects” on page 121.
•Adummy array: An array that is identified by its appearance in a dummy argument list;
its bounds may be constants or expressions. Dummy arrays may only be declared in a
subroutine or function.
•Anadjustable array: A particular form of a dummy array. Its name is specified in a
dummy argument list, and at least one of its bounds is a nonconstant specification
expression.
Explicit-shape arrays may also be used as function results, as described in “Array-valued
functions” on page 79 and in “Array dummy argument” on page 172.
The following code segment illustrates different forms of explicit-shape arrays:
SUBROUTINE sort(list1,list2,m,n)
! examples of arrays with explicit shape
INTEGER :: m,n
INTEGER :: cnt1(2:99)
! a rank-one array, having an explicit shape represented by
! the vector [98]
REAL :: list1(100), list2(0:m-1,-m:n)
! two dummy arrays with explicit shape: list1 is a rank-one
! array with an extent of 100; list2 is a rank-two array with an
! extent of m * (m+n+1). list2 is also an adjustable array.
REAL :: work(100,n)
! work is an automatic array; it does not appear in the dummy
! argument list and at least one of its bounds is not constant