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

Clune, Thomas L. GSFC-6101 thomas.l.clune
Fri Jul 28 13:32:17 EDT 2017


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)

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

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20170728/aa75ede2/attachment.html 



More information about the J3 mailing list