Over this past weekend, I had the motivation and time to overhaul Open MPI’s Fortran support for the better. Points worth noting:
- The “use mpi” module now includes all MPI subroutines. Strict type checking for everything!
- Open MPI now only uses a single Fortran compiler — there’s no more artificial division between “f77″ and “f90″
There’s still work to be done, of course (this is still off in a Mercurial bitbucket repo — not in the Open MPI main line SVN trunk yet), but the results of this weekend code sprint are significantly simpler Open MPI Fortran plumbing behind the scenes and a much, much better implementation of the MPI-2 “use mpi” Fortran bindings.
Much of this work is the result of discussions at the last MPI Forum meeting; we presented the proposed MPI-3 F08 bindings to the entire Forum in detail and got some very good feedback.
Craig Rasmussen (from Los Alamos) and I spent several more hours after the formal Forum meeting ended discussing implementation implications for Open MPI, and decided to re-do our F08 prototype from scratch to be smaller, simpler, and generally mo’betta.
The first part was revamping OMPI’s Fortran plumbing, which I have just done. Specifically, Open MPI used to differentiate between “F77″ and “F90″ compilers and Fortran bindings. This was a false division. Indeed, there are no F77 compilers any more — there haven’t been for 20+ years. And to be clear: MPI has never been compliant with Fortran 77 for two obvious reasons:
- Fortran 77 symbols were limited to 6 characters
- MPI-2 uses KIND attributes (which are not part of the Fortran 77 specification)
Hence, it’s much more accurate to refer to MPI’s Fortran “mpif.h interface” or “mpi module interface.”
My changes make Open MPI use only one Fortran compiler. It is specified via the FC (and FCFLAGS) environment variable when Open MPI is configured. The F77 and FFLAGS environment variables are now ignored!
Also, since the choice of which Fortran interface to use is on a per-Fortran-block basis (i.e., a single .f90 file can contain both “include ‘mpif.h’” and “use mpi”), it made no sense to have multiple Fortran wrapper compilers. Hence, Open MPI also grew a new wrapper compiler: mpifort. mpifort can be used to compile any MPI Fortran code.
mpif77 and mpif90 still exist for backwards compatibility, but are now sym links to mpifort.
Finally, most Fortran compilers have custom pragma implementations to effect (void*)-like functionality for choice buffers, such as the send buffer parameter to MPI_SEND. Unfortunately, gfortran does not support this kind of functionality, so it falls back to OMPI’s old “use mpi” implementation. But all other Fortran compilers will enjoy a full “use mpi” module that gives strict type checking. W00 hoo!!
There’s a few more things to do and clean up — I’m sure the code is not bug-free yet. But basic testing indicates that my revamped mpif.h and “use mpi” interfaces are working. w00t!
I now pass the baton over to Craig to re-do the “use mpi_f08″ implementation with this new infrastructure…