Next: Assumed-size Arrays Up: Arrays as Arguments Previous: Arrays as Arguments

A more satisfactory solution is to generalise the procedure so that it can be used on arrays of any size. This is done by using an adjustable arrays declaration. Here the operands in each dimension bound expression may include integer variables which are also arguments of the procedure (or members of a common block). The following example shows how this may be done:
```
SUBROUTINE DOTPRO(NPTS, X, Y, Z)
REAL X(NPTS), Y(NPTS), Z(NPTS)
DO 15, I = 1,NPTS
* etc.
```
In this case the calling sequence would be something like:
` CALL DOTPRO(100, A, B, C)`
An adjustable array declaration is permitted only for arrays which are dummy arguments, since the actual array space has in this case already been allocated in the calling unit or at some higher level. The method can be extended in the obvious way to cover multi-dimensional arrays and those with upper and lower bounds, for example:
```       SUBROUTINE MULTI(MAP, K1, L1, K2, L2, TRACE)
DOUBLE PRECISION MAP(K1:L1, K2:L2)
REAL TRACE(L1-K1+1)
```
The adjustable array mechanism can, of course, be used for arrays of any data type; an adjustable array can also be passed as an actual argument of a procedure with, if necessary, the array bounds passed on in parallel.

Each array bound of a dummy argument array may be an integer expression involving not only constants but also integer variables passed in to the procedure either as arguments or by means of a common block. The extent of each dimension of the array must not be less than one and must not be greater than the extent of the corresponding dimension of the actual argument array.

If any integer variable (or named constant) used in an array-bound expression has a name which does not imply integer type then the INTEGER statement which specifies its type must precede its use in a dimension-bound expression.

Next: Assumed-size Arrays Up: Arrays as Arguments Previous: Arrays as Arguments
Helen Rowlands
8/27/1998