I have a code that has some mpi api-dependent bits:
#if MPIVERSION==1
...
#elif MPIVERSION==2
...
#endif
that switches between assuming MPI-1 and MPI-2.
Is there a good way to infer a good version — particularly one that might go in the build system?
Thanks!
Do what
configurescripts usually do – try to compile and run a very simple test MPI code that consists of:Compile this code with
mpicc(or whatever compiler was specified) and run it (directly and not throughmpirun) during code configuration time and you will both:You can do the same for Fortran projects.
You can also try to parse
mpi.hdirectly and search forMPI_VERSIONandMPI_SUBVERSIONbut you might run into some non-portability issues. Besides those macros are meant to be used for conditional compilation inside the C/C++ code.