我用fortran90 写程序时出现了这样的问题,谁能告诉我是怎么回事啊?
代码如下:moduleglobalimplicitnoneintegera,bcommona,bendmoduleprogramexampleuseglobalimpli...
代码如下:
module global
implicit none
integer a, b
common a,b
end module
program example
use global
implicit none
a=1
b=2
call sub(a, b)
end program
subroutine sub(a, b)
use global
implicit none
write(*,*) a+b
return
end subroutine
编译时出现了这样的问题:
error #6405: The same named entity from different modules and/or program units cannot be referenced. [A]
error #6405: The same named entity from different modules and/or program units cannot be referenced. [B]
error #6404: This name does not have a type, and must have an explicit type. [A]
error #6404: This name does not have a type, and must have an explicit type. [B] 展开
module global
implicit none
integer a, b
common a,b
end module
program example
use global
implicit none
a=1
b=2
call sub(a, b)
end program
subroutine sub(a, b)
use global
implicit none
write(*,*) a+b
return
end subroutine
编译时出现了这样的问题:
error #6405: The same named entity from different modules and/or program units cannot be referenced. [A]
error #6405: The same named entity from different modules and/or program units cannot be referenced. [B]
error #6404: This name does not have a type, and must have an explicit type. [A]
error #6404: This name does not have a type, and must have an explicit type. [B] 展开
2个回答
展开全部
common公共变量的 数据类型声明语句 和 common声明语句,在凡是使用到它的主程序或者子程序(模块)中都必须再写一遍,谁用到它谁就得写。
.
.
另外common用法是已经淘汰的低效、不安全写法,你都已经用module这种现代结构了就该用module的办法,何必混进落后的common? 事实上你直接在主程序里面(implicit none的下一行)写use global 就行了,根本不需要common
.
.
另外common用法是已经淘汰的低效、不安全写法,你都已经用module这种现代结构了就该用module的办法,何必混进落后的common? 事实上你直接在主程序里面(implicit none的下一行)写use global 就行了,根本不需要common
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询