+#ifdef GMX_MPI
+ if (cr->nnodes + cr->npmenodes > 1)
+ {
+ /* Get the min and max thread counts over the MPI ranks */
+ int buf_in[4], buf_out[4];
+
+ buf_in[0] = -modth.gnth;
+ buf_in[1] = modth.gnth;
+ buf_in[2] = -modth.gnth_pme;
+ buf_in[3] = modth.gnth_pme;
+
+ MPI_Allreduce(buf_in, buf_out, 4, MPI_INT, MPI_MAX, cr->mpi_comm_mysim);
+
+ nth_min = -buf_out[0];
+ nth_max = buf_out[1];
+ nth_pme_min = -buf_out[2];
+ nth_pme_max = buf_out[3];
+ }
+ else
+#endif
+ {
+ nth_min = modth.gnth;
+ nth_max = modth.gnth;
+ nth_pme_min = modth.gnth_pme;
+ nth_pme_max = modth.gnth_pme;
+ }
+