【发布时间】:2017-02-07 21:39:32
【问题描述】:
我正在尝试编写一个 Fortran 90 程序来执行 Euler 的方法来使用自适应时间步来求解 ode。
我在do while 循环内有一个if 语句,我在其中检查代码每次迭代的错误是否小于某个容差。但是,如果不小于某个公差,我必须改变某个值(步长)并再次进行计算,以获得新的误差与公差进行比较。
看起来像(原谅我这是我第一次使用这个网站):
do while (some condition)
(Get an approximation to the ODE with various subroutine calls)
(Calculate the error)
if (error < tol)
step = step/2
else
step = 2*step
(Something that will return to the top of my do while loop)
end if
end do
例如,我有 do while (i < 4),其中 i 从 1 开始,并且我的误差不小于我的容差,我将不得不以新的步长再次为 i=1 重复计算。
我希望这对阅读本文的人有意义。如果您需要任何澄清,请告诉我。
【问题讨论】: