Fortran Coder

标题: 调用imsl的 DN2QNJ出现错误 [打印本页]

作者: Yowai    时间: 2018-6-14 20:33
标题: 调用imsl的 DN2QNJ出现错误

test.txt (12.46 KB, 下载次数: 4)

调用imsl的 DN2QNJ的时候(封装在module中)出现以下错误提示:
1>C:\Users\wenv\source\repos\Console5\Console5\Source1.f90(238): error #7061: The characteristics of dummy argument 1 of the associated actual procedure differ from the characteristics of dummy argument 1 of the dummy procedure.   [FCN]
1>C:\Users\wenv\source\repos\Console5\Console5\Source1.f90(238): error #7062: The characteristics of dummy argument 2 of the associated actual procedure differ from the characteristics of dummy argument 2 of the dummy procedure.   [FCN]
1>C:\Users\wenv\source\repos\Console5\Console5\Source1.f90(238): error #7063: The characteristics of dummy argument 3 of the associated actual procedure differ from the characteristics of dummy argument 3 of the dummy procedure.   [FCN]
1>C:\Users\wenv\source\repos\Console5\Console5\Source1.f90(238): error #7061: The characteristics of dummy argument 1 of the associated actual procedure differ from the characteristics of dummy argument 1 of the dummy procedure.   [LSJAC]
1>C:\Users\wenv\source\repos\Console5\Console5\Source1.f90(238): error #7062: The characteristics of dummy argument 2 of the associated actual procedure differ from the characteristics of dummy argument 2 of the dummy procedure.   [LSJAC]
1>C:\Users\wenv\source\repos\Console5\Console5\Source1.f90(238): error #7063: The characteristics of dummy argument 3 of the associated actual procedure differ from the characteristics of dummy argument 3 of the dummy procedure.   [LSJAC]




调用指令如下:
program kakusann

Include 'link_fnl_shared.h'
!use numerical_libraries
use DN2QNJ_int
USE UMACH_INT
USE Inverse


call  DN2QNJ (FCN, LSJAC, ERRREL, N, ITMAX, XGUESS, X, FNORM, FVEC, FJAC, R, QTF, WK)


具体代码在附件里面,希望得到大佬的帮助,谢谢。

作者: vvt    时间: 2018-6-15 07:49
[Fortran] 纯文本查看 复制代码
  subroutine fcn(X,F,N)
    integer, intent(in) :: n   
    real(kind(1d0)), intent(in) :: x(n)  
    real(kind(1d0)), intent(out) :: f(n)

subroutine lsjac(n,X,fjac)
  integer::i1,j1
  integer, intent(in) :: n                                                         
  real(kind(1d0)), intent(in) :: x(n)                                             
  real(kind(1d0)), intent(out) :: fjac(n,n)

作者: Yowai    时间: 2018-6-15 09:56
vvt 发表于 2018-6-15 07:49
[mw_shl_code=fortran,true]  subroutine fcn(X,F,N)
    integer, intent(in) :: n   
    real(kind(1d0 ...

谢谢回复,貌似是能成功调用函数了,但是又出现了新的问题。也没有错误提示。您知道C:\Users\wenv\Desktop\zhao是什么意思吗?
作者: vvt    时间: 2018-6-15 10:41
这个问题需要精细的单步调试才能找到原因。
作者: Yowai    时间: 2018-6-15 15:45
vvt 发表于 2018-6-15 10:41
这个问题需要精细的单步调试才能找到原因。

谢谢回复。问题解决了,出错是数组越界。但我有一点不明白。
我有两台电脑,一个mac,一个windows。都装的ivf。mac用终端运行,windows用vs。
一模一样的代码,mac能运行,windows就会出问题。
比如数组
integer::i
real::a(3)


do i=1,3
a(i+2)=i
end do

在mac会出结果a(3)=1,a(4)=2,a(5)=3
但在windos就会报错,说数组越界。
您知道这个是什么原因吗?

作者: vvt    时间: 2018-6-15 15:54
本帖最后由 vvt 于 2018-6-15 15:58 编辑

跟操作系统没关系呀,主要是编译器的默认参数不一样。
ivf 用VS编译,会默认检查数组越界,而命令行则不会

命令行可以加选项 -check:bounds 使其增加越界检查。
作者: Yowai    时间: 2018-6-16 22:58
vvt 发表于 2018-6-15 15:54
跟操作系统没关系呀,主要是编译器的默认参数不一样。
ivf 用VS编译,会默认检查数组越界,而命令行则不会
...

谢谢回复,解决了我很大的困惑。




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