Compiler errors Msys2->;f951.exe:致命错误:读取模块'';第2行第1列:意外的EOF

Compiler errors Msys2->;f951.exe:致命错误:读取模块'';第2行第1列:意外的EOF,compiler-errors,fortran,gfortran,msys2,Compiler Errors,Fortran,Gfortran,Msys2,我正在尝试使用Win 10+便携式Msys2下的gfortran 8.2.0模块。 这个问题在Ubuntu18.04LTS下的gfortran 7.3.0中没有出现。 在未能编译我的实际案例后,我将 我的或: main.f90: program main_prog use testmod implicit none integer :: j end program main_prog module testmod implicit none <various statements>

我正在尝试使用Win 10+便携式Msys2下的gfortran 8.2.0模块。 这个问题在Ubuntu18.04LTS下的gfortran 7.3.0中没有出现。 在未能编译我的实际案例后,我将

我的或

  • main.f90

    program main_prog
    use testmod
    implicit none
    integer :: j
    end program main_prog
    
    module testmod
    implicit none
    <various statements>
    end module testmod
    
    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
    
    program main_prog
    use testmod
    implicit none
    integer :: j
    end program main_prog
    
  • mod_testmod.f90

    program main_prog
    use testmod
    implicit none
    integer :: j
    end program main_prog
    
    module testmod
    implicit none
    <various statements>
    end module testmod
    
    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
    
    program main_prog
    use testmod
    implicit none
    integer :: j
    end program main_prog
    
  • main.f90
    (在
    mod_testmod.f90
    !)中)由几个变量定义组成:

    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
    
    已注释/未注释的。根据组合的不同,编译是成功还是失败(这完全让我困惑,一切都应该成功)。 失败时,错误消息为

    $ gfortran -g -c -o main.o main.f90
    f951.exe: Fatal Error: Reading module 'testmod' at line 34 column 62: Unexpected EOF
    compilation terminated.
    
    我不知道行/列组合是否有助于跟踪问题

    有效的未注释定义的组合: (1), (1,4,5), (2,4,5), (3,4,5), (1,2,3,4), (1,2,4,5)

    失败的未注释定义的组合: (无)(High Performance Mark的评论是正确的), (4,5), (1,3,4,5), (1,2,3,4,5)

    这些都是我尝试过的组合,足以让我完全不知道发生了什么


如何解决此问题?

我建议升级您的msys2安装。我已经在我的
gfortran 8.3.0-2
mingw64/mingw-w64-x86\u 64-gcc-libgfortran 8.3.0-2(mingw-w64-x86\u 64-toolchain)
)和windows7(我还没有一个带有win10的虚拟机)和msys2

我用
pacman-Syu
更新了我的msys2安装。接下来,我通过pacman-Ss gfortran搜索gfortran,并选择了x64版本

要检查我是否有fortran:

$ whereis gfortran
gfortran: /mingw64/bin/gfortran.exe
我这样做:

main.f90

program main_prog
use testmod
implicit none
integer :: j
end program main_prog
module testmod
implicit none
<various statements>
end module testmod
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
program main_prog
use testmod
implicit none
integer :: j
end program main_prog

mod_testmod.f90

program main_prog
use testmod
implicit none
integer :: j
end program main_prog
module testmod
implicit none
<various statements>
end module testmod
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
program main_prog
use testmod
implicit none
integer :: j
end program main_prog
以下是日志:

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
注意:为了完整起见,我尝试了您报告为失败的所有组合,所有组合都成功

  • 我认为您应该升级您的MSYS2环境
  • 升级您的gfortran安装

  • 请对所有Fortran问题使用tag。您能否显示
    testmod.mod
    中的内容?不幸的是,他们将.mod文件改为二进制格式。你能删除所有的目标文件和模块文件吗?以确保所有文件都是干净的,并且是由当前版本的编译器生成的,然后重新发布
    gfortran.exe-c mod_testmod.f90
    gfortran.exe-c main.f90
    ?@VladimirF-你看到我的了。它是一个空模块,作为MCVE放在一起。请看更新的作品@Pierredebyl-这就是我所做的。这是一个从零开始组装的MCVE。我会试试这个并发回。在升级msys2/gfortran之前,您是否也尝试了一些失败的组合?@sancho.s我没有安装旧的gfortran,因此我没有测试它。我安装了
    gfortran
    (碰巧是更新的),只是为了测试您的案例。我在升级时遇到了困难。。。我觉得升级可能会解决这个问题很奇怪,但我会继续尝试。@sancho.s也许你可以尝试全新的MSYS2 env。它可能是某个地方的一个bug,在升级过程中得到了修复。我觉得没那么奇怪。到处都是bug。我刚升级到8.3.0,我也遇到了同样的错误。