Fortran Coder

标题: 非线性方程组:IMSL neqnf [打印本页]

作者: sit2018    时间: 2018-5-27 22:59
标题: 非线性方程组:IMSL neqnf
本帖最后由 sit2018 于 2018-5-27 23:20 编辑

编译器:compaq visual fortran 6.6
以下代码出错:

--------------------Configuration: hello - Win32 Debug--------------------
Compiling Fortran...
C:\Program Files\Microsoft Visual Studio\MyProjects\hello\hello.f90
C:\Program Files\Microsoft Visual Studio\MyProjects\hello\hello.f90(33) : Error: This is an actual argument keyword name, and not a dummy argument name.   [XGUESS]
call neqnf(fcn, x, XGUESS=xguess, FNORM=fnorm)
-------------------^
Error executing df.exe.
hello.exe - 1 error(s), 0 warning(s)


program hello
    use imsl
implicit none
integer n
parameter (n = 3)
integer k, nout
real fnorm, x(n), xguess(n)
external fcn
data xguess/4.0, 4.0, 4.0/
call umach (2,nout)
call neqnf(fcn, x, XGUESS=xguess, FNORM=fnorm)
write (nout, 99999) (x(k),k=1,n), fnorm
99999 format (' the solution to the system is', /, ' x = (', 3f5.1, &
')', /, ' with fnorm = ', f5.4, //)

end program hello
subroutine fcn(x,f,n)
integer n
real x(n), f(n)
real exp,sin
intrinsic exp, sin
f(1) = x(1)+exp(x(1)-1.0)+(x(2)+x(3))*(x(2)+x(3)) -27.0
f(2) = exp(x(2)-2.0)/x(1)+x(3)*x(3)-10.0
f(3) = x(3)+sin(x(2)-2.0)+x(2)*x(2)-7.0
return
end subroutine fcn


作者: sit2018    时间: 2018-5-27 23:21
参考一下帖子没有解决:
http://bbs.fcode.cn/forum.php?mo ... &highlight=imsl
作者: li913    时间: 2018-5-28 10:10
查一下 neqnf 函数 的说明,参数列表没有XGUESS。
作者: sit2018    时间: 2018-5-30 03:51
我是按照手册里的例子写的。一模一样。不知道为什么会出错
作者: sit2018    时间: 2018-5-30 04:11
这个例子可以编译。
http://bbs.fcode.cn/forum.php?mo ... mp;highlight=DNEQNF

program sss

        use imsl

        implicit none

        external FCN
       
        double precision , parameter :: errrel = 1d-7
       
        integer , parameter :: n = 2
        integer , parameter :: itmax = 200
        double precision x_guess,ans(2),fnorm
        x_guess = (1d0,1d0)
        call dneqnf(FCN,errrel,n,itmax,x_guess,ans,fnorm)
       
        print *, ans

        print *, 'Hello World'

        end program sss

        subroutine fcn(xx, yy, nn)
        implicit none
        integer nn
        double precision xx(nn), yy(nn)

        yy(1) = xx(1)**2 + xx(2)**2 - 5d0
        yy(2) = (xx(1) + 1d0) * xx(2) - (3d0 * xx(1) + 1d0)
        return

        end subroutine
作者: li913    时间: 2018-5-30 19:05
如果是完全按照手册的话,就是手册和你实际安装的版本不一样。




欢迎光临 Fortran Coder (http://bbs.fcode.cn/) Powered by Discuz! X3.2