Add more const correctness
[gromacs.git] / src / gromacs / fileio / trrio.h
blob489f25cb9c67f271697ef84b7321debe91c993c0
1 /*
2 * This file is part of the GROMACS molecular simulation package.
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,2016, 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.
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.
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.
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.
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.
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.
37 #ifndef GMX_FILEIO_TRRIO_H
38 #define GMX_FILEIO_TRRIO_H
40 #include "gromacs/math/vectypes.h"
41 #include "gromacs/utility/basedefinitions.h"
42 #include "gromacs/utility/real.h"
44 /**************************************************************
46 * These routines handle trr (trajectory) I/O, they read and
47 * write trr files. The routines should be able to read single
48 * and double precision files without the user noting it.
49 * The files are backward compatible, therefore the header holds
50 * some unused variables.
52 * The routines in the corresponding c-file trrio.cpp
53 * are based on the lower level routines in gmxfio.cpp
54 * The file handle returned from gmx_trr_open()
55 * can also be used with the routines in gmxfio.h
57 **************************************************************/
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
63 struct t_fileio;
65 /* This struct describes the order and the */
66 /* sizes of the structs in a trr file, sizes are given in bytes. */
67 typedef struct gmx_trr_header_t
69 gmx_bool bDouble; /* Double precision? */
70 int ir_size; /* Backward compatibility */
71 int e_size; /* Backward compatibility */
72 int box_size; /* Non zero if a box is present */
73 int vir_size; /* Backward compatibility */
74 int pres_size; /* Backward compatibility */
75 int top_size; /* Backward compatibility */
76 int sym_size; /* Backward compatibility */
77 int x_size; /* Non zero if coordinates are present */
78 int v_size; /* Non zero if velocities are present */
79 int f_size; /* Non zero if forces are present */
81 int natoms; /* The total number of atoms */
82 int step; /* Current step number */
83 int nre; /* Backward compatibility */
84 real t; /* Current time */
85 real lambda; /* Current value of lambda */
86 int fep_state; /* Current value of alchemical state */
87 } gmx_trr_header_t;
89 struct t_fileio *gmx_trr_open(const char *fn, const char *mode);
90 /* Open a trr file */
92 void gmx_trr_close(struct t_fileio *fio);
93 /* Close it */
95 gmx_bool gmx_trr_read_frame_header(struct t_fileio *fio, gmx_trr_header_t *header, gmx_bool *bOK);
96 /* Read the header of a trr file. Return FALSE if there is no frame.
97 * bOK will be FALSE when the header is incomplete.
100 gmx_bool gmx_trr_read_frame_data(struct t_fileio *fio, gmx_trr_header_t *sh,
101 rvec *box, rvec *x, rvec *v, rvec *f);
102 /* Extern read a frame except the header (that should be pre-read,
103 * using routine gmx_trr_read_frame_header(), see above) from a trr file.
104 * Return FALSE on error
107 gmx_bool gmx_trr_read_frame(struct t_fileio *fio, int *step, real *t, real *lambda,
108 rvec *box, int *natoms, rvec *x, rvec *v, rvec *f);
109 /* Read a trr frame, including the header from fp. box, x, v, f may
110 * be NULL, in which case the data will be skipped over.
111 * return FALSE on error
114 void gmx_trr_write_frame(struct t_fileio *fio, int step, real t, real lambda,
115 const rvec *box, int natoms, const rvec *x, const rvec *v, const rvec *f);
116 /* Write a trr frame to file fp, box, x, v, f may be NULL */
118 void gmx_trr_read_single_header(const char *fn, gmx_trr_header_t *header);
119 /* Read the header of a trr file from fn, and close the file afterwards.
122 void gmx_trr_read_single_frame(const char *fn, int *step, real *t, real *lambda,
123 rvec *box, int *natoms, rvec *x, rvec *v, rvec *f);
124 /* Read a single trr frame from file fn, which is closed afterwards
127 void gmx_trr_write_single_frame(const char *fn, int step, real t, real lambda,
128 const rvec *box, int natoms, const rvec *x, const rvec *v, const rvec *f);
129 /* Write a single trr frame to file fn, which is closed afterwards */
131 #ifdef __cplusplus
133 #endif
136 #endif