Fortran 变量类型转换
快问。 我有一个带有变量声明的 fortran77 子例程,
DIMENSIONS HH(13, 1000)
我假设由于没有指定类型,因此该变量是一个整数数组。稍后在程序中,我有一个循环,其中有以下行:
HH(2,N) = HH(4,N) + W2
W2 未在子例程中显式声明,也未作为参数传递。我假设它是默认类型的实变量。
我猜想对于上面的命令,W2 在添加到 HH(4,N) 之前先转换为整数。这是正确的吗?
抱歉,如果这真的很基本。
Quick question.
I have a fortran77 subroutine with a variable declaration
DIMENSIONS HH(13, 1000)
I assume that since no type is specified, this variable is an array of integers. Later in the programme I have a loop in which there is the following line:
HH(2,N) = HH(4,N) + W2
W2 is not explicitly declared in the subroutine, nor is it passed as an argument. I assume that it is types by default as a real variable.
I guess that for the above command, W2 is converted to an integer before it is added to HH(4,N). Is this correct?
Apologies if this is really basic.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Fortran 77 中,以 I、J、K、L、M 或 N 开头的变量隐式为
INTEGER
,除非另有定义。所有其他变量都隐式为REAL
。这意味着您的数组 HH 是 REAL。因此结果将是 REAL,不涉及隐式转换。
In Fortran 77, variables starting with I, J, K, L, M, or N are implicitly
INTEGER
unless defined otherwise. All other variables are implicitlyREAL
. This implies your array HH isREAL
. So the resultwill be
REAL
with no implicit casting involved.