(j3.2006) Disassociated array pointer actual argument corresponding to an optional argument of elemental procedure.

Bill Long longb
Mon Dec 8 15:57:49 EST 2014


On Dec 8, 2014, at 10:12 AM, Daniel C Chen <cdchen at ca.ibm.com> wrote:

> Hello,
> 
> Is the following program standard conforming?
>       integer, pointer :: p1(:)
>       integer k
> 
>       nullify(p1)
> 
>       call sub1(p1, k)
> 
>       contains
>       impure elemental subroutine sub1(arg1, arg2)
>         integer,  intent(inout), optional :: arg1
>         integer,  intent(in) :: arg2
>       end subroutine
>       End
> 
> P1 is disassocated, but its extent is used to scalarize the elemental procedure call. Is this code standard conforming?

A disassociated pointer has no extent.  The call should have the same effect as
  

   call sub1 (arg2 = k)

which is valid and results in a scalar call, since all of the actual arguments are scalar.   Perhaps 12.8.2  and 12.8.3 could be more clear that nonpresent arguments corresponding to optional dummy arguments don?t count in the determination of the shape of an elemental function result or how the arguments are processed in an elemental subroutine call. 

Cheers,
Bill


> 
> The only thing I found that is sort of relevant in the standard is [12.5.2.12: p3: (6)]
> 
> "An optional dummy argument that is not present is subject to the following restrictions.
> ...
> (6) If it is an array, it shall not be supplied as an actual argument to an elemental procedure unless an array of the same rank is supplied as an actual argument corresponding to a nonoptional dummy argument of that elemental procedure."
> 
> Do we need something similar to this for the test case at the above?
> 
> 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 mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3

Bill Long                                                                       longb at cray.com
Fortran Technical Suport  &                                  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