An adjustable array is an explicit-shape array that is a dummy
argument to a subprogram. At least one bound of an adjustable
array must be a nonconstant specification expression. The bounds
are determined when the subprogram is called.
The array specification can contain integer variables that are
either dummy arguments or variables in a common block.
When the subprogram is entered, each dummy argument specified in
the bounds must be associated with an actual argument. If the
specification includes a variable in a common block, it must have a
defined value. The array specification is evaluated using the
values of the actual arguments, as well as any constants or common
block variables that appear in the specification.
The size of the adjustable array must be less than or equal to the
size of the array that is its corresponding actual argument.
To avoid possible errors in subscript evaluation, make sure that
the bounds expressions used to declare multidimensional adjustable
arrays match the bounds as declared by the caller.
In the following example, the function computes the sum of the
elements of a rank-two array. Notice how the dummy arguments M and
N control the iteration:
FUNCTION MY_SUM(A, M, N)
DIMENSION A(M, N)
SUMX = 0.0
DO J = 1, N
DO I = 1, M
SUMX = SUMX + A(I, J)
END DO
END DO
MY_SUM = SUMX
END FUNCTION
The following are examples of calls on SUM:
DIMENSION A1(10,35), A2(3,56)
SUM1 = MY_SUM(A1,10,35)
SUM2 = MY_SUM(A2,3,56)