(j3.2006) Select Rank

Van Snyder Van.Snyder
Tue Feb 17 16:37:55 EST 2015


On Mon, 2015-02-16 at 05:16 +0000, Bill Long wrote:

> It was not clear if Van was suggesting something simple, or he wanted
> to allow variable length subscript lists on the variable name.  The
> later (like the example from Stan) is a pretty radical departure from
> basic Fortran syntax rules, and I fear it would be a full employment
> feature for /Interp for years to come.  Rather than completely
> removing the limitations on where an assumed-rank object could appear
> in a program (assuming we want this feature in F2020 at all), there is
> a simpler option:  Allow an assumed-rank name as a selector in an
> associate construct.  Since the associate names do not appear in
> declaration statements there is a less disruption to the standard. 
> 
> select rank (A)  
> 
> case (1)
>    associate (B => A)  ! Current rules already say B assumes the rank of A
>         B(4) = 1
>    end associate
> case (2)
>    associate (B=>A)  ! Or maybe (B(:,:) => A) to be more explicit about the rank of B
>        B(2,3) = 1
>    end associate
> ?
> ! case default not allowed for select rank, or allowed, but no reference to A allowed.
> 
> end select
> 
> 
> OR, borrowing from the syntax of SELECT TYPE, an alternative that is a
> bit more confusing and more work to implement, but still simpler than
> the original:
> 
> select rank (B => A)
>  
> case(1)
>    B(4) = 1
> case(2)
>    B(2,3) = 1
> 
> end select

Borrowing from SELECT TYPE:

select rank ( A )
case ( 1 )
  a(4) = 1
case ( 2 )
  a(2,3) = 1
end select

See R841 in 15-007: the "<associate-name> =>" part is optional.  So this
isn't a radical departure from current practice.





More information about the J3 mailing list