J3/06-108 Date: December 5, 2005 To: J3 From: Aleksandar Donev Subject: Copy in/out and contiguous arrays This paper continues the integration of the CONTIGUOUS attribute with the rest of the standard, in particular, with the use of the TARGET attribute in relation to copy in/out of actual array arguments. BACKGROUND There are situations in which it is necessary for a programmer to ensure that there will be no copy in/out of array arguments, and that pointers pointed to the dummy will be associated with the actual as well. This is particularly useful in C Interop, where C may keep a pointer to a Fortran array for future use, for example, asynchronous data transfer. J3's response to this need was through a complex interp request (125) and essentially consisted of: If one wants to ensure no copying will take place, an assumed-shape or scalar dummy must be used, and both the dummy and the actual must have the TARGET attribute. This answer no longer holds true if the assumed-shape dummy has the CONTIGUOUS attribute. Users must choose between one or the other. This is very unfortunate, especially since one of the primary uses of copy-less argument association is with contiguous arrays in relation to using external procedures written in something other than Fortran. Copying may be required if the actual is not contiguous. However, if it is, then there is no need for it. In fact, it would be beneficial to users to guarantee that it does not happen. SPECIFICATION Modify the words on page 270 so that if the dummy is an assumed-shape array with the TARGET and CONTIGOUS attributes, and the actual has the CONTIGUOUS attribute or is an assumed-size or explicit-shape array (i.e., known at compile-time to be contiguous), then no copy in/out will take place and pointers associated with the dummy will be associated with the actual as well. Note that one could make this more general and say that if the actual is (runtime) contiguous no copying will take place, however, this requires runtime checks and may inhibit some optimizations. The point is to allow the user that really needs copyless association to get it, rather than to prevent compilers for copying if that is beneficial. SYNTAX No new syntax is needed. EDITS The edits are somewhat involved and will require carefull crafting by DATA subgroup. I will not attempt them by myself.