program main
implicit none
integer :: Time(5), Inflow(5)
integer :: j
real :: CurTime, InflowNow
Time = (/ 0, 1, 3, 4, 8 /)
Inflow = (/ 10, 15, 20, 22, 15 /)
Do j = 1, 5
IF(CurTime == Time(j)) Then
InflowNow = Inflow(j)
Exit
Else IF(CurTime < Time(j)) Then
InflowNow = Inflow(j-1) + (CurTime - Time(j-1))*(Inflow(j) - Inflow(j-1)) / (Time(j) - Time(j-1))
Exit
End IF
End Do
end
fcode 发表于 2023-1-10 10:43
数百行,乃至千行。
这个不算多,是我的话,就全部读在内存里。
necrohan 发表于 2023-1-10 22:06
如果Time是整数,可以考虑把Time作为数组序号用,这样插值就不用查找了,Time数组也不需要了,但是缺失的数 ...
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |