Skip to content

FOR003 lower-bounds-lost-in-assumed-shape ​

warning opt-in

An array with non-default lower bounds is passed to an assumed-shape dummy: inside, its bounds restart at 1.

Why ​

An assumed-shape dummy (u(:, :)) takes the shape of the actual argument, not its bounds: every lower bound becomes 1. When the caller declares an array with ghost cells, q(1-ng:ni+ng), the callee's u(1:ni) is no longer the interior but starts in the lower ghost layer. Nothing fails: indices are in range, just shifted, so neither the compiler nor bounds checking reports it. Declare the dummy with the same lower bounds (u(1-ng:, :) or explicit shape), or pass the bounds and use them. Reported for calls to project procedures whose dummy is assumed-shape without lower bounds.

Reported ​

fortran
real :: q(1-ng:ni+ng)
call smooth(q)        ! subroutine smooth(u); real, intent(inout) :: u(:)

Preferred ​

fortran
subroutine smooth(u, ng)
  integer, intent(in) :: ng
  real, intent(inout) :: u(1-ng:)

Suppressing ​

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

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

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

References ​

Sections of the shipped knowledge packs behind this rule:

  • hpc-practice:fortran-practice#array-programming (fobis kb show hpc-practice:fortran-practice#array-programming)
  • fortran-std:ch08-attribute-declarations#array-dummy-bounds-the-rebasing-trap (fobis kb show fortran-std:ch08-attribute-declarations#array-dummy-bounds-the-rebasing-trap)