Fortran 嵌套循环,带有一个 continue
我正在重写一些遗留代码,并发现了这一点:
DO 4 I=1,N
...
DO 4 J=1,N
...
4 CONTINUE
这两个循环似乎只有一个 CONTINUE
。它相当于这个Java代码吗?
for (int i=0; i<n; i++) {
...
for (int j=0; j<n; j++) {
...
}
}
I'm rewriting some legacy code and came across this:
DO 4 I=1,N
...
DO 4 J=1,N
...
4 CONTINUE
There appears to be only one CONTINUE
for these two loops. Is it equivalent to this Java code?
for (int i=0; i<n; i++) {
...
for (int j=0; j<n; j++) {
...
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你对于它相当于什么是正确的。这
只是循环结束点的标记。使用两个 CONTINUE 语句,或者更好的是使用两个 ENDDO(如果您的编译器支持)会更清晰。
本页
http://www.math.hawaii.edu/lab/197/fortran /fort2.htm
同意,只需搜索“相同继续”。
但一个细节是,我认为 Java 代码中的循环变量开始值和结束值与 Fortran 代码中的循环变量开始值和结束值不同。
I think you are correct as to what it is equivalent to. The
is just a labeled marker for the spot where the loop ends. Using two CONTINUE statements, or even better yet using two ENDDO (if supported by your compiler) would have been much clearer.
This page
http://www.math.hawaii.edu/lab/197/fortran/fort2.htm
concurs, just search for "same continue".
One detail though is that I don't think your loop variable start and end values are the same in your Java code as in the Fortran code.