From 54733837dac5a52a8ae76d9912f0e246fd1ad2ad Mon Sep 17 00:00:00 2001 From: Berk Hess Date: Wed, 16 Mar 2016 15:42:29 +0100 Subject: [PATCH] Update mdrun termination info Both the mdrun help and stderr/log messages reported that mdrun would stop at the next step or next nstlist step, which has not been correct for some time. Fixes #1918. Change-Id: Ia890ffb3ccfdbdbed3d003b149c3cbb55e5c1818 --- src/programs/mdrun/md.cpp | 19 +++++++++++-------- src/programs/mdrun/mdrun.cpp | 9 +++++---- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/programs/mdrun/md.cpp b/src/programs/mdrun/md.cpp index fa65cabe81..92fa911eb4 100644 --- a/src/programs/mdrun/md.cpp +++ b/src/programs/mdrun/md.cpp @@ -44,6 +44,8 @@ #include #include +#include + #include "thread_mpi/threads.h" #include "gromacs/commandline/filenm.h" @@ -929,7 +931,7 @@ double gmx::do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[], } } - /* < 0 means stop at next step, > 0 means stop at next NS step */ + /* < 0 means stop after this step, > 0 means stop at next NS step */ if ( (gs.set[eglsSTOPCOND] < 0) || ( (gs.set[eglsSTOPCOND] > 0) && (bNStList || ir->nstlist == 0) ) ) { @@ -1291,30 +1293,31 @@ double gmx::do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[], #endif ) { + int nsteps_stop = -1; + /* this is just make gs.sig compatible with the hack of sending signals around by MPI_Reduce with together with other floats */ if (gmx_get_stop_condition() == gmx_stop_cond_next_ns) { gs.sig[eglsSTOPCOND] = 1; + nsteps_stop = std::max(ir->nstlist, 2*nstglobalcomm); } if (gmx_get_stop_condition() == gmx_stop_cond_next) { gs.sig[eglsSTOPCOND] = -1; + nsteps_stop = nstglobalcomm + 1; } - /* < 0 means stop at next step, > 0 means stop at next NS step */ if (fplog) { fprintf(fplog, - "\n\nReceived the %s signal, stopping at the next %sstep\n\n", - gmx_get_signal_name(), - gs.sig[eglsSTOPCOND] == 1 ? "NS " : ""); + "\n\nReceived the %s signal, stopping within %d steps\n\n", + gmx_get_signal_name(), nsteps_stop); fflush(fplog); } fprintf(stderr, - "\n\nReceived the %s signal, stopping at the next %sstep\n\n", - gmx_get_signal_name(), - gs.sig[eglsSTOPCOND] == 1 ? "NS " : ""); + "\n\nReceived the %s signal, stopping within %d steps\n\n", + gmx_get_signal_name(), nsteps_stop); fflush(stderr); handled_stop_condition = (int)gmx_get_stop_condition(); } diff --git a/src/programs/mdrun/mdrun.cpp b/src/programs/mdrun/mdrun.cpp index 641f513278..9458dfbf91 100644 --- a/src/programs/mdrun/mdrun.cpp +++ b/src/programs/mdrun/mdrun.cpp @@ -204,10 +204,11 @@ int gmx_mdrun(int argc, char *argv[]) "terminated only when the time limit set by [TT]-maxh[tt] is reached (if any)" "or upon receiving a signal." "[PAR]", - "When [TT]mdrun[tt] receives a TERM signal, it will set nsteps to the current", - "step plus one. When [TT]mdrun[tt] receives an INT signal (e.g. when ctrl+C is", - "pressed), it will stop after the next neighbor search step ", - "(with nstlist=0 at the next step).", + "When [TT]mdrun[tt] receives a TERM signal, it will stop as soon as", + "checkpoint file can be written, i.e. after the next global communication step.", + "When [TT]mdrun[tt] receives an INT signal (e.g. when ctrl+C is", + "pressed), it will stop at the next neighbor search step or at the", + "second global communication step, whichever happens later.", "In both cases all the usual output will be written to file.", "When running with MPI, a signal to one of the [TT]mdrun[tt] ranks", "is sufficient, this signal should not be sent to mpirun or", -- 2.11.4.GIT