SYCL: Avoid using no_init read accessor in rocFFT
[alexxy/gromacs.git] / src / gromacs / fileio / trrio.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,2016,2018 by the GROMACS development team.
7  * Copyright (c) 2019,2020, by the GROMACS development team, led by
8  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
9  * and including many others, as listed in the AUTHORS file in the
10  * top-level source directory and at http://www.gromacs.org.
11  *
12  * GROMACS is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public License
14  * as published by the Free Software Foundation; either version 2.1
15  * of the License, or (at your option) any later version.
16  *
17  * GROMACS is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with GROMACS; if not, see
24  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
26  *
27  * If you want to redistribute modifications to GROMACS, please
28  * consider that scientific software is very special. Version
29  * control is crucial - bugs must be traceable. We will be happy to
30  * consider code for inclusion in the official distribution, but
31  * derived work must not be called official GROMACS. Details are found
32  * in the README & COPYING files - if they are missing, get the
33  * official version at http://www.gromacs.org.
34  *
35  * To help us fund GROMACS development, we humbly ask that you cite
36  * the research papers on the package. Check out http://www.gromacs.org.
37  */
38 #ifndef GMX_FILEIO_TRRIO_H
39 #define GMX_FILEIO_TRRIO_H
40
41 #include "gromacs/math/vectypes.h"
42 #include "gromacs/utility/basedefinitions.h"
43 #include "gromacs/utility/real.h"
44
45 /**************************************************************
46  *
47  * These routines handle trr (trajectory) I/O, they read and
48  * write trr files. The routines should be able to read single
49  * and double precision files without the user noting it.
50  * The files are backward compatible, therefore the header holds
51  * some unused variables.
52  *
53  * The routines in the corresponding c-file trrio.cpp
54  * are based on the lower level routines in gmxfio.cpp
55  * The file handle returned from gmx_trr_open()
56  * can also be used with the routines in gmxfio.h
57  *
58  * Note that TRR was designed to represent a step number as a default
59  * integer, which depends on the implementation, but is typically and
60  * 32 bit. We didn't design the format to be extensible, so we can't
61  * fix the fact that after 2^31 frames, step numbers will wrap to be
62  * negative. Fortunately, this tends not to cause serious problems,
63  * and we've fixed it in TNG. Meanwhile, the implementation pretends
64  * to the rest of GROMACS that it functions with int64_t like all
65  * other step numbers, but the actual range in practice depends on the
66  * defaults of the implementation in use now (or when the file was
67  * written).
68  *
69  **************************************************************/
70
71 struct t_fileio;
72
73 /* This struct describes the order and the  */
74 /* sizes of the structs in a trr file, sizes are given in bytes. */
75 typedef struct gmx_trr_header_t
76 {
77     gmx_bool bDouble;   /* Double precision?                   */
78     int      ir_size;   /* Backward compatibility              */
79     int      e_size;    /* Backward compatibility              */
80     int      box_size;  /* Non zero if a box is present        */
81     int      vir_size;  /* Backward compatibility              */
82     int      pres_size; /* Backward compatibility              */
83     int      top_size;  /* Backward compatibility              */
84     int      sym_size;  /* Backward compatibility              */
85     int      x_size;    /* Non zero if coordinates are present */
86     int      v_size;    /* Non zero if velocities are present  */
87     int      f_size;    /* Non zero if forces are present      */
88
89     int     natoms;    /* The total number of atoms           */
90     int64_t step;      /* Current step number                 */
91     int     nre;       /* Backward compatibility              */
92     real    t;         /* Current time                        */
93     real    lambda;    /* Current value of lambda             */
94     int     fep_state; /* Current value of alchemical state   */
95 } gmx_trr_header_t;
96
97 struct t_fileio* gmx_trr_open(const char* fn, const char* mode);
98 /* Open a trr file */
99
100 void gmx_trr_close(struct t_fileio* fio);
101 /* Close it */
102
103 gmx_bool gmx_trr_read_frame_header(struct t_fileio* fio, gmx_trr_header_t* header, gmx_bool* bOK);
104 /* Read the header of a trr file. Return FALSE if there is no frame.
105  * bOK will be FALSE when the header is incomplete.
106  */
107
108 gmx_bool gmx_trr_read_frame_data(struct t_fileio* fio, gmx_trr_header_t* sh, rvec* box, rvec* x, rvec* v, rvec* f);
109 /* Extern read a frame except the header (that should be pre-read,
110  * using routine gmx_trr_read_frame_header(), see above) from a trr file.
111  * Return FALSE on error
112  */
113
114 gmx_bool gmx_trr_read_frame(struct t_fileio* fio,
115                             int64_t*         step,
116                             real*            t,
117                             real*            lambda,
118                             rvec*            box,
119                             int*             natoms,
120                             rvec*            x,
121                             rvec*            v,
122                             rvec*            f);
123 /* Read a trr frame, including the header from fp. box, x, v, f may
124  * be NULL, in which case the data will be skipped over.
125  * return FALSE on error
126  */
127
128 void gmx_trr_write_frame(struct t_fileio* fio,
129                          int64_t          step,
130                          real             t,
131                          real             lambda,
132                          const rvec*      box,
133                          int              natoms,
134                          const rvec*      x,
135                          const rvec*      v,
136                          const rvec*      f);
137 /* Write a trr frame to file fp, box, x, v, f may be NULL */
138
139 void gmx_trr_read_single_header(const char* fn, gmx_trr_header_t* header);
140 /* Read the header of a trr file from fn, and close the file afterwards.
141  */
142
143 void gmx_trr_read_single_frame(const char* fn,
144                                int64_t*    step,
145                                real*       t,
146                                real*       lambda,
147                                rvec*       box,
148                                int*        natoms,
149                                rvec*       x,
150                                rvec*       v,
151                                rvec*       f);
152 /* Read a single trr frame from file fn, which is closed afterwards
153  */
154
155 void gmx_trr_write_single_frame(const char* fn,
156                                 int64_t     step,
157                                 real        t,
158                                 real        lambda,
159                                 const rvec* box,
160                                 int         natoms,
161                                 const rvec* x,
162                                 const rvec* v,
163                                 const rvec* f);
164 /* Write a single trr frame to file fn, which is closed afterwards */
165
166
167 #endif