Subset Co-Array Fortran

The full Co-Array Fortran language (Numrich and Reid, 1998) provides support for legacy SPMD programs based on Cray's SHMEM put and get library. It requires that all variables in saved COMMON be treatable either as standard variables or as co-arrays and which objects in the COMMON block are co-arrays is allowed to vary between scoping units. This makes it difficult to implement co-arrays as if they were Fortran arrays of higher rank. Here we present relatively minor restrictions on the full language that widen the implementation choices, and in particular allow a simple mapping from Co-Array Fortran to OpenMP Fortran.

  1. If a named COMMON includes a co-array, every object in that COMMON must be a co-array. The objects in the COMMON must agree in size, type, shape, co-rank and co-extents in all scoping units that contain the COMMON.

  2. The EQUIVALENCE statement is not permitted for co-arrays.

  3. The sum of the local rank plus the co-rank of a co-array is limited to seven.

  4. A dummy co-array argument cannot have assumed-size local dimensions.

  5. A dummy co-array argument cannot have assumed-shape local dimensions, unless the co-rank is one. The actual argument shall then also have co-rank one.

  6. If a dummy argument has both nonzero local rank and nonzero co-rank and does not have assumed shape local dimensions, the actual argument must agree in size and type with the dummy argument.

The restrictions on COMMON are similar to those for non-sequence COMMON in HPF. The restrictions on EQUIVALENCE are more severe than in HPF, for simplicity, but in Subset Co-Array Fortran the restrictions only apply to co-arrays. COMMON can be largely replaced by MODULE for new programs, so the restrictions are easily met except when migrating legacy Fortran 77 programs that make heavy use of COMMON and either EQUIVALENCE or different layouts for the same named common in different scopes. If the objects in a legacy COMMON already agree in size, type, and shape in all scoping units (which is good programming practice), then every object in that COMMON can be converted to a co-array without changing the meaning of the program. This is because a reference to a co-array without square brackets is always a reference to the local part of the co-array. Migration to the subset is therefore easy in this case.

In Co-Array Fortran both the local rank and the co-rank of a co-array can be seven, but the local rank plus co-rank of any co-array subobject that is actually used in an executable statement must be no more than seven (because the rank and co-rank are merged and the object treated as a standard array subobject). Thus the subset's restriction on local rank plus co-rank to seven is not typically a severe additional constraint. It would be helpful if Fortran 2000 increased the limit on the rank from seven to, say, ten, since this would give more room for rank plus co-rank.

The restrictions on dummy co-array arguments may require the programmer to explicitly pass additional array dimension information through the argument list. The restriction on assumed-shape is probably the most severe of all for new programs, since assumed-shape arrays are a significant simplifying factor in Fortran 95 programs and Co-Array Fortran requires some kinds of co-array actual arguments to only be associated with assumed shape dummy arguments. It is a consequence of the fact that co-size is always NUM_IMAGES() and therefore that, when the co-rank is greater than one, the co-array has no final extent, no final upper bound, and no co-shape. Note that Cray's initial implementation of Co-Array Fortran disallows both assumed local size and assumed local shape dummy co-array arguments.

The Subset does not allow any kind of array element sequence association for co-arrays. It therefore prohibits an element of a co-array being passed to a subroutine and treated there as a co-array of non-zero rank. Only entire co-arrays can be passed to explicit-shape co-array dummy arguments and the size of the actual and dummy argument must be identical.

More details are available on translating Subset Co-Array Fortran into OpenMP Fortran.

Back to Co-Array Fortran home page