Skip to content

Commit 167c10f

Browse files
committed
fix: guard QBMM boundary extrapolation with present(pb_in)
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.
1 parent febffab commit 167c10f

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/common/m_boundary_common.fpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ contains
116116
call s_dirichlet(q_prim_vf, 1, -1, k, l)
117117
end select
118118

119-
if (qbmm .and. (.not. polytropic) .and. &
119+
if (qbmm .and. (.not. polytropic) .and. present(pb_in) .and. &
120120
(bc_type(1, 1)%sf(0, k, l) <= BC_GHOST_EXTRAP)) then
121121
call s_qbmm_extrapolation(1, -1, k, l, pb_in, mv_in)
122122
end if
@@ -146,7 +146,7 @@ contains
146146
call s_dirichlet(q_prim_vf, 1, 1, k, l)
147147
end select
148148

149-
if (qbmm .and. (.not. polytropic) .and. &
149+
if (qbmm .and. (.not. polytropic) .and. present(pb_in) .and. &
150150
(bc_type(1, 2)%sf(0, k, l) <= BC_GHOST_EXTRAP)) then
151151
call s_qbmm_extrapolation(1, 1, k, l, pb_in, mv_in)
152152
end if
@@ -184,7 +184,7 @@ contains
184184
call s_dirichlet(q_prim_vf, 2, -1, k, l)
185185
end select
186186

187-
if (qbmm .and. (.not. polytropic) .and. &
187+
if (qbmm .and. (.not. polytropic) .and. present(pb_in) .and. &
188188
(bc_type(2, 1)%sf(k, 0, l) <= BC_GHOST_EXTRAP) .and. &
189189
(bc_type(2, 1)%sf(k, 0, l) /= BC_AXIS)) then
190190
call s_qbmm_extrapolation(2, -1, k, l, pb_in, mv_in)
@@ -215,7 +215,7 @@ contains
215215
call s_dirichlet(q_prim_vf, 2, 1, k, l)
216216
end select
217217

218-
if (qbmm .and. (.not. polytropic) .and. &
218+
if (qbmm .and. (.not. polytropic) .and. present(pb_in) .and. &
219219
(bc_type(2, 2)%sf(k, 0, l) <= BC_GHOST_EXTRAP)) then
220220
call s_qbmm_extrapolation(2, 1, k, l, pb_in, mv_in)
221221
end if
@@ -253,7 +253,7 @@ contains
253253
call s_dirichlet(q_prim_vf, 3, -1, k, l)
254254
end select
255255

256-
if (qbmm .and. (.not. polytropic) .and. &
256+
if (qbmm .and. (.not. polytropic) .and. present(pb_in) .and. &
257257
(bc_type(3, 1)%sf(k, l, 0) <= BC_GHOST_EXTRAP)) then
258258
call s_qbmm_extrapolation(3, -1, k, l, pb_in, mv_in)
259259
end if
@@ -283,7 +283,7 @@ contains
283283
call s_dirichlet(q_prim_vf, 3, 1, k, l)
284284
end select
285285

286-
if (qbmm .and. (.not. polytropic) .and. &
286+
if (qbmm .and. (.not. polytropic) .and. present(pb_in) .and. &
287287
(bc_type(3, 2)%sf(k, l, 0) <= BC_GHOST_EXTRAP)) then
288288
call s_qbmm_extrapolation(3, 1, k, l, pb_in, mv_in)
289289
end if

0 commit comments

Comments
 (0)