Skip to content

OBS009 forall ​

warning enabled by default

A forall statement or construct.

Why ​

forall is obsolescent since Fortran 2018. Its semantics (every right-hand side evaluated before any assignment) often forces temporaries and rarely parallelises; do concurrent or plain array syntax are the replacements.

Reported ​

fortran
forall (i = 1:n) a(i) = b(i) * 2

Preferred ​

fortran
do concurrent (i = 1:n)
  a(i) = b(i) * 2
end do

Suppressing ​

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

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

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

References ​

Sections of the shipped knowledge packs behind this rule:

  • fortran-std:cheatsheet#loop-choice (fobis kb show fortran-std:cheatsheet#loop-choice)

Equivalent ​

Fortitude rule OB071 (see Lint Rules).