祖传代码错误
cvf祖传代码现需要ivf编译代码示意:subroutine sub
use link
implicit none
integer :: add
integer :: a,b
potinter(add,fileonpen)
call fileonpen(a,b)
end subroutine sub
module link
interface
subroutine fileopen(a,n)
intger :: a,b
end subroutine fileopen
end interface
endmodule link
问题: error#6401: the attributes of this name conflict with those made accessible by a use statement.【fileopen】
在sub中fileopen未定义,ivf编译后错误与link中子例程fileopen命名冲突,cvf编译无误。
求解,祖传代码太大,是否ivf存在某个选项可以关闭这个错误识别,或者如何修改?
除了两个单词拼写错误之外,我这里没有发现这个问题,用的也是ivf
module link
interface
subroutine fileopen(a,n)
integer :: a,b
end subroutine fileopen
end interface
endmodule link
subroutine sub
use link
implicit none
integer :: add
integer :: a,b
pointer(add,fileonpen)
call fileonpen(a,b)
end subroutine sub
program s
call sub()
end program s 楚香饭 发表于 2016-11-2 16:50
除了两个单词拼写错误之外,我这里没有发现这个问题,用的也是ivf
module link ...
确实我也试了下,没有任何问题。
我把module link生成mod文件添加到主程序内,ivf编译也没有任何问题。
但是很奇怪祖传代码还是报错,暂时不能理解。
我想询问下pointer(add,fileopen)是实现了什么样的功能,将一个intger和子例程名fileoepn绑定了地址? 是的,以前 fortran 没有 procedures pointer,所以借用这种方法来加载外部函数。
比如通过 GetProcAddress 获得一个DLL中的函数,结果是 (add) integer ,但是你不能 call integer 啊
所以 pointer( add , fileopen) 令 fileopen 这个函数的首地址,是 add 这个integer的值,这样就类似于 add 是指向 fileopen 这个 procedures 的 pointer 了
以后就可以 call fileopen 了。
(这种方法是不规范的写法,是以前没有 procedures pointer 的权宜之计)
但是,现在 fortran 2003 增加了 procedures pointer ,因此可以不用这样写了。
页:
[1]