(j3.2006) Optional argument for intrinsics
Bill Long
longb
Mon May 28 14:41:31 EDT 2012
Hi Daniel,
This question was the topic of Interp F08/0003, which has completed
processing and resulted in edits in Corrigendum 1 to F2008. The
Corrigendum file is N1902. For a full text of the interp, see N1875.
Cheers,
Bill
On 5/28/12 12:04 PM, Daniel C Chen wrote:
> Questions:
>
> 1. Are the optional DIM dummy arguments of intrinsics allowed to be
> associated with disassociated pointer or unallocated allocatable actual
> arguments?
> 2. Are other optional dummy arguments of intrinsics allowed to be
> associated with disassociated pointer or unallocated allocatable actual
> arguments?
>
>
> According to the rules defined in section 12.5.2.12, the optional dummy
> argument 'arg' in the following example is not present:
>
> integer, pointer :: ptr
>
> nullify(ptr)
> call foo(ptr)
>
> contains
> subroutine foo(arg)
> integer, optional :: arg
> print *, present(arg)
> end subroutine
>
> end
>
> This is because the dummy argument 'arg' does not have the POINTER
> attribute, and it corresponds to an actual argument that has the POINTER
> attribute and is disassociated.
>
> The question is whether the same argument presence rules apply to the
> optional DIM argument of some intrinsic procedures. For instance, in the
> following example:
>
> 1 real, allocatable :: array(:,:)
> 2 integer, pointer :: ptr
> 3
> 4 allocate(array(2,3))
> 5
> 6 ... = ubound(array, ptr)
> 7
> 8 end
>
> is the result of the ubound on line 6 a scalar or an array?
>
> Since the rank of the result depends on the presence of the DIM
> argument, shouldn't argument association between a disassociated pointer
> or unallocated allocatable and the DIM argument be disallowed?
>
> There are provisions in the standard that disallow optional dummy
> arguments to be associated with the DIM argument. For example
>
> Section 13.2.4, paragraph 1: "The DIM argument of a reduction function
> isnot permitted to be an optional dummy argument."
>
> This rule eliminates the uncertainty about the rank of the result of a
> reduction intrinsic at compile-time. One would expect a similar
> restriction for passing a disassociated pointer or unallocated
> allocatable as the actual argument corresponding to the optional DIM
> argument.
>
> Thanks,
>
> Daniel
>
> XL Fortran Development - 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
>
>
> _______________________________________________
> 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