File ‘mpi.mod’ opened at (1) is not a GNU Fortran module file

user3645282 picture user3645282 · Jul 31, 2016 · Viewed 8.4k times · Source

I'm trying to compile RegCM4.5 my configuration looks like have no errors but while compiling (by make command) I get this error

File ‘mpi.mod’ opened at (1) is not a GNU Fortran module file

I have installed mpich by dnf install package manager. How can I solve this problem?

Answer

b-fg picture b-fg · Nov 8, 2016

I had this problem recently. The problem was that I had different versions of the gfortran compiler and openmpi was not pointing to the right one, aka. the one being used for compiling my program. So using the use mpi statement would lead to that error. Typing in the following command will indicate which Fortran compilers are currently installed:

dpkg -l | grep Fortran

My output was

ii  gfortran                                    4:5.3.1-1ubuntu1                              amd64        GNU Fortran 95 compiler
ii  gfortran-4.8                                4.8.5-4ubuntu2                                amd64        GNU Fortran compiler
ii  gfortran-5                                  5.4.1-2ubuntu1~16.04                          amd64        GNU Fortran compiler
ii  libgfortran-4.8-dev:amd64                   4.8.5-4ubuntu2                                amd64        Runtime library for GNU Fortran applications (development files)
ii  libgfortran-5-dev:amd64                     5.4.1-2ubuntu1~16.04                          amd64        Runtime library for GNU Fortran applications (development files)
ii  libgfortran3:amd64                          6.2.0-3ubuntu11~16.04                         amd64        Runtime library for GNU Fortran applications

You can solve this by exporting the fortran compiler you are actually using. In my case it was gfortran-4.8, so I simply had to type

export FC=gfortran-4.8