我正在使用IMSL Fortran Library中的NEQNF函数来求解非线性方程组并得到3个错误.我在x64系统上使用Visual Studio 2017.错误说明如下:
Error #7061: The characterístic of dummy argument 1 of the associated actual procedure differ from the characteristics of dummy argument 1 of the dummy procedure [FCN_SS]
Error #7062: The characterístic of dummy argument 2 of the associated actual procedure differ from the characteristics of dummy argument 2 of the dummy procedure [FCN_SS]
Error #7063: The characterístic of dummy argument 3 of the associated actual procedure differ from the characteristics of dummy argument 3 of the dummy procedure [FCN_SS]
Run Code Online (Sandbox Code Playgroud)
代码是:
include 'link_fnl_shared.h'
use neqnf_int
use umach_int
implicit none
!Declaring variables
.
.
.
Contains
subroutine solve_ss(x, fnorm)
integer n
parameter (n=2)
integer k, nout
real(dp) :: fnorm, x(n), xguess(n)
data xguess/1.0_dp, 0.3_dp/ !guess for total output in units
call umach (2, nout)
call neqnf (fcn_ss, x, xguess=xguess, fnorm=fnorm)
end subroutine solve_ss
subroutine fcn_ss(x, f, n)
implicit none
!specification
integer n
real(dp) :: x(n), f(n)
.
.
.
F(1)=...
F(2)=...
end subroutine fcn_ss
Run Code Online (Sandbox Code Playgroud)
我不确定错误是什么,因为变量的声明在solve_ss和中是相同的fcn_ss.
该库的文档明确指出(此处和此处)您需要use相应的模块才能访问例程的现代实现。
否则,您可能(我无法测试,但我基于此)访问该库的遗留支持。因此,它可能会引导您进入 FORTRAN77 特定接口,而不是通用的 Fortran 90 接口:
NEQNF (FCN, ERRREL, N, ITMAX, XGUESS, X, FNORM)
Run Code Online (Sandbox Code Playgroud)
其他细节是文档明确指出您必须将传递的函数声明为外部函数:
external fcn_ss
Run Code Online (Sandbox Code Playgroud)
不过,我仍然不确定这些猜测。可能是那个错误或任何其他奇怪的错误。请提供反馈。
| 归档时间: |
|
| 查看次数: |
237 次 |
| 最近记录: |