5
votes

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++) {
        ...
    }
}
1
Ahh, my eyes! Haven't had to look at Fortran since college :) Wish I could help, but I just don't remember on this one... - Michael Dorgan

1 Answers

8
votes

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.