Array elements

Array elements are the scalar data that make up an array. Each element inherits the type, type parameters, and INTENT, PARAMETER, TARGET, Fortran 2003 beginsPROTECTED, ASYNCHRONOUS, and VOLATILEFortran 2003 ends attributes from its parent array. The POINTER and ALLOCATABLE attributes are not inherited.

Syntax

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 a scalar integer expression

IBM extension begins A subscript can be a scalar real expression in XL Fortran. IBM extension ends

Rules

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

Related information