0

我有一个可以毫无问题地编译的 Fortran 程序,但随后出现错误:

当需要 real(kind=2) 时,尝试将参数编号为 1 的例程作为过程调用

ROOTS!X_ROOT - 在文件 exercise2base.f90 的第 20 行 [+0074]

main - 在文件 exercise2base.f90 的第 65 行 [+00c8]

我真的不知道这意味着什么,我想这可能意味着我将一个参数传递给了某个类型不正确的函数,但是给出的引用没有意义:

  • 第 20 行是 end function x_rtsmpl
  • 第 66 行是answer=x_root(bb_integral,l1,l2,epsx,epsf,root_type)

所以我不明白发生了什么...

我在 Plato IDE 中使用 Silverfrost。

module roots
  implicit none
  character(20) :: root_type

contains

  function x_rtsmpl(f,x1,x2,epsx,epsf) result(x_root)
    implicit none
    real(2) :: x_root
    real(2), intent(IN) :: x1,x2,epsx,epsf
    interface
      function f(x)
        implicit none
        real(2), intent(IN) :: x
        real(2) :: f
      end function f
    end interface
    real(2) :: xx,fx
    x_root=x1
  end function x_rtsmpl

  function x_root(f,x1,x2,epsx,epsf) result(x_r)
    implicit none
    real(2) :: x_r
    real(2), intent(IN) :: x1,x2,epsx,epsf
    interface
      function f(x)
        implicit none
        real(2), intent(IN) :: x
        real(2) :: f
      end function f
    end interface
      x_r=x_rtsmpl(f,x1,x2,epsx,epsf)
    return
  end function x_root

end module roots

module blackbody
  implicit none
  private
  public :: Ibb

contains
  function Ibb(lambda)
    real(2) , intent (in) :: lambda
    real(2) :: Ibb
    Ibb=lambda+1._2
    return
  end function Ibb

end module blackbody

program master

  use roots
  use blackbody
  implicit none
  real(2) :: l2,epsx,epsf,answer,l1,epsi,requested
  l1=4.d-7
  l2=1.d-4
  epsx=1.d-2*l1
  epsf=1.d-1
  epsi=1.d-4
  answer=x_root(Ibb,l1,l2,epsx,epsf)

end program master

编辑:代码现在一直修剪到它的基本功能,只有声明和简单的“虚拟”计算。

4

0 回答 0