Description
The concept of assumed rank permits definition of interfaces that are rank-agnostic.
The addition of the SELECT RANK block construct permits definitions and references to the object by resolving at run time to whatever rank the actual argument has. This is fine in case the array rank e.g. reflects different problem dimensions, requiring different algorithms for its solution. However, there are also cases in which uniform treatment of the argument's data irrespective of its rank is required. This is currently cumbersome to do.
This proposal suggests supporting this at least for the case of a CONTIGUOUS argument by remapping to a suitable rank-1 entity.
Variant 1: Permit pointer assignment
Assuming declarations
REAL, CONTIGUOUS, TARGET :: X(..)
REAL, POINTER :: XP(:)
it should be permissible to write
XP(1:SIZE(X)) => X
Note that for X assumed shape and any rank, this is already permitted. Some words would be needed to treat the rank 0 and rank "*" cases. The data in X could then be processed via XP.
Variant 2: Extend ASSOCIATE semantics
Assuming a declaration
REAL, CONTIGUOUS :: X(..)
it should be permissible to write
ASSOCIATE(XA(1:SIZE(X)) => X)
... ! definitions and references to XA
END ASSOCIATE
This variant would not require the TARGET attribute on X. Inside the ASSOCIATE block, the data could be processed via XA.
Requiring the CONTIGUOUS attribute imposes no limitation on functionality. Users need to be made aware of the potential performance impact for copy-in/out.