当需要实数时,尝试使用参数作为过程调用例程

时间:2017-04-23 15:44:14

标签: fortran runtime-error fortran90 silverfrost-fortran

我有一个Fortran程序,编译没有问题,但后来出错:

  

尝试使用参数编号1作为过程调用例程   需要真实的(种类= 2)

     

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

     

main - 在第65行[+ 00c8]

的文件exercise2base.f90中

我真的不知道这意味着什么,我想也许这意味着我将一个参数传递给一些不正确类型的函数,但是给出的参考文献没有意义:< / p>

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

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

我正在使用Silverfrost和Plato IDE。

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

编辑:代码现在一直被修剪到它的基本功能,只有声明和简单的&#34;虚拟&#34;计算

0 个答案:

没有答案