Skip to content

Commit 506dccd

Browse files
sbryngelsonclaude
andcommitted
Fix optional arg UB, missing deallocates, missing intent
- Remove case default in f_advance_step that dereferenced absent optional args fVel/fPos (undefined behavior when called from EE path with adap_dt) - Add @:DEALLOCATE for p_send_buff, p_recv_buff, p_send_ids in MPI finalize - Add intent(in) on lag_num_ts in s_initialize_particles_mpi - Add intent(in) on nBub, pos, posPrev in s_add_particles_to_transfer_list - Fix bare 3 -> 3._wp in vel_model=3 force computation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 52adde3 commit 506dccd

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

src/simulation/m_bubbles.fpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -597,17 +597,12 @@ contains
597597
do l = 1, num_dims
598598
f_bTemp = f_get_bubble_force(fPos(l), fR, fV, fVel(l), fmass_g, fmass_v, &
599599
fRe, fRho, cell, l, q_prim_vf)
600-
aTemp(l) = 2._wp*f_bTemp/(fmass_g + fmass_v) - 3*fV*fVel(l)/fR
600+
aTemp(l) = 2._wp*f_bTemp/(fmass_g + fmass_v) - 3._wp*fV*fVel(l)/fR
601601
end do
602602
do l = 1, num_dims
603603
fVel(l) = fVel(l) + h*aTemp(l)
604604
fPos(l) = fPos(l) + h*fVel(l)
605605
end do
606-
case default
607-
do l = 1, num_dims
608-
fVel(l) = fVel(l)
609-
fPos(l) = fPos(l)
610-
end do
611606
end select
612607
end if
613608

src/simulation/m_mpi_proxy.fpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ contains
8787
!! @param lag_num_ts Number of stages in time-stepping scheme
8888
subroutine s_initialize_particles_mpi(lag_num_ts)
8989

90+
integer, intent(in) :: lag_num_ts
9091
integer :: i, j, k
91-
integer :: real_size, int_size, nReal, lag_num_ts
92+
integer :: real_size, int_size, nReal
9293
integer :: ierr !< Generic flag used to identify and report MPI errors
9394

9495
#ifdef MFC_MPI
@@ -503,8 +504,9 @@ contains
503504
!! for communication of initial condition)
504505
impure subroutine s_add_particles_to_transfer_list(nBub, pos, posPrev)
505506

506-
real(wp), dimension(:, :) :: pos, posPrev
507-
integer :: bubID, nbub
507+
integer, intent(in) :: nBub
508+
real(wp), dimension(:, :), intent(in) :: pos, posPrev
509+
integer :: bubID
508510
integer :: i, j, k
509511

510512
do k = nidx(3)%beg, nidx(3)%end
@@ -989,6 +991,11 @@ contains
989991
if (ib) then
990992
@:DEALLOCATE(ib_buff_send, ib_buff_recv)
991993
end if
994+
995+
if (bubbles_lagrange) then
996+
@:DEALLOCATE(p_send_buff, p_recv_buff)
997+
@:DEALLOCATE(p_send_ids)
998+
end if
992999
#endif
9931000

9941001
end subroutine s_finalize_mpi_proxy_module

0 commit comments

Comments
 (0)