| 查看: 1170 | 回复: 4 | ||
[求助]
未分配内存的动态数组,如何作为参数传递到子函数,并在子函数中分配内存 已有2人参与
|
|
这是我的代码,编译不通过,提示错误是: ||Error: Dummy argument 'ns' of procedure 'rd' has an attribute that requires an explicit interface for this procedure| 代码请点这里查看 http://paste.ubuntu.com/6603805/ [ Last edited by heyzol on 2013-12-20 at 13:52 ] |
» 猜你喜欢
基金申报
已经有6人回复
存款400万可以在学校里躺平吗
已经有6人回复
推荐一本书
已经有13人回复
拟解决的关键科学问题还要不要写
已经有5人回复
基金委咋了?2026年的指南还没有出来?
已经有9人回复
国自然申请面上模板最新2026版出了吗?
已经有17人回复
纳米粒子粒径的测量
已经有8人回复
疑惑?
已经有5人回复
计算机、0854电子信息(085401-058412)调剂
已经有5人回复
Materials Today Chemistry审稿周期
已经有5人回复
» 本主题相关价值贴推荐,对您同样有帮助:

2楼2013-12-20 18:06:24
3楼2013-12-20 18:08:38

4楼2013-12-22 13:43:21
virtualzx
木虫 (著名写手)
- 应助: 263 (大学生)
- 金币: 7161.3
- 红花: 54
- 帖子: 1605
- 在线: 317.6小时
- 虫号: 2069080
- 注册: 2012-10-18
- 性别: GG
- 专业: 理论和计算化学
【答案】应助回帖
★ ★ ★ ★ ★
感谢参与,应助指数 +1
heyzol: 金币+5, ★★★★★最佳答案, 非常感谢 2013-12-23 12:53:37
感谢参与,应助指数 +1
heyzol: 金币+5, ★★★★★最佳答案, 非常感谢 2013-12-23 12:53:37
|
常用方法1,主程序里加入interface block interface subroutine rd(n,ns) integer :: n integer,allocatable :: ns( : ) end subroutine rd end interface 常用方法2,把子程序放在module里 module my_module contains // 把rd的定义放进来 subroutine rd(n,ns) ... end module my_module 然后在主程序里,只需要调用module,就会自动定义子程序。 program main use my_module integer :: n integer, allocatable :: ns( : ) call rd(n,ns) ... end program |
5楼2013-12-22 23:21:04











回复此楼