next up previous

4.1 Array Operations     continued...

Assumed-Shape Dummy Arguments
One place that Fortran 77 permitted the appearance of an (unsubscripted) array name was as a procedure argument. Given the limited Fortran 77 concept of an array, this was sufficient to be considered as passing the array object to the procedure. However, a Fortran 77 array always occupied a block of contiguous storage, and therefore only the location of this block needed to be passed to the procedure. The procedure could treat this as the location of a (contiguous) array of the same shape, as an array of a different shape, or even as a scalar. This is not sufficient for Fortran 90, where arrays are full-fledged objects, the conformability rules apply, and array objects need not occupy contiguous storage (as is the case with many array sections-see section 4.2).

In Fortran 90, arbitrary array expressions may be used as actual arguments in procedure calls. The called procedure must handle these arguments properly as array-valued objects, which is not always possible if just a single location is passed. Assumed-shape dummy arguments solve this problem. They accommodate the passing of array ``descriptors", which contain descriptive information about the array in addition to its location. This additional information includes the rank (number of dimensions) of the array object being passed, the type and size of each element, the number of elements in each dimension, and the ``stride" in each dimension; the stride represents the spread between elements in a dimension and hence accounts for any departure from contiguity. Thus any array expression can be passed to an assumed-shape dummy argument. (Any array expression can be passed to an ``old fashioned" dummy argument as well, but that might result in expensive behind-the-scenes packing into and unpacking from contiguous temporary storage.)

An assumed-shape dummy argument is declared with a colon for each dimension, as in the following example in which T is a scalar, is a two- dimensional assumed-shape array, and is a one-dimensional assumed-shape array.

SUBROUTINE CALC3(T,U,V)
     REAL   T,U(:,:),V(:)
     ...
END  SUBROUTINE CALC3