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

Clune, Thomas L. (GSFC-6101) thomas.l.clune at nasa.gov
Tue Jan 24 16:52:24 UTC 2023


Hi Vipul,

Yes – SELECT RANK could be the best way to sidestep this concern.  Thanks!


  *   Tom

From: Vipul Parekh <parekhvs at gmail.com>
Date: Tuesday, January 24, 2023 at 11:42 AM
To: "Clune, Thomas L. (GSFC-6101)" <thomas.l.clune at nasa.gov>
Cc: j3 <j3 at mailman.j3-fortran.org>
Subject: Re: [EXTERNAL] Re: [J3] Is this legal in F202X? Rank agnosticism and scalars



On Tue, Jan 24, 2023 at 9:00 AM Clune, Thomas L. (GSFC-6101) <thomas.l.clune at nasa.gov<mailto:thomas.l.clune at nasa.gov>> wrote:
..

If something like this cannot be permitted then it will generally  limit the ability to use RANK(N) for the scalar case to whole array operations.   It cannot even be guarded with a conditional ala: ..

Hi Tom,

Thanks for your explanation.  What I write below may not be what you want to read, but I am trying to extrapolate to what you might hear from others and what you may then feel about it!  And which is this: does the SELECT RANK from Fortran 2018 offer anything for you here?   Or are there any improvements to SELECT RANK semantics that might be of help here?  Say if this variant of your example were considered?

template t(N)
   integer, constant :: N
contains
   real function first_element(A)
      real, rank(N), intent(in) :: A
      select rank ( A )
         rank( 0 )
            print *, A
            first_element = A
         rank( * )  !<-- dunno - does assumed size case apply?
            error stop ! ??
         rank default
            block
            integer :: idx(N)
            idx = 1
            print *, A(@idx)
            first_element =  A(@idx)
      end select
   end function
end template

Thanks,
Vipul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20230124/9f82f791/attachment.htm>


More information about the J3 mailing list