Hi all:
I am new to Fortran and this forum. I would like to ask a technical question about using OpenMPI in my Macbook (M2) Ventura system.
I have installed OpenMPI using “brew install openmpi”. However, when I try to compile a module that includes “use mpi”, it shows an error message:
“Fatal Error: Cannot open module file ‘mpi.mod’ for reading at (1): No such file or directory”
Any suggestions will be super helpful!
Thanks, and I look forward to hearing from you!
Best,
Long
1 Like
You have to add OpenMPI to your library search path. You can show the MPI build flags with:
$ mpifort --showme:link
You should then compile with, for example, -L/usr/local/mpi/openmpi3/lib -I/usr/local/mpi/openmpi3/lib
.
Thanks so much, @interkosmos !
I got the following when I did $ mpifort --showme:link
-Wl,-flat_namespace -Wl,-commons,use_dylibs -I/opt/homebrew/Cellar/open-mpi/4.1.5/lib -L/opt/homebrew/Cellar/open-mpi/4.1.5/lib -L/opt/homebrew/opt/libevent/lib -lmpi_usempif08 -lmpi_usempi_ignore_tkr -lmpi_mpifh -lmpi
Does it mean that I will have to copy these two while compiling?
-I/opt/homebrew/Cellar/open-mpi/4.1.5/lib -L/opt/homebrew/Cellar/open-mpi/4.1.5/lib -L/opt/homebrew/opt/libevent/lib
Thanks!
Best,
Long
You’ll want to set it to FFLAGS
, e.g. FFLAGS=$(mpifort --showme:link) mpifort whatever.f90
Hello!
Might I suggest that you move to Open Co-Arrays! It installs just as easy but the compile and run were easier for me:
CAF task.f90
CAFRUN -n 8 a.out
Not a lot of funny business in those calls!
Edit: also you don’t have to call anything specific to get it to compile but you get the thread number functions and synchronization calls for free.
this_image()
num_images()
sync all
Knarfnarf