Skip to content

COR080 magic-number-in-array-size ​

warning opt-in

An array is declared with a literal size other than 0 or 1.

Why ​

real :: flux(5) hard-codes a size that other code must repeat, and the copies drift apart. Name it once (integer, parameter :: nvar = 5) and declare flux(nvar).

Reported ​

fortran
real(R8P) :: q(5, 100)

Preferred ​

fortran
real(R8P) :: q(nvar, ncell)

Suppressing ​

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

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

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

Equivalent ​

Fortitude rule C031 (see Lint Rules).