Skip to content

OBS014 goto-end-do ​

warning enabled by default

A go to jumps to the end do of a loop.

Why ​

Jumping to the labelled end do of a loop is the pre-Fortran 90 way of starting the next iteration. cycle says the same thing without a label, and keeps working when the loop is moved or renamed.

Reported ​

fortran
do i = 1, n
  if (skip(i)) go to 10
  a(i) = 0.0
10 end do

Preferred ​

fortran
do i = 1, n
  if (skip(i)) cycle
  a(i) = 0.0
end do

Suppressing ​

For one occurrence, with the reason on the same line (or alone on the line before the statement):

fortran
! fobis: ignore[OBS014] <why this occurrence is fine>

For the whole project, ignore = OBS014 in the fobos [lint] section.

Equivalent ​

Fortitude rule OB094 (see Lint Rules).