Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Migrating fortran from windows to unix (mac) 2

Status
Not open for further replies.

dlfritz

Technical User
Dec 3, 2010
2
US
I have inherited this fortran code from a colleague of mine and wish to expand on his research. He had written the fortran code in question for the Lahey Fujitsu windows compiler, I however do not have access to this software, nor do I have a windows machine. After receiving his code I had attempted to compile it on my Mac with gfortran and the code immediately gave the following error:


$ gfortran cavitymat.f95
cavitymat.f95:13.15:

USE MYVAR
1
Fatal Error: Can't open module file 'myvar.mod' for reading at (1): No such file or directory


The source code (cavitymat.f95) has all of the subroutines included as well as the module MYVAR. This module is responsible for calling and allocating all of the global variables. I have attempted to compile this with many different flags all producing the same error. If anyone can help me, I would like to know how to migrate this code over to the UNIX system.

Thank you in advance for your help!

Dave
 
You need to recompile MYVAR too try:
gfortran cavitymat.f95 myvar.f95

 
mikrom,

Thank you for you quick reply! The thing is myvar is a module at the end of the cavitymat.f95 program source and is not a separate file. I have tried removing it from the original file and saving it as myvar.f95 and compiling just as you have suggested however it still results in the same error. I cant imagine this will help too much however I will include it any way, here is the MYVAR module at the end of the source code (pardon the spacing as it didn't copy very well):

IMPLICIT NONE

INTEGER :: NI,NJ,NK,NT,NSWP,NICON,NNODO,NPLOTS,NSAVE,MAUX,TAUX,XEND,VIDEO, &
SOURCE(3,2),PREF(3,3),ITER,OUTER,CONT,TNS(2),DIST
INTEGER, ALLOCATABLE :: ICON:),:),NODOC:),:),NODOM:),:,:),KE:))
DOUBLE PRECISION, ALLOCATABLE :: AP:),:,:),AE:),:,:),AW:),:,:),AN:),:,:),AS:),:,:),AT:),:,:),AB:),:,:), &
TL:)),R:)),NODO:),:),ELEMFILL:),:), &
FLUIDVIS:),:,:),XP:)),XP0:)),VISCOSITY:)),SU:),:,:), &
FI:),:,:),FI0:),:,:,:),FI1:),:,:,:),PC:)),XYZ:),:,:),FIP:),:)
DOUBLE PRECISION :: URF,SOR,FIBC(6),QI,DX,DY,DZ,DT,LX,LY,LZ,TF,PI,LAMMBDA, &
MU1,MU2,GAMMA,THETA,RM,TREF,SATA,SATV,SATS,VOL,AREA,PER,QIT,QR
CHARACTER (LEN=100) :: TITLE
 
dlfritz said:
The thing is myvar is a module at the end of the cavitymat.f95 program source and is not a separate file.
The module don't need to be in a separate source file, it could be in the same file.
It seems to be ok...
 
dlfritz said:
The thing is myvar is a module [highlight]at the end[/highlight] of the cavitymat.f95 program source and is not a separate file.
The problem seems to be that it is at the end
when I try this
Code:
program mypgm
  use mymod
  NI = 1
  NJ = 2
  URF = 3.1415926535897931
  SOR = 2.7182818284590451 
  write(*,*) 'NI = ', NI, ', NJ = ', NJ
  write(*,*) 'URF = ', URF, ', SOR = ', SOR  
end program mypgm

module mymod
IMPLICIT NONE

INTEGER                        :: NI,NJ,NK,NT,NSWP,NICON,NNODO,NPLOTS,NSAVE,MAUX,TAUX,XEND,VIDEO,  &
                                  SOURCE(3,2),PREF(3,3),ITER,OUTER,CONT,TNS(2),DIST
INTEGER,          ALLOCATABLE  :: ICON(:,:),NODOC(:,:),NODOM(:,:,:),KE(:)
DOUBLE PRECISION, ALLOCATABLE  :: AP(:,:,:),AE(:,:,:),AW(:,:,:),AN(:,:,:),AS(:,:,:),AT(:,:,:),AB(:,:,:),   &
                                  TL(:),R(:),NODO(:,:),ELEMFILL(:,:),    &
                                  FLUIDVIS(:,:,:),XP(:),XP0(:),VISCOSITY(:),SU(:,:,:),                 &
                                  FI(:,:,:),FI0(:,:,:,:),FI1(:,:,:,:),PC(:),XYZ(:,:,:),FIP(:,:)
DOUBLE PRECISION               :: URF,SOR,FIBC(6),QI,DX,DY,DZ,DT,LX,LY,LZ,TF,PI,LAMMBDA,  &
                                  MU1,MU2,GAMMA,THETA,RM,TREF,SATA,SATV,SATS,VOL,AREA,PER,QIT,QR
CHARACTER (LEN=100)            :: TITLE 
end module mymod
to compile, I get this error
Code:
$ gfortran mod_ex.f95 -o mod_ex
mod_ex.f95:2.11:

  use mymod
          1
Fatal Error: Can't open module file 'mymod.mod' for reading at (1): No such file or directory
gfortran.exe: Internal error: Aborted (program f951)
Please submit a full bug report.
See <[URL unfurl="true"]http://gcc.gnu.org/bugs.html>[/URL] for instructions.
But when I declare the module before the main program
Code:
module mymod
IMPLICIT NONE

INTEGER                        :: NI,NJ,NK,NT,NSWP,NICON,NNODO,NPLOTS,NSAVE,MAUX,TAUX,XEND,VIDEO,  &
                                  SOURCE(3,2),PREF(3,3),ITER,OUTER,CONT,TNS(2),DIST
INTEGER,          ALLOCATABLE  :: ICON(:,:),NODOC(:,:),NODOM(:,:,:),KE(:)
DOUBLE PRECISION, ALLOCATABLE  :: AP(:,:,:),AE(:,:,:),AW(:,:,:),AN(:,:,:),AS(:,:,:),AT(:,:,:),AB(:,:,:),   &
                                  TL(:),R(:),NODO(:,:),ELEMFILL(:,:),    &
                                  FLUIDVIS(:,:,:),XP(:),XP0(:),VISCOSITY(:),SU(:,:,:),                 &
                                  FI(:,:,:),FI0(:,:,:,:),FI1(:,:,:,:),PC(:),XYZ(:,:,:),FIP(:,:)
DOUBLE PRECISION               :: URF,SOR,FIBC(6),QI,DX,DY,DZ,DT,LX,LY,LZ,TF,PI,LAMMBDA,  &
                                  MU1,MU2,GAMMA,THETA,RM,TREF,SATA,SATV,SATS,VOL,AREA,PER,QIT,QR
CHARACTER (LEN=100)            :: TITLE 
end module mymod

program mypgm
  use mymod
  NI = 1
  NJ = 2
  URF = 3.1415926535897931
  SOR = 2.7182818284590451 
  write(*,*) 'NI = ', NI, ', NJ = ', NJ
  write(*,*) 'URF = ', URF, ', SOR = ', SOR  
end program mypgm
then it compiles and runs
Code:
$ gfortran mod_ex.f95 -o mod_ex

$ mod_ex
 NI =            1 , NJ =            2
 URF =    3.1415927410125732      , SOR =    2.7182817459106445
Btw, I never declared module after the main program - maybe Lahey-Fujistu compiler you used makes it possible.
 
Lahey-Fujitsu is a 2 pass compiler so it is possible to have modules anywhere. It tends to be pure F95 or F90 so all of the F77isms are taken out. You can't mix and match with Lahey. Took me ages to go from gfortran to Lahey: it was moaning about every other thing. A lot easier the other way round.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top