Skip to content

fix: guard QBMM boundary extrapolation with present(pb_in)#1332

Draft
sbryngelson wants to merge 1 commit intoMFlowCode:masterfrom
sbryngelson:fix-qbmm-boundary-present
Draft

fix: guard QBMM boundary extrapolation with present(pb_in)#1332
sbryngelson wants to merge 1 commit intoMFlowCode:masterfrom
sbryngelson:fix-qbmm-boundary-present

Conversation

@sbryngelson
Copy link
Member

@sbryngelson sbryngelson commented Mar 20, 2026

Summary

  • Post_process calls s_populate_variables_buffers without the optional pb_in/mv_in arguments, but the QBMM guard (qbmm .and. .not. polytropic) could still evaluate to true, causing access to an absent optional argument — undefined behavior in Fortran.
  • Add present(pb_in) to all 6 call sites of s_qbmm_extrapolation in m_boundary_common.fpp.
  • Caught by gfortran -fcheck=bounds in the macOS debug CI build.

Test plan

  • Compiles with gfortran
  • ./mfc.sh precheck passes
  • CI macOS debug build passes (currently fails on master for QBMM + post_process)

@sbryngelson sbryngelson force-pushed the fix-qbmm-boundary-present branch from f3bb4b6 to 167c10f Compare March 20, 2026 16:57
@github-actions
Copy link

github-actions bot commented Mar 20, 2026

Claude Code Review

Incremental review from: f3bb4b6
Head SHA: 4ecd249

New findings since last Claude review:

  • Silent skip of QBMM boundary extrapolation may produce wrong results (src/common/m_boundary_common.fpp, all 6 hunks): When qbmm .and. (.not. polytropic) is true at runtime but pb_in/mv_in are absent, the new guard silently skips s_qbmm_extrapolation. This prevents a Fortran runtime error, but ghost-cell QBMM state is left uninitialized/stale without any diagnostic. If a call site reaches this code with QBMM non-polytropic physics active but omits the optional arguments, the boundary condition is silently wrong rather than aborting. An @:PROHIBIT(qbmm .and. (.not. polytropic) .and. .not. present(pb_in), "QBMM non-polytropic boundary requires pb_in/mv_in") would catch erroneous call sites rather than silently degrading physics correctness.

post_process calls s_populate_variables_buffers without the optional
pb_in/mv_in arguments, but the QBMM guard (qbmm .and. .not. polytropic)
could still evaluate to true, causing access to an absent optional
argument. This is undefined behavior caught by gfortran -fcheck=bounds.

Add present(pb_in) to all 6 call sites of s_qbmm_extrapolation.
@sbryngelson sbryngelson force-pushed the fix-qbmm-boundary-present branch from 167c10f to 4ecd249 Compare March 20, 2026 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant