Limitiations of the CAF2OMP Translator

Limitations of Subset Co-Array 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.

Non-standard extensions:

  1. Square bracket expressions identical to the matching declaration but with "*" replaced by "@" are converted to the subscripts identifying the local part of the co-array. These can be used for local part references that don't require square brackets in Co-Array Fortran, and can be easily removed when using a fully conforming compiler.
  2. Explicit interfaces are not required (are in fact ignored) when passing a co-array to an explicit shape co-array dummy argument.
  3. The actual argument associated with an assumed shape dummy co-array argument (co-rank 1), must be a co-array section with co-shape [lb:lb-1+NUM_IMAGES()] (lb=lower co-bound).
  4. Must explicitly pass the local part of a co-array as a co-array section or a co-array element through the argument list if the dummy argument is not a co-array.
  5. Unformatted sequential READONLY I/O for a multi-image TEAM is allowed. In addition to TEAM= on OPEN and CLOSE, TEAM= is required for READ. The effect is to read the same record from the OPEN file on all images in TEAM.

Only the TEAM READ extension would be needed by an actual source to source compiler. All the other extensions are work-arounds for the limitations of caf2omp.

Limitations of the current, pattern matching, method include:

  1. Free form source code only.
  2. At most one statement per line.
  3. The following are reserved words: PROGRAM, INTERFACE, MODULE, SUBROUTINE, FUNCTION, ALLOCATABLE, ALLOCATE, SAVE, END, Co-Array intrinsics, COMMON, CALL, OPEN, CLOSE, REWIND, BACKSPACE, ENDFILE, TEAM. They must not be object names, and must not be mixed case.
  4. Continuation line breaks must not occur inside: reserved words, co-arrays, or co-array intrinsics.
  5. The main program must start with a program-name.
  6. Local SAVEd variables must be on a SAVE statement that contains only local variables (no co-arrays or named common). This includes variables in DATA statements and variables initialized on a type declaration (implicit SAVE).
  7. Co-arrays in COMMON must have shape and co-shape declared in the COMMON statement, and at least one co-array must be on the first line of the statement (with COMMON).
  8. Local fixed size co-arrays must be declared with the SAVE attribute and without the DIMENSION attribute (... SAVE ... ::). The declaration must only contain local co-arrays, and at least one co-array must be on the first line of the statement (with SAVE).
  9. Allocatable co-arrays must be declared with the ALLOCATABLE attribute (... ALLOCATABLE ... ::) and without an explicit SAVE attribute (SAVE is implied). The declaration must only contain local co-arrays, and at least one co-array must be on the first line of the statement (with ALLOCATABLE).
  10. Co-array ALLOCATE must be for a single array on a single line.
  11. The entire spec-list of an I/O statement with TEAM= must be on the first line of the statement, except that for OPEN only the specifiers UNIT, ACCESS, ACTION, and TEAM must be on the first line. TEAM= must refer to a whole rank-1 array (no array subscripts or constructor). UNIT= is required and must appear before TEAM=.
  12. Co-arrays of co-rank 1 must not be referenced using [:], use [lb:lb-1+NUM_IMAGES()] instead (lb=lower co-bound).
  13. Except as actual arguments, co-arrays must always be referenced using (...)[...]. The non-standard [...@] syntax is one way to do this.
  14. THIS_IMAGE co-array argument must include [...@].
  15. The implied SYNC_MEMORY calls required before and after each function call are not implemented. If a function contains a sync, the user must add these SYNC_MEMORY calls explicitly.
  16. Unit specifier's must be between 1 and 100,000. This is to allow implementation of the TEAM= sequential READ language extension, by making copies of the file and reading a different copy (from a different unit) on each thread. Note that the copies will only be deleted if an explicit TEAM= CLOSE is issued.
  17. Actual arguments associated with assumed shape dummy co-arrays (co-rank 1) require a language extension.
  18. A co-array actual argument must be associated with an explicit-shape co-array dummy argument. Local parts of co-arrays can only be passed to arguments of co-rank 0 via an extension.

All 18 limitations could be removed by an actual source to source compiler.

Notes:

  1. The implied SYNC_MEMORY calls required before and after each subroutine call are disabled if input variable flush is non-zero (it is zero by default).
  2. SYNC_MEMORY is implemented by blanket !$OMP FLUSH directives. A better method would be to only apply !$OMP FLUSH to all actual co-array dummy arguments. Only dummy arguments need flushing, because all other co-arrays are in common and therefore are implicitly flushed.
  3. Currently "[...,lb:*]" in COMMON becomes "(...,lb:lb+nimg-1)" and "[...,lb:*]" in ALLOCATE becomes "(...,lb:lb+NUM_IMAGES()-1)". This will waste memory for multi-dimensional co-ranks, but is always safe.
  4. OpenMP I/O is assumed to be thread-safe.
  5. caf2omp does not check syntax and issues no error messages.
  6. As with OpenMP, a common source of problems will be implicitly saved local variables. All variables on DATA statements or initialized on type statements MUST be listed on a SAVE statement.
  7. Most illegal Subset Co-Array Fortran code will produce a compile-time error from OpenMP, but there are exceptions.
  8. Compile-time OpenMP errors may be obscure, but the vast majority of the source is unchanged - so diff or sdiff between *.caf and *.f90 should provide an indication of the problem.
  9. The command sed -e 's/\[[^][]*@[ \t]*\]//g' strips out all [...@] expressions, and this will often be sufficient to make the code legal Co-Array Fortran.


Back to Co-Array Fortran home page