(j3.2006) Fortran 201x wish: SELECT RANK

Rafik Zurob rzurob
Mon Feb 18 23:42:54 EST 2013


Hi

The ink on TS 29113 hasn't dried yet and extensions are already being 
proposed for it!

My first thought on this was that instead of adding yet another SELECT 
construct, we can just allow assumed-rank actual arguments to be 
argument-associated with assumed-shape and deferred-shape (if appropriate) 
dummy arguments of any rank.  Procedures that have assumed-shape or 
deferred-shape dummy arguments require explicit interfaces anyway, so the 
compiler has enough information to make it work.  Upon further reflection, 
I think SELECT RANK is a better solution because:
1. One would be able to access the elements of the array inside the CASE 
statement instead of just being able to pass it.
2. There are fewer implications / interactions with SELECT RANK.  e.g. It 
would not affect generic interface resolution since the rank of the 
effective argument would be known at compile time.
3. It would be clear from reading code what ranks an assumed-rank array 
can have.  I'm assuming one would be able to also put a CASE DEFAULT if 
they wanted to.

I suggest we wait a bit though.  This may or may not be small.  If we're 
allowing the use of assumed-rank arrays in Fortran, we should consider the 
implications on the rest of the standard.  For example, we should consider 
how we want assumed-rank arrays to work with generic interfaces.  Also, if 
we're going in this direction, we should also think about whether we need 
a static casting construct for assumed-type entities.

Regards

Rafik

j3-bounces at mailman.j3-fortran.org wrote on 17/02/2013 04:49:47 PM:

> From: Tobias Burnus <burnus at net-b.de>
> To: fortran standards email list for J3 <j3 at j3-fortran.org>, 
> Date: 17/02/2013 04:49 PM
> Subject: (j3.2006) Fortran 201x wish: SELECT RANK
> Sent by: j3-bounces at mailman.j3-fortran.org
> 
> Dear all,
> 
> using assumed-rank arrays, I missed the possibility to pass an 
> assumed-rank dummy argument to a non-assumed-rank dummy argument. I 
> think using something like:
> 
> SELECT RANK(assumed_rank_dummy)
> CASE (3)
> call rank_3_sub(assumed_rank_dummy)
> END SELECT RANK
> 
> would be a useful and simply addition. The implementation effort should 
> be rather low and it makes assumed-rank arrays more useful from Fortran 
> ? currently one has either to use them for this purpose from C or one 
> has to use rather clumsy code such as the following, which in addition 
> requires the target attribute.
> 
> SELECT CASE (rank(assumed_rank_dummy))
> CASE (3):
> block
> type(...), pointer :: fptr
> call c_f_pointer (c_loc(assumed_rank_dummy), fptr, &
> shape=shape(assumed_rank_dummy))
> call rank_3_sub(fptr)
> end block
> end select case
> 
> 
> Tobias
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3




More information about the J3 mailing list