开发者

Fortran nested loops with one continue

开发者 https://www.devze.com 2023-04-02 08:10 出处:网络
I\'m rewriting some legacy code and came across this: DO 4 I=1,N ... DO 4 J=1,N ... 4 CONT开发者_StackOverflowINUE

I'm rewriting some legacy code and came across this:

  DO 4 I=1,N
   ...
  DO 4 J=1,N
   ...
4 CONT开发者_StackOverflowINUE

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++) {
        ...
    }
}


I think you are correct as to what it is equivalent to. The

4 CONTINUE

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号