(j3.2006) allocatable and pointer actual arguments to intrinsicfunctions

Bill Long longb at cray.com
Tue Mar 9 17:55:32 EST 2010



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.

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

-- 
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