[MPI3 Fortran] [Fwd: add TYPE(*) and DIMENSION(..) to Fortran]

Craig Rasmussen crasmussen at lanl.gov
Fri Sep 5 13:13:45 CDT 2008


On Sep 5, 2008, at 11:48 AM, Jeff Squyres wrote:

> Great!  Note a few changes, though; MPI functions in C [almost] all  
> return int.  So we can't use the BIND(C) stuff, unfortunately -- it  
> was felt that making all MPI invocations be FUNCTIONS would be  
> unnatural for Fortran programmers.  So it'll really be something  
> like this (note that MPI_xxx returns "int" in C and we pass an  
> additional "ierr" c_int integer argument in Fortran):
>
> In C: int MPI_xxx (void * buffer, int n);
>
> In the Fortran MPI module:
>
> interface MPI_xxx
>   subroutine MPI_xxx (buffer, n, ierr) bind(c,name="MPI_xxx_fortran")
>      type(*),dimension(*) :: buffer
>      integer(c_int),value :: n, ierr
>   end subroutine MPI_xxx
> end interface MPI_xxx
>
> And then then MPI will still have to have a "wrapper" function (in C  
> or Fortran; whatever they want) to call the back-end/"real" MPI C  
> function.

Actually BIND(C) will be used as you show in your example, just not  
directly to call the C MPI implementation.

The really cool thing to come out of TYPE(*) and DIMENSION(..) is that  
the programmer can pass array sections in and have the wrapper pull  
out the appropriate portions of the array and do the correct thing.   
If the array section is non-contiguous, what is the right thing to  
do?  Should the wrapper make a contiguous copy of the array or is  
there a more efficient way to sent the contiguous portions of the  
array via MPI, perhaps using a lower level protocol?

Cheers,
Craig




More information about the mpiwg-fortran mailing list