Fortran 当需要实数时,尝试调用带有参数的例程作为过程
我有一个Fortran程序,编译时没有问题,但随后出现错误: 在以下情况下尝试调用参数为1的例程作为过程: 需要一个真实(种类=2)的 根!X_ROOT-在文件exercise2base.f90的第20行[+0074] main-第65行[+00c8]处的exercise2base.f90文件中 我真的不知道这意味着什么,我想这可能意味着我将一个参数传递给了某个类型不正确的函数,但给出的引用没有意义:Fortran 当需要实数时,尝试调用带有参数的例程作为过程,fortran,runtime-error,fortran90,silverfrost-fortran,Fortran,Runtime Error,Fortran90,Silverfrost Fortran,我有一个Fortran程序,编译时没有问题,但随后出现错误: 在以下情况下尝试调用参数为1的例程作为过程: 需要一个真实(种类=2)的 根!X_ROOT-在文件exercise2base.f90的第20行[+0074] main-第65行[+00c8]处的exercise2base.f90文件中 我真的不知道这意味着什么,我想这可能意味着我将一个参数传递给了某个类型不正确的函数,但给出的引用没有意义: 第20行是结束函数x\u rtsmpl 第66行是answer=x_根(bb_积分,l1,l
- 第20行是
结束函数x\u rtsmpl
- 第66行是
answer=x_根(bb_积分,l1,l2,epsx,epsf,根类型)
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
编辑:代码现在被裁剪到基本功能,只需要声明和简单的“虚拟”计算。你能把它缩小一点,并且仍然显示问题吗()?@francescalus我不太理解问题的核心,所以我不想排除可能相关的内容。您能指出(除了一般指南外)错误的真正含义是什么,我应该在哪里找到此类错误的问题原因?我会尽量减少我的代码。@francescalus我减少了代码。如果它仍然需要修剪,请告诉我,我将尝试进一步减少。错误消息指向调用堆栈主->
检查->>x\u root
->x\u rtsmpl
。您应该能够删除任何与此无关的内容。以增量的方式进行,当您可以删除任何内容而不使问题消失时,您就有了一个(希望更多)较小的示例。还有更多的内容需要修剪。例如,直接从master
调用x_root
。没有理由打开第11单元。。等