diff --git a/src/CabanaPD_Particles.hpp b/src/CabanaPD_Particles.hpp index 51ffcac..a3b3979 100644 --- a/src/CabanaPD_Particles.hpp +++ b/src/CabanaPD_Particles.hpp @@ -328,11 +328,7 @@ class Particles if ( create_frozen ) frozen_offset = size; - // Not using Allreduce because global count is only used for printing. - auto local_offset_mpi = - static_cast( local_offset ); - MPI_Reduce( &local_offset_mpi, &num_global, 1, MPI_UNSIGNED_LONG_LONG, - MPI_SUM, 0, MPI_COMM_WORLD ); + updateGlobal(); _init_timer.stop(); } @@ -379,6 +375,17 @@ class Particles nofail( pid ) = 0; rho( pid ) = 1.0; } ); + + updateGlobal(); + } + + void updateGlobal() + { + // Not using Allreduce because global count is only used for printing. + auto local_offset_mpi = + static_cast( local_offset ); + MPI_Reduce( &local_offset_mpi, &num_global, 1, MPI_UNSIGNED_LONG_LONG, + MPI_SUM, 0, MPI_COMM_WORLD ); } template