未定义的参考 - fortran

时间:2016-06-10 04:04:57

标签: compiler-errors fortran

我正在编译具有多个链接模块的代码。下面我列出了三个模块:modparamsmain使用modparams; modleeplextemp使用modparams和modparamsmain。

编译时遇到的错误是

modleeplextemp.o: In function `__modleeplextemp_MOD_leeplextemp':
modleeplextemp.f90:(.text+0x341): undefined reference to `__modparams_MOD_id'

我非常感谢任何帮助! 以下是模块:

modparams.f90:

module modparams
implicit none
integer, public:: id, nvar, ntarget,nfix,nsevar,nsestart,nsefin
parameter (nvar=132,ntarget=260,nfix=38,nsevar=132,nsestart=1,nsefin=132)
integer ierr
integer,public:: na=19,nsc=16,nsu=28,ntype=3,nrace=3,ncatstate=4,np=2,nh=3,nsl=5,nslc=3,nslu=3,ndel=5,nba=2,nrandstates=600,nrandshocks=40,ncoeffs=83
integer,public:: minage=18, maxage=41,nstates=15,nshocks=4,nchoices=3,ngammap=11,nxparam=25,ngammavterm=1,ngammahcy=13,ngammau=48,ngammaminwage=2
integer,public:: ngammaps=12,ngammajoby=5,ngammaba=5,cbar=1,nsems=3,sumtime=1, springtime=3, falltime=2,ngammaabar=5
integer,public:: nstataper=35,afqt1=165,afqt2=191,nafqt=219,numwkssem=20,ngammaty=14,ncreg=3,ninit=9,nbase=1492,ncopies=5,nppl=5*1492
integer,public:: minparinc=10,maxparinc=300,grantcut1=20,grantcut2=72,rmbrd2yr=4539,rmbrd4yr=6532,pinc1=57,pinc2=90,nclass=1
end module modparams

modparamsmain.f90:

module modparamsmain
use MPI
use modparams
implicit none
real(8) t1,t2,gammainit(nvar),fv,t7,t8,minstep,maxstep,stepvec(nvar),gammafix(nfix),dqdb(ntarget,1),jmat(ntarget,ntarget),omega(ntarget,ntarget)
real(8)::  xgs(nvar),step(nvar),statacoeffs(ntarget),estcoeffs(ntarget),derbump(nsevar),bigsevec(nsevar)
integer:: nproc 
integer nproc2
integer maxeval,kcount,naux
real(8) ftol,wvar(ntarget,ntarget)
integer id4,i,j,kk,jj,which,seed(2),ii,wflag
external fcn
! include 'mpif.h'      
integer, dimension(MPI_STATUS_SIZE):: STATUS        
end module modparamsmain

modleeplextemp.f90:

module modleeplextemp
use MPI
use modparams
use modparamsmain
implicit none
contains
subroutine leeplextemp(xgs, step, nproc, nproc2, maxeval, fcn, ftol,statacoeffs,estcoeffs,jj)
implicit none
real(8):: ftol,rtol,statacoeffs(ntarget), estcoeffs(ntarget)
integer id2, id3, id4
real(8) fx2(nvar, nvar+1), fx3(nvar, nvar+1), fx4(nvar, nvar+1), fv2(nvar+1), fv3(nvar+1), fv4(nvar+1), fx5(nvar, nvar+1), fv5(nvar+1)
real(8) fx6(nvar, nvar+1), fv6(nvar+1), fx7(nvar, nvar+1), fv7(nvar+1)
integer order3(nvar+1), order2(nvar+1)
real(8) centroid(nvar), eststore(ntarget,ntarget+1),eststore2(ntarget,ntarget+1),eststore3(ntarget,ntarget+1),eststore4(ntarget,ntarget+1)
real(8) eststore5(ntarget,ntarget+1),eststore6(ntarget,ntarget+1),eststore7(ntarget,ntarget+1)
integer min1, reduce2(nvar+1)
real(8) step2, step(nvar), distance, xgs(nvar),t5,t6,dqdb(ntarget,1),jmat(ntarget,ntarget),omega(ntarget,ntarget),wvar(ntarget,ntarget)
integer nproc2, nproc
integer eval, i, j, maxeval,kk,jj,kkk,wflag
external fcn    
 !include 'mpif.h'      
!__________________________
wflag=0
call cpu_time(t5)
!!! initial simplex from the input point
fx3(:,nvar+1)=xgs
do id2=1, nvar
   fx3(:,id2)=fx3(:,nvar+1)
   fx3(id2,id2) =fx3(id2,nvar+1) + step(id2)
enddo
! simulate for the N+1 points
do id2=1,nvar+1
   if (id==mod(id2-1, nproc)+1) then
      call fcn(fx3(:,id2), fv3(id2),statacoeffs,estcoeffs,id,gammafix,dqdb,jmat,wflag,wvar,omega)
      eststore3(:,id2)=estcoeffs
   end if
enddo   
end subroutine leeplextemp
end module modleeplextemp

编译:

# DEFAULT FLAGS
CFLAGS := -I$(CPATH) -I$(F90_MODULES_PATH) 
F90 := mpif90

# ADD ALL LIBRARIES HERE (with -l$LIBRARY_NAME)
LDFLAGS :=  -llapack -v 

# ADD ALL SOURCE FILES HERE (with .o extension)
OBJECTS := modparams.o 
# the typo was on the following line. I had ":" instead of "+"
OBJECTS += modparamsmain.o 
OBJECTS += modleeplextemp.o 
OBJECTS += modutils.o


# ADD ADDITIONAL COMPILER FLAGS HERE
CFLAGS += -fbounds-check
CFLAGS += -ffree-line-length-350


# ADD ADDITIONAL MODULE FOLDERS HERE (with -I$PATH_TO_FOLDER)
F90_MODULES += -I.

all: main

main: main.f90 $(OBJECTS)
    $(F90) $(CFLAGS) $(LDFLAGS) $(OBJECTS) $< -o $@ 

%.o : %.f90
    $(F90) -c $< $(CFLAGS) $(F90_MODULES) $(LDFLAGS) -o $@

clean:
    rm -rf $(OBJECTS) *.mod

0 个答案:

没有答案