INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Gfortran module definition

Gfortran module definition

(OP)
Hi all,

I am struggling to get a module working, it returns the error:

$ gfortran -o executable variable1.f95

/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20):
undefined reference to `main'
collect2: error: ld returned 1 exit status

I'm using Ubuntu MATE V16.04 running Gfortran v5.4

I've noticed I have to call the module with the actual name 'variable1 otherwise it Gfortran won't see it.

The module definition follows:

MODULE variable1


implicit none

SAVE

integer nmax !number of steps in problem
integer isn !integration step number
double precision stepsize,fintim
double precision printinterval, printtime
integer Imax !number of state variables
integer I,a,ii,b !a = 0, predictor step,
!1= corrector step
integer ifintim,Irecipstepsize,Itime
double precision, ALLOCATABLE :: y(:,:)
double precision, ALLOCATABLE :: ydot(:,:)
double precision, ALLOCATABLE :: ydum(:)
double precision, DIMENSION(:,:), ALLOCATABLE :: dydt


double precision TMD,MM,VW,PO,B1,B2,MF,cpgmix,gasvi
double precision Twout,HW,TM,Xd,PI,HI,QM,HZ,htcw,di,tout
double precision KW,KTI,KTO,CPw,KTempd,KPecon,KPdrum
double precision KWgas,KTOgas,KTIgas,KTempg,CPgas

double precision TsoPL,HsoPL,RsoPL,TMPL,QMPL
double precision WsiPL,TgiPL,TgoPL,TgoPLD,WgiPL
double precision WgiFS,TMPLD,HsoPLD,PsoPL,QradPL,PgiPL,PgoPL
double precision RhogPL,RhogPLD,PsoPLD,TgoFS,Gasconst

double precision QMFS,WsiFS,WsoSM,TgoFSD
double precision WgiFRH,WgiPSH,TMFSD,HsoFSD,PsoFS,PsoFSD,PsoFS_D,QradFS
double precision PgoFS,RhogFS,RhogFSD,TgoFRH,HsoSM,TgoPSH
double precision HsoPSH,TMPSH,PsoPSH,RhogPSH,QradPSH,RsoPSH
double precision HsoPSHD,TMPSHD,PsoPSHD,RhogPSHD,TgoPSHD,QMPSH,WsiPSH
double precision PgoPSH,TsoPSH
double precision TsoFRH,HsoFRH,WgiPRHT,RsoFRH,TMFRH,PsoPRHT,HsoPRHT
double precision QMFRH,WsiFRH,WsoRSM,WsoRSMD,TgoFRHD,TMFRHD,HsoFRHD,PsoFRH
double precision PsoFRHD,QradFRH,PgoFRH,RhogFRH,RhogFRHD,TgoPRHT,HsoFRHSM
double precision TsoPRHT,RsoPRHT,TMPRHT,HsoPRHTD,TMPRHTD,TgoPRHTD
double precision PsoPRHTD,RhogPRHTD,PsoPRHB,HsoPRHB,QMPRHT,WsiPRHT
double precision WgiPRHB,QradPRHT,PgoPRHT,RhogPRHT,TgoPRHB,PsoCRHM
double precision WgiHGT,HsoCRHM
double precision TsoPRHB,RsoPRHB,TMPRHB,HsoPRHBD,TMPRHBD,TgoPRHBD
double precision PsoPRHBD,RhogPRHBD,QMPRHB,WsiPRHB,RhogPRHB,PgoPRHB
double precision QradPRHB
double precision PgoRHECON,RhogRHECON,WgiRHECON,WgiRHGDamper,RhogRHECOND
double precision PgoSHECON,RhogSHECON,WgiSHECON,WgiSHGDamper,RhogSHECOND
double precision WgiCGT,PgoECONmix,RhogECONmix,RhogECONmixD
double precision TgoECONmix,TgoECONmixD,WgiAHMILL,PgiAHMILL,RhoigAHMILL
double precision RhoigAHMILLD,TgiAHMILL,TgiAHMILLD
double precision TgoAHMILL,TgoAHMILLD,WleakAHMILL,TMAHMILL,TMAHMILLD
double precision WgoAHMILL,PgoAHMILL,RhogAHMILL,RhogAHMILLD,TgdownAHMILL
double precision MMAHMILL,AsurfaceAHMILL,khtcAHMILL

double precision WgiAHMAIN,PgiAHMAIN,RhoigAHMAIN,WgoAHMAIN
double precision RhoigAHMAIND,TgiAHMAIN,TgiAHMAIND

double precision TgoAHMAIN1,TgoAHMAIN1D,WleakAHMAIN1,TMAHMAIN1,TMAHMAIN1D
double precision WgiAHMAIN1,WgoAHMAIN1,PgoAHMAIN1,RhogAHMAIN1,RhogAHMAIN1D
double precision MMAHMAIN,AsurfaceAHMAIN,khtcAHMAIN,WgoAHMAIN1D

double precision TgoAHMAIN2,TgoAHMAIN2D,WleakAHMAIN2,TMAHMAIN2,TMAHMAIN2D
double precision WgoAHMAIN2,PgoAHMAIN2,WgiAHMAIN2
double precision RhogAHMAIN2,RhogAHMAIN2D

double precision TleakAHMILL,TleakAHMAIN1,TleakAHMAIN2
integer OPMOFRAHMILL,OPMOFRAHMAIN1,OPMOFRAHMAIN2
integer AHTYPEAHMILL,AHTYPEAHMAIN


double precision RhogiPL,RhogiPLD

double precision WgiDamper1,RhogDamper1D,WgiDamper2,RhogDamper2D

double precision TgiPRE,TgiPRED,WgiPRE,PgiPRE,VolgPRE,RhoigPRE,RhoigPRED
double precision TgoPRE,TgoPRED,WgoPRE,PgoPRE,VolgPRECIP,RhogPRE,RhogPRED

double precision IGVposA,IGVposAD,PgiPL_lag,PgiPL_lagD
double precision Intac, IntacD,Contr_out
double precision manDVID
integer AMFLAGID

double precision, parameter :: CPM = 0.465d0 !tube material specific heat capacity KJ/kgK
double precision, parameter :: RHOM = 7.833d3 ! carbon steel density kg/m3


! real(8) gasflow,gasvol


double precision PRhpt,R3hpt,HsoCRSH_fit,Tsihpt,wgIDfan
double precision vgIDfan, PgoID, Pgstack, KglossID

double precision Tgog1,Tgog2,Tgog3,Rhog1,Rhog2,Rhog3
double precision Tgog1D,Tgog2D,Tgog3D,Rhog1D,Rhog2D,Rhog3D
double precision time,Wgin1,Wgin2,Wgin3,Wgin4,Wgin5,Wgin6
double precision kgloss,pgo1,pgo2,pgo3,Tgdown3,KQloss1,volgas1
double precision Rgas,Tgin1,Wgo1,Wgo2,Wgo3,CPgas1,CPgas2,CPgas3

! set up pre calculated values
! fuel is FyF @ 2.09% O2 wet
double precision, parameter :: CO2 = 0.233d0
double precision, parameter :: H2O = 0.0345d0
double precision, parameter :: O2 = 0.0222d0
double precision, parameter :: N2 = 0.708d0
double precision, parameter :: SO2 = 0.0017d0

! determine gas constant for mixture
double precision, parameter :: Ro = 8.3144d0 !kJ/kmole K
double precision, parameter :: Mwcot = 44.d0
double precision, parameter :: Mwoxy = 32.d0
double precision, parameter :: Mwnit = 28.d0
double precision, parameter :: Mwsuldi = 64.d0
double precision, parameter :: Mwmoist = 18.d0
double precision, parameter :: qh1 = 1.d5 !kW
double precision, parameter :: qh2 = 1.d5
double precision, parameter :: qh3 = 1.d5


END MODULE variable1
!---------------------------------------------------------------

RE: Gfortran module definition

You've got a module - the module won't do anything unless you have a program that calls it. Try something like

CODE

module modulename
...
end module
program anyname
   use modulename

   ! call routines from modulename
end program 

Alternatively, you can put the program in a different file and build both files together

RE: Gfortran module definition

(OP)
Hi xwb,

I am using this module in a main program via the USE statement, I should have mentioned this, sorry.

RE: Gfortran module definition

Does variable1.f95 contain the program?

If it doesn't, you have to add the file to the compile/link line

RE: Gfortran module definition

Oh boy...you really need to go beyond scalars, that declaration is a bit ridiculous.

You need your own type definitions (like C structs) and collect related variables...instead of all those common sufixes you are using.

RE: Gfortran module definition

(OP)
Hi salgerman,

yes you're probably right. However, the data definitions are the least of my problems currently. I'd just like to get something working

RE: Gfortran module definition

Baby steps, baby steps...


module myvars_mod
implicit none
integer i, j, k
end module myvars_mod

program main
use myvars_mod
implicit none
j = 3
write(*,*) "j = ", j
end program main


Start with something like that; then, move the module to another file, etc.

RE: Gfortran module definition

(OP)
Thanks salgerman, I'll try this.

RE: Gfortran module definition

I have gotten the same type errors when using code::blocks. then I just gave the command directly in Dos to gfortran having nothing to do with code::blocks and then mine worked.

like i use
gfortran -c modulename.f95
gfortran main program.f95 modulename.o

It also worked in directly at dos prompt BUT NOT in code;;blocks when
put them both in the same file with the module part first( though don't know whether that is really necessary) with the single
command

gfortran main program.f95

RE: Gfortran module definition

(OP)
Thanks zmth, I'll try what you suggest. Despite contributions from others none of which worked I might have a chance now.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close