I am working on a shared code in Fortran. The code is used by multiple groups, and not everyone have the latest MPI libraries and compilers.
Now I want to use a feature from MPI-3, however, I cannot rely on everyone having this yet (yes, I know it's sad). In C this would have been trivial, in 'mpi.h' there is something like '#define MPI_VERSION 3' I could have used to switch to the new MPI-3 functions in the code, like:
#if MPI_VERSION >= 3 mpi_new_v3_function() #else mpi_send() mpi_recv() #endif
In the MPI module (or mpif.h) there is only a PARAMETER with the same information.
So I made a test, and the following works great in gfortran:
PROGRAM main USE mpi IMPLICIT NONE IF (mpi_version == 4) CALL mpi_nonexisting_call() WRITE(*,*) mpi_version END PROGRAM main
I can compile this with both -O0 and -O3, with and without the -g flag. It execute perfectly and print the current MPI version.
With Intel Fortran I get the error "undefined reference to `mpi_nonexisting_call_'" when trying to compile with -O0. With higher optimizations, I don't get this error.
I could of course give a define-directive to the compiler manually, and use the preprocessor like in C, but this require some effort from the users side, or it require me to use some build system like autoconf or cmake (currently we only have a hand-written makefile). We already use some define directives in our Fortran code, so it would not change any compilation workflow.
Do you have any ideas on how I can get the desired behaviour in this case working with the Intel Fortran compiler?