Found by the #330 audit, still present on master.
In xm_periodic (src/modboundary.f90; same pattern in ym_periodic), the one-equation-model halo copy sits AFTER the do m = 1, ih loop ends but still indexes with m:
do m = 1, ih
u0(ib - m, :, :) = u0(ie + 1 - m, :, :)
...
end do
if (loneeqn) then
e120(ib - m, :, :) = e120(ie + 1 - m, :, :) ! m == ih + 1 here
...
end if
After the loop Fortran leaves m = ih + 1, so e120/e12m copy a single plane one past the intended halo range instead of planes 1..ih — wrong periodic BCs for the one-equation SGS model and an out-of-bounds access when the halo width is ih (with ih = 1 it touches ib-2/ie+2). Fix: move the loneeqn block inside the loop.
🤖 Generated with Claude Code
Found by the #330 audit, still present on master.
In
xm_periodic(src/modboundary.f90; same pattern inym_periodic), the one-equation-model halo copy sits AFTER thedo m = 1, ihloop ends but still indexes withm:After the loop Fortran leaves
m = ih + 1, soe120/e12mcopy a single plane one past the intended halo range instead of planes 1..ih — wrong periodic BCs for the one-equation SGS model and an out-of-bounds access when the halo width isih(withih = 1it touchesib-2/ie+2). Fix: move theloneeqnblock inside the loop.🤖 Generated with Claude Code