Skip to content

Commit 1bbe86e

Browse files
committed
fix: grow patch_ib on non-rank-0 before MPI broadcast of IB patches
When particle beds are used, rank 0 grows patch_ib to num_ib_patches_max inside s_generate_particle_beds. Non-rank-0 ranks only have the namelist-sized allocation (num_ib_patches_max_namelist). The num_ibs scalar is broadcast first, so we can check and grow before the per-patch MPI_BCAST loop accesses patch_ib(i) for i > num_ib_patches_max_namelist.
1 parent 06b802e commit 1bbe86e

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/simulation/m_mpi_proxy.fpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,19 @@ contains
192192
#:endfor
193193
end do
194194

195+
! Non-rank-0 processes may have patch_ib sized to num_ib_patches_max_namelist while rank 0 grew it
196+
! for particle beds. Grow here before receiving the broadcast entries.
197+
if (proc_rank /= 0 .and. num_ibs > size(patch_ib)) then
198+
block
199+
type(ib_patch_parameters), allocatable :: tmp(:)
200+
integer :: n
201+
n = size(patch_ib)
202+
call move_alloc(patch_ib, tmp)
203+
allocate (patch_ib(num_ib_patches_max))
204+
patch_ib(1:n) = tmp
205+
end block
206+
end if
207+
195208
do i = 1, num_ibs
196209
#:for VAR in [ 'radius', 'length_x', 'length_y', 'length_z', &
197210
& 'x_centroid', 'y_centroid', 'z_centroid', 'c', 'm', 'p', 't', 'theta', 'slip', 'mass', &

0 commit comments

Comments
 (0)