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

Vipul Parekh parekhvs at gmail.com
Tue Jan 24 16:42:39 UTC 2023


On Tue, Jan 24, 2023 at 9:00 AM Clune, Thomas L. (GSFC-6101) <
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/e43feb26/attachment-0001.htm>


More information about the J3 mailing list