Skip to content

OBS013 bad-do-termination ​

warning enabled by default

A labelled do loop ends on a statement other than continue or end do.

Why ​

Ending a loop on an action statement (an assignment, a write) was deleted in Fortran 2018 and makes the last iteration's work easy to misread as following the loop.

Reported ​

fortran
do 10 i = 1, n
10 a(i) = 0.0

Preferred ​

fortran
do i = 1, n
  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[OBS013] <why this occurrence is fine>

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

Equivalent ​

Fortitude rule OB093 (see Lint Rules).