Compiling Multiple Files with modules

2019-07-23 14:48发布

问题:

I am programming in Fortran 90 using GFortran and I'm having troubles with Modules. When I compile the code below, I get the following error:

Derivatives.f90:7.16:
Included at C:\Users\dchalhub\Dropbox\Doutorado\#Tese\New folder\main.f90:1:
    Use Mesh
            1
Fatal Error: Can't open module file 'mesh.mod' for reading at (1): No such file or directory
gfortran.exe: Internal error: Aborted (program f951)
Please submit a full bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.

So, the 'mesh.mod' file is not created. But when I remove the first two lines: 'include 'Derivatives.f90'' and 'include 'Poisson.f90'' the module is created without any problems.

After the mod file is created, I put back the first two lines, compile the code again and it works perfectly.

include 'Derivatives.f90'
include 'Poisson.f90'

!**************************************************************
MODULE MESH
IMPLICIT NONE
INTEGER :: IMAX,JMAX,NMAX
REAL(8), ALLOCATABLE :: XD(:),YD(:),FX(:,:),FY(:,:)
REAL(8) :: PI,E,DX,DY,H,L,RHO,MU
PARAMETER (PI = ACOS(-1.D0))
PARAMETER (E = 2.71828182845904523536028747135266249775724709369995)
END MODULE MESH
!**************************************************************



!**************************************************************
!*********** Lid-driven Cavity Program*************************
!**************************************************************
program Cavity
Use Mesh
implicit none


End program Cavity

I don't know why but there is something wrong with compiling multiple files with modules. Does any one know what should I do to make it work properly?

标签: fortran90