(j3.2006) Question about lbound of an assumed-rank entity

Bill Long longb
Wed Mar 1 14:03:36 EST 2017

On Mar 1, 2017, at 3:08 AM, Cohen Malcolm <malcolm at nag-j.co.jp> wrote:

> (1)
>> terms like ?assumed-bounds? or ?assumed-shape? when talking about 
>> assumed-rank just confuse the issue.
> No they do not.  The current text says
>   "If the rank is nonzero, the lower and upper bounds of the dummy argument 
> are those that would be given by the intrinsic functions LBOUND and UBOUND 
> respectively if applied to the actual argument,"
> ... which in fewer words, means "the dummy assumes the bounds of the 
> actual", i.e. it is the very definition of "assumed-bounds?.

Then there might be a contradiction.  Whether the bounds are assumed from the actual argument, or assigned internally is independent of whether the dummy is assumed-rank.  It does depend on whether it is allocatable/pointer or not.  18.5.3p3:

"For a C descriptor of an array pointer or allocatable array, the value of the lower_bound member of each element of the dim member of the descriptor is determined by argument association, allocation, or pointer association. For a C descriptor of a nonallocatable nonpointer object, the value of the lower_bound member of each element of the dim member of the descriptor is zero."

That?s what you get in the C descriptor, which is all the information you have if the procedure is BIND(C).  You have to assume the caller was C for interpreting the descriptor, whether it was actually or not. 

The question is what is the value of the lower bound as seen in the callee.  For a C callee, the value in the descriptor is the lower bound value.  For a Fortran callee, where it is possible to call LBOUND, the result should be what you get from applying LBOUND to the dummy argument (almost of the definition of LBOUND).  That would be the actual argument?s lower bound(s) if the dummy is allocatable or pointer, and 1 otherwise.   LBOUND has to be ?taught? how to interpret a C descriptor. 

> ...whereas the TS (in the non-edits section) said the dummy "assumes the 
> extents"; since the extents form the shape, this is the very definition of 

The extents are assumed whether the argument is allocatable, pointer, or assumed-shape.  The original question was, if I recall, about the lower bounds. The extents and bounds are separate issues. 


> assumed-shape.  (plus there is the exception for assumed-size, but that's an 
> exception whether you talk about "assumed extents" or "assumed-shape".
> I make no apology for using obvious terminology in place of unwieldy 
> definitions!
> (2)
> No one has suggested changing what is passed in the lower_bound members.
> (3)
> I am pleased that you do not disagree with what was actually suggested, 
> which is to make the lower bounds in Fortran equal to 1.
> Cheers,
> -- 
> .............Malcolm Cohen, NAG Oxford/Tokyo. 
> _______________________________________________
> 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