5

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 mpifortwrapper defaults to gfortraninstead of ifort?

1
  • 4
    The 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). Jun 2, 2016 at 12:30

2 Answers 2

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.

0
0

mpifort -fc=gfortran main.f90 (or other files you want to compile) can also help change the compiler.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.