Clean up gmxfio includes
[alexxy/gromacs.git] / src / gromacs / legacyheaders / checkpoint.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, 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 #ifndef _checkpoint_h
39 #define _checkpoint_h
40
41 #include "gromacs/fileio/filenm.h"
42 #include "gromacs/legacyheaders/typedefs.h"
43
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47
48 struct gmx_file_position_t;
49 struct t_fileio;
50
51 /* the name of the environment variable to disable fsync failure checks with */
52 #define GMX_IGNORE_FSYNC_FAILURE_ENV "GMX_IGNORE_FSYNC_FAILURE"
53
54 /* Write a checkpoint to <fn>.cpt
55  * Appends the _step<step>.cpt with bNumberAndKeep,
56  * otherwise moves the previous <fn>.cpt to <fn>_prev.cpt
57  */
58 void write_checkpoint(const char *fn, gmx_bool bNumberAndKeep,
59                       FILE *fplog, t_commrec *cr,
60                       int eIntegrator, int simulation_part,
61                       gmx_bool bExpanded, int elamstats,
62                       gmx_int64_t step, double t,
63                       t_state *state);
64
65 /* Loads a checkpoint from fn for run continuation.
66  * Generates a fatal error on system size mismatch.
67  * The master node reads the file
68  * and communicates all the modified number of steps and the parallel setup,
69  * but not the state itself.
70  * When bAppend is set, lock the log file and truncate the existing output
71  * files so they can be appended.
72  * With bAppend and bForceAppend: truncate anyhow if the system does not
73  * support file locking.
74  */
75 void load_checkpoint(const char *fn, FILE **fplog,
76                      t_commrec *cr, ivec dd_nc,
77                      t_inputrec *ir, t_state *state,
78                      gmx_bool *bReadEkin,
79                      gmx_bool bAppend, gmx_bool bForceAppend);
80
81 /* Read the state from checkpoint file.
82  * Arrays in state that are NULL are allocated.
83  * If bReadRNG=TRUE a RNG state compatible with the current
84  * number of nodes was read.
85  */
86 void read_checkpoint_state(const char *fn, int *simulation_part,
87                            gmx_int64_t *step, double *t, t_state *state);
88
89 /* Read everything that can be stored in t_trxframe from a checkpoint file */
90 void read_checkpoint_trxframe(struct t_fileio *fp, t_trxframe *fr);
91
92 /* Print the complete contents of checkpoint file fn to out */
93 void list_checkpoint(const char *fn, FILE *out);
94
95 /* ! \brief Read simulation step and part from a checkpoint file
96  *
97  * Used by tune_pme to handle tuning with a checkpoint file as part of the input.
98  *
99  * \param[in]  filename         Name of checkpoint file
100  * \param[out] simulation_part  The part of the simulation that wrote the checkpoint
101  * \param[out] step             The final step number of the simulation that wrote the checkpoint
102  *
103  * The output variables will both contain 0 if filename is NULL, the file
104  * does not exist, or is not readable. */
105 void read_checkpoint_part_and_step(const char  *filename,
106                                    int         *simulation_part,
107                                    gmx_int64_t *step);
108
109 /* ! \brief Read simulation part and output filenames from a checkpoint file
110  *
111  * Used by mdrun to handle restarts
112  *
113  * \param[in]  fp               Handle to open checkpoint file
114  * \param[out] simulation_part  The part of the simulation that wrote the checkpoint
115  * \param[out] nfiles           Number of output files from the previous run
116  * \param[out] outputfiles      Pointer to array of output file names from the previous run. Pointer is allocated in this function.
117  */
118 void
119 read_checkpoint_simulation_part_and_filenames(struct t_fileio             *fp,
120                                               int                         *simulation_part,
121                                               int                         *nfiles,
122                                               struct gmx_file_position_t **outputfiles);
123
124 #ifdef __cplusplus
125 }
126 #endif
127
128 #endif