【发布时间】:2017-04-17 15:24:34
【问题描述】:
如果我有一个名为 var 的变量位于名为 myCB 的公共块中,我可以使用相同的名称在不使用公共块 myCB 的其他两个子例程之间传递参数吗?
代码如下。
Subroutine SR1(Var)
!something here using Var
end Subroutine SR1
Subroutine SR2()
....
Call SR1(B)
....
end Subroutine SR2
Subroutine SR3()
common \myCB\ Var
...
! something using the other Var shared with SR4
......
end Subroutine SR3
Subroutine SR4()
common \myCB\ Var
....
... ! something using the other Var shared with SR3
....
end Subroutine SR4
Var 在SR1 和SR2 之间传递确实有问题,问题可能来自公共块中另一个名为Var 的问题吗?
【问题讨论】:
-
我认为您需要给出一个更完整的示例(请参阅minimal reproducible example),并说明您认为存在问题的原因。就目前的问题而言,我们将不得不猜测。范围内有一些重要的东西,但是当前的代码片段中缺少很多东西,以至于无法分辨。
-
整个代码是 2600 行,但我会考虑如何通过代码中的更多细节来编辑我的帖子更具体,谢谢
标签: variables fortran subroutine fortran-common-block