Skip to content

Commit 12e31ca

Browse files
committed
Fix segfault in 3D cylindrical post-process: make pb_in/mv_in optional in s_axis and add present() guards
1 parent cf13fa1 commit 12e31ca

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

src/common/m_boundary_common.fpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ contains
101101
call s_dirichlet(q_prim_vf, 1, -1, k, l)
102102
end select
103103

104-
if (qbmm .and. (.not. polytropic) .and. (bc_type(1, 1)%sf(0, k, l) <= BC_GHOST_EXTRAP)) then
104+
if (qbmm .and. (.not. polytropic) .and. present(pb_in) .and. present(mv_in) .and. (bc_type(1, 1)%sf(0, k, &
105+
& l) <= BC_GHOST_EXTRAP)) then
105106
call s_qbmm_extrapolation(1, -1, k, l, pb_in, mv_in)
106107
end if
107108
end do
@@ -130,7 +131,8 @@ contains
130131
call s_dirichlet(q_prim_vf, 1, 1, k, l)
131132
end select
132133

133-
if (qbmm .and. (.not. polytropic) .and. (bc_type(1, 2)%sf(0, k, l) <= BC_GHOST_EXTRAP)) then
134+
if (qbmm .and. (.not. polytropic) .and. present(pb_in) .and. present(mv_in) .and. (bc_type(1, 2)%sf(0, k, &
135+
& l) <= BC_GHOST_EXTRAP)) then
134136
call s_qbmm_extrapolation(1, 1, k, l, pb_in, mv_in)
135137
end if
136138
end do
@@ -166,8 +168,8 @@ contains
166168
call s_dirichlet(q_prim_vf, 2, -1, k, l)
167169
end select
168170

169-
if (qbmm .and. (.not. polytropic) .and. (bc_type(2, 1)%sf(k, 0, l) <= BC_GHOST_EXTRAP) .and. (bc_type(2, &
170-
& 1)%sf(k, 0, l) /= BC_AXIS)) then
171+
if (qbmm .and. (.not. polytropic) .and. present(pb_in) .and. present(mv_in) .and. (bc_type(2, 1)%sf(k, 0, &
172+
& l) <= BC_GHOST_EXTRAP) .and. (bc_type(2, 1)%sf(k, 0, l) /= BC_AXIS)) then
171173
call s_qbmm_extrapolation(2, -1, k, l, pb_in, mv_in)
172174
end if
173175
end do
@@ -196,7 +198,8 @@ contains
196198
call s_dirichlet(q_prim_vf, 2, 1, k, l)
197199
end select
198200

199-
if (qbmm .and. (.not. polytropic) .and. (bc_type(2, 2)%sf(k, 0, l) <= BC_GHOST_EXTRAP)) then
201+
if (qbmm .and. (.not. polytropic) .and. present(pb_in) .and. present(mv_in) .and. (bc_type(2, 2)%sf(k, 0, &
202+
& l) <= BC_GHOST_EXTRAP)) then
200203
call s_qbmm_extrapolation(2, 1, k, l, pb_in, mv_in)
201204
end if
202205
end do
@@ -231,7 +234,8 @@ contains
231234
call s_dirichlet(q_prim_vf, 3, -1, k, l)
232235
end select
233236

234-
if (qbmm .and. (.not. polytropic) .and. (bc_type(3, 1)%sf(k, l, 0) <= BC_GHOST_EXTRAP)) then
237+
if (qbmm .and. (.not. polytropic) .and. present(pb_in) .and. present(mv_in) .and. (bc_type(3, 1)%sf(k, l, &
238+
& 0) <= BC_GHOST_EXTRAP)) then
235239
call s_qbmm_extrapolation(3, -1, k, l, pb_in, mv_in)
236240
end if
237241
end do
@@ -260,7 +264,8 @@ contains
260264
call s_dirichlet(q_prim_vf, 3, 1, k, l)
261265
end select
262266

263-
if (qbmm .and. (.not. polytropic) .and. (bc_type(3, 2)%sf(k, l, 0) <= BC_GHOST_EXTRAP)) then
267+
if (qbmm .and. (.not. polytropic) .and. present(pb_in) .and. present(mv_in) .and. (bc_type(3, 2)%sf(k, l, &
268+
& 0) <= BC_GHOST_EXTRAP)) then
264269
call s_qbmm_extrapolation(3, 1, k, l, pb_in, mv_in)
265270
end if
266271
end do
@@ -675,10 +680,10 @@ contains
675680
subroutine s_axis(q_prim_vf, pb_in, mv_in, k, l)
676681

677682
$:GPU_ROUTINE(parallelism='[seq]')
678-
type(scalar_field), dimension(sys_size), intent(inout) :: q_prim_vf
679-
real(stp), dimension(idwbuff(1)%beg:,idwbuff(2)%beg:,idwbuff(3)%beg:,1:,1:), intent(inout) :: pb_in, mv_in
680-
integer, intent(in) :: k, l
681-
integer :: j, q, i
683+
type(scalar_field), dimension(sys_size), intent(inout) :: q_prim_vf
684+
real(stp), dimension(idwbuff(1)%beg:,idwbuff(2)%beg:,idwbuff(3)%beg:,1:,1:), optional, intent(inout) :: pb_in, mv_in
685+
integer, intent(in) :: k, l
686+
integer :: j, q, i
682687

683688
do j = 1, buff_size
684689
if (z_cc(l) < pi) then
@@ -708,7 +713,7 @@ contains
708713
end if
709714
end do
710715

711-
if (qbmm .and. .not. polytropic) then
716+
if (qbmm .and. .not. polytropic .and. present(pb_in) .and. present(mv_in)) then
712717
do i = 1, nb
713718
do q = 1, nnode
714719
do j = 1, buff_size

0 commit comments

Comments
 (0)