风和 发表于 2023-7-7 18:56:09

求助,关于imsl5.0函数使用

想用imsl解非线性方程组的方法求计算程序的解(就是逐步逼近),用的imsl里的是zreal函数,但是这个函数非要用external,外部函数,我这整套程序都是在算这个结果,总不至于全部都放外边,求大神支招。

风和 发表于 2023-7-7 20:16:00

program main
include 'link_f90_static.h'
use test

use numerical_libraries

call ttt


pause
end program



module test
include 'link_f90_static.h'
use numerical_libraries
contains

real function f(x)!样例,实际主计算程序比这个多的多
implicit none
real x
f=X**2+5*X+3
!write(*,*)x,f
return
end function


subroutine ttt
implicit none
integer, parameter :: ITMAX = 100   !最大计算次数
integer, parameter :: NROOT = 1   !初始值数量
real, parameter :: EPS = 1.0E-6   !定义两个解之间最短距离,任何两个解的差值一定不小于EPS,ABS(Xi-Xj)>=eps
real, parameter :: ERRABS = 1.0E-6!当ABS(F(Xi))<ERRABS时,就视Xi为F(Xi)的解
real, parameter :: ERRREL = 1.0E-6!当新Xi和就Xi值,很接近时,就视Xi为解,不再做新的逼近
real, parameter :: ETA =0.01 !0.0005 !求解步长
integer INFO(NROOT)
real,external :: f
real :: X(NROOT)   !答案
real :: XGUESS(NROOT) =0 !(/ -1.0000, 1.0000/)

call ZREAL (f, ERRABS, ERRREL, EPS, ETA, &
            NROOT, ITMAX, XGUESS, X, INFO)
write(*,*) X !,f(X)

end subroutine

end module

风和 发表于 2023-7-8 16:13:53

该问题已解决
页: [1]
查看完整版本: 求助,关于imsl5.0函数使用