其实你的函数可以简化一下。
[Fortran] 纯文本查看 复制代码 FUNCTION FUNCRHO (Z)
USE NRTYPE, ONLY: WP
REAL(WP), INTENT(IN) :: Z
REAL(WP) :: FUNCRHO
Real(WP) , parameter :: zList(*) = [-huge(z),5._WP,18._WP,54._WP,92._WP,130._WP,165._WP,huge(z)]
Real(WP) , parameter :: fList(*) = [1220._WP,1487._WP,1945._WP,1966._WP,1966._WP,1966._WP,2123._WP]
integer :: i
Do i = 1 , size(zList)-1
if( zList(i) <= z .and. z < zList(i+1) ) then
funcRho = fList(i)
return
end if
End Do
END FUNCTION FUNCRHO
这样更易读、易修改、易扩展 |