编译子程序时出错,该子程序使用在同一fortran文件中定义的模块

时间:2015-02-08 18:07:11

标签: compiler-errors fortran

我正在尝试编译fortran文件,timedel.f,文件

此文件创建模块gettimedel

  module gettimedel

  parameter (maxpnt=10000)
  double precision :: q(maxpnt),qen(maxpnt)
  integer :: nrestofit

  end module gettimedel

它定义了两个数组q,qen和整数nrestofit。

稍后在这个fortran文件中,timedel.f,我有一个子程序,它使用这个模块来获取这些数组和整数

      subroutine fitlors(nresdum,npt,dum1,dum2,approx,reson,backgr,
 1     error,ifail)

  use gettimedel

  intent(in) nresdum,npt,dum1,dum2,approx
  intent(out) reson,backgr,error,ifail
  integer :: liw,ifail,i,lw,nresdum,npt
  parameter (liw=2000)
  double precision :: error,backgr,fvec(npt),
 1     work(14*(nresdum+1)+4*(nresdum+1)**2 +4*npt*(nresdum+1)
 2     + 3*npt + (nresdum+1)*(2*(nresdum+1)-1))
  double precision :: dum1(npt),dum2(npt),reson(nresdum*2)
  double precision :: x(nresdum*2+1),tol
  integer :: approx(nresdum),info,iw(liw)
  external fcn,lmdf1
  work=0.0D0
  x=0.0D0
  nrestofit=nresdum
  q(1:npt)=dum1
  qen(1:npt)=dum2
  do i=1,nrestofit
     x(2*i-1)=qen(approx(i))
     x(2*i)=q(approx(i))
  enddo
  tol=1.0D-03

          call lmdif1 (fcn,npt,nrestofit*2+1,x,fvec,tol,info,iw,
 *              work,lw)            
  reson=x(1:nrestofit*2)
  backgr=x((nrestofit*2)+1)
    print *,'Fitlors done.INFO=',info
  return
  end

此子例程使用此模块gettimedel来定义整数nrestofit以及模块中使用的数组q()和qen()。

但是当我编译这个fortran文件时,我看到了错误消息

timedel.f(1): error #7001: Error in creating the compiled module file.   [GETTIMEDEL]
      module gettimedel
-------------^
timedel.f(388): error #7002: Error in opening the compiled module file.  Check INCLUDE paths.   [GETTIMEDEL]
      use gettimedel
----------^
timedel.f(407): error #6404: This name does not have a type, and must have an explicit type.   [NRESTOFIT]
      nrestofit=nresdum
------^
timedel.f(415): error #6404: This name does not have a type, and must have an explicit type.   [Q]
      q(1:npt)=dum1
------^
timedel.f(415): error #6514: A substring must be of type CHARACTER.   [Q]
      q(1:npt)=dum1
------^
timedel.f(415): error #6054: A CHARACTER data type is required in this context.   [DUM1]
      q(1:npt)=dum1
---------------^
timedel.f(415): error #6366: The shapes of the array expressions do not conform.   [Q]
      q(1:npt)=dum1
------^
timedel.f(416): error #6404: This name does not have a type, and must have an explicit type.   [QEN]
      qen(1:npt)=dum2
------^
timedel.f(416): error #6514: A substring must be of type CHARACTER.   [QEN]
      qen(1:npt)=dum2
------^
timedel.f(416): error #6054: A CHARACTER data type is required in this context.   [DUM2]
      qen(1:npt)=dum2
-----------------^
timedel.f(416): error #6366: The shapes of the array expressions do not conform.   [QEN]
      qen(1:npt)=dum2
------^
compilation aborted for timedel.f (code 1)
make: *** [timedel.o] Error 1

我可以解决这个问题但是在子例程fitlors中定义q,qen和nrestofit的类型但是我想修复它以便模块gettimedel正确定义这些类型。 (我认为我的代码应该这样做)。

我不认为这是INCLUDE路径的问题,因为模块gettimedel是在与子例程相同的文件中创建的。

我正在使用编译器ifort。

如有任何帮助将不胜感激,如果需要进一步的信息,请告诉我。

非常感谢

詹姆斯

(从minpack调用函数lmdif1)

1 个答案:

答案 0 :(得分:0)

一些建议(采用这种格式,因为我无法评论)您可能想尝试解决此问题:

1将子程序fitlors放入一个新模型(如果你愿意,可以在同一个文件中)然后在这个模型中使用gettimedel

2尝试将您的子程序放在主程序后面(可能已经这样做了)

4通常我将我的参数定义为(也许maxpnt是罪魁祸首?):

integer, parameter :: a=1

5尝试添加隐式none,并查看编译器输出是否更改

相关问题