* \param [in] cr Pointer to MPI communication object.
* \param [in] dlbOption Enum value for the DLB option.
* \param [in] bRecordLoad True if the load balancer is recording load information.
- * \param [in] Flags Simulation flags passed from main.
+ * \param [in] mdrunOptions Options for mdrun.
* \param [in] ir Pointer mdrun to input parameters.
* \returns DLB initial/startup state.
*/
static int determineInitialDlbState(FILE *fplog, t_commrec *cr,
DlbOption dlbOption, gmx_bool bRecordLoad,
- unsigned long Flags, const t_inputrec *ir)
+ const MdrunOptions &mdrunOptions,
+ const t_inputrec *ir)
{
int dlbState = edlbsOffCanTurnOn;
}
/* Reruns don't support DLB: bail or override auto mode */
- if (Flags & MD_RERUN)
+ if (mdrunOptions.rerun)
{
std::string reasonStr = "it is not supported in reruns.";
return forceDlbOffOrBail(dlbState, reasonStr, cr, fplog);
return forceDlbOffOrBail(dlbState, reasonStr, cr, fplog);
}
- if (Flags & MD_REPRODUCIBLE)
+ if (mdrunOptions.reproducible)
{
std::string reasonStr = "you started a reproducible run.";
switch (dlbState)
/*! \brief Set the cell size and interaction limits, as well as the DD grid */
static void set_dd_limits_and_grid(FILE *fplog, t_commrec *cr, gmx_domdec_t *dd,
const DomdecOptions &options,
- unsigned long Flags,
+ const MdrunOptions &mdrunOptions,
const gmx_mtop_t *mtop,
const t_inputrec *ir,
matrix box, const rvec *x,
/* Initialize to GPU share count to 0, might change later */
comm->nrank_gpu_shared = 0;
- comm->dlbState = determineInitialDlbState(fplog, cr, options.dlbOption, comm->bRecordLoad, Flags, ir);
+ comm->dlbState = determineInitialDlbState(fplog, cr, options.dlbOption, comm->bRecordLoad, mdrunOptions, ir);
dd_dlb_set_should_check_whether_to_turn_dlb_on(dd, TRUE);
/* To consider turning DLB on after 2*nstlist steps we need to check
* at partitioning count 3. Thus we need to increase the first count by 2.
gmx_domdec_t *init_domain_decomposition(FILE *fplog, t_commrec *cr,
const DomdecOptions &options,
- unsigned long Flags,
+ const MdrunOptions &mdrunOptions,
const gmx_mtop_t *mtop,
const t_inputrec *ir,
matrix box, rvec *x,
set_dd_envvar_options(fplog, dd, cr->nodeid);
- set_dd_limits_and_grid(fplog, cr, dd, options, Flags,
+ set_dd_limits_and_grid(fplog, cr, dd, options, mdrunOptions,
mtop, ir,
box, x,
ddbox,
struct gmx_domdec_t;
struct gmx_ddbox_t;
struct gmx_domdec_zones_t;
+struct MdrunOptions;
struct t_commrec;
struct t_inputrec;
class t_state;
gmx_domdec_t *init_domain_decomposition(FILE *fplog,
t_commrec *cr,
const DomdecOptions &options,
- unsigned long Flags,
+ const MdrunOptions &mdrunOptions,
const gmx_mtop_t *mtop,
const t_inputrec *ir,
matrix box,
#include "gromacs/gmxpreprocess/readir.h"
#include "gromacs/math/vec.h"
#include "gromacs/mdlib/mdatoms.h"
+#include "gromacs/mdlib/mdrun.h"
#include "gromacs/mdtypes/inputrec.h"
#include "gromacs/mdtypes/md_enums.h"
#include "gromacs/mdtypes/pull-params.h"
double t_start;
pull = ir->pull;
- pull_work = init_pull(nullptr, pull, ir, 0, nullptr, mtop, nullptr, oenv, lambda, FALSE, 0);
+ pull_work = init_pull(nullptr, pull, ir, 0, nullptr, mtop, nullptr, oenv, lambda, FALSE, ContinuationOptions());
md = init_mdatoms(nullptr, mtop, ir->efep);
atoms2md(mtop, ir, -1, nullptr, mtop->natoms, md);
if (ir->efep)
*
* Call on master only.
*/
-static FILE *open_imd_out(const char *fn,
- t_gmx_IMD_setup *IMDsetup,
- int nat_total,
- const gmx_output_env_t *oenv,
- unsigned long Flags)
+static FILE *open_imd_out(const char *fn,
+ t_gmx_IMD_setup *IMDsetup,
+ int nat_total,
+ const gmx_output_env_t *oenv,
+ const ContinuationOptions &continuationOptions)
{
FILE *fp;
if (fn && oenv)
{
/* If we append to an existing file, all the header information is already there */
- if (Flags & MD_APPENDFILES)
+ if (continuationOptions.appendFiles)
{
fp = gmx_fio_fopen(fn, "a+");
}
int nfile,
const t_filenm fnm[],
const gmx_output_env_t *oenv,
- int imdport,
- unsigned long Flags)
+ const MdrunOptions &mdrunOptions)
{
int i;
int nat_total;
return;
}
+ const ImdOptions &options = mdrunOptions.imdOptions;
+
/* It seems we have a .tpr file that defines an IMD group and thus allows IMD sessions.
* Check whether we can actually provide the IMD functionality for this setting: */
if (MASTER(cr))
{
/* Check whether IMD was enabled by one of the command line switches: */
- if ((Flags & MD_IMDWAIT) || (Flags & MD_IMDTERM) || (Flags & MD_IMDPULL))
+ if (options.wait || options.terminatable || options.pull)
{
/* Multiple simulations or replica exchange */
if (MULTISIM(cr))
/* Initialize IMD setup structure. If we read in a pre-IMD .tpr file, imd->nat
* will be zero. For those cases we transfer _all_ atomic positions */
ir->imd->setup = imd_create(ir->imd->nat > 0 ? ir->imd->nat : nat_total,
- defnstimd, imdport);
+ defnstimd, options.port);
IMDsetup = ir->imd->setup;
/* We might need to open an output file for IMD forces data */
if (MASTER(cr))
{
- IMDsetup->outf = open_imd_out(opt2fn("-if", nfile, fnm), ir->imd->setup, nat_total, oenv, Flags);
+ IMDsetup->outf = open_imd_out(opt2fn("-if", nfile, fnm), ir->imd->setup, nat_total, oenv, mdrunOptions.continuationOptions);
}
/* Make sure that we operate with a valid atom index array for the IMD atoms */
snew(IMDsetup->energysendbuf, recsize);
/* Shall we wait for a connection? */
- if (Flags & MD_IMDWAIT)
+ if (options.wait)
{
IMDsetup->bWConnect = TRUE;
fprintf(stderr, "%s Pausing simulation while no IMD connection present (-imdwait).\n", IMDstr);
}
/* Will the IMD clients be able to terminate the simulation? */
- if (Flags & MD_IMDTERM)
+ if (options.terminatable)
{
IMDsetup->bTerminatable = TRUE;
fprintf(stderr, "%s Allow termination of the simulation from IMD client (-imdterm).\n", IMDstr);
}
/* Is pulling from IMD client allowed? */
- if (Flags & MD_IMDPULL)
+ if (options.pull)
{
IMDsetup->bForceActivated = TRUE;
fprintf(stderr, "%s Pulling from IMD remote is enabled (-imdpull).\n", IMDstr);
struct gmx_mtop_t;
struct gmx_output_env_t;
struct gmx_wallcycle;
+struct MdrunOptions;
struct t_commrec;
struct t_filenm;
struct t_gmx_IMD;
* \param nfile Number of files.
* \param fnm Struct containing file names etc.
* \param oenv Output options.
- * \param imdport Port to use for IMD connections.
- * \param Flags Flags passed over from main, used to determine
- * whether or not we are appending.
+ * \param mdrunOptions Options for mdrun.
*/
void init_IMD(t_inputrec *ir, t_commrec *cr, gmx_mtop_t *top_global,
FILE *fplog, int defnstimd, rvec x[],
int nfile, const t_filenm fnm[], const gmx_output_env_t *oenv,
- int imdport, unsigned long Flags);
+ const MdrunOptions &mdrunOptions);
/*! \brief IMD required in this time step?
#include "gromacs/math/units.h"
#include "gromacs/math/vec.h"
#include "gromacs/math/vecdump.h"
+#include "gromacs/mdlib/expanded.h"
#include "gromacs/mdlib/gmx_omp_nthreads.h"
-#include "gromacs/mdlib/mdrun.h"
#include "gromacs/mdlib/sim_util.h"
#include "gromacs/mdlib/update.h"
#include "gromacs/mdtypes/commrec.h"
*/
#include "gmxpre.h"
+#include "expanded.h"
+
#include <stdio.h>
#include <cmath>
#include "gromacs/mdlib/calcmu.h"
#include "gromacs/mdlib/constr.h"
#include "gromacs/mdlib/force.h"
-#include "gromacs/mdlib/mdrun.h"
#include "gromacs/mdlib/update.h"
#include "gromacs/mdtypes/inputrec.h"
#include "gromacs/mdtypes/md_enums.h"
/* Eventually should contain all the functions needed to initialize expanded ensemble
before the md loop starts */
-extern void init_expanded_ensemble(gmx_bool bStateFromCP, t_inputrec *ir, df_history_t *dfhist)
+void init_expanded_ensemble(gmx_bool bStateFromCP, t_inputrec *ir, df_history_t *dfhist)
{
if (!bStateFromCP)
{
}
/* print out the weights to the log, along with current state */
-extern void PrintFreeEnergyInfoToFile(FILE *outfile, t_lambda *fep, t_expanded *expand, t_simtemp *simtemp, df_history_t *dfhist,
- int fep_state, int frequency, gmx_int64_t step)
+void PrintFreeEnergyInfoToFile(FILE *outfile, t_lambda *fep, t_expanded *expand, t_simtemp *simtemp, df_history_t *dfhist,
+ int fep_state, int frequency, gmx_int64_t step)
{
int nlim, i, ifep, jfep;
real dw, dg, dv, Tprint;
}
}
-extern int ExpandedEnsembleDynamics(FILE *log, t_inputrec *ir, gmx_enerdata_t *enerd,
- t_state *state, t_extmass *MassQ, int fep_state, df_history_t *dfhist,
- gmx_int64_t step,
- rvec *v, t_mdatoms *mdatoms)
+int ExpandedEnsembleDynamics(FILE *log, t_inputrec *ir, gmx_enerdata_t *enerd,
+ t_state *state, t_extmass *MassQ, int fep_state, df_history_t *dfhist,
+ gmx_int64_t step,
+ rvec *v, t_mdatoms *mdatoms)
/* Note that the state variable is only needed for simulated tempering, not
Hamiltonian expanded ensemble. May be able to remove it after integrator refactoring. */
{
--- /dev/null
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2017, 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.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+#ifndef GMX_MDLIB_EXPANDED_H
+#define GMX_MDLIB_EXPANDED_H
+
+#include <stdio.h>
+
+#include "gromacs/math/vectypes.h"
+#include "gromacs/utility/basedefinitions.h"
+
+struct df_history_t;
+struct gmx_enerdata_t;
+struct t_expanded;
+struct t_extmass;
+struct t_inputrec;
+struct t_lambda;
+struct t_mdatoms;
+struct t_simtemp;
+class t_state;
+
+void init_npt_masses(t_inputrec *ir, t_state *state, t_extmass *MassQ, gmx_bool bInit);
+
+void init_expanded_ensemble(gmx_bool bStateFromCP, t_inputrec *ir, df_history_t *dfhist);
+
+int ExpandedEnsembleDynamics(FILE *log, t_inputrec *ir, gmx_enerdata_t *enerd,
+ t_state *state, t_extmass *MassQ, int fep_state, df_history_t *dfhist,
+ gmx_int64_t step,
+ rvec *v, t_mdatoms *mdatoms);
+
+void PrintFreeEnergyInfoToFile(FILE *outfile, t_lambda *fep, t_expanded *expand, t_simtemp *simtemp, df_history_t *dfhist,
+ int fep_state, int frequency, gmx_int64_t step);
+
+#endif
struct gmx_mtop_t;
struct gmx_membed_t;
struct gmx_output_env_t;
+struct MdrunOptions;
struct ObservablesHistory;
struct ReplicaExchangeParameters;
struct t_commrec;
* \param[in] nfile Number of files
* \param[in] fnm Filename structure array
* \param[in] oenv Output information
- * \param[in] bVerbose Verbose output or not
- * \param[in] nstglobalcomm How often global communication is done
+ * \param[in] mdrunOptions Options for mdrun
* \param[in] vsite Virtual site information
* \param[in] constr Constraint information
- * \param[in] stepout How often we writen to the console
* \param[in] outputProvider Additional output provider
* \param[in] inputrec Input record with mdp options
* \param[in] top_global Molecular topology for the whole system
* \param[in] fr Force record with cut-off information and more
* \param[in] replExParams Parameters for the replica exchange algorithm
* \param[in] membed Membrane embedding data structure
- * \param[in] cpt_period How often to checkpoint the simulation
- * \param[in] max_hours Maximume length of the simulation (wall time)
- * \param[in] imdport Interactive MD port (socket)
- * \param[in] Flags Flags to control mdrun
* \param[in] walltime_accounting More timing information
*/
typedef double integrator_t (FILE *fplog, t_commrec *cr, const gmx::MDLogger &mdlog,
int nfile, const t_filenm fnm[],
- const gmx_output_env_t *oenv, gmx_bool bVerbose,
- int nstglobalcomm,
+ const gmx_output_env_t *oenv,
+ const MdrunOptions &mdrunOptions,
gmx_vsite_t *vsite, gmx_constr_t constr,
- int stepout,
gmx::IMDOutputProvider *outputProvider,
t_inputrec *inputrec,
gmx_mtop_t *top_global, t_fcdata *fcd,
t_forcerec *fr,
const ReplicaExchangeParameters &replExParams,
gmx_membed_t gmx_unused * membed,
- real cpt_period, real max_hours,
- int imdport,
- unsigned long Flags,
gmx_walltime_accounting_t walltime_accounting);
} // namespace gmx
gmx_mdoutf_t init_mdoutf(FILE *fplog, int nfile, const t_filenm fnm[],
- int mdrun_flags, const t_commrec *cr,
+ const MdrunOptions &mdrunOptions,
+ const t_commrec *cr,
gmx::IMDOutputProvider *outputProvider,
const t_inputrec *ir, gmx_mtop_t *top_global,
const gmx_output_env_t *oenv, gmx_wallcycle_t wcycle)
if (MASTER(cr))
{
- bAppendFiles = (mdrun_flags & MD_APPENDFILES);
+ bAppendFiles = mdrunOptions.continuationOptions.appendFiles;
- of->bKeepAndNumCPT = (mdrun_flags & MD_KEEPANDNUMCPT);
+ of->bKeepAndNumCPT = mdrunOptions.checkpointOptions.keepAndNumberCheckpointFiles;
filemode = bAppendFiles ? appendMode : writeMode;
class energyhistory_t;
struct gmx_mtop_t;
struct gmx_output_env_t;
+struct MdrunOptions;
struct ObservablesHistory;
struct t_commrec;
struct t_filenm;
gmx_mdoutf_t init_mdoutf(FILE *fplog,
int nfile,
const t_filenm fnm[],
- int mdrun_flags,
+ const MdrunOptions &mdrunOptions,
const t_commrec *cr,
gmx::IMDOutputProvider *outputProvider,
const t_inputrec *ir,
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
+
+/*! \libinternal \file
+ *
+ * \brief This file declares types and functions for initializing an MD run
+ *
+ * \author Berk Hess <hess@kth.se>
+ * \inlibraryapi
+ */
+
#ifndef GMX_MDLIB_MDRUN_H
#define GMX_MDLIB_MDRUN_H
-#include <stdio.h>
-#include <time.h>
-
#include "gromacs/timing/wallcycle.h"
-struct df_history_t;
-struct gmx_constr;
-struct gmx_edsam;
-struct gmx_enerdata_t;
struct gmx_mtop_t;
struct t_commrec;
-struct t_expanded;
-struct t_extmass;
struct t_inputrec;
-struct t_lambda;
-struct t_mdatoms;
-struct t_simtemp;
class t_state;
-#define MD_POLARISE (1<<2)
-#define MD_RERUN (1<<4)
-#define MD_RERUN_VSITE (1<<5)
-#define MD_CONFOUT (1<<12)
-#define MD_REPRODUCIBLE (1<<13)
-#define MD_APPENDFILES (1<<15)
-#define MD_APPENDFILESSET (1<<21)
-#define MD_KEEPANDNUMCPT (1<<16)
-#define MD_READ_EKIN (1<<17)
-#define MD_STARTFROMCPT (1<<18)
-#define MD_RESETCOUNTERSHALFWAY (1<<19)
-#define MD_TUNEPME (1<<20)
-#define MD_NTOMPSET (1<<21)
-#define MD_IMDWAIT (1<<23)
-#define MD_IMDTERM (1<<24)
-#define MD_IMDPULL (1<<25)
-
-void init_npt_masses(t_inputrec *ir, t_state *state, t_extmass *MassQ, gmx_bool bInit);
-
-void init_expanded_ensemble(gmx_bool bStateFromCP, t_inputrec *ir, df_history_t *dfhist);
-
-int ExpandedEnsembleDynamics(FILE *log, t_inputrec *ir, gmx_enerdata_t *enerd,
- t_state *state, t_extmass *MassQ, int fep_state, df_history_t *dfhist,
- gmx_int64_t step,
- rvec *v, t_mdatoms *mdatoms);
-
-void PrintFreeEnergyInfoToFile(FILE *outfile, t_lambda *fep, t_expanded *expand, t_simtemp *simtemp, df_history_t *dfhist,
- int fep_state, int frequency, gmx_int64_t step);
-
-/* Allocate and initialize node-local state entries. */
+//! \internal \brief Options and settings for continuing from checkpoint
+struct ContinuationOptions
+{
+ //! \brief Constructor
+ ContinuationOptions() :
+ appendFiles(false),
+ appendFilesOptionSet(false),
+ startedFromCheckpoint(false),
+ haveReadEkin(false)
+ {
+ }
+
+ //! True if we are continuing from a checkpoint and should append output files
+ bool appendFiles;
+ //! True if the -append option was explicitly set by the user (either to true of false
+ bool appendFilesOptionSet;
+ //! True if we started from a checkpoint file
+ bool startedFromCheckpoint;
+ //! True if we read the kinetic energy from checkpoint file
+ bool haveReadEkin;
+};
+
+//! \internal \brief Options for writing checkpoint files
+struct CheckpointOptions
+{
+ //! \brief Constructor
+ CheckpointOptions() :
+ keepAndNumberCheckpointFiles(FALSE),
+ period(15)
+ {
+ }
+
+ //! True means keep all checkpoint file and add the step number to the name
+ gmx_bool keepAndNumberCheckpointFiles;
+ //! The period in minutes for writing checkpoint files
+ real period;
+};
+
+//! \internal \brief Options for timing (parts of) mdrun
+struct TimingOptions
+{
+ //! \brief Constructor
+ TimingOptions() :
+ resetStep(-1),
+ resetHalfway(FALSE)
+ {
+ }
+
+ //! Reset timers at the start of this MD step, -1 means do not reset
+ int resetStep;
+ //! If true, reset timers half-way the run
+ gmx_bool resetHalfway;
+};
+
+//! \internal \brief Options for IMD
+struct ImdOptions
+{
+ //! Constructor
+ ImdOptions() :
+ port(8888),
+ wait(FALSE),
+ terminatable(FALSE),
+ pull(FALSE)
+ {
+ }
+
+ //! IMD listening port
+ int port;
+ //! If true, pause the simulation while no IMD client is connected
+ gmx_bool wait;
+ //! If true, allow termination of the simulation from IMD client
+ gmx_bool terminatable;
+ //! If true, allow COM pulling in the simulation from IMD client
+ gmx_bool pull;
+};
+
+//! \internal \brief Collection of all options of mdrun that are not processed separately
+struct MdrunOptions
+{
+ //! \brief Constructor
+ MdrunOptions() :
+ rerun(FALSE),
+ rerunConstructVsites(FALSE),
+ globalCommunicationInterval(-1),
+ reproducible(FALSE),
+ writeConfout(TRUE),
+ continuationOptions(),
+ checkpointOptions(),
+ numStepsCommandline(-2),
+ maximumHoursToRun(-1),
+ timingOptions(),
+ tunePme(TRUE),
+ ntompOptionIsSet(FALSE),
+ imdOptions(),
+ verbose(FALSE),
+ verboseStepPrintInterval(100)
+ {
+ }
+
+ //! Re-compute energies, and possibly forces, for frames from an input tracjectory
+ gmx_bool rerun;
+ //! Re-construct virual sites durin a rerun simulation
+ gmx_bool rerunConstructVsites;
+ //! Request to do global communication at this interval in steps, -1 is determine from inputrec
+ int globalCommunicationInterval;
+ //! Try to make the simulation binary reproducible
+ gmx_bool reproducible;
+ //! Write confout.gro at the end of the run
+ gmx_bool writeConfout;
+ //! Options for continuing a simulation from a checkpoint file
+ ContinuationOptions continuationOptions;
+ //! Options for checkpointing th simulation
+ CheckpointOptions checkpointOptions;
+ //! Number of steps to run, -2 is use inputrec, -1 is infinite
+ gmx_int64_t numStepsCommandline;
+ //! Maximum duration of this simulation in wall-clock hours, -1 is no limit
+ real maximumHoursToRun;
+ //! Options for timing the run
+ TimingOptions timingOptions;
+ //! If true and supported, will tune the PP-PME load balance
+ gmx_bool tunePme;
+ //! True if the user explicitly set the -ntomp command line option
+ gmx_bool ntompOptionIsSet;
+ //! Options for IMD
+ ImdOptions imdOptions;
+ //! Increase the verbosity level in the logging and/or stdout/stderr
+ gmx_bool verbose;
+ //! If verbose=true, print remaining runtime at this step interval
+ int verboseStepPrintInterval;
+};
+
+//! \brief Allocate and initialize node-local state entries
void set_state_entries(t_state *state, const t_inputrec *ir);
-/* Broadcast the data for a simulation, and allocate node-specific settings */
+//! \brief Broadcast inputrec and mtop and allocate node-specific settings
void init_parallel(t_commrec *cr, t_inputrec *inputrec,
gmx_mtop_t *mtop);
+//! \brief Broadcasts state from the master to all ranks in cr->mpi_comm_mygroup
void bcast_state(const t_commrec *cr, t_state *state);
-/* Broadcasts state from the master to all nodes in cr->mpi_comm_mygroup.
- */
#endif
static void init_em(FILE *fplog, const char *title,
t_commrec *cr, gmx::IMDOutputProvider *outputProvider,
t_inputrec *ir,
+ const MdrunOptions &mdrunOptions,
t_state *state_global, gmx_mtop_t *top_global,
em_state_t *ems, gmx_localtop_t **top,
t_nrnb *nrnb, rvec mu_tot,
gmx_vsite_t *vsite, gmx_constr_t constr, gmx_shellfc_t **shellfc,
int nfile, const t_filenm fnm[],
gmx_mdoutf_t *outf, t_mdebin **mdebin,
- int imdport, unsigned long gmx_unused Flags,
gmx_wallcycle_t wcycle)
{
real dvdl_constr;
/* Interactive molecular dynamics */
init_IMD(ir, cr, top_global, fplog, 1, as_rvec_array(state_global->x.data()),
- nfile, fnm, nullptr, imdport, Flags);
+ nfile, fnm, nullptr, mdrunOptions);
if (ir->eI == eiNM)
{
*gstat = nullptr;
}
- *outf = init_mdoutf(fplog, nfile, fnm, 0, cr, outputProvider, ir, top_global, nullptr, wcycle);
+ *outf = init_mdoutf(fplog, nfile, fnm, mdrunOptions, cr, outputProvider, ir, top_global, nullptr, wcycle);
snew(*enerd, 1);
init_enerdata(top_global->groups.grps[egcENER].nr, ir->fepvals->n_lambda,
/*! \brief Do conjugate gradients minimization
\copydoc integrator_t(FILE *fplog, t_commrec *cr, const gmx::MDLogger &mdlog,
int nfile, const t_filenm fnm[],
- const gmx_output_env_t *oenv, gmx_bool bVerbose,
- int nstglobalcomm,
+ const gmx_output_env_t *oenv,
+ const MdrunOptions &mdrunOptions,
gmx_vsite_t *vsite, gmx_constr_t constr,
- int stepout,
gmx::IMDOutputProvider *outputProvider,
t_inputrec *inputrec,
gmx_mtop_t *top_global, t_fcdata *fcd,
t_forcerec *fr,
const ReplicaExchangeParameters &replExParams,
gmx_membed_t gmx_unused *membed,
- real cpt_period, real max_hours,
- int imdport,
- unsigned long Flags,
gmx_walltime_accounting_t walltime_accounting)
*/
double do_cg(FILE *fplog, t_commrec *cr, const gmx::MDLogger gmx_unused &mdlog,
int nfile, const t_filenm fnm[],
- const gmx_output_env_t gmx_unused *oenv, gmx_bool bVerbose,
- int gmx_unused nstglobalcomm,
+ const gmx_output_env_t gmx_unused *oenv,
+ const MdrunOptions &mdrunOptions,
gmx_vsite_t *vsite, gmx_constr_t constr,
- int gmx_unused stepout,
gmx::IMDOutputProvider *outputProvider,
t_inputrec *inputrec,
gmx_mtop_t *top_global, t_fcdata *fcd,
t_forcerec *fr,
const ReplicaExchangeParameters gmx_unused &replExParams,
gmx_membed_t gmx_unused *membed,
- real gmx_unused cpt_period, real gmx_unused max_hours,
- int imdport,
- unsigned long gmx_unused Flags,
gmx_walltime_accounting_t walltime_accounting)
{
const char *CG = "Polak-Ribiere Conjugate Gradients";
em_state_t *s_c = &s3;
/* Init em and store the local state in s_min */
- init_em(fplog, CG, cr, outputProvider, inputrec,
+ init_em(fplog, CG, cr, outputProvider, inputrec, mdrunOptions,
state_global, top_global, s_min, &top,
nrnb, mu_tot, fr, &enerd, &graph, mdatoms, &gstat,
vsite, constr, nullptr,
- nfile, fnm, &outf, &mdebin, imdport, Flags, wcycle);
+ nfile, fnm, &outf, &mdebin, wcycle);
/* Print to log file */
print_em_start(fplog, cr, walltime_accounting, wcycle, CG);
/* Print it if necessary */
if (MASTER(cr))
{
- if (bVerbose)
+ if (mdrunOptions.verbose)
{
double sqrtNumAtoms = sqrt(static_cast<double>(state_global->natoms));
fprintf(stderr, "\rStep %d, Epot=%12.6e, Fnorm=%9.3e, Fmax=%9.3e (atom %d)\n",
/*! \brief Do L-BFGS conjugate gradients minimization
\copydoc integrator_t(FILE *fplog, t_commrec *cr, const gmx::MDLogger &mdlog,
int nfile, const t_filenm fnm[],
- const gmx_output_env_t *oenv, gmx_bool bVerbose,
- int nstglobalcomm,
+ const gmx_output_env_t *oenv,
+ const MdrunOptions &mdrunOptions,
gmx_vsite_t *vsite, gmx_constr_t constr,
- int stepout,
gmx::IMDOutputProvider *outputProvider,
t_inputrec *inputrec,
gmx_mtop_t *top_global, t_fcdata *fcd,
t_forcerec *fr,
const ReplicaExchangeParameters &replExParams,
gmx_membed_t gmx_unused *membed,
- real cpt_period, real max_hours,
- int imdport,
- unsigned long Flags,
gmx_walltime_accounting_t walltime_accounting)
*/
double do_lbfgs(FILE *fplog, t_commrec *cr, const gmx::MDLogger gmx_unused &mdlog,
int nfile, const t_filenm fnm[],
- const gmx_output_env_t gmx_unused *oenv, gmx_bool bVerbose,
- int gmx_unused nstglobalcomm,
+ const gmx_output_env_t gmx_unused *oenv,
+ const MdrunOptions &mdrunOptions,
gmx_vsite_t *vsite, gmx_constr_t constr,
- int gmx_unused stepout,
gmx::IMDOutputProvider *outputProvider,
t_inputrec *inputrec,
gmx_mtop_t *top_global, t_fcdata *fcd,
t_forcerec *fr,
const ReplicaExchangeParameters gmx_unused &replExParams,
gmx_membed_t gmx_unused *membed,
- real gmx_unused cpt_period, real gmx_unused max_hours,
- int imdport,
- unsigned long gmx_unused Flags,
gmx_walltime_accounting_t walltime_accounting)
{
static const char *LBFGS = "Low-Memory BFGS Minimizer";
neval = 0;
/* Init em */
- init_em(fplog, LBFGS, cr, outputProvider, inputrec,
+ init_em(fplog, LBFGS, cr, outputProvider, inputrec, mdrunOptions,
state_global, top_global, &ems, &top,
nrnb, mu_tot, fr, &enerd, &graph, mdatoms, &gstat,
vsite, constr, nullptr,
- nfile, fnm, &outf, &mdebin, imdport, Flags, wcycle);
+ nfile, fnm, &outf, &mdebin, wcycle);
start = 0;
end = mdatoms->homenr;
/* Print it if necessary */
if (MASTER(cr))
{
- if (bVerbose)
+ if (mdrunOptions.verbose)
{
double sqrtNumAtoms = sqrt(static_cast<double>(state_global->natoms));
fprintf(stderr, "\rStep %d, Epot=%12.6e, Fnorm=%9.3e, Fmax=%9.3e (atom %d)\n",
/*! \brief Do steepest descents minimization
\copydoc integrator_t(FILE *fplog, t_commrec *cr, const gmx::MDLogger &mdlog,
int nfile, const t_filenm fnm[],
- const gmx_output_env_t *oenv, gmx_bool bVerbose,
- int nstglobalcomm,
+ const gmx_output_env_t *oenv,
+ const MdrunOptions &mdrunOptions,
gmx_vsite_t *vsite, gmx_constr_t constr,
- int stepout,
gmx::IMDOutputProvider *outputProvider,
t_inputrec *inputrec,
gmx_mtop_t *top_global, t_fcdata *fcd,
gmx_edsam_t ed,
t_forcerec *fr,
const ReplicaExchangeParameters &replExParams,
- real cpt_period, real max_hours,
- int imdport,
- unsigned long Flags,
gmx_walltime_accounting_t walltime_accounting)
*/
double do_steep(FILE *fplog, t_commrec *cr, const gmx::MDLogger gmx_unused &mdlog,
int nfile, const t_filenm fnm[],
- const gmx_output_env_t gmx_unused *oenv, gmx_bool bVerbose,
- int gmx_unused nstglobalcomm,
+ const gmx_output_env_t gmx_unused *oenv,
+ const MdrunOptions &mdrunOptions,
gmx_vsite_t *vsite, gmx_constr_t constr,
- int gmx_unused stepout,
gmx::IMDOutputProvider *outputProvider,
t_inputrec *inputrec,
gmx_mtop_t *top_global, t_fcdata *fcd,
t_forcerec *fr,
const ReplicaExchangeParameters gmx_unused &replExParams,
gmx_membed_t gmx_unused *membed,
- real gmx_unused cpt_period, real gmx_unused max_hours,
- int imdport,
- unsigned long gmx_unused Flags,
gmx_walltime_accounting_t walltime_accounting)
{
const char *SD = "Steepest Descents";
em_state_t *s_try = &s1;
/* Init em and store the local state in s_try */
- init_em(fplog, SD, cr, outputProvider, inputrec,
+ init_em(fplog, SD, cr, outputProvider, inputrec, mdrunOptions,
state_global, top_global, s_try, &top,
nrnb, mu_tot, fr, &enerd, &graph, mdatoms, &gstat,
vsite, constr, nullptr,
- nfile, fnm, &outf, &mdebin, imdport, Flags, wcycle);
+ nfile, fnm, &outf, &mdebin, wcycle);
/* Print to log file */
print_em_start(fplog, cr, walltime_accounting, wcycle, SD);
/* Print it if necessary */
if (MASTER(cr))
{
- if (bVerbose)
+ if (mdrunOptions.verbose)
{
fprintf(stderr, "Step=%5d, Dmax= %6.1e nm, Epot= %12.5e Fmax= %11.5e, atom= %d%c",
count, ustep, s_try->epot, s_try->fmax, s_try->a_fmax+1,
/*! \brief Do normal modes analysis
\copydoc integrator_t(FILE *fplog, t_commrec *cr, const gmx::MDLogger &mdlog,
int nfile, const t_filenm fnm[],
- const gmx_output_env_t *oenv, gmx_bool bVerbose,
- int nstglobalcomm,
+ const gmx_output_env_t *oenv,
+ const MdrunOptions &mdrunOptions,
gmx_vsite_t *vsite, gmx_constr_t constr,
- int stepout,
gmx::IMDOutputProvider *outputProvider,
t_inputrec *inputrec,
gmx_mtop_t *top_global, t_fcdata *fcd,
gmx_edsam_t ed,
t_forcerec *fr,
const ReplicaExchangeParameters &replExParams,
- real cpt_period, real max_hours,
- int imdport,
- unsigned long Flags,
gmx_walltime_accounting_t walltime_accounting)
*/
double do_nm(FILE *fplog, t_commrec *cr, const gmx::MDLogger &mdlog,
int nfile, const t_filenm fnm[],
- const gmx_output_env_t gmx_unused *oenv, gmx_bool bVerbose,
- int gmx_unused nstglobalcomm,
+ const gmx_output_env_t gmx_unused *oenv,
+ const MdrunOptions &mdrunOptions,
gmx_vsite_t *vsite, gmx_constr_t constr,
- int gmx_unused stepout,
gmx::IMDOutputProvider *outputProvider,
t_inputrec *inputrec,
gmx_mtop_t *top_global, t_fcdata *fcd,
t_forcerec *fr,
const ReplicaExchangeParameters gmx_unused &replExParams,
gmx_membed_t gmx_unused *membed,
- real gmx_unused cpt_period, real gmx_unused max_hours,
- int imdport,
- unsigned long gmx_unused Flags,
gmx_walltime_accounting_t walltime_accounting)
{
const char *NM = "Normal Mode Analysis";
em_state_t state_work {};
/* Init em and store the local state in state_minimum */
- init_em(fplog, NM, cr, outputProvider, inputrec,
+ init_em(fplog, NM, cr, outputProvider, inputrec, mdrunOptions,
state_global, top_global, &state_work, &top,
nrnb, mu_tot, fr, &enerd, &graph, mdatoms, &gstat,
vsite, constr, &shellfc,
- nfile, fnm, &outf, nullptr, imdport, Flags, wcycle);
+ nfile, fnm, &outf, nullptr, wcycle);
std::vector<size_t> atom_index = get_atom_index(top_global);
snew(fneg, atom_index.size());
if (shellfc)
{
/* Now is the time to relax the shells */
- (void) relax_shell_flexcon(fplog, cr, bVerbose, step,
+ (void) relax_shell_flexcon(fplog, cr, mdrunOptions.verbose, step,
inputrec, bNS, force_flags,
top,
constr, enerd, fcd,
}
}
- if (bVerbose && fplog)
+ if (mdrunOptions.verbose && fplog)
{
fflush(fplog);
}
}
/* write progress */
- if (bIsMaster && bVerbose)
+ if (bIsMaster && mdrunOptions.verbose)
{
fprintf(stderr, "\rFinished step %d out of %d",
static_cast<int>(std::min(atom+nnodes, atom_index.size())),
void init_md(FILE *fplog,
t_commrec *cr, gmx::IMDOutputProvider *outputProvider,
t_inputrec *ir, const gmx_output_env_t *oenv,
+ const MdrunOptions &mdrunOptions,
double *t, double *t0,
gmx::ArrayRef<real> lambda, int *fep_state, double *lam0,
t_nrnb *nrnb, gmx_mtop_t *mtop,
int nfile, const t_filenm fnm[],
gmx_mdoutf_t *outf, t_mdebin **mdebin,
tensor force_vir, tensor shake_vir, rvec mu_tot,
- gmx_bool *bSimAnn, t_vcm **vcm, unsigned long Flags,
+ gmx_bool *bSimAnn, t_vcm **vcm,
gmx_wallcycle_t wcycle)
{
int i;
*vcm = init_vcm(fplog, &mtop->groups, ir);
}
- if (EI_DYNAMICS(ir->eI) && !(Flags & MD_APPENDFILES))
+ if (EI_DYNAMICS(ir->eI) && !mdrunOptions.continuationOptions.appendFiles)
{
if (ir->etc == etcBERENDSEN)
{
if (nfile != -1)
{
- *outf = init_mdoutf(fplog, nfile, fnm, Flags, cr, outputProvider, ir, mtop, oenv, wcycle);
+ *outf = init_mdoutf(fplog, nfile, fnm, mdrunOptions, cr, outputProvider, ir, mtop, oenv, wcycle);
- *mdebin = init_mdebin((Flags & MD_APPENDFILES) ? nullptr : mdoutf_get_fp_ene(*outf),
+ *mdebin = init_mdebin(mdrunOptions.continuationOptions.appendFiles ? nullptr : mdoutf_get_fp_ene(*outf),
mtop, ir, mdoutf_get_fp_dhdl(*outf));
}
struct gmx_localtop_t;
struct gmx_output_env_t;
struct gmx_update_t;
+struct MdrunOptions;
struct nonbonded_verlet_t;
struct t_mdatoms;
struct t_nrnb;
void init_md(FILE *fplog,
t_commrec *cr, gmx::IMDOutputProvider *outputProvider,
t_inputrec *ir, const gmx_output_env_t *oenv,
+ const MdrunOptions &mdrunOptions,
double *t, double *t0,
gmx::ArrayRef<real> lambda, int *fep_state, double *lam0,
t_nrnb *nrnb, gmx_mtop_t *mtop,
gmx_mdoutf_t *outf, t_mdebin **mdebin,
tensor force_vir, tensor shake_vir,
rvec mu_tot,
- gmx_bool *bSimAnn, t_vcm **vcm, unsigned long Flags,
+ gmx_bool *bSimAnn, t_vcm **vcm,
gmx_wallcycle_t wcycle);
/* Routine in sim_util.c */
/*! \brief Do test particle insertion.
\copydoc integrator_t (FILE *fplog, t_commrec *cr, const gmx::MDLogger &mdlog,
int nfile, const t_filenm fnm[],
- const gmx_output_env_t *oenv, gmx_bool bVerbose,
- int nstglobalcomm,
+ const gmx_output_env_t *oenv,
+ const MdrunOptions &mdrunOptions,
gmx_vsite_t *vsite, gmx_constr_t constr,
- int stepout,
gmx::IMDOutputProvider *outputProvider,
t_inputrec *inputrec,
gmx_mtop_t *top_global, t_fcdata *fcd,
gmx_edsam_t ed,
t_forcerec *fr,
const ReplicaExchangeParameters &replExParams,
- real cpt_period, real max_hours,
- int imdport,
- unsigned long Flags,
+ gmx_membed_t gmx_unused *membed,
gmx_walltime_accounting_t walltime_accounting)
*/
double do_tpi(FILE *fplog, t_commrec *cr, const gmx::MDLogger gmx_unused &mdlog,
int nfile, const t_filenm fnm[],
- const gmx_output_env_t *oenv, gmx_bool bVerbose,
- int gmx_unused nstglobalcomm,
+ const gmx_output_env_t *oenv,
+ const MdrunOptions &mdrunOptions,
gmx_vsite_t gmx_unused *vsite, gmx_constr_t gmx_unused constr,
- int gmx_unused stepout,
gmx::IMDOutputProvider *outputProvider,
t_inputrec *inputrec,
gmx_mtop_t *top_global, t_fcdata *fcd,
t_forcerec *fr,
const ReplicaExchangeParameters gmx_unused &replExParams,
gmx_membed_t gmx_unused *membed,
- real gmx_unused cpt_period, real gmx_unused max_hours,
- int gmx_unused imdport,
- unsigned long gmx_unused Flags,
gmx_walltime_accounting_t walltime_accounting)
{
gmx_localtop_t *top;
if (fp_tpi)
{
- if (bVerbose || frame%10 == 0 || frame < 10)
+ if (mdrunOptions.verbose || frame%10 == 0 || frame < 10)
{
fprintf(stderr, "mu %10.3e <mu> %10.3e\n",
-log(sum_embU/nsteps)/beta, -log(VembU_all/V_all)/beta);
int nfile, const t_filenm fnm[],
const char *part_suffix,
gmx_bool *bAddPart,
- gmx_bool *bDoAppendFiles)
+ bool *bDoAppendFiles)
{
t_fileio *fp;
int nfiles;
gmx_bool bTryToAppendFiles,
const int NFILE,
t_filenm fnm[],
- gmx_bool *bDoAppendFiles,
- gmx_bool *bStartFromCpt)
+ bool *bDoAppendFiles,
+ bool *bStartFromCpt)
{
gmx_bool bAddPart;
int sim_part, sim_part_fn;
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017, 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.
gmx_bool bTryToAppendFiles,
const int NFILE,
t_filenm fnm[],
- gmx_bool *bDoAppendFiles,
- gmx_bool *bStartFromCpt);
+ bool *bDoAppendFiles,
+ bool *bStartFromCpt);
#endif
static FILE *open_pull_out(const char *fn, struct pull_t *pull,
const gmx_output_env_t *oenv,
- gmx_bool bCoord, unsigned long Flags)
+ gmx_bool bCoord,
+ const ContinuationOptions &continuationOptions)
{
FILE *fp;
int nsets, c, m;
char **setname, buf[50];
- if (Flags & MD_APPENDFILES)
+ if (continuationOptions.appendFiles)
{
fp = gmx_fio_fopen(fn, "a+");
}
int nfile, const t_filenm fnm[],
const gmx_mtop_t *mtop, t_commrec *cr,
const gmx_output_env_t *oenv, real lambda,
- gmx_bool bOutFile, unsigned long Flags)
+ gmx_bool bOutFile,
+ const ContinuationOptions &continuationOptions)
{
struct pull_t *pull;
pull_comm_t *comm;
}
GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
pull->out_x = open_pull_out(px_appended.c_str(), pull, oenv,
- TRUE, Flags);
+ TRUE, continuationOptions);
pull->out_f = open_pull_out(pf_appended.c_str(), pull, oenv,
- FALSE, Flags);
+ FALSE, continuationOptions);
return pull;
}
else
if (pull->params.nstxout != 0)
{
pull->out_x = open_pull_out(opt2fn("-px", nfile, fnm), pull, oenv,
- TRUE, Flags);
+ TRUE, continuationOptions);
}
if (pull->params.nstfout != 0)
{
pull->out_f = open_pull_out(opt2fn("-pf", nfile, fnm), pull, oenv,
- FALSE, Flags);
+ FALSE, continuationOptions);
}
}
extern "C" {
#endif
+struct ContinuationOptions;
struct gmx_mtop_t;
struct gmx_output_env_t;
struct pull_params_t;
* \param oenv Output options.
* \param lambda FEP lambda.
* \param bOutFile Open output files?
- * \param Flags Flags passed over from main, used to determine
- * whether or not we are appending.
+ * \param continuationOptions Options for continuing from checkpoint file
*/
-struct pull_t *init_pull(FILE *fplog,
- const pull_params_t *pull_params,
- const t_inputrec *ir,
- int nfile,
- const t_filenm fnm[],
- const gmx_mtop_t *mtop,
- t_commrec * cr,
- const gmx_output_env_t *oenv,
- real lambda,
- gmx_bool bOutFile,
- unsigned long Flags);
+struct pull_t *init_pull(FILE *fplog,
+ const pull_params_t *pull_params,
+ const t_inputrec *ir,
+ int nfile,
+ const t_filenm fnm[],
+ const gmx_mtop_t *mtop,
+ t_commrec * cr,
+ const gmx_output_env_t *oenv,
+ real lambda,
+ gmx_bool bOutFile,
+ const ContinuationOptions &continuationOptions);
/*! \brief Close the pull output files.
real *mpi_inbuf; /* MPI buffer */
real *mpi_outbuf; /* MPI buffer */
int mpi_bufsize; /* Allocation size of in & outbuf */
- unsigned long Flags; /* mdrun flags */
+ gmx_bool appendFiles; /* If true, append output files */
gmx_bool bOut; /* Used to skip first output when appending to
* avoid duplicate entries in rotation outfiles */
} t_gmx_enfrot;
t_rotgrp *rotg;
- if (rot->enfrot->Flags & MD_APPENDFILES)
+ if (rot->enfrot->appendFiles)
{
fp = gmx_fio_fopen(fn, "a");
}
char *LegendStr = nullptr;
- if (rot->enfrot->Flags & MD_APPENDFILES)
+ if (rot->enfrot->appendFiles)
{
fp = gmx_fio_fopen(fn, "a");
}
char buf[100];
- if (rot->enfrot->Flags & MD_APPENDFILES)
+ if (rot->enfrot->appendFiles)
{
fp = gmx_fio_fopen(fn, "a");
}
t_rotgrp *rotg;
- if (rot->enfrot->Flags & MD_APPENDFILES)
+ if (rot->enfrot->appendFiles)
{
fp = gmx_fio_fopen(fn, "a");
}
extern void init_rot(FILE *fplog, t_inputrec *ir, int nfile, const t_filenm fnm[],
t_commrec *cr, rvec *x, matrix box, gmx_mtop_t *mtop, const gmx_output_env_t *oenv,
- gmx_bool bVerbose, unsigned long Flags)
+ const MdrunOptions &mdrunOptions)
{
t_rot *rot;
t_rotgrp *rotg;
rvec *x_pbc = nullptr; /* Space for the pbc-correct atom positions */
- if (MASTER(cr) && bVerbose)
+ if (MASTER(cr) && mdrunOptions.verbose)
{
fprintf(stdout, "%s Initializing ...\n", RotStr);
}
rot = ir->rot;
snew(rot->enfrot, 1);
- er = rot->enfrot;
- er->Flags = Flags;
+ er = rot->enfrot;
+ er->appendFiles = mdrunOptions.continuationOptions.appendFiles;
/* When appending, skip first output to avoid duplicate entries in the data files */
- if (er->Flags & MD_APPENDFILES)
+ if (er->appendFiles)
{
er->bOut = FALSE;
}
}
/* Output every step for reruns */
- if (er->Flags & MD_RERUN)
+ if (mdrunOptions.rerun)
{
if (nullptr != fplog)
{
erg->nat_loc = rotg->nat;
erg->ind_loc = rotg->ind;
}
- init_rot_group(fplog, cr, g, rotg, x_pbc, mtop, bVerbose, er->out_slabs, box, ir,
- !(er->Flags & MD_APPENDFILES) ); /* Do not output the reference centers
- * again if we are appending */
+ init_rot_group(fplog, cr, g, rotg, x_pbc, mtop, mdrunOptions.verbose, er->out_slabs, box, ir,
+ !er->appendFiles); /* Do not output the reference centers
+ * again if we are appending */
}
}
struct gmx_domdec_t;
struct gmx_mtop_t;
struct gmx_output_env_t;
+struct MdrunOptions;
struct t_commrec;
struct t_filenm;
struct t_inputrec;
* \param box The simulation box.
* \param mtop Molecular topology.
* \param oenv Needed to open the rotation output xvgr file.
- * \param bVerbose Whether to print extra status information.
- * \param Flags Flags passed over from main, used to determine
- * whether or not we are doing a rerun.
+ * \param mdrunOptions Options for mdrun.
*/
extern void init_rot(FILE *fplog, t_inputrec *ir, int nfile, const t_filenm fnm[],
struct t_commrec *cr, rvec *x, matrix box, gmx_mtop_t *mtop, const gmx_output_env_t *oenv,
- gmx_bool bVerbose, unsigned long Flags);
+ const MdrunOptions &mdrunOptions);
/*! \brief Make a selection of the home atoms for all enforced rotation groups.
void init_swapcoords(
FILE *fplog,
- gmx_bool bVerbose,
t_inputrec *ir,
const char *fn,
gmx_mtop_t *mtop,
ObservablesHistory *oh,
t_commrec *cr,
const gmx_output_env_t *oenv,
- unsigned long Flags)
+ const MdrunOptions &mdrunOptions)
{
t_swapcoords *sc;
t_swap *s;
t_swapgrp *g;
swapstateIons_t *gs;
- gmx_bool bAppend, bStartFromCpt, bRerun;
+ gmx_bool bAppend, bStartFromCpt;
matrix boxCopy;
swaphistory_t *swapstate = nullptr;
gmx_fatal(FARGS, "Position swapping is only implemented for domain decomposition!");
}
- bAppend = Flags & MD_APPENDFILES;
- bStartFromCpt = Flags & MD_STARTFROMCPT;
- bRerun = Flags & MD_RERUN;
+ bAppend = mdrunOptions.continuationOptions.appendFiles;
+ bStartFromCpt = mdrunOptions.continuationOptions.startedFromCheckpoint;
sc = ir->swap;
snew(sc->si_priv, 1);
s = sc->si_priv;
- if (bRerun)
+ if (mdrunOptions.rerun)
{
if (PAR(cr))
{
break;
}
+ const gmx_bool bVerbose = mdrunOptions.verbose;
+
// For compatibility with old .tpr files
if (bConvertFromOldTpr(sc) )
{
sc->cyl1r, sc->cyl1u, sc->cyl1l);
fprintf(s->fpout, "#\n");
- if (!bRerun)
+ if (!mdrunOptions.rerun)
{
fprintf(s->fpout, "# Coupling constant (number of swap attempt steps to average over): %d (translates to %f ps).\n",
sc->nAverage, sc->nAverage*sc->nstswap*ir->delta_t);
else
{
fprintf(stderr, "%s Determining initial numbers of ions per compartment.\n", SwS);
- get_initial_ioncounts(ir, x, box, cr, bRerun);
+ get_initial_ioncounts(ir, x, box, cr, mdrunOptions.rerun);
}
/* Prepare (further) checkpoint writes ... */
struct gmx_mtop_t;
struct gmx_output_env_t;
struct gmx_wallcycle;
+struct MdrunOptions;
struct swaphistory_t;
struct t_commrec;
struct t_inputrec;
* the output file, sets up swap data checkpoint writing, etc.
*
* \param[in] fplog General output file, normally md.log.
- * \param[in] bVerbose Should we be quiet or verbose?
* \param[in] ir Structure containing MD input parameters, among those
* also the structure needed for position swapping.
* \param[in] fn Output file name for swap data.
* \param[in] oh Contains struct with swap data that is read from or written to checkpoint.
* \param[in] cr Pointer to MPI communication data.
* \param[in] oenv Needed to open the swap output XVGR file.
- * \param[in] Flags Flags passed over from main, used to determine
- * whether we are doing a rerun, appending, etc.
+ * \param[in] mdrunOptions Options for mdrun.
*/
void init_swapcoords(
FILE *fplog,
- gmx_bool bVerbose,
t_inputrec *ir,
const char *fn,
gmx_mtop_t *mtop,
ObservablesHistory *oh,
t_commrec *cr,
const gmx_output_env_t *oenv,
- unsigned long Flags);
+ const MdrunOptions &mdrunOptions);
/*! \brief Finalizes ion / water position swapping.
#include "gromacs/mdlib/compute_io.h"
#include "gromacs/mdlib/constr.h"
#include "gromacs/mdlib/ebin.h"
+#include "gromacs/mdlib/expanded.h"
#include "gromacs/mdlib/force.h"
#include "gromacs/mdlib/force_flags.h"
#include "gromacs/mdlib/forcerec.h"
/*! \libinternal
\copydoc integrator_t (FILE *fplog, t_commrec *cr, const gmx::MDLogger &mdlog,
int nfile, const t_filenm fnm[],
- const gmx_output_env_t *oenv, gmx_bool bVerbose,
- int nstglobalcomm,
+ const gmx_output_env_t *oenv,
+ const MdrunOptions &mdrunOptions,
gmx_vsite_t *vsite, gmx_constr_t constr,
- int stepout,
gmx::IMDOutputProvider *outputProvider,
t_inputrec *inputrec,
gmx_mtop_t *top_global, t_fcdata *fcd,
t_mdatoms *mdatoms,
t_nrnb *nrnb, gmx_wallcycle_t wcycle,
t_forcerec *fr,
- int repl_ex_nst, int repl_ex_nex, int repl_ex_seed,
- real cpt_period, real max_hours,
- int imdport,
- unsigned long Flags,
+ const ReplicaExchangeParameters &replExParams,
+ gmx_membed_t *membed,
gmx_walltime_accounting_t walltime_accounting)
*/
double gmx::do_md(FILE *fplog, t_commrec *cr, const gmx::MDLogger &mdlog,
int nfile, const t_filenm fnm[],
- const gmx_output_env_t *oenv, gmx_bool bVerbose,
- int nstglobalcomm,
+ const gmx_output_env_t *oenv,
+ const MdrunOptions &mdrunOptions,
gmx_vsite_t *vsite, gmx_constr_t constr,
- int stepout, gmx::IMDOutputProvider *outputProvider,
+ gmx::IMDOutputProvider *outputProvider,
t_inputrec *ir,
gmx_mtop_t *top_global,
t_fcdata *fcd,
t_forcerec *fr,
const ReplicaExchangeParameters &replExParams,
gmx_membed_t *membed,
- real cpt_period, real max_hours,
- int imdport,
- unsigned long Flags,
gmx_walltime_accounting_t walltime_accounting)
{
gmx_mdoutf_t outf = nullptr;
double elapsed_time;
double t, t0, lam0[efptNR];
gmx_bool bGStatEveryStep, bGStat, bCalcVir, bCalcEnerStep, bCalcEner;
- gmx_bool bNS, bNStList, bSimAnn, bStopCM, bRerunMD,
- bFirstStep, startingFromCheckpoint, bInitStep, bLastStep = FALSE,
+ gmx_bool bNS, bNStList, bSimAnn, bStopCM,
+ bFirstStep, bInitStep, bLastStep = FALSE,
bBornRadii, bUsingEnsembleRestraints;
gmx_bool bDoDHDL = FALSE, bDoFEP = FALSE, bDoExpanded = FALSE;
gmx_bool do_ene, do_log, do_verbose, bRerunWarnNoV = TRUE,
// signals, and will use this object to achieve that.
SimulationSignaller nullSignaller(nullptr, nullptr, false, false);
- /* Check for special mdrun options */
- bRerunMD = (Flags & MD_RERUN);
- if (Flags & MD_RESETCOUNTERSHALFWAY)
+ if (mdrunOptions.timingOptions.resetHalfway)
{
if (ir->nsteps > 0)
{
wcycle_set_reset_counters(wcycle, ir->nsteps/2);
}
/* Signal to reset the counters halfway the simulation time. */
- bResetCountersHalfMaxH = (max_hours > 0);
+ bResetCountersHalfMaxH = (mdrunOptions.maximumHoursToRun > 0);
}
/* md-vv uses averaged full step velocities for T-control
md uses averaged half step kinetic energies to determine temperature unless defined otherwise by GMX_EKIN_AVE_VEL; */
bTrotter = (EI_VV(ir->eI) && (inputrecNptTrotter(ir) || inputrecNphTrotter(ir) || inputrecNvtTrotter(ir)));
+ const gmx_bool bRerunMD = mdrunOptions.rerun;
+ int nstglobalcomm = mdrunOptions.globalCommunicationInterval;
+
if (bRerunMD)
{
/* Since we don't know if the frames read are related in any way,
top_global, ir, cr, constr,
as_rvec_array(state_global->x.data()),
state_global->box, observablesHistory,
- oenv, Flags & MD_APPENDFILES);
+ oenv, mdrunOptions.continuationOptions.appendFiles);
}
if (ir->eSwapCoords != eswapNO)
{
/* Initialize ion swapping code */
- init_swapcoords(fplog, bVerbose, ir, opt2fn_master("-swap", nfile, fnm, cr),
- top_global, as_rvec_array(state_global->x.data()), state_global->box, observablesHistory, cr, oenv, Flags);
+ init_swapcoords(fplog, ir, opt2fn_master("-swap", nfile, fnm, cr),
+ top_global, as_rvec_array(state_global->x.data()), state_global->box, observablesHistory, cr, oenv, mdrunOptions);
}
/* Initial values */
- init_md(fplog, cr, outputProvider, ir, oenv, &t, &t0, state_global->lambda,
+ init_md(fplog, cr, outputProvider, ir, oenv, mdrunOptions,
+ &t, &t0, state_global->lambda,
&(state_global->fep_state), lam0,
nrnb, top_global, &upd,
nfile, fnm, &outf, &mdebin,
- force_vir, shake_vir, mu_tot, &bSimAnn, &vcm, Flags, wcycle);
+ force_vir, shake_vir, mu_tot, &bSimAnn, &vcm, wcycle);
clear_mat(total_vir);
clear_mat(pres);
/* Set up interactive MD (IMD) */
init_IMD(ir, cr, top_global, fplog, ir->nstcalcenergy, as_rvec_array(state_global->x.data()),
- nfile, fnm, oenv, imdport, Flags);
+ nfile, fnm, oenv, mdrunOptions);
if (DOMAINDECOMP(cr))
{
update_mdatoms(mdatoms, state->lambda[efptMASS]);
- startingFromCheckpoint = Flags & MD_STARTFROMCPT;
+ const ContinuationOptions &continuationOptions = mdrunOptions.continuationOptions;
+ bool startingFromCheckpoint = continuationOptions.startedFromCheckpoint;
if (ir->bExpanded)
{
if (startingFromCheckpoint)
{
/* Update mdebin with energy history if appending to output files */
- if (Flags & MD_APPENDFILES)
+ if (continuationOptions.appendFiles)
{
restore_energyhistory_from_state(mdebin, observablesHistory->energyHistory.get());
}
/* PME tuning is only supported in the Verlet scheme, with PME for
* Coulomb. It is not supported with only LJ PME, or for
* reruns. */
- bPMETune = ((Flags & MD_TUNEPME) && EEL_PME(fr->eeltype) && !bRerunMD &&
- !(Flags & MD_REPRODUCIBLE) && ir->cutoff_scheme != ecutsGROUP);
+ bPMETune = (mdrunOptions.tunePme && EEL_PME(fr->eeltype) && !bRerunMD &&
+ !mdrunOptions.reproducible && ir->cutoff_scheme != ecutsGROUP);
if (bPMETune)
{
pme_loadbal_init(&pme_loadbal, cr, mdlog, ir, state->box,
*/
bStopCM = (ir->comm_mode != ecmNO && !ir->bContinuation);
- if (Flags & MD_READ_EKIN)
+ if (continuationOptions.haveReadEkin)
{
restore_ekinstate_from_state(cr, ekind, &state_global->ekinstate);
}
| (bStopCM ? CGLO_STOPCM : 0)
| (EI_VV(ir->eI) ? CGLO_PRESSURE : 0)
| (EI_VV(ir->eI) ? CGLO_CONSTRAINT : 0)
- | ((Flags & MD_READ_EKIN) ? CGLO_READEKIN : 0));
+ | (continuationOptions.haveReadEkin ? CGLO_READEKIN : 0));
bSumEkinhOld = FALSE;
compute_globals(fplog, gstat, cr, ir, fr, ekind, state, mdatoms, nrnb, vcm,
}
/* Calculate the initial half step temperature, and save the ekinh_old */
- if (!(Flags & MD_STARTFROMCPT))
+ if (!continuationOptions.startedFromCheckpoint)
{
for (i = 0; (i < ir->opts.ngtc); i++)
{
fprintf(stderr, "starting md rerun '%s', reading coordinates from"
" input trajectory '%s'\n\n",
*(top_global->name), opt2fn("-rerun", nfile, fnm));
- if (bVerbose)
+ if (mdrunOptions.verbose)
{
fprintf(stderr, "Calculated time to finish depends on nsteps from "
"run input file,\nwhich may not correspond to the time "
}
}
- /* loop over MD steps or if rerunMD to end of input trajectory */
- bFirstStep = TRUE;
+ /* Loop over MD steps or if rerunMD to end of input trajectory,
+ * or, if max_hours>0, until max_hours is reached.
+ */
+ real max_hours = mdrunOptions.maximumHoursToRun;
+ bFirstStep = TRUE;
/* Skip the first Nose-Hoover integration when we get the state from tpx */
bInitStep = !startingFromCheckpoint || EI_VV(ir->eI);
bSumEkinhOld = FALSE;
{
/* PME grid + cut-off optimization with GPUs or PME nodes */
pme_loadbal_do(pme_loadbal, cr,
- (bVerbose && MASTER(cr)) ? stderr : nullptr,
+ (mdrunOptions.verbose && MASTER(cr)) ? stderr : nullptr,
fplog, mdlog,
ir, fr, state,
wcycle,
copy_mat(rerun_fr.box, state_global->box);
copy_mat(state_global->box, state->box);
- if (vsite && (Flags & MD_RERUN_VSITE))
+ if (vsite && mdrunOptions.rerunConstructVsites)
{
if (DOMAINDECOMP(cr))
{
* beyond the last step. But we don't consider that to be an issue.
*/
do_log = do_per_step(step, ir->nstlog) || (bFirstStep && !startingFromCheckpoint) || bLastStep || bRerunMD;
- do_verbose = bVerbose &&
- (step % stepout == 0 || bFirstStep || bLastStep || bRerunMD);
+ do_verbose = mdrunOptions.verbose &&
+ (step % mdrunOptions.verboseStepPrintInterval == 0 || bFirstStep || bLastStep || bRerunMD);
if (bNS && !(bFirstStep && ir->bContinuation && !bRerunMD))
{
* but never at the first step or with rerun.
*/
bCPT = (((signals[eglsCHKPT].set && (bNS || ir->nstlist == 0)) ||
- (bLastStep && (Flags & MD_CONFOUT))) &&
+ (bLastStep && mdrunOptions.writeConfout)) &&
step > ir->init_step && !bRerunMD);
if (bCPT)
{
if (shellfc)
{
/* Now is the time to relax the shells */
- relax_shell_flexcon(fplog, cr, bVerbose, step,
+ relax_shell_flexcon(fplog, cr, mdrunOptions.verbose, step,
ir, bNS, force_flags, top,
constr, enerd, fcd,
state, &f, force_vir, mdatoms,
top_global, fr,
outf, mdebin, ekind, &f,
&nchkpt,
- bCPT, bRerunMD, bLastStep, (Flags & MD_CONFOUT),
+ bCPT, bRerunMD, bLastStep,
+ mdrunOptions.writeConfout,
bSumEkinhOld);
/* Check if IMD step and do IMD communication, if bIMD is TRUE. */
bIMDstep = do_IMD(ir->bIMD, step, cr, bNS, state->box, as_rvec_array(state->x.data()), ir, t, wcycle);
* where we do global communication,
* otherwise the other nodes don't know.
*/
+ const real cpt_period = mdrunOptions.checkpointOptions.period;
if (MASTER(cr) && ((bGStat || !PAR(cr)) &&
cpt_period >= 0 &&
(cpt_period == 0 ||
bNeedRepartition = do_swapcoords(cr, step, t, ir, wcycle,
bRerunMD ? rerun_fr.x : as_rvec_array(state->x.data()),
bRerunMD ? rerun_fr.box : state->box,
- MASTER(cr) && bVerbose, bRerunMD);
+ MASTER(cr) && mdrunOptions.verbose,
+ bRerunMD);
if (bNeedRepartition && DOMAINDECOMP(cr))
{
bFirstStep = FALSE;
bInitStep = FALSE;
- startingFromCheckpoint = FALSE;
+ startingFromCheckpoint = false;
/* ####### SET VARIABLES FOR NEXT ITERATION IF THEY STILL NEED IT ###### */
/* With all integrators, except VV, we need to retain the pressure
"When [TT]mdrun[tt] is started with MPI, it does not run niced by default."
};
- /* Command line option parameters, with their default values */
- gmx_bool bTunePME = TRUE;
- gmx_bool bRerunVSite = FALSE;
- gmx_bool bConfout = TRUE;
- gmx_bool bReproducible = FALSE;
- gmx_bool bIMDwait = FALSE;
- gmx_bool bIMDterm = FALSE;
- gmx_bool bIMDpull = FALSE;
-
/* Command line options */
rvec realddxyz = {0, 0, 0};
const char *ddrank_opt_choices[static_cast<int>(DdRankOrder::nr)+1] =
const char *nbpu_opt_choices[] =
{ nullptr, "auto", "cpu", "gpu", "gpu_cpu", nullptr };
gmx_bool bTryToAppendFiles = TRUE;
- gmx_bool bKeepAndNumCPT = FALSE;
- gmx_bool bResetCountersHalfWay = FALSE;
const char *gpuIdTaskAssignment = "";
+ ImdOptions &imdOptions = mdrunOptions.imdOptions;
+
t_pargs pa[] = {
{ "-dd", FALSE, etRVEC, {&realddxyz},
"HIDDENA string containing a vector of the relative sizes in the z "
"direction of the corresponding DD cells. Only effective with static "
"load balancing." },
- { "-gcom", FALSE, etINT, {&nstglobalcomm},
+ { "-gcom", FALSE, etINT, {&mdrunOptions.globalCommunicationInterval},
"Global communication frequency" },
{ "-nb", FALSE, etENUM, {nbpu_opt_choices},
"Calculate non-bonded interactions on" },
{ "-nstlist", FALSE, etINT, {&nstlist_cmdline},
"Set nstlist when using a Verlet buffer tolerance (0 is guess)" },
- { "-tunepme", FALSE, etBOOL, {&bTunePME},
+ { "-tunepme", FALSE, etBOOL, {&mdrunOptions.tunePme},
"Optimize PME load between PP/PME ranks or GPU/CPU (only with the Verlet cut-off scheme)" },
- { "-v", FALSE, etBOOL, {&bVerbose},
+ { "-v", FALSE, etBOOL, {&mdrunOptions.verbose},
"Be loud and noisy" },
{ "-pforce", FALSE, etREAL, {&pforce},
"Print all forces larger than this (kJ/mol nm)" },
- { "-reprod", FALSE, etBOOL, {&bReproducible},
+ { "-reprod", FALSE, etBOOL, {&mdrunOptions.reproducible},
"Try to avoid optimizations that affect binary reproducibility" },
- { "-cpt", FALSE, etREAL, {&cpt_period},
+ { "-cpt", FALSE, etREAL, {&mdrunOptions.checkpointOptions.period},
"Checkpoint interval (minutes)" },
- { "-cpnum", FALSE, etBOOL, {&bKeepAndNumCPT},
+ { "-cpnum", FALSE, etBOOL, {&mdrunOptions.checkpointOptions.keepAndNumberCheckpointFiles},
"Keep and number checkpoint files" },
{ "-append", FALSE, etBOOL, {&bTryToAppendFiles},
"Append to previous output files when continuing from checkpoint instead of adding the simulation part number to all file names" },
- { "-nsteps", FALSE, etINT64, {&nsteps_cmdline},
+ { "-nsteps", FALSE, etINT64, {&mdrunOptions.numStepsCommandline},
"Run this number of steps, overrides .mdp file option (-1 means infinite, -2 means use mdp option, smaller is invalid)" },
- { "-maxh", FALSE, etREAL, {&max_hours},
+ { "-maxh", FALSE, etREAL, {&mdrunOptions.maximumHoursToRun},
"Terminate after 0.99 times this time (hours)" },
{ "-multi", FALSE, etINT, {&nmultisim},
"Do multiple simulations in parallel" },
"Number of random exchanges to carry out each exchange interval (N^3 is one suggestion). -nex zero or not specified gives neighbor replica exchange." },
{ "-reseed", FALSE, etINT, {&replExParams.randomSeed},
"Seed for replica exchange, -1 is generate a seed" },
- { "-imdport", FALSE, etINT, {&imdport},
+ { "-imdport", FALSE, etINT, {&imdOptions.port},
"HIDDENIMD listening port" },
- { "-imdwait", FALSE, etBOOL, {&bIMDwait},
+ { "-imdwait", FALSE, etBOOL, {&imdOptions.wait},
"HIDDENPause the simulation while no IMD client is connected" },
- { "-imdterm", FALSE, etBOOL, {&bIMDterm},
+ { "-imdterm", FALSE, etBOOL, {&imdOptions.terminatable},
"HIDDENAllow termination of the simulation from IMD client" },
- { "-imdpull", FALSE, etBOOL, {&bIMDpull},
+ { "-imdpull", FALSE, etBOOL, {&imdOptions.pull},
"HIDDENAllow pulling in the simulation from IMD client" },
- { "-rerunvsite", FALSE, etBOOL, {&bRerunVSite},
+ { "-rerunvsite", FALSE, etBOOL, {&mdrunOptions.rerunConstructVsites},
"HIDDENRecalculate virtual site coordinates with [TT]-rerun[tt]" },
- { "-confout", FALSE, etBOOL, {&bConfout},
+ { "-confout", FALSE, etBOOL, {&mdrunOptions.writeConfout},
"HIDDENWrite the last configuration with [TT]-c[tt] and force checkpointing at the last step" },
- { "-stepout", FALSE, etINT, {&nstepout},
+ { "-stepout", FALSE, etINT, {&mdrunOptions.verboseStepPrintInterval},
"HIDDENFrequency of writing the remaining wall clock time for the run" },
- { "-resetstep", FALSE, etINT, {&resetstep},
+ { "-resetstep", FALSE, etINT, {&mdrunOptions.timingOptions.resetStep},
"HIDDENReset cycle counters after these many time steps" },
- { "-resethway", FALSE, etBOOL, {&bResetCountersHalfWay},
+ { "-resethway", FALSE, etBOOL, {&mdrunOptions.timingOptions.resetHalfway},
"HIDDENReset the cycle counters after half the number of steps or halfway [TT]-maxh[tt]" }
};
- gmx_bool bDoAppendFiles, bStartFromCpt;
int rc;
char **multidir = nullptr;
}
}
- handleRestart(cr, bTryToAppendFiles, nfile, fnm, &bDoAppendFiles, &bStartFromCpt);
-
- Flags = opt2bSet("-rerun", nfile, fnm) ? MD_RERUN : 0;
- Flags = Flags | (bTunePME ? MD_TUNEPME : 0);
- Flags = Flags | (bConfout ? MD_CONFOUT : 0);
- Flags = Flags | (bRerunVSite ? MD_RERUN_VSITE : 0);
- Flags = Flags | (bReproducible ? MD_REPRODUCIBLE : 0);
- Flags = Flags | (bDoAppendFiles ? MD_APPENDFILES : 0);
- Flags = Flags | (opt2parg_bSet("-append", asize(pa), pa) ? MD_APPENDFILESSET : 0);
- Flags = Flags | (bKeepAndNumCPT ? MD_KEEPANDNUMCPT : 0);
- Flags = Flags | (bStartFromCpt ? MD_STARTFROMCPT : 0);
- Flags = Flags | (bResetCountersHalfWay ? MD_RESETCOUNTERSHALFWAY : 0);
- Flags = Flags | (opt2parg_bSet("-ntomp", asize(pa), pa) ? MD_NTOMPSET : 0);
- Flags = Flags | (bIMDwait ? MD_IMDWAIT : 0);
- Flags = Flags | (bIMDterm ? MD_IMDTERM : 0);
- Flags = Flags | (bIMDpull ? MD_IMDPULL : 0);
+ ContinuationOptions &continuationOptions = mdrunOptions.continuationOptions;
+
+ continuationOptions.appendFilesOptionSet = opt2parg_bSet("-append", asize(pa), pa);
+
+ handleRestart(cr, bTryToAppendFiles, nfile, fnm, &continuationOptions.appendFiles, &continuationOptions.startedFromCheckpoint);
+
+ mdrunOptions.rerun = opt2bSet("-rerun", nfile, fnm);
+ mdrunOptions.ntompOptionIsSet = opt2parg_bSet("-ntomp", asize(pa), pa);
/* We postpone opening the log file if we are appending, so we can
first truncate the old log file and append to the correct position
there instead. */
- if (MASTER(cr) && !bDoAppendFiles)
+ if (MASTER(cr) && !continuationOptions.appendFiles)
{
gmx_log_open(ftp2fn(efLOG, nfile, fnm), cr,
- Flags & MD_APPENDFILES, &fplog);
+ continuationOptions.appendFiles, &fplog);
}
else
{
/* Log file has to be closed in mdrunner if we are appending to it
(fplog not set here) */
- if (MASTER(cr) && !bDoAppendFiles)
+ if (MASTER(cr) && !continuationOptions.appendFiles)
{
gmx_log_close(fplog);
}
t_inputrec *inputrec = &inputrecInstance;
snew(mtop, 1);
- if (Flags & MD_APPENDFILES)
+ if (mdrunOptions.continuationOptions.appendFiles)
{
fplog = nullptr;
}
bool doMembed = opt2bSet("-membed", nfile, fnm);
- bool doRerun = (Flags & MD_RERUN);
+ bool doRerun = mdrunOptions.rerun;
/* Handle GPU-related user options. Later, we check consistency
* with things like whether support is compiled, or tMPI thread
tMPI_Thread_mutex_unlock(&deform_init_box_mutex);
}
- ObservablesHistory observablesHistory = {};
+ ObservablesHistory observablesHistory = {};
- if (Flags & MD_STARTFROMCPT)
+ ContinuationOptions &continuationOptions = mdrunOptions.continuationOptions;
+
+ if (continuationOptions.startedFromCheckpoint)
{
/* Check if checkpoint file exists before doing continuation.
* This way we can use identical input options for the first and subsequent runs...
load_checkpoint(opt2fn_master("-cpi", nfile, fnm, cr), &fplog,
cr, domdecOptions.numCells,
inputrec, state, &bReadEkin, &observablesHistory,
- (Flags & MD_APPENDFILES),
- (Flags & MD_APPENDFILESSET),
- (Flags & MD_REPRODUCIBLE));
+ continuationOptions.appendFiles,
+ continuationOptions.appendFilesOptionSet,
+ mdrunOptions.reproducible);
if (bReadEkin)
{
- Flags |= MD_READ_EKIN;
+ continuationOptions.haveReadEkin = true;
}
}
- if (SIMMASTER(cr) && (Flags & MD_APPENDFILES))
+ if (SIMMASTER(cr) && continuationOptions.appendFiles)
{
gmx_log_open(ftp2fn(efLOG, nfile, fnm), cr,
- Flags, &fplog);
+ continuationOptions.appendFiles, &fplog);
logOwner = buildLogger(fplog, nullptr);
mdlog = logOwner.logger();
}
- /* override nsteps with value from cmdline */
- override_nsteps_cmdline(mdlog, nsteps_cmdline, inputrec);
+ /* override nsteps with value set on the commamdline */
+ override_nsteps_cmdline(mdlog, mdrunOptions.numStepsCommandline, inputrec);
if (SIMMASTER(cr))
{
if (PAR(cr) && !(EI_TPI(inputrec->eI) ||
inputrec->eI == eiNM))
{
- cr->dd = init_domain_decomposition(fplog, cr, domdecOptions, Flags,
+ cr->dd = init_domain_decomposition(fplog, cr, domdecOptions, mdrunOptions,
mtop, inputrec,
box, as_rvec_array(state->x.data()),
&ddbox, &npme_major, &npme_minor);
#endif
/* Now that we know the setup is consistent, check for efficiency */
- check_resource_division_efficiency(hwinfo, hw_opt.nthreads_tot, !gpuTaskAssignment.empty(), Flags & MD_NTOMPSET,
+ check_resource_division_efficiency(hwinfo, hw_opt.nthreads_tot, !gpuTaskAssignment.empty(), mdrunOptions.ntompOptionIsSet,
cr, mdlog);
gmx_device_info_t *shortRangedDeviceInfo = nullptr;
*/
nthreads_pme = gmx_omp_nthreads_get(emntPME);
- wcycle = wallcycle_init(fplog, resetstep, cr);
+ wcycle = wallcycle_init(fplog, mdrunOptions.timingOptions.resetStep, cr);
if (PAR(cr))
{
/* Note that membed cannot work in parallel because mtop is
* changed here. Fix this if we ever want to make it run with
* multiple ranks. */
- membed = init_membed(fplog, nfile, fnm, mtop, inputrec, state, cr, &cpt_period);
+ membed = init_membed(fplog, nfile, fnm, mtop, inputrec, state, cr, &mdrunOptions.checkpointOptions.period);
}
snew(nrnb, 1);
{
status = gmx_pme_init(pmedata, cr, npme_major, npme_minor, inputrec,
mtop ? mtop->natoms : 0, nChargePerturbed, nTypePerturbed,
- (Flags & MD_REPRODUCIBLE),
+ mdrunOptions.reproducible,
ewaldcoeff_q, ewaldcoeff_lj,
nthreads_pme);
}
inputrec->pull_work =
init_pull(fplog, inputrec->pull, inputrec, nfile, fnm,
mtop, cr, oenv, inputrec->fepvals->init_lambda,
- EI_DYNAMICS(inputrec->eI) && MASTER(cr), Flags);
+ EI_DYNAMICS(inputrec->eI) && MASTER(cr),
+ continuationOptions);
}
if (inputrec->bRot)
{
/* Initialize enforced rotation code */
init_rot(fplog, inputrec, nfile, fnm, cr, as_rvec_array(state->x.data()), state->box, mtop, oenv,
- bVerbose, Flags);
+ mdrunOptions);
}
/* Let init_constraints know whether we have essential dynamics constraints.
/* Now do whatever the user wants us to do (how flexible...) */
my_integrator(inputrec->eI) (fplog, cr, mdlog, nfile, fnm,
- oenv, bVerbose,
- nstglobalcomm,
+ oenv,
+ mdrunOptions,
vsite, constr,
- nstepout, mdModules.outputProvider(),
+ mdModules.outputProvider(),
inputrec, mtop,
fcd, state, &observablesHistory,
mdatoms, nrnb, wcycle, fr,
replExParams,
membed,
- cpt_period, max_hours,
- imdport,
- Flags,
walltime_accounting);
if (inputrec->bRot)
walltime_accounting_destroy(walltime_accounting);
/* Close logfile already here if we were appending to it */
- if (MASTER(cr) && (Flags & MD_APPENDFILES))
+ if (MASTER(cr) && continuationOptions.appendFiles)
{
gmx_log_close(fplog);
}
#include "gromacs/domdec/domdec.h"
#include "gromacs/hardware/hw_info.h"
#include "gromacs/math/vec.h"
+#include "gromacs/mdlib/mdrun.h"
#include "gromacs/utility/basedefinitions.h"
#include "gromacs/utility/real.h"
int nfile = filenames.size();
//! Output context for writing text files
gmx_output_env_t *oenv = nullptr;
- //! TRUE if mdrun should be verbose.
- gmx_bool bVerbose = FALSE;
- //! Number of steps between global communication.
- int nstglobalcomm = -1;
+ //! Ongoing collection of mdrun options
+ MdrunOptions mdrunOptions;
//! Options for the domain decomposition.
DomdecOptions domdecOptions;
//! Target short-range interations for "cpu", "gpu", "gpu_cpu", or "auto". Default is "auto".
const char *nbpu_opt = nullptr;
//! Command-line override for the duration of a neighbor list with the Verlet scheme.
int nstlist_cmdline = 0;
- //! Command-line override for the number of MD steps (-2 means that the mdp option will be used).
- gmx_int64_t nsteps_cmdline = -2;
- //! Number of steps between output to the console of time remaining.
- int nstepout = 100;
- //! Number of steps that elapse before cycle counters are reset.
- int resetstep = -1;
//! Number of simulations in multi-simulation set.
int nmultisim = 0;
//! Parameters for replica-exchange simulations.
ReplicaExchangeParameters replExParams;
//! Print a warning if any force is larger than this (in kJ/mol nm).
real pforce = -1;
- //! Period (in wall-clock minutes) between writing checkpoint files.
- real cpt_period = 15.0;
- //! Maximum duration of this simulation (in wall-clock hours).
- real max_hours = -1;
- //! Socket number used for IMD inter-process communication.
- int imdport = 8888;
- //! Bitfield of boolean flags configuring mdrun behavior.
- unsigned long Flags = 0;
//! Handle to file used for logging.
FILE *fplog;
//! Handle to communication data structure.