b4f85cfeac94ac3b2125b470facbad48fac53512
[alexxy/gromacs.git] / src / gromacs / mdlib / mdrun.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5  * Copyright (c) 2001-2004, The GROMACS development team.
6  * Copyright (c) 2013,2014,2015,2017,2018, by the GROMACS development team, led by
7  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
8  * and including many others, as listed in the AUTHORS file in the
9  * top-level source directory and at http://www.gromacs.org.
10  *
11  * GROMACS is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public License
13  * as published by the Free Software Foundation; either version 2.1
14  * of the License, or (at your option) any later version.
15  *
16  * GROMACS is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with GROMACS; if not, see
23  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
25  *
26  * If you want to redistribute modifications to GROMACS, please
27  * consider that scientific software is very special. Version
28  * control is crucial - bugs must be traceable. We will be happy to
29  * consider code for inclusion in the official distribution, but
30  * derived work must not be called official GROMACS. Details are found
31  * in the README & COPYING files - if they are missing, get the
32  * official version at http://www.gromacs.org.
33  *
34  * To help us fund GROMACS development, we humbly ask that you cite
35  * the research papers on the package. Check out http://www.gromacs.org.
36  */
37
38 /*! \libinternal \file
39  *
40  * \brief This file declares types and functions for initializing an MD run
41  *
42  * \author Berk Hess <hess@kth.se>
43  * \inlibraryapi
44  */
45
46 #ifndef GMX_MDLIB_MDRUN_H
47 #define GMX_MDLIB_MDRUN_H
48
49 #include "gromacs/timing/wallcycle.h"
50 #include "gromacs/utility/real.h"
51
52 struct gmx_mtop_t;
53 struct t_commrec;
54 struct t_inputrec;
55 class t_state;
56
57 //! \internal \brief Options and settings for continuing from checkpoint
58 struct ContinuationOptions
59 {
60     //! True if we are continuing from a checkpoint and should append output files
61     bool appendFiles = false;
62     //! True if the -append option was explicitly set by the user (either to true of false
63     bool appendFilesOptionSet = false;
64     //! True if we started from a checkpoint file
65     bool startedFromCheckpoint = false;
66     //! True if we read the kinetic energy from checkpoint file
67     bool haveReadEkin = false;
68 };
69
70 //! \internal \brief Options for writing checkpoint files
71 struct CheckpointOptions
72 {
73     //! True means keep all checkpoint file and add the step number to the name
74     gmx_bool keepAndNumberCheckpointFiles = FALSE;
75     //! The period in minutes for writing checkpoint files
76     real     period = 15;
77 };
78
79 //! \internal \brief Options for timing (parts of) mdrun
80 struct TimingOptions
81 {
82     //! Reset timers at the start of this MD step, -1 means do not reset
83     int      resetStep = -1;
84     //! If true, reset timers half-way the run
85     gmx_bool resetHalfway = FALSE;
86 };
87
88 //! \internal \brief Options for IMD
89 struct ImdOptions
90 {
91     //! IMD listening port
92     int      port = 8888;
93     //! If true, pause the simulation while no IMD client is connected
94     gmx_bool wait = FALSE;
95     //! If true, allow termination of the simulation from IMD client
96     gmx_bool terminatable = FALSE;
97     //! If true, allow COM pulling in the simulation from IMD client
98     gmx_bool pull = FALSE;
99 };
100
101 //! \internal \brief Collection of all options of mdrun that are not processed separately
102 struct MdrunOptions
103 {
104     //! Re-compute energies, and possibly forces, for frames from an input tracjectory
105     gmx_bool            rerun = FALSE;
106     //! Re-construct virual sites durin a rerun simulation
107     gmx_bool            rerunConstructVsites = FALSE;
108     //! Request to do global communication at this interval in steps, -1 is determine from inputrec (deprecated).
109     int                 globalCommunicationInterval = -1;
110     //! Try to make the simulation binary reproducible
111     gmx_bool            reproducible = FALSE;
112     //! Write confout.gro at the end of the run
113     gmx_bool            writeConfout = TRUE;
114     //! Options for continuing a simulation from a checkpoint file
115     ContinuationOptions continuationOptions;
116     //! Options for checkpointing th simulation
117     CheckpointOptions   checkpointOptions;
118     //! Number of steps to run, -2 is use inputrec, -1 is infinite
119     int64_t             numStepsCommandline = -2;
120     //! Maximum duration of this simulation in wall-clock hours, -1 is no limit
121     real                maximumHoursToRun = -1;
122     //! Options for timing the run
123     TimingOptions       timingOptions;
124     //! If true and supported, will tune the PP-PME load balance
125     gmx_bool            tunePme = TRUE;
126     //! True if the user explicitly set the -ntomp command line option
127     gmx_bool            ntompOptionIsSet = FALSE;
128     //! Options for IMD
129     ImdOptions          imdOptions;
130     //! Increase the verbosity level in the logging and/or stdout/stderr
131     gmx_bool            verbose = FALSE;
132     //! If verbose=true, print remaining runtime at this step interval
133     int                 verboseStepPrintInterval = 100;
134 };
135
136 //! \brief Allocate and initialize node-local state entries
137 void set_state_entries(t_state *state, const t_inputrec *ir);
138
139 //! \brief Broadcast inputrec and mtop and allocate node-specific settings
140 void init_parallel(t_commrec *cr, t_inputrec *inputrec,
141                    gmx_mtop_t *mtop);
142
143 //! \brief Broadcasts the, non-dynamic, state from the master to all ranks in cr->mpi_comm_mygroup
144 //
145 // This is intended to be used with MPI parallelization without
146 // domain decompostion (currently with NM and TPI).
147 void broadcastStateWithoutDynamics(const t_commrec *cr, t_state *state);
148
149 #endif