Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28508 Discussions

How to check if Intel MPI is running from within Fortran (Windows)


So I am porting a Fortran code from Linux to Windows. The program is parallelised with MPI (specifically Intel MPI). The porting of the serial part of the code was successful and it runs on Windows without any hitch.


In the MPI parallel part of the code, there is a line which I assume is checking whether the program has been called with MPI or not.


call get_environment_variable("I_MPI_MPIRUN",  value = env_var, status = ev_status)
if(ev_status .eq. 1) call exec_mpirun(IMPI)


From what I can understand if the program is called with mpirun the I_MPI_MPIRUN environment variable is defined to some value. The program checks for that and if MPI isn't running then calls the function exec_mpirun(). IMPI is a parameter defined as 1. The exec_mpirun() is a C function which runs execvp("mpirun", "mpirun","--map-by","node", "dmrcc_mpi"). dmrcc_mpi is the executable that needs to run.

However, I can't find any Intel MPI documentation where the I_MPI_MPIRUN environment variable is mentioned. And I am not even sure that the same variable is used for Windows. For windows, the MPI executable is called with mpiexec, which also leads me to suspect the same environment variable wouldn't be used.

So, is there any way to check whether the program has been called with MPI from within a Fortran code?


[Sorry if this is the wrong forum to post on this, I couldn't see any forums on MPI]

0 Kudos
1 Reply
Honored Contributor III

Not surprising that you couldn't find the Intel MPI forum, as it is well-disguised. What you want is Intel® oneAPI HPC Toolkit - Intel Community