Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: Re: [OMPI users] OPEN_MPI macro for mpif.h?
From: Jeff Squyres (jsquyres_at_[hidden])
Date: 2010-03-31 09:09:18

On Mar 29, 2010, at 4:10 PM, Martin Bernreuther wrote:

> looking at the Open MPI mpi.h include file there's a preprocessor macro
> and OMPI_RELEASE_VERSION. version.h e.g. also defines OMPI_VERSION
> This seems to be missing in mpif.h and therefore something like
> include 'mpif.h'
> [...]
> #ifdef OPEN_MPI
> write( *, '("MPI library: OpenMPI",I2,".",I2,".",I2)' ) &
> #endif
> doesn't work for a FORTRAN openmpi program.

Correct. The reason we didn't do this is because not all Fortran compilers will submit your code through a preprocessor. For example:

shell% cat bogus.h
#define MY_VALUE 1
shell% cat bogus.f90
program main
#include "bogus.h"
  implicit none
  integer a
  a = MY_VALUE
end program
shell% ln -s bogus.f90 bogus-preproc.F90
shell% gfortran bogus.f90
Warning: bogus.f90:2: Illegal preprocessor directive

  a = MY_VALUE
Error: Symbol 'my_value' at (1) has no IMPLICIT type
shell% gfortran bogus-preproc.F90

That's one example. I used gfortran here; I learned during the process that include'd files are not preprocessed by gfortran, but #include'd files are (regardless of the filename of the main source file). The moral of the story here is that it's a losing game for our wrappers to try and keep up with what file extensions and/or compiler switches enable preprocessing, and trying to determine whether mpif.h was include'd or #include'd. :-(

That being said, I have a [very] dim recollection of adding some -D's to the wrapper compiler command line so that -DOPEN_MPI would be defined and we wouldn't have to worry about all the .f90 vs. .F90 / include vs. #include muckety muck... I don't remember what happened with that, though...

Are you enough of a fortran person to know whether -D is pretty universally supported among Fortran compilers? It wouldn't be too hard to add a configure test to see if -D is supported. Would you have any time/interest to create a patch for this, perchance?

Jeff Squyres
For corporate legal information go to: