Fixed bug for unrealistic case n_decay < n_cores
This commit is contained in:
@@ -122,11 +122,14 @@ void Simulation::doit() {
|
|||||||
if (mpi_rank < overflow) { // Split overflows equaly to left over CPUs.
|
if (mpi_rank < overflow) { // Split overflows equaly to left over CPUs.
|
||||||
num_remaining += 1;
|
num_remaining += 1;
|
||||||
}
|
}
|
||||||
std::cout <<mpi_rank<<": "<<decays_this_cpu<<"\n";
|
|
||||||
for (int i = 0; i<(num_cycles-1); i++) {
|
for (int i = 0; i<(num_cycles-1); i++) {
|
||||||
do_decays(simulationStepWidth);
|
do_decays(simulationStepWidth);
|
||||||
}
|
}
|
||||||
|
if (num_cycles == 0) { // Rather unrealistic case.. maybe find a more elegant solution later.
|
||||||
|
do_decays(num_remaining);
|
||||||
|
} else {
|
||||||
do_decays(simulationStepWidth + num_remaining);
|
do_decays(simulationStepWidth + num_remaining);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void Simulation::do_decays(int number_decays) {
|
void Simulation::do_decays(int number_decays) {
|
||||||
@@ -137,7 +140,6 @@ void Simulation::do_decays(int number_decays) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Simulation::sync_cpus() {
|
void Simulation::sync_cpus() {
|
||||||
std::cout<<mpi_rank<<"\n";
|
|
||||||
MPI_Allreduce(&number_local_decays, &number_global_decays, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
|
MPI_Allreduce(&number_local_decays, &number_global_decays, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
|
||||||
looper.set_global_decays(number_global_decays - number_local_decays);
|
looper.set_global_decays(number_global_decays - number_local_decays);
|
||||||
sync_populations();
|
sync_populations();
|
||||||
|
|||||||
Reference in New Issue
Block a user