Cisco Blogs

A bucket full of new MPI Fortran features

- May 23, 2011 - 2 Comments

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:

  1. Fortran 77 symbols were limited to 6 characters
  2. 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…


In an effort to keep conversations fresh, Cisco Blogs closes comments after 60 days. Please visit the Cisco Blogs hub page for the latest content.


  1. The use mpi_f08 interfaces now compile so Jeff believes that they will just work now :-) Myself I think we need to do some testing first. These mpi_f08 interfaces use the basic Open MPI C implementation of mpif.h directly now the mpi_f08 implementation is much cleaner and simpler. For example, no Fortran wrappers are needed.

    • ...until Fortran compilers start supporting the assumed shape syntax, and users start passing in array subsections as choice buffers. We'll eventually therefore need wrappers for functions with choice buffers, but functions such as MPI_COMM_SPLIT (for example) won't need a wrapper for the mpi_f08 module. w00t.