OpenMPI is not currently available for native Windows. While Cygwin and WSL do have working OpenMPI, it is also possible to use MPICH via Microsoft MS-MPI as described in this article.
setup MPI on Windows MSYS2
This procedure gives MPI via MSYS2 GCC / Gfortran compilers on Windows.
Download and install Microsoft MS-MPI
mpiexec.exeavailable, add to user PATH: “C:/Program Files/Microsoft MPI/Bin” – this is needed even when using MSYS2.
Install MSYS2 MS-MPI library, from the MSYS2 Terminal
pacman -S mingw-w64-x86_64-msmpi
compile the MPI module with Gfortran from PowerShell or Windows Terminal. This also creates “mpi.mod” for Fortran use.
cd C:/msys64/mingw64/ gfortran include/mpi.f90 -c -fno-range-check ar cr lib/libmpi.a mpi.o
If you don’t compile the mpi.f90 as above, errors may result like:
use mpi Fatal Error: Cannot open module file 'mpi.mod' for reading at (1): No such file or directory
MS-MPI without MSYS2
If not using MSYS2, it’s still possible use MS-MPI. We will put the resulting artifacts under c:/lib/mpi
mkdir c:/lib/mkl/include Copy-Item -Path "C:/Program Files (x86)/Microsoft SDKs/MPI/Include" -Destination "c:/lib/mpi/include" -Recurse cd c:/lib/mpi
you may need to edit “include/mpi.f90” to have
gfortran include/mpi.f90 -c -fno-range-check ar cr lib/libmpi.a mpi.o