Skip to content

OBS012 shared-do-termination ​

warning enabled by default

Several do loops end on the same labelled statement.

Why ​

Nested loops sharing one terminal statement (deleted in Fortran 2018) make jumps to the label ambiguous and hide the nesting structure. Give each loop its own end do.

Reported ​

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

Preferred ​

fortran
do i = 1, n
  do j = 1, m
    a(i, j) = 0.0
  end do
end do

Suppressing ​

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

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

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

Equivalent ​

Fortitude rule OB092 (see Lint Rules).