Skip to content

OBS010 arithmetic-if ​

warning enabled by default

An arithmetic if (x) l1, l2, l3.

Why ​

The arithmetic IF branches on the sign of an expression to one of three labels. It was deleted in Fortran 2018. Use a block if / select case.

Reported ​

fortran
if (x) 10, 20, 30

Preferred ​

fortran
if (x < 0) then
  ...
else if (x == 0) then
  ...
end if

Suppressing ​

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

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

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

Equivalent ​

Fortitude rule OB081 (see Lint Rules).