From ac970fdc1cabd77bdcb1af6219fb26bf53b8eb6a Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <schaller@strw.leidenuniv.nl>
Date: Thu, 1 Nov 2018 17:00:21 +0000
Subject: [PATCH] Check the return value of the top-level multipole all-reduce.

---
 src/engine.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/engine.c b/src/engine.c
index b17b7b9e46..ad0d8ff413 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -2343,9 +2343,11 @@ void engine_exchange_top_multipoles(struct engine *e) {
    * multi-pole is present on more than one node (two things guaranteed by the
    * domain decomposition).
    */
-  MPI_Allreduce(MPI_IN_PLACE, e->s->multipoles_top,
-                e->s->nr_cells * sizeof(struct gravity_tensors), MPI_BYTE,
-                MPI_BOR, MPI_COMM_WORLD);
+  int err = MPI_Allreduce(MPI_IN_PLACE, e->s->multipoles_top,
+                          e->s->nr_cells * sizeof(struct gravity_tensors),
+                          MPI_BYTE, MPI_BOR, MPI_COMM_WORLD);
+  if (err != MPI_SUCCESS)
+    mpi_error(err, "Failed to all-reduce the top-level multipoles.");
 
 #ifdef SWIFT_DEBUG_CHECKS
   long long counter = 0;
-- 
GitLab