Avoidance of ephemeral arrays in PSyclone-processed source code
Context
In order to achieve efficient GPU-based acceleration of NEMO, it can be important to avoid ephemeral arrays with a lifespan within a single execution of individual time-step components (in particular automatic arrays and temporarily allocated local arrays). To support this, PSyclone v2.5.0 provides the transformation HoistLocalArraysTrans
, which promotes automatic arrays to persistent module arrays (for example, this transformation is enabled in the PSyclone transformation script developed in the context of issue #403 (closed)). However, PSyclone v2.5.0 does not fully interpret (albeit correctly reproduce) variable declarations that include arithmetic expressions, and therefore the HoistLocalArraysTrans
transformation ignores the many automatic-array declarations that utilise "do-loop" bounds substitution (even in the case of arrays without halo, where an offset of zero is axplicitly added to or subtracted from the bounds of the interior domain). Further, PSyclone v2.5.0 does not provide a transformation for the corresponding promotion of local arrays that are explicitly allocated and deallocated during individual procedure calls..
Proposal
It is proposed to temporarily implement a workaround that makes many automatic arrays with arithmetic bounds expression and some explicitly allocated local arrays targets of the HoistLocalArraysTrans
transformation of PSyclone v2.5.0. This can be achieved through the temporary substitution of arithmetic bounds expressions with a mock scalar-variable name during PSyclone processing and by substituting locally allocated arrays with automatic arrays. Fortran source-code changes for this workaround can be made conditional on a CPP key and build-system changes should only be required inside the PSyclone-processing wrapper; further, the workaround can be removed as soon as NEMO is updated to be compatible with a future PSyclone release version with native support for the promotion of the two local-array types covered by this implementation.