A similar question has been asked before but the answers don't directly address the problem I have. I am trying to compile a fortran based application on an HPC machine. The machine has both gfortan
and ifort
installed and in path. When I use the MPI (Open MPI 1.8.8) wrapper mpifort
it automatically uses ifort
which is fine. But I, for some reason, want to use gfortran
instead. How can I make sure that the mpifort
wrapper defaults to gfortran
instead of ifort
?
Asked
Active
Viewed 1.1k times
5

R.U.
- 355
- 1
- 5
- 12
-
4The question makes little sense unless you provide the MPI implementation name and eventually version. But note that Intel Fortran and GNU Fortran have incompatible module file formats and use their own Fortran runtime libraries and if the MPI library was built with Intel Fortran, you won't be able to use it from GNU Fortran (the F77 interface, a.k.a. `include 'mpi.h'`, might work, but its use is strongly discouraged). – Hristo Iliev Jun 02 '16 at 12:30
2 Answers
5
The default Fortran compiler used by Open MPI's mpifort
is read from $ompi_root/share/openmpi/mpifort-wrapper-data.txt
. The build process stores there the Fortran compiler picked while building the library. It could be overridden by setting the OMPI_FC
environment variable. The same applies to the C wrapper (OMPI_CC
) and the C++ wrapper (OMPI_CXX
).
Example:
$ mpifort -showme:command
ifort
$ env OMPI_FC=gfortran mpifort -showme:command
gfortran
Keep in mind that unlike with C and C++, Intel disagrees with GCC on the Fortran ABI.

Hristo Iliev
- 72,659
- 12
- 135
- 186
0
mpifort -fc=gfortran main.f90 (or other files you want to compile)
can also help change the compiler.

zmwang
- 519
- 1
- 7
- 13