(j3.2006) allocatable and pointer actual arguments to intrinsicfunctions
Van Snyder
Van.Snyder at jpl.nasa.gov
Tue Mar 9 18:49:30 EST 2010
On Tue, 2010-03-09 at 14:55 -0800, Bill Long wrote:
>
> Robert Corbett wrote:
> > Malcolm Cohen wrote:
> >
> >> "An allocatable variable with [unallocated] status shall not be referenced"
> >>
> >> Similarly pointer.
> >>
> >> Cheers,
> >
> > I must not have explained the problem well enough. Consider the
> > following function:
> >
> > LOGICAL FUNCTION F(A, P)
> > LOGICAL A{:}
> > INTEGER P
> > POINTER P
> > F = ALL(A, P)
> > END
> >
> > The dummy argument P of F is not an optional dummy argument and
> > so is allowed to be argument associated with the optional dummy
> > argument DIM of the intrinsic reduction function ALL. In
> > Fortran 2003, the dummy argument DIM of ALL is considered to be
> > present, regardless of whether P is associated, and so the
> > statement you cited applies. In 09-007r3, if P in F is not
> > associated, the dummy argument DIM of ALL is considered not to
> > be present. The question is when 09-007r3, Section 13.7.8
> > [302:24] states
> >
> > It is scalar if DIM is absent
> >
> > does the word "absent" mean "not present" or does it mean
> > "omitted?"
>
> The goal here is to ensure that the compiler can tell at compile time
> whether the result is a scalar or an array, based on whether or not DIM
> is "absent". The standard is clear that the rules regarding optional
> arguments are the ones specified in 12.5.2 (see 09-007r3[317:33-34]).
> The restriction that the actual DIM argument cannot be an optional dummy
> is to circumvent a possible ambiguity. I think we should have also
> disallow unallocated allocatable variables and pointers that are not
> associated as actual arguments. Seems like interp material.
Yeah, I think that's why some of the intrinsics are described using two
interfaces instead of with optional arguments. All of the ones where
the rank of the result depends upon whether an argument appears should
either be described using two interfaces or "is absent" should be
replaced by "does not appear." It will be difficult to use two
interfaces to describe the ones where there is more than one optional
argument, one of whose appearance determines the rank.
ANY can go either way.
COUNT has to be described using "does not appear".
CSHIFT doesn't use DIM to determine the rank, but uses "omitted" and
"present" instead of "absent" and "present".
Same for EOSHIFT.
FINDLOC is already described using two interfaces.
IALL is already described using two interfaces.
IANY is already described using two interfaces.
IPARITY is already described using two interfaces.
LBOUND has to be described using "does not appear".
LCOBOUND has to be described using "does not appear".
MAXLOC is already described using two interfaces.
MAXVAL is already described using two interfaces.
MINLOC is already described using two interfaces.
MINVAL is already described using two interfaces.
NORM2 can go either way.
PARITY can go either way.
PRODUCT is already described using two interfaces.
SUM is already described using two interfaces.
UBOUND has to be described using "does not appear".
UCOBOUND has to be described using "does not appear".
Off topic, but noticed while researching this, the second and third
sentences of the description of the SHAPE argument of RESHAPE ought to
be exchanged, so it doesn't appear that "SIZE(x) shall not have an
element whose value is negative" (unless that's what we actually mean,
in which case using "It" is still confusing.
> Cheers,
> Bill
>
>
>
> If it means not present, then the function F is
> > conformant even if P is unassociated, as it will not reference
> > P If it means omitted, then the statement you cited still
> > applies and so F is not conformant.
> >
> > The descriptions of the intrinsic procedures appear to use the
> > word "absent" inconsistently. In the description of the
> > intrinsic function ASSOCIATED [13.7.13, 304-305], the word
> > absent clearly means omitted. In the description of the
> > intrinsic function INDEX [13.7.52, 322-323], if the word
> > absent means omitted, there is a missing case for the result
> > value.
> >
> > Robert Corbett
> > _______________________________________________
> > J3 mailing list
> > J3 at j3-fortran.org
> > http://j3-fortran.org/mailman/listinfo/j3
>
More information about the J3
mailing list