Defining Variables, Arrays, And Memory

FORTRAN-SO

3.2.3 Properties of Arrays

The examples following the description of the DIMENSION statement specify the types of the array names and, by implication, the types of the elements in the ar- rays. They also specify (by default) the lengths of the elements.

The remaining properties of the array are determined from the dimension declarator. These are:

The number of dimensions in the array

The size of each dimension

The total number of array elements

The number of dimensions equals the number of dimension declarators in the array declarator. Thus, the array

TABLE(4,4)

has two dimensions.

The size of a dimension is the same as the value 'd' in the array declarator format; it is also the same as the 'upper dimension bound.' The lower dimension bound is assumed to have the value one. The upper bound may be an asterisk in the case of an assumed-size array declarator.

The size of an array can generally be computed as the product of the sizes of the dimensions specified by the array declarator. Thus

ARRAY(3,3,3)

would have 27 elements. The number of elements in an assumed-size dummy array can be determined as follows:

If the actual argument corresponding to the dummy array is an array name, the size is that of the actual array;

If the actual argument is an array element name with a subscript value of 'p' in an array of size 'n,' the size of the dummy array is n + l-p.

Array elements are stored sequentially. For example, in the following sequence

DIMENSION TABLE(3,3)

TABLE(3,1) = 2.9

TABLE(2,3) = 7.3

'2.9' would be assigned to the third storage location in the block whose low address is 'TABLE,' and '7.3' would be assigned to the eighth location.

(1,1 )(2,1 )2.9(1,2)(2,2)(3,2)(1,3)7.3(3,3)

The total number of bytes in an array is the number of elements in the array multiplied by the number of bytes occupied by each element.

3.2.4 Referencing Array Elements

Array elements are referenced by qualifying an array name with a subscript in the form

ary (s [,s] ...)

3-6

Page 32
Image 32
Intel fortran-80 manual Properties of Arrays, Referencing Array Elements, Dimension ,3, Ary s ,s