Skip to content

OBS001 common-block ​

warning enabled by default

A common block.

Why ​

Common blocks share storage by position, not by name: every program unit must repeat the same layout, and a mismatch silently reinterprets memory. They are obsolescent since Fortran 2018. Put the shared data in a module.

Reported ​

fortran
common /state/ t, dt

Preferred ​

fortran
module state
  real :: t, dt
end module state

Suppressing ​

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

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

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

References ​

Sections of the shipped knowledge packs behind this rule:

  • fortran-std:ch21-annex-b-deleted-obsolescent#obsolescent-features-b-3-still-legal-avoid-in-new-code (fobis kb show fortran-std:ch21-annex-b-deleted-obsolescent#obsolescent-features-b-3-still-legal-avoid-in-new-code)

Equivalent ​

Fortitude rule OB011 (see Lint Rules).