(j3.2006) Question about lbound of an assumed-rank entity
Bill Long
longb
Tue Feb 28 12:00:08 EST 2017
On Feb 27, 2017, at 7:41 PM, Van Snyder <van.snyder at jpl.nasa.gov> wrote:
> On Tue, 2017-02-28 at 10:10 +0900, Cohen Malcolm wrote:
>> SUMMARY:
>> (1) The TS does not require LBOUND of assumed-rank to give the LBOUND of a
>> nonallocatable nonpointer actual, because you cannot introduce a new
>> technical effect by burying it in the edits section,
>> (2) Requiring LBOUND of assumed-rank to give the LBOUND of a nonallocatable
>> nonpointer actual, as the 007 does now, would either create a lot of extra
>> work for the processor (it cannot use lower_bound in the C descriptor for
>> the lower bounds, but has to pass them around separately) or produce
>> inconsistent results,
>> (3) Those problems go away if nonallocatable nonpointer assumed-rank acts
>> like assumed-shape (LBOUND==1), and this is easy to implement.
>
> I prefer to make this kind of change now, rather than to battle over it for several years using interps and corrigenda.
The text in 18.5.3p3 is pretty clear - the lower_bound field in the C descriptor for assumed-rank gets the bounds of the actual argument for allocatable or pointer arguments and is set to 0 for nonpointer nonallocatable cases. So, terms like ?assumed-bounds? or ?assumed-shape? when talking about assumed-rank just confuse the issue. The lower bound value is determined by its other attributes (allocatable, pointer, or neither). There was insistence that C programmers could not comprehend a default lower bound of 1, so we voted for 0. We definitely do not want to change that 0 to a 1. The assumed-rank feature was specifically requested for use with the MPI_F08 module file and is already widely implemented because of that demand.
For a C programmer, using the lower_bound member of the struct as the ?lower bound? for that dimension is the obvious thing to do. This discussion started from the example of a Fortran-written procedure with the BIND(C) attribute calling LBOUND(). The question is whether the incoming descriptor for an assumed-rank argument should be converted to the corresponding Fortran descriptor on entry to a Fortran-written BIND(C) routine. That would result in the nonpointer nonallocatable case having the lower bounds reset to 1. We do assume that descriptor conversion for allocatable and pointer arguments, so it seems reasonable to make the same decision for assumed-rank. Particularly now that the SELECT RANK construct lets you actually do something with an assumed-rank argument in Fortran. For the nonpointer nonallocatable case LBOUND(X) where X is represented by a Fortran descriptor would give the result 1 automatically.
Cheers,
Bill
>
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3
Bill Long longb at cray.com
Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9142
Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101
More information about the J3
mailing list