From e672c15fea293647ea13588098c6e3f129a21ee0 Mon Sep 17 00:00:00 2001 From: Artem Zhmurov Date: Wed, 29 Apr 2020 12:10:20 +0000 Subject: [PATCH] Fix the number of steps check when checkpoint is loaded The check ignores the initial step in the config file, thust only works when loading for the trajectory that was originally started from step zero. --- docs/release-notes/2020/2020.2.rst | 9 +++++++++ src/gromacs/fileio/checkpoint.cpp | 39 +++++++++++++++++++++----------------- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/docs/release-notes/2020/2020.2.rst b/docs/release-notes/2020/2020.2.rst index 06272ad451..2673c2393d 100644 --- a/docs/release-notes/2020/2020.2.rst +++ b/docs/release-notes/2020/2020.2.rst @@ -54,6 +54,15 @@ in particular these where this velocity is large in the beginning of the run. :issue:`3508` +Fix checkpoint restart with non-zero initial step +""""""""""""""""""""""""""""""""""""""""""""""""" + +When restarting from the checkpoint, the init-step mdp parameter was ignored while +checking if the simulation is already finished. As a result, this check only worked +properly when init-step was 0 or was not specified. + +:issue:`3489` + Fixes for ``gmx`` tools ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/gromacs/fileio/checkpoint.cpp b/src/gromacs/fileio/checkpoint.cpp index 03b5ae8fb1..6aaedafbc5 100644 --- a/src/gromacs/fileio/checkpoint.cpp +++ b/src/gromacs/fileio/checkpoint.cpp @@ -2842,26 +2842,31 @@ void load_checkpoint(const char* fn, mdModulesNotifier.notifier_.notify(broadcastCheckPointData); } ir->bContinuation = TRUE; - // TODO Should the following condition be <=? Currently if you - // pass a checkpoint written by an normal completion to a restart, - // mdrun will read all input, does some work but no steps, and - // write successful output. But perhaps that is not desirable. - if ((ir->nsteps >= 0) && (ir->nsteps < headerContents.step)) + if (ir->nsteps >= 0) { + // TODO Should the following condition be <=? Currently if you + // pass a checkpoint written by an normal completion to a restart, + // mdrun will read all input, does some work but no steps, and + // write successful output. But perhaps that is not desirable. // Note that we do not intend to support the use of mdrun // -nsteps to circumvent this condition. - char nstepsString[STEPSTRSIZE], stepString[STEPSTRSIZE]; - gmx_step_str(ir->nsteps, nstepsString); - gmx_step_str(headerContents.step, stepString); - gmx_fatal(FARGS, - "The input requested %s steps, however the checkpoint " - "file has already reached step %s. The simulation will not " - "proceed, because either your simulation is already complete, " - "or your combination of input files don't match.", - nstepsString, stepString); - } - if (ir->nsteps >= 0) - { + if (ir->nsteps + ir->init_step < headerContents.step) + { + char buf[STEPSTRSIZE]; + std::string message = + gmx::formatString("The input requested %s steps, ", gmx_step_str(ir->nsteps, buf)); + if (ir->init_step > 0) + { + message += gmx::formatString("starting from step %s, ", gmx_step_str(ir->init_step, buf)); + } + message += gmx::formatString( + "however the checkpoint " + "file has already reached step %s. The simulation will not " + "proceed, because either your simulation is already complete, " + "or your combination of input files don't match.", + gmx_step_str(headerContents.step, buf)); + gmx_fatal(FARGS, "%s", message.c_str()); + } ir->nsteps += ir->init_step - headerContents.step; } ir->init_step = headerContents.step; -- 2.11.4.GIT