Remove gmx custom fixed int (e.g. gmx_int64_t) types
[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
51 struct gmx_mtop_t;
52 struct t_commrec;
53 struct t_inputrec;
54 class t_state;
55
56 //! \internal \brief Options and settings for continuing from checkpoint
57 struct ContinuationOptions
58 {
59     //! \brief Constructor
60     ContinuationOptions() :
61         appendFiles(false),
62         appendFilesOptionSet(false),
63         startedFromCheckpoint(false),
64         haveReadEkin(false)
65     {
66     }
67
68     //! True if we are continuing from a checkpoint and should append output files
69     bool appendFiles;
70     //! True if the -append option was explicitly set by the user (either to true of false
71     bool appendFilesOptionSet;
72     //! True if we started from a checkpoint file
73     bool startedFromCheckpoint;
74     //! True if we read the kinetic energy from checkpoint file
75     bool haveReadEkin;
76 };
77
78 //! \internal \brief Options for writing checkpoint files
79 struct CheckpointOptions
80 {
81     //! \brief Constructor
82     CheckpointOptions() :
83         keepAndNumberCheckpointFiles(FALSE),
84         period(15)
85     {
86     }
87
88     //! True means keep all checkpoint file and add the step number to the name
89     gmx_bool keepAndNumberCheckpointFiles;
90     //! The period in minutes for writing checkpoint files
91     real     period;
92 };
93
94 //! \internal \brief Options for timing (parts of) mdrun
95 struct TimingOptions
96 {
97     //! \brief Constructor
98     TimingOptions() :
99         resetStep(-1),
100         resetHalfway(FALSE)
101     {
102     }
103
104     //! Reset timers at the start of this MD step, -1 means do not reset
105     int      resetStep;
106     //! If true, reset timers half-way the run
107     gmx_bool resetHalfway;
108 };
109
110 //! \internal \brief Options for IMD
111 struct ImdOptions
112 {
113     //! Constructor
114     ImdOptions() :
115         port(8888),
116         wait(FALSE),
117         terminatable(FALSE),
118         pull(FALSE)
119     {
120     }
121
122     //! IMD listening port
123     int      port;
124     //! If true, pause the simulation while no IMD client is connected
125     gmx_bool wait;
126     //! If true, allow termination of the simulation from IMD client
127     gmx_bool terminatable;
128     //! If true, allow COM pulling in the simulation from IMD client
129     gmx_bool pull;
130 };
131
132 //! \internal \brief Collection of all options of mdrun that are not processed separately
133 struct MdrunOptions
134 {
135     //! \brief Constructor
136     MdrunOptions() :
137         rerun(FALSE),
138         rerunConstructVsites(FALSE),
139         globalCommunicationInterval(-1),
140         reproducible(FALSE),
141         writeConfout(TRUE),
142         continuationOptions(),
143         checkpointOptions(),
144         numStepsCommandline(-2),
145         maximumHoursToRun(-1),
146         timingOptions(),
147         tunePme(TRUE),
148         ntompOptionIsSet(FALSE),
149         imdOptions(),
150         verbose(FALSE),
151         verboseStepPrintInterval(100)
152     {
153     }
154
155     //! Re-compute energies, and possibly forces, for frames from an input tracjectory
156     gmx_bool            rerun;
157     //! Re-construct virual sites durin a rerun simulation
158     gmx_bool            rerunConstructVsites;
159     //! Request to do global communication at this interval in steps, -1 is determine from inputrec
160     int                 globalCommunicationInterval;
161     //! Try to make the simulation binary reproducible
162     gmx_bool            reproducible;
163     //! Write confout.gro at the end of the run
164     gmx_bool            writeConfout;
165     //! Options for continuing a simulation from a checkpoint file
166     ContinuationOptions continuationOptions;
167     //! Options for checkpointing th simulation
168     CheckpointOptions   checkpointOptions;
169     //! Number of steps to run, -2 is use inputrec, -1 is infinite
170     int64_t             numStepsCommandline;
171     //! Maximum duration of this simulation in wall-clock hours, -1 is no limit
172     real                maximumHoursToRun;
173     //! Options for timing the run
174     TimingOptions       timingOptions;
175     //! If true and supported, will tune the PP-PME load balance
176     gmx_bool            tunePme;
177     //! True if the user explicitly set the -ntomp command line option
178     gmx_bool            ntompOptionIsSet;
179     //! Options for IMD
180     ImdOptions          imdOptions;
181     //! Increase the verbosity level in the logging and/or stdout/stderr
182     gmx_bool            verbose;
183     //! If verbose=true, print remaining runtime at this step interval
184     int                 verboseStepPrintInterval;
185 };
186
187 //! \brief Allocate and initialize node-local state entries
188 void set_state_entries(t_state *state, const t_inputrec *ir);
189
190 //! \brief Broadcast inputrec and mtop and allocate node-specific settings
191 void init_parallel(t_commrec *cr, t_inputrec *inputrec,
192                    gmx_mtop_t *mtop);
193
194 //! \brief Broadcasts the, non-dynamic, state from the master to all ranks in cr->mpi_comm_mygroup
195 //
196 // This is intended to be used with MPI parallelization without
197 // domain decompostion (currently with NM and TPI).
198 void broadcastStateWithoutDynamics(const t_commrec *cr, t_state *state);
199
200 #endif