Array elements

Array elements are the scalar data that make up an array. Each element inherits the type, type parameters, and INTENT, PARAMETER, Fortran 2003 Begins PROTECTED, Fortran 2003 Ends TARGET, and Fortran 2003 BeginsVOLATILE Fortran 2003 Ends attributes from its parent array. The POINTER attribute is not inherited.

You identify an array element by an array element designator, whose form is:

Read syntax diagramSkip visual syntax diagram>>---+-array_name--------+--(--subscript_list--)---------------><
     '-array_struct_comp-'
 
array_name
is the name of an array
array_struct_comp
is a structure component whose rightmost comp_name is an array
subscript
is an scalar integer expression
IBM Extension

A subscript can be a real expression in XL Fortran.

End of IBM Extension

Notes

The subscript value depends on the value of each subscript expression and on the dimensions of the array. It determines which element of the array is identified by the array element designator.

Related information:

Array element order

The elements of an array are arranged in storage in a sequence known as the array element order, in which the subscripts change most rapidly in the first dimension, and subsequently in the remaining dimensions.

For example, an array declared as A(2, 3, 2) has the following elements:

 Position of Array Element             Array Element Order
 -------------------------             -------------------
          A(1,1,1)                              1
          A(2,1,1)                              2
          A(1,2,1)                              3
          A(2,2,1)                              4
          A(1,3,1)                              5
          A(2,3,1)                              6
          A(1,1,2)                              7
          A(2,1,2)                              8
          A(1,2,2)                              9
          A(2,2,2)                             10
          A(1,3,2)                             11
          A(2,3,2)                             12