# 4.6 DIMENSION Statement

The DIMENSION statement defines the number of dimensions in an array and the number of elements in each dimension. It takes the following form:

    DIMENSION a(d) [,a(d)] . . .

a(d)
  Is an array declarator.

Rules and Behavior

The DIMENSION statement allocates a number of storage elements to each array named in the statement, one storage element to each array element in each dimension. The size of each storage element is determined by the data type of the array.

The total number of storage elements assigned to an array is equal to the number produced by multiplying together the number of elements in each dimension in the array declarator. For example, the following statement defines ARRAY as having 16 real elements of 4 bytes each and defines MATRIX as having 125 integer elements of 4 bytes each:

    DIMENSION ARRAY(4,4), MATRIX(5,5,5)

Although arrays can also be declared in type declaration and COMMON statements, array names can appear in only one array declarator in each program unit.

Examples

The following examples show valid DIMENSION statements:

    DIMENSION BUD(12,24,10)

    DIMENSION X(5,5,5), Y(4,85), Z(100)

    DIMENSION MARK(4,4,4,4)

    SUBROUTINE APROC(A1,A2,N1,N2,N3)

    DIMENSION A1(N1:N2), A2(N3:*)

For More Information:

- On array declarators, see Section 2.2.3.1.

- On arrays and the storage of array elements, see Section 2.2.3.

Previous Page Next Page Table of Contents