diff --git a/cpp/particles/particles_distr_mpi.hpp b/cpp/particles/particles_distr_mpi.hpp index f330e638c039b03bb25e2ce7fed2dc7799b7627d..3bb4a6901ee85c97a52b714bea5f2a23b03eb2e8 100644 --- a/cpp/particles/particles_distr_mpi.hpp +++ b/cpp/particles/particles_distr_mpi.hpp @@ -148,11 +148,14 @@ protected: // some environments need the tag to be small // see https://www.intel.com/content/www/us/en/developer/articles/technical/large-mpi-tags-with-the-intel-mpi.html // TODO: is there a better way of achieving this result? - const int new_mpi_tag = mpi_tag_input % maximum_MPI_tag_value; + int new_mpi_tag = mpi_tag_input % maximum_MPI_tag_value; + if (new_mpi_tag < 0) + new_mpi_tag = -new_mpi_tag; // no idea if this is reasonable... if (new_mpi_tag >= maximum_MPI_tag_value || new_mpi_tag < 0) { - DEBUG_MSG("new_mpi_tag is %d, MPI_TAG_UB is %d, 2**20 is 1048576\n", + DEBUG_MSG("new_mpi_tag is %d, MPI_TAG_UB is %d, mpi_tag_input is %d, 2**20 is 1048576\n", new_mpi_tag, + mpi_tag_input, MPI_TAG_UB); assert(false); }