(j3.2006) Question about lbound of an assumed-rank entity
Daniel C Chen
cdchen
Wed Mar 1 17:30:21 EST 2017
The original question I posted is indeed about lower bound of an
assumed-rank entity.
It seems the following two paragraphs contradict to each other for a
nonallocatable, nonpointer actual argument that corresponds to an
assumed-rank dummy argument regardless if the callee is BIND(C) or not.
[497: 12-15]:
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.
[318: 31-36]:
An actual argument of any rank may correspond to an assumed-rank dummy
argument. The rank and shape
of the dummy argument are the rank and shape of the corresponding actual
argument. 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, except
that when the actual argument
is assumed-size, the upper bound of the last dimension of the dummy
argument is 2 less than the lower bound of
that dimension.
As for assumed-shape, the standard explicitly says the lower bound should
be set to 1 if users don't specify it.
But again, if the callee is bind(c), should the lower bound be 0 then?
8.5.8.3: If lower-bound appears it specifies the lower bound; otherwise the
lower bound is 1.
Thanks,
Daniel
XL Fortran Development, Fortran Standard Representative
IBM Toronto Software Lab
Phone: 905-413-3056
Tie: 969-3056
Email: cdchen at ca.ibm.com
http://www.ibm.com/software/awdtools/fortran/xlfortran
From: Bill Long <longb at cray.com>
To: fortran standards email list for J3 <j3 at mailman.j3-fortran.org>
Date: 03/01/2017 14:04
Subject: Re: (j3.2006) Question about lbound of an assumed-rank entity
Sent by: j3-bounces at mailman.j3-fortran.org
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.
Cheers,
Bill
> 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
_______________________________________________
J3 mailing list
J3 at mailman.j3-fortran.org
http://mailman.j3-fortran.org/mailman/listinfo/j3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20170301/b74b7d90/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
Url : http://mailman.j3-fortran.org/pipermail/j3/attachments/20170301/b74b7d90/attachment-0001.gif
More information about the J3
mailing list