fortran - Fortran 中的 BLOCK 有什么意义?
问题描述
我正在看一些代码,有这样的:
BLOCK
...lines of code...
END BLOCK
目的是BLOCK
什么?我试图用谷歌搜索它,但我发现的只是一些关于BLOCK DATA
和COMMON
块的东西。我不确定它们是否相关。
解决方案
来自 Fortran 2008 标准:
BLOCK 构造是一个可执行的构造,它可能包含声明。
它与公共块或块数据程序单元无关。
因此,主要用途是这种“包含声明”。
作为范围单位,我们有类似的东西
integer i
block
integer j ! A local integer
integer i ! Another i
save i ! ... which can even be SAVEd
end block
它提供了声明的位置:
! ... lots of code
block
integer something
read *, something
end block
! ... lots more code
这些范围块允许自动对象:
integer i
i = 5
block
real x(i)
end block
作为可执行结构,它们还具有有用的流控制:
this_block: block
if (something) exit this_block
! ... lots of code
end block
他们还具有最终控制权:
type(t) x
block
type(t) y
end block ! y is finalized
end ! x is not finalized
为x
和y
可终结的类型。
哦,让我们不要忘记如何将人们与隐式类型混淆。
推荐阅读
- ioredis - ioredis 从 AWS 启动应用程序时出现未处理的错误
- html - 使用上有什么区别
- 带有列表样式类型:光盘;和
- javascript - 在 JavaScript 中存储字符串的空间复杂度是多少?
- node.js - 使用 MUI V5 最新版本通过 React、Next JS 和本地存储切换暗模式
- python - Python Invalid Syntax 错误 - 刚刚回到编程中
- html - 如果 img 不存在,如何使边框丢失
- loops - 为什么程序总是退出这个循环?
- nestjs - 当 Nestjs 上的代码更改时刷新应用程序
- r - 使用 group_by > mutate > slice 的更有效方式
- javascript - 在 Google Maps 的“map_changed”监听器中调用的函数被多次调用