Fortran Coder

标题: 关于intent属性的问题! [打印本页]

作者: mkingx    时间: 2014-10-28 15:53
标题: 关于intent属性的问题!
编写了一个小程序,程序见附录!为了便于说明截了两张图,图一是程序截图,图二是错误提示截图
如果把integer,intent(out):: z去掉的话,可以编译成功!
所以迷茫intent(out)该怎么用!!!
[Fortran] 纯文本查看 复制代码
module param
integer :: x,y,z,a,b,c,d
contains

subroutine haha(x,y)
implicit none
integer ,intent(in):: x
integer ,intent(in):: y
integer ,intent(out):: z !// 此处
z=x+y
print*,'z',z
return
end subroutine haha

end module param

program test
use param
implicit none
x=1
y=2
call haha(x,y)

end program test

DeepinScreenshot20141028154920.png (84.41 KB, 下载次数: 198)

DeepinScreenshot20141028154920.png

作者: fcode    时间: 2014-10-28 15:57
z 加了 intent(out) 就必须是虚参
局部变量不允许加 intent
作者: 百事可乐    时间: 2014-10-30 09:36
这是一个逻辑问题哦,语法性反而不强。




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