Merge branch release-5-1
[alexxy/gromacs.git] / src / gromacs / mdlib / constr.cpp
index 2e9c9b45ae1b2da4b4ace55f9a36d78ed03c621c..5b850d0f5673be171eeca00c67a3827b5cdcb5ff 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -470,6 +470,8 @@ gmx_bool constrain(FILE *fplog, gmx_bool bLog, gmx_bool bEner,
                         if (th > 0)
                         {
                             clear_mat(constr->vir_r_m_dr_th[th]);
+
+                            constr->settle_error[th] = -1;
                         }
 
                         start_th = (nsettle* th   )/nth;
@@ -543,40 +545,30 @@ gmx_bool constrain(FILE *fplog, gmx_bool bLog, gmx_bool bEner,
 
     if (settle->nr > 0)
     {
-        /* Combine virial and error info of the other threads */
-        for (i = 1; i < nth; i++)
-        {
-            settle_error = constr->settle_error[i];
-        }
         if (vir != NULL)
         {
+            /* Reduce the virial contributions over the threads */
             for (i = 1; i < nth; i++)
             {
                 m_add(vir_r_m_dr, constr->vir_r_m_dr_th[i], vir_r_m_dr);
             }
         }
 
-        if (econq == econqCoord && settle_error >= 0)
+        if (econq == econqCoord)
         {
-            bOK = FALSE;
-            if (constr->maxwarn >= 0)
+            for (i = 1; i < nth; i++)
             {
-                char buf[256];
-                sprintf(buf,
-                        "\nstep " "%" GMX_PRId64 ": Water molecule starting at atom %d can not be "
-                        "settled.\nCheck for bad contacts and/or reduce the timestep if appropriate.\n",
-                        step, ddglatnr(cr->dd, settle->iatoms[settle_error*(1+NRAL(F_SETTLE))+1]));
-                if (fplog)
-                {
-                    fprintf(fplog, "%s", buf);
-                }
-                fprintf(stderr, "%s", buf);
-                constr->warncount_settle++;
-                if (constr->warncount_settle > constr->maxwarn)
-                {
-                    too_many_constraint_warnings(-1, constr->warncount_settle);
-                }
-                bDump = TRUE;
+                settle_error = std::max(settle_error, constr->settle_error[i]);
+            }
+
+            if (settle_error >= 0)
+            {
+                dump_confs(fplog, step, constr->warn_mtop, start, homenr, cr, x, xprime, box);
+
+                gmx_fatal(FARGS,
+                          "\nstep " "%" GMX_PRId64 ": Water molecule starting at atom %d can not be "
+                          "settled.\nCheck for bad contacts and/or reduce the timestep if appropriate.\n",
+                          step, ddglatnr(cr->dd, settle->iatoms[settle_error*(1+NRAL(F_SETTLE))+1]));
             }
         }
     }