From aeda168f4c64ab466e7f5b5dd0a4a6db8cdf54b6 Mon Sep 17 00:00:00 2001 From: Berk Hess Date: Tue, 22 Oct 2019 11:33:20 +0200 Subject: [PATCH] Require -ei for essential dynamics Essential dynamics sampling was switching on by either the -ei option or by ED information being present in the checkpoint file. As this complicates initialization and we should not choose algorithms based on a checkpoint, it is now only switched on by the -ei option (but an mdp option is we actually want). Change-Id: I6e0873a38ee42779d09f66ed7e55c6d1b8bf25da --- src/gromacs/mdrun/md.cpp | 9 ++++++++- src/gromacs/mdrun/runner.cpp | 18 ++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/gromacs/mdrun/md.cpp b/src/gromacs/mdrun/md.cpp index d62fafa249..a01c2decad 100644 --- a/src/gromacs/mdrun/md.cpp +++ b/src/gromacs/mdrun/md.cpp @@ -237,7 +237,7 @@ void gmx::LegacySimulator::do_md() SimulationGroups *groups = &top_global->groups; std::unique_ptr ed = nullptr; - if (opt2bSet("-ei", nfile, fnm) || observablesHistory->edsamHistory != nullptr) + if (opt2bSet("-ei", nfile, fnm)) { /* Initialize essential dynamics sampling */ ed = init_edsam(mdlog, @@ -248,6 +248,13 @@ void gmx::LegacySimulator::do_md() oenv, startingBehavior); } + else if (observablesHistory->edsamHistory) + { + gmx_fatal(FARGS, + "The checkpoint is from a run with essential dynamics sampling, " + "but the current run did not specify the -ei option. " + "Either specify the -ei option to mdrun, or do not use this checkpoint file."); + } initialize_lambdas(fplog, *ir, MASTER(cr), &state_global->fep_state, state_global->lambda, lam0); Update upd(ir, deform); diff --git a/src/gromacs/mdrun/runner.cpp b/src/gromacs/mdrun/runner.cpp index a49f5372d5..ee79084fb4 100644 --- a/src/gromacs/mdrun/runner.cpp +++ b/src/gromacs/mdrun/runner.cpp @@ -685,8 +685,10 @@ int Mdrunner::mdrunner() cr doesn't reflect the final parallel state right now */ gmx_mtop_t mtop; - bool doMembed = opt2bSet("-membed", filenames.size(), filenames.data()); - bool doRerun = mdrunOptions.rerun; + /* TODO: inputrec should tell us whether we use an algorithm, not a file option */ + const bool doEssentialDynamics = opt2bSet("-ei", filenames.size(), filenames.data()); + const bool doMembed = opt2bSet("-membed", filenames.size(), filenames.data()); + const bool doRerun = mdrunOptions.rerun; // Handle task-assignment related user options. EmulateGpuNonbonded emulateGpuNonbonded = (getenv("GMX_EMULATE_GPU") != nullptr ? @@ -1504,14 +1506,10 @@ int Mdrunner::mdrunner() startingBehavior); } - /* Let makeConstraints know whether we have essential dynamics constraints. - * TODO: inputrec should tell us whether we use an algorithm, not a file option or the checkpoint - */ - bool doEssentialDynamics = (opt2fn_null("-ei", filenames.size(), filenames.data()) != nullptr - || observablesHistory.edsamHistory); - auto constr = makeConstraints(mtop, *inputrec, pull_work, doEssentialDynamics, - fplog, *mdAtoms->mdatoms(), - cr, ms, &nrnb, wcycle, fr->bMolPBC); + /* Let makeConstraints know whether we have essential dynamics constraints. */ + auto constr = makeConstraints(mtop, *inputrec, pull_work, doEssentialDynamics, + fplog, *mdAtoms->mdatoms(), + cr, ms, &nrnb, wcycle, fr->bMolPBC); /* Energy terms and groups */ gmx_enerdata_t enerd(mtop.groups.groups[SimulationAtomGroupType::EnergyOutput].size(), inputrec->fepvals->n_lambda); -- 2.11.4.GIT