[J3] Is this legal in F202X? Rank agnosticism and scalars

Clune, Thomas L. (GSFC-6101) thomas.l.clune at nasa.gov
Mon Jan 23 19:08:56 UTC 2023


Suppose we have a template that is parameterized by rank N:

TEMPLATE TMPL(N)
   INTEGER, CONSTANT :: N

CONTAINS

   REAL FUNCTION FIRST_ELEMENT(A)
      REAL, RANK(N), INTENT(IN) :: A

      INTEGER :: idx(N)
      idx = 1
      PRINT*, A(@idx)   ! is this legal for N=0

   END REAL
END TEMPLATE


Now, consider the case for N = 0.    Is the PRINT statement above legal?  I recall discussing this issue when the multiple-subscript-triplet paper went in, but I’m not seeing anything in the text that allows us to use scalars in this context.

This constraint seems to strongly indicate the scalar case is not supported:

C925 (R918) Exactly one part-ref shall have nonzero rank, and either the final part-ref shall have a section
subscript-list with nonzero rank, another part-ref shall have nonzero rank, or the complex-part-designator
shall be an array.



  *   Tom

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20230123/d8d56de8/attachment.htm>


More information about the J3 mailing list