Reputation: 15561
I am trying to use a module with gfortran 8.2.0 under Win 10 + Portable Msys2. This problem does not show up with gfortran 7.3.0 under Ubuntu 18.04LTS. After failing to compile my actual case, I put together
main.f90
:
program main_prog
use testmod
implicit none
integer :: j
end program main_prog
mod_testmod.f90
:
module testmod
implicit none
<various statements>
end module testmod
depending on the contents of <various statements>
, compilation worked or failed (see below).
Compilation
mod_testmod.f90
: Compiled ok, regardless of the combinations that I used for <various statements>
(mod_testmod.o
and testmod.mod
were created with no errors):
$ gfortran -g -c -o mod_testmod.o mod_testmod.f90
main.f90
:
<various statements>
(in mod_testmod.f90
!) consisted of a few variable definitions:
integer :: Npuntos=10 ! def 1
double precision :: PI=3.1415296 ! def 2
double precision :: T=4.0 ! def 3
double precision :: T0=4.0 ! def 4
double precision :: S0=4.0 ! def 5
which were commented/uncommented. Depending on the combination, compilation worked or failed (it completely puzzles me, all should work). When failed, the error message was
$ gfortran -g -c -o main.o main.f90
f951.exe: Fatal Error: Reading module 'testmod' at line 34 column 62: Unexpected EOF
compilation terminated.
I wouldn't know if the line/column combination is of any use to track the problem.
Combinations of unocmmented definitions that worked: (1), (1,4,5), (2,4,5), (3,4,5), (1,2,3,4), (1,2,4,5),
Combinations of unocmmented definitions that failed: (none) (comment by High Performance Mark was right), (4,5), (1,3,4,5), (1,2,3,4,5),
These are the combinations I tried, enough to have me completely lost on what's going on.
How can I solve this?
Upvotes: 3
Views: 7904
Reputation: 31
It seems that this problem is caused by the search rule of msys2. This error will emerge as long as there exists any invalid path before the location of msys64\mingw64\bin
in path
of Environment Variables
.
You can solve this problem either by removing those invalid paths or moving the mingw64 path location to the first one.
Upvotes: 0
Reputation: 17347
I recommend upgrading your msys2 installation. I have tried your MCVE on my gfortran 8.3.0-2
(mingw64/mingw-w64-x86_64-gcc-libgfortran 8.3.0-2 (mingw-w64-x86_64-toolchain)
) and windows 7 (I don't have a virtual machine with win10 yet) with msys2.
I updated my msys2 installation with pacman -Syu
. Next I searched for gfortran via pacman -Ss gfortran
and picked the x64 version.
To check I had the fortran:
$ whereis gfortran
gfortran: /mingw64/bin/gfortran.exe
I did this:
main.f90
:
module testmod
implicit none
integer :: Npuntos=10 ! def 1
double precision :: PI=3.1415296 ! def 2
double precision :: T=4.0 ! def 3
double precision :: T0=4.0 ! def 4
double precision :: S0=4.0 ! def 5
end module testmod
and
mod_testmod.f90
:
program main_prog
use testmod
implicit none
integer :: j
end program main_prog
Here is the log:
Ugun@thor MSYS /c/t/fortran
$ gfortran -g -c -o mod_testmod.o mod_testmod.f90
Ugun@thor MSYS /c/t/fortran
$ ls
main.f90 mod_testmod.f90 mod_testmod.o testmod.mod
Ugun@thor MSYS /c/t/fortran
$ gfortran -g -c -o main.o main.f90
Note: for the sake of completness I have tried all the combinations you reported as failed and all were successful.
Upvotes: 1