From 2ee7caefbfb569aa7bf4b7068112d67b6c99dfc2 Mon Sep 17 00:00:00 2001 From: Berk Hess Date: Tue, 2 Feb 2016 15:01:05 +0100 Subject: [PATCH] Fix SETTLE error handling With OpenMP threading only SETTLE errors detected by the last OpenMP thread were processed. Also made SETTLE errors fatal, there is no use of generating warnings and continuing a simulation after a SETTLE error. This only causes confusion for users, since the run will usually terminate with a confusing error message instead. Change-Id: Ieb76d9bb0d74087c544124b0c548be4c5698b16c --- src/gromacs/mdlib/constr.cpp | 42 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/src/gromacs/mdlib/constr.cpp b/src/gromacs/mdlib/constr.cpp index e4d2f9d3c5..7a3a215039 100644 --- a/src/gromacs/mdlib/constr.cpp +++ b/src/gromacs/mdlib/constr.cpp @@ -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. @@ -463,6 +463,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; @@ -530,40 +532,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])); } } } -- 2.11.4.GIT