"use mpi" failed to compile

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

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