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
> OPEN_MPI defined, as well as e.g. OMPI_MAJOR_VERSION, OMPI_MINOR_VERSION
> 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)' ) &
> &            OMPI_MAJOR_VERSION, OMPI_MINOR_VERSION, OMPI_RELEASE_VERSION
> #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
bogus.f90:5.14:

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

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
jsquy...@cisco.com
For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/


Reply via email to