(j3.2006) TYPE(*), DIMENSION(..) dummy argument with unallocated or zero-sized actual argument?

Bill Long longb
Fri Jul 28 16:08:41 EDT 2017


> On Jul 28, 2017, at 12:32 PM, Clune, Thomas L. (GSFC-6101) <thomas.l.clune at nasa.gov> wrote:
> 
> This question is motivate by the F2008 bindings for MPI.   Is the following program standard conforming?  
> 
> module Foo
> contains
>    subroutine f(buf)   ! NOTE: dummy argument is not actually used.
>        type(*), dimension(..), intent(in) :: buf
>    end subroutine f
> end module
> 
> program main
>    use Foo
> 
>    real,  allocatable :: x(:)
> 
> ! Is this call legal?
>    call f(x)

No. Violates "Except in references to intrinsic inquiry functions, if the dummy argument is nonoptional and the actual argument is allocatable, the corresponding actual argument shall be allocated.?

> 
>    allocate(x(0))
> ! How about this one:
>    call f(x)

OK.  There is enough information in the descriptor for the buf dummy to determine that the actual is zero-size. 

Cheers,
Bill

> 
> end program main
> 
> 
> The motivation is when calling MPI collective procedures, e.g.  MPI_Gather().    In many cases, one of the dummy arguments is only used on the root process, and it would be nice to not have to allocate the array on the other processes.     With the F77 bindings (via INCLUDE ?mpif.h?), the analog to the above would definitely violate the standard because you can?t pass 0-sized and unallocated thingies to an implicit interface.     It is less clear to me what the implications are for the F90 bindings (via USE MPI), but I really only care about the F2008 bindings (USE MPI_F08) at this point.
> 
> (And yes, it will be great when we can just use coarrays, but I predict that I?ll be using MPI for a while yet while vendor implementations of CAF mature.)
> 
> Cheers,
> 
> - Tom
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3

Bill Long                                                                       longb at cray.com
Principal Engineer, Fortran Technical Support &   voice:  651-605-9024
Bioinformatics Software Development                      fax:  651-605-9143
Cray Inc./ 2131 Lindau Lane/  Suite 1000/  Bloomington, MN  55425





More information about the J3 mailing list