Skip to content

Commit

Permalink
Fix plasma injection from file for parallel runs (ECP-WarpX#4597)
Browse files Browse the repository at this point in the history
The use of amrex::ParallelDescriptor::ReduceBoolOr was incorrect. The logic
is also simplified, even though it may not the most efficient way.
  • Loading branch information
WeiqunZhang authored Jan 10, 2024
1 parent 69e9262 commit 82f7f1e
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions Source/Initialization/PlasmaInjector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,18 +501,15 @@ void PlasmaInjector::setupExternalFile (amrex::ParmParse const& pp_species)
} // IOProcessor

// Broadcast charge and mass to non-IO processors if read in from the file
if (!charge_is_specified && !species_is_specified) {
// Use ReduceBoolOr since Bcast(bool) doesn't compile
amrex::ParallelDescriptor::ReduceBoolOr(charge_from_source, amrex::ParallelDescriptor::IOProcessorNumber());
if (charge_from_source) {
amrex::ParallelDescriptor::Bcast(&charge, 1, amrex::ParallelDescriptor::IOProcessorNumber());
}
std::array<int,2> flags{charge_from_source, mass_from_source};
amrex::ParallelDescriptor::Bcast(flags.data(), flags.size(), amrex::ParallelDescriptor::IOProcessorNumber());
charge_from_source = flags[0];
mass_from_source = flags[1];
if (charge_from_source) {
amrex::ParallelDescriptor::Bcast(&charge, 1, amrex::ParallelDescriptor::IOProcessorNumber());
}
if (!mass_is_specified && !species_is_specified) {
amrex::ParallelDescriptor::ReduceBoolOr(mass_from_source, amrex::ParallelDescriptor::IOProcessorNumber());
if (mass_from_source) {
amrex::ParallelDescriptor::Bcast(&mass, 1, amrex::ParallelDescriptor::IOProcessorNumber());
}
if (mass_from_source) {
amrex::ParallelDescriptor::Bcast(&mass, 1, amrex::ParallelDescriptor::IOProcessorNumber());
}
#else
WARPX_ABORT_WITH_MESSAGE(
Expand Down

0 comments on commit 82f7f1e

Please sign in to comment.