73ebd2a8f0f8148f0a00dda615b3faf9aa31e91b
[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, 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
42 #include "gromacs/legacyheaders/typedefs.h"
43 #include "../fileio/gmxfio.h"
44 #include "../fileio/filenm.h"
45
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49
50 /* the name of the environment variable to disable fsync failure checks with */
51 #define GMX_IGNORE_FSYNC_FAILURE_ENV "GMX_IGNORE_FSYNC_FAILURE"
52
53 /* Write a checkpoint to <fn>.cpt
54  * Appends the _step<step>.cpt with bNumberAndKeep,
55  * otherwise moves the previous <fn>.cpt to <fn>_prev.cpt
56  */
57 void write_checkpoint(const char *fn, gmx_bool bNumberAndKeep,
58                       FILE *fplog, t_commrec *cr,
59                       int eIntegrator, int simulation_part,
60                       gmx_bool bExpanded, int elamstats,
61                       gmx_int64_t step, double t,
62                       t_state *state);
63
64 /* Loads a checkpoint from fn for run continuation.
65  * Generates a fatal error on system size mismatch.
66  * The master node reads the file
67  * and communicates all the modified number of steps and the parallel setup,
68  * but not the state itself.
69  * When bAppend is set, lock the log file and truncate the existing output
70  * files so they can be appended.
71  * With bAppend and bForceAppend: truncate anyhow if the system does not
72  * support file locking.
73  */
74 void load_checkpoint(const char *fn, FILE **fplog,
75                      t_commrec *cr, ivec dd_nc,
76                      t_inputrec *ir, t_state *state,
77                      gmx_bool *bReadEkin,
78                      gmx_bool bAppend, gmx_bool bForceAppend);
79
80 /* Read the state from checkpoint file.
81  * Arrays in state that are NULL are allocated.
82  * If bReadRNG=TRUE a RNG state compatible with the current
83  * number of nodes was read.
84  */
85 void read_checkpoint_state(const char *fn, int *simulation_part,
86                            gmx_int64_t *step, double *t, t_state *state);
87
88 /* Read everything that can be stored in t_trxframe from a checkpoint file */
89 void read_checkpoint_trxframe(t_fileio *fp, t_trxframe *fr);
90
91 /* Print the complete contents of checkpoint file fn to out */
92 void list_checkpoint(const char *fn, FILE *out);
93
94 /* Read just the simulation 'generation' and with bAppendReq check files.
95  * This is necessary already at the beginning of mdrun,
96  * to be able to rename the logfile correctly.
97  * When file appending is requested, checks which output files are present:
98  * all present: return TRUE,
99  * none present: return FALSE,
100  * part present: fatal error.
101  * When TRUE is returned, bAddPart will tell whether the simulation part
102  * needs to be added to the output file name.
103  */
104 gmx_bool read_checkpoint_simulation_part(const char *filename, int *simulation_part,
105                                          gmx_int64_t *step, t_commrec *cr,
106                                          gmx_bool bAppendReq,
107                                          int nfile, const t_filenm fnm[],
108                                          const char *part_suffix, gmx_bool *bAddPart);
109
110 #ifdef __cplusplus
111 }
112 #endif
113
114 #endif