Skip to content

PRT011 literal-kind ​

warning enabled by default

A kind given as a number in a type declaration (real(8), integer(kind=4)).

Why ​

Kind numbers are compiler-specific: real(8) is double precision for gfortran and ifx, but kind values are not defined by the standard and differ elsewhere (NAG uses 1, 2, 3). Use named constants from iso_fortran_env (real64, int32) or selected_real_kind.

Reported ​

fortran
real(8) :: x

Preferred ​

fortran
real(real64) :: x

Suppressing ​

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

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

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

References ​

Sections of the shipped knowledge packs behind this rule:

  • hpc-practice:fortran-practice#kind-specifications-portability (fobis kb show hpc-practice:fortran-practice#kind-specifications-portability)

Equivalent ​

Fortitude rule PORT011 (see Lint Rules).