must use the "roots" communicator only on world->me == 0

Thanks to @joshuakempfert. See issue #4210
This commit is contained in:
Axel Kohlmeyer
2024-06-28 14:17:20 -04:00
parent 0717019b2d
commit 850e4d14cd

View File

@ -200,7 +200,7 @@ void NEB::run()
if (me == 0) if (me == 0)
color = 0; color = 0;
else else
color = 1; color = MPI_UNDEFINED;
MPI_Comm_split(uworld, color, 0, &roots); MPI_Comm_split(uworld, color, 0, &roots);
auto fixes = modify->get_fix_by_style("^neb$"); auto fixes = modify->get_fix_by_style("^neb$");
@ -610,10 +610,12 @@ void NEB::open(char *file)
void NEB::print_status() void NEB::print_status()
{ {
double fnorm2 = sqrt(update->minimize->fnorm_sqr()); double fnorm2 = sqrt(update->minimize->fnorm_sqr());
double fmaxreplica;
MPI_Allreduce(&fnorm2, &fmaxreplica, 1, MPI_DOUBLE, MPI_MAX, roots);
double fnorminf = update->minimize->fnorm_inf(); double fnorminf = update->minimize->fnorm_inf();
double fmaxatom; double fmaxreplica = 0.0;
double fmaxatom = 0.0;
if (me == 0) {
MPI_Allreduce(&fnorm2, &fmaxreplica, 1, MPI_DOUBLE, MPI_MAX, roots);
MPI_Allreduce(&fnorminf, &fmaxatom, 1, MPI_DOUBLE, MPI_MAX, roots); MPI_Allreduce(&fnorminf, &fmaxatom, 1, MPI_DOUBLE, MPI_MAX, roots);
if (print_mode == VERBOSE) { if (print_mode == VERBOSE) {
@ -622,6 +624,7 @@ void NEB::print_status()
fmaxatomInRepl = new double[nreplica]; fmaxatomInRepl = new double[nreplica];
MPI_Allgather(&fnorminf, 1, MPI_DOUBLE, &fmaxatomInRepl[0], 1, MPI_DOUBLE, roots); MPI_Allgather(&fnorminf, 1, MPI_DOUBLE, &fmaxatomInRepl[0], 1, MPI_DOUBLE, roots);
} }
}
double one[7]; double one[7];
one[0] = fneb->veng; one[0] = fneb->veng;
@ -705,7 +708,7 @@ void NEB::print_status()
fflush(universe->ulogfile); fflush(universe->ulogfile);
} }
} }
if (print_mode == VERBOSE) { if ((me == 0) && (print_mode == VERBOSE)) {
delete[] freplica; delete[] freplica;
delete[] fmaxatomInRepl; delete[] fmaxatomInRepl;
} }