Bound Pair List

<bound pair list>

  ┌◄───── , ─────┐
──┴─<bound pair>─┴─────────────────────────────────────────────────────┤

<bound pair>

──<lower bound>── : ──<upper bound>────────────────────────────────────┤

<lower bound>

──<arithmetic expression>──────────────────────────────────────────────┤

<upper bound>

──<arithmetic expression>──────────────────────────────────────────────┤

The subscript bounds for an array are given in the first bound pair list following the array identifier. The bound pair list gives the lower and upper bounds of all dimensions, in order from left to right. In all cases, upper bounds must not be less than their associated lower bounds.

For arrays declared within a STRUCTURE BLOCK TYPE declaration, evaluations of the arithmetic expressions in the bound pair list are done once for each structure block instance (structure block variable or structure block array element) when the structure block instance is first created. The structure block instance is created upon the execution of the first reference to the structure block variable or structure block array element, that is, when the activation record for the structure block instance is first made present.

Arithmetic expressions used as array dimension bounds are evaluated once (from left to right) on entering the block in which the array is declared. These expressions can depend only on values that are global to that block or passed in as actual parameters. The results of the arithmetic expressions are evaluated as integers. Arrays declared in the outermost block must use constant bounds or constant expression bounds.

The maximum value of the lower bound is 2**39-1; the minimum value of the lower bound is - 2**39-1. The total size of the array is machine dependent.

Original and Referred Arrays

Every array identifier that is declared with a bound pair list is an original array, which is distinct from all other original arrays.

There are three other ways to associate an identifier with an array: array row equivalence, array reference assignment, and array specification in a PROCEDURE declaration. In each of these cases, the identifier refers to the same data as an original array. Such an identifier is called a referred array. An array row equivalence or array reference assignment can cause an array identifier of one array class to refer to data in an original array of another array class.

Dimensionality

The dimensionality (number of dimensions) of an original array is the number of bound pairs in the bound pair list with which the array is declared. Arrays cannot have more than 16 dimensions.

The size (number of elements) of each dimension of an array declared with a particular bound pair is given by the following expression:

<upper bound> - <lower bound> + 1

The maximum number of elements in an ARRAY dimension can vary and is checked by the MCP when a program is executed. The maximum size of a dimension is dependent on the system on which the program is executed.

Array Row Equivalence

<array row equivalence>

──<identifier>── [ ──<lower bound>── ] ── = ──<array row>──────────────┤

An array row equivalence causes the declared array identifier to refer to the same data as the specified array row. That array row can be an original array or another referred array. The declared identifier is an equivalent array.

The size of the declared array is determined by the size and element width of the array row and the element width for the array class of this declaration. For example, assume that Sa and Wa are the size and element width of the array row, and that Wea is the element width for the equivalent array. The size of the equivalent array, Sea, is then the following:

Sea := (Sa * Wa) DIV Wea

Because of the truncation implicit in the DIV operation, Sea * Wea might be less than Sa * Wa.. In this case, indexing the equivalent array by Sea + <lower bound> does not cause an invalid index fault. Pointer operations that use the equivalent array can access the entire area of memory allocated to the original array to which the array identifier ultimately refers; the memory area can hold more than Sea elements of width Wea.

The array row equivalence enables the program to reference the same array row with two or more identifiers. Each identifier can reference the same data with different type, character type, or lower bound specifications. For example, in the following program, both I[2] and R[0] contain the value 25.0 after the assignment I[2] := 25.234 is executed. However, after the assignment R[0] :=25.234 is executed, both I[2] and R[0] contain the value 25.234.

BEGIN
   REAL ARRAY R[0:9];
   INTEGER ARRAY I[2] = R;  % Array row equivalence. The INTEGER
                            % array I refers to the same data as
                            % the REAL array R.
   I[2]:= 25.234;
   R[0]:= 25.234;
END.

The array row equivalence part cannot appear in an ARRAY declaration that declares an OWN array. For example, the following declaration is invalid:

OWN ARRAY A[0] = B

An array declared with an array row equivalence part is an OWN array if and only if the array to which it is equated is an OWN array.

Note: There are subtle restrictions on the correct declaration and use of an array row equivalence in which the array row of the declaration is a row of an array reference, because the default state of an array reference variable is uninitialized.

If the array reference is one-dimensional and has the same element width as the new array, then the two identifiers become synonyms. Whenever the array reference variable is assigned a value, the equivalent array describes the same data.

If the array reference is multidimensional and/or has a different element width than the new array, the array row equivalence is established from the value of the array reference variable at the time the program enters the block containing the array row equivalence declaration. Later assignments to the array reference variable do not affect the array row equivalence. Therefore, in order for the declaration to be useful, the array reference variable must have been declared and initialized in a scope global to the block declaring the array row equivalence.

Array Row

<array row>

──┬──────────────────────────────┬─┬─<one-dimensional array name>─┬────┤
  ├─<connection block qualifier>─┤ └─<array name>──<row selector>─┘
  └─<structure block qualifier>──┘

An array row is a one-dimensional array designator.

<one-dimensional array name>

An <array name> whose identifier was declared with one dimension.

<array name>

──┬─<array identifier>───────────┬─────────────────────────────────────┤
  ├─<direct array identifier>────┤
  ├─<array reference identifier>─┤
  └─<value array identifier>─────┘

Row Selector

<row selector>

── [ ─┬──────────────────────┬─ * ── ] ────────────────────────────────┤
      │ ┌◄─────────────────┐ │
      └─┴─<subscript>── , ─┴─┘

<subscript>

──<arithmetic expression>──────────────────────────────────────────────┤

A row selector is the limiting case of a subarray selector, with only one asterisk.

ARRAY Allocation

When an array row or procedure-reference array row is allocated, it is made present. For array rows, each element is initialized to (zero). For procedure-reference array rows, each element is in the uninitialized state.