### 3.4.2.2 Array Elements

An array element is one of the scalar data items that make up an array. A subscript list (appended to the array or array component) determines which element is being referred to. A reference to an array element takes the following form:

  array(subscript-list)
  array
  Is the name of the array.
  subscript-list
  Is a list of one or more subscripts separated by commas. The number of subscripts must equal the rank of the array.

  Each subscript must be a scalar integer (or other numeric) expression with a value that is within the bounds of its dimension.

Rules and Behavior

Each array element inherits the type, kind type parameter, and certain attributes (INTENT, PARAMETER, and TARGET) of the parent array. An array element cannot inherit the POINTER attribute.

If an array element is of type character, it can be followed by a substring range in parentheses; for example:

    ARRAY_D(1,2) (1:3)    ! Elements are substrings of length 3

However, by convention, such an object is considered to be a substring rather than an array element.

The following are some valid array element references for an array declared as REAL B(10,20): B(1,3), B(10,10), and B(5,8).

For information on forms for array specifications, see Section 5.1.4.

Array Element Order

The elements of an array form a sequence known as array element order. The position of an element in this sequence is its subscript order value.

The elements of an array are stored as a linear sequence of values. A one-dimensional array is stored with its first element in the first storage location and its last element in the last storage location of the sequence. A multidimensional array is stored so that the leftmost subscripts vary most rapidly. This is called the order of subscript progression.

Figure 3-1 shows array storage in one, two, and three dimensions.

Figure 3-1 Array Storage

For example, in two-dimensional array BAN, element BAN(1,2) has a subscript order value of 4; in three-dimensional array BOS, element BOS(1,1,1) has a subscript order value of 1.

In an array section, the subscript order of the elements is their order within the section itself. For example, if an array is declared as B(20), the section B(4:19:4) consists of elements B(4), B(8), B(12), and B(16). The subscript order value of B(4) in the array section is 1; the subscript order value of B(12) in the section is 3.

In High Performance Fortran programs compiled for parallel execution on Tru64 UNIX systems, element order and storage association do not apply unless explicitly requested with the SEQUENCE directive. If the SEQUENCE directive is used, the named data objects cannot be mapped by data placement and layout directives.

For More Information:

- On substrings, see Section 3.1.5.2.
- On arrays as structure components, see Section 3.2.3.
- On array association, see Section 16.4.3.2.
- On storage sequence association, see Section 16.4.3.
- On the [NO]SEQUENCE directive, see Section 15.3.7.
- On data placement and layout directives for Tru64 UNIX systems, see Section 15.3.

Previous Page Next Page Table of Contents