Fortran Coder

查看: 8828|回复: 5
打印 上一主题 下一主题

[非线性] DNEQNF 算法求解非线性方程组

[复制链接]

23

帖子

9

主题

0

精华

熟手

F 币
124 元
贡献
79 点
跳转到指定楼层
楼主
发表于 2015-3-19 16:09:43 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式
大家好,我采用DNEQNF求解非线性方程组,代码如下:
[Fortran] 纯文本查看 复制代码
C module function_equation
 C implicit none

 C contains
 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
 C end module
 program main_test
 use imsl
 C use function_equation
 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
 end 

如果希望将求解的方程封装在一个module里面,则出现错误。这样的问题应该怎么解决呢?
(上述代码去掉注释后 ,就将求解的函数封装在module里面了。)
分享到:  微信微信
收藏收藏 点赞点赞 点踩点踩

23

帖子

9

主题

0

精华

熟手

F 币
124 元
贡献
79 点
沙发
 楼主| 发表于 2015-3-20 09:56:18 | 显示全部楼层
楚香饭 发表于 2015-3-19 17:22
错误提示很重要,为什么每次都不给出?

你好 ,这个是提示信息。

D:\Fortran\Algorithm\nonliner_equation_03\main_test.for
D:\Fortran\Algorithm\nonliner_equation_03\main_test.for(22) : Error: The attributes of this name conflict with those made accessible by a USE statement.   [FCN]
external FCN
-----------------^
D:\Fortran\Algorithm\nonliner_equation_03\main_test.for(29) : Error: The characteristics of dummy argument 1 of the associated actual procedure differ from the characteristics of dummy argument 1 of the dummy procedure. (12.2)   [FCN]
call dneqnf(FCN,errrel,n,itmax,x_guess,ans,fnorm)
--------------------^
D:\Fortran\Algorithm\nonliner_equation_03\main_test.for(29) : Error: The characteristics of dummy argument 2 of the associated actual procedure differ from the characteristics of dummy argument 2 of the dummy procedure. (12.2)   [FCN]
call dneqnf(FCN,errrel,n,itmax,x_guess,ans,fnorm)
--------------------^
Error executing df.exe.

main_test.obj - 3 error(s), 0 warning(s)

非常感谢!!
您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )

GMT+8, 2024-5-16 06:58

Powered by Tencent X3.4

© 2013-2024 Tencent

快速回复 返回顶部 返回列表