HP Fortran Programmer's Reference (September 2007)

Arrays
Array fundamentals
Chapter 3 57
Array fundamentals
An array consists of a set of elements, each of which is a scalar and has the same type and
type parameter as declared for the array. Elements are organized into dimensions.
Fortran 90 allows arrays up to seven dimensions. The number of dimensions in an array
determines its rank.
Dimensions have an upper bound and a lower bound. The total number of elements in a
dimension—its extent—is calculated by the formula:
upper-bound
-
lower-bound
+ 1
The size of an array is the product of its extents. If the extent of any dimension is zero, the
array contains no elements and is a zero-sized array.
Elements within an array are referenced by subscripts—one for each dimension. A subscript
is a specification expression and is enclosed in parentheses. As an extension,
HP Fortran allows a subscript expression of type real; the expression is converted to type
integer after it has been evaluated.
The shape of an array is determined by its rank and by the extents of each dimension of the
array. An array’s shape may be expressed as a vector where each element is the extent of the
corresponding dimension. For example, given the declaration:
REAL, DIMENSION(10,2,5) :: x
the shape of x can be represented by the vector [10, 2, 5].
Two arrays are conformable if they have the same shape, although the lower and upper
bounds of the corresponding dimensions need not be the same. A scalar is conformable with
any array.
A whole array is an array referenced by its name only, as in the following statements:
REAL, DIMENSION(10) :: x, y, z
PRINT *, x
x = y + z
The array element order used by HP Fortran for storing arrays is column-major order;
that is, the subscripts along the first dimension vary most rapidly, and the subscripts along
the last dimension vary most slowly. For example, given the declaration:
INTEGER, DIMENSION(3,2) :: a
the order of the elements would be:
a(1,1)
a(2,1)
a(3,1)