I am trying to compile a code with gfortran
. One of the first things that happens in the compilation is the creation of constants.mod
. Soon after that gfortran
tells me:
Fatal Error: Cannot read module file ‘constants.mod’ opened at (1), because it was created by a different version of GNU Fortran
Now here's the thing: This module file is created by the same gfortran
that it's trying to read it. gfortran
creates the thing itself and then 1 second later thinks the file was created by some other version! Any idea what's going on here?
You'll probably want to see the compile command:
mpif90 -c -O3 -ISDF/FORTRAN/include -I/usr/include -Iobj -Jobj -o obj/shared_data.o src/core/shared_data.F90
shared_data.F90
contains the module constants
at the top of the file.
EDIT: Here's the compile command followed by the full error message:
$> mpif90 -c -O3 -ISDF/FORTRAN/include -I/usr/include -Iobj -Jobj -o obj/shared_data.o src/core/shared_data.F90
src/core/shared_data.F90:67:6:
USE constants
1
Fatal Error: Cannot read module file ‘constants.mod’ opened at (1), because it was created by a different version of GNU Fortran
compilation terminated.
UPDATE: I hope you'll agree this is weird. The file that is failing is in src/core
. If I cd
to src/core
and issue this command:
mpif90 -c -O3 -I../../SDF/FORTRAN/include -I../../obj -J../../obj -o ../../obj/shared_data.o shared_data.F90
it compiles just fine! But then I clean everything out of the obj
directory and I cd
two levels up and issue:
mpif90 -c -O3 -ISDF/FORTRAN/include -Iobj -Jobj -o shared_data.o src/core/shared_data.F90
and it fails with the error I showed above! What is the difference??? Thanks.
(1)
? Any chance there is another constants.mod in one of the include directories? – Desiraedesiregfortran
instead ofmpif90
somewhere? They can actually be different. – Chongsed
) to turn that into a valid Fortran 90 module. – Cuzcofind <path> -name constants.mod
where<path>
is changed to each and all possible paths searched via your use of the-I
options? Or, have you triedlocate constants.mod
? It would also be helpful to see the output ofmpif90 --version
andgfortran --version
. – Hellbent