Fortran Coder

查看: 14003|回复: 3
打印 上一主题 下一主题

[指针] 祖传代码错误

[复制链接]

35

帖子

17

主题

0

精华

熟手

F 币
136 元
贡献
240 点
跳转到指定楼层
楼主
发表于 2016-11-2 13:31:26 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
cvf祖传代码现需要ivf编译
代码示意:
[Fortran] 纯文本查看 复制代码
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存在某个选项可以关闭这个错误识别,或者如何修改?

分享到:  微信微信
收藏收藏 点赞点赞 点踩点踩

712

帖子

4

主题

0

精华

大师

农村外出务工人员

F 币
607 元
贡献
311 点

新人勋章爱心勋章水王勋章元老勋章热心勋章

沙发
发表于 2016-11-2 16:50:19 | 只看该作者
除了两个单词拼写错误之外,我这里没有发现这个问题,用的也是ivf

[Fortran] 纯文本查看 复制代码
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

35

帖子

17

主题

0

精华

熟手

F 币
136 元
贡献
240 点
板凳
 楼主| 发表于 2016-11-4 11:38:48 | 只看该作者
楚香饭 发表于 2016-11-2 16:50
除了两个单词拼写错误之外,我这里没有发现这个问题,用的也是ivf

[mw_shl_code=fortran,true]module link ...

确实我也试了下,没有任何问题。
我把module link生成mod文件添加到主程序内,ivf编译也没有任何问题。

但是很奇怪祖传代码还是报错,暂时不能理解。

我想询问下pointer(add,fileopen)是实现了什么样的功能,将一个intger和子例程名fileoepn绑定了地址?

1958

帖子

12

主题

5

精华

论坛跑堂

臭石头雪球

F 币
1341 元
贡献
565 点

美女勋章热心勋章星光勋章新人勋章贡献勋章管理勋章帅哥勋章爱心勋章规矩勋章元老勋章水王勋章

地板
发表于 2016-11-4 13:07:52 | 只看该作者
是的,以前 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 ,因此可以不用这样写了。
您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

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

GMT+8, 2024-4-24 09:36

Powered by Tencent X3.4

© 2013-2024 Tencent

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