Merge branch 'release-2018'
[alexxy/gromacs.git] / src / programs / mdrun / runner.cpp
index c8d8b54c4c9eda1825f182f441e61f364640e10c..67824e3258e4705a9d4c2312dab72175a0124469 100644 (file)
@@ -1041,7 +1041,14 @@ int Mdrunner::mdrunner()
     }
     if (isMultiSim(ms))
     {
-        MPI_Barrier(ms->mpi_comm_masters);
+        if (MASTER(cr))
+        {
+            MPI_Barrier(ms->mpi_comm_masters);
+        }
+        /* We need another barrier to prevent non-master ranks from contiuing
+         * when an error occured in a different simulation.
+         */
+        MPI_Barrier(cr->mpi_comm_mysim);
     }
 #endif