在模块中的另一个函数中使用一个函数

时间:2019-05-20 20:34:54

标签: module fortran

我的模块中有函数和子例程。然后,我在主程序中使用该模块。但是在我的模块内部有一个函数,我在其中调用另一个函数。虽然我在编译时说它在Fortran中是未定义的引用。

module A
  implicit none
  real*8 :: k(1:4),ls(1:4)
contains
  function B(p,q)
    implicit none
    real*8 :: p,q,B
     B=p+q
  end function B

  subroutine C(u,v,res)
   implicit none
   real*8 :: u,v,res,B

   res=B(u,v)

  end subroutine
end module A

program main
  use A
  implicit none
  real*8 :: Out
  call C(4.d0,3.d0,out)
  write(*,*) out
end program main

我想获得7.0d0,但是我在Fortran中获得了B的未定义引用。

0 个答案:

没有答案
相关问题