fixed recent bug with CUDA texture objects
[gromacs.git] / include / enxio.h
blob7336a44db8d4ba5a7ae307b6ac74238709b8c996
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 * check out http://www.gromacs.org for more information.
7 * Copyright (c) 2012,2013, by the GROMACS development team, led by
8 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
9 * others, as listed in the AUTHORS file in the top-level source
10 * directory and at http://www.gromacs.org.
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.
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.
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.
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.
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.
39 #ifndef _enxio_h
40 #define _enxio_h
41 #include "visibility.h"
42 #include "sysstuff.h"
43 #include "typedefs.h"
44 #include "pbc.h"
45 #include "gmxfio.h"
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
51 /**************************************************************
52 * These are the base datatypes + functions for reading and
53 * writing energy files (.edr). They are either called directly
54 * (as in the processing tools), or indirectly through mdebin.c
55 * during mdrun.
57 * The routines in the corresponding c-file enxio.c
58 * are based on the lower level routines in gmxfio.c.
59 * The file pointer returned from open_enx
60 * can also be used with the routines in gmxfio.h
62 **************************************************************/
64 typedef struct {
65 char *name;
66 char *unit;
67 } gmx_enxnm_t;
70 * Index for the IDs of additional blocks in the energy file.
71 * Blocks can be added without sacrificing backward and forward
72 * compatibility of the energy files.
74 * For backward compatibility, the order of these should not be changed.
76 enum {
77 enxOR, /* Time and ensemble averaged data for orientation restraints */
78 enxORI, /* Instantaneous data for orientation restraints */
79 enxORT, /* Order tensor(s) for orientation restraints */
80 enxDISRE, /* Distance restraint blocks */
82 enxDHCOLL, /* Data about the free energy blocks in this frame. */
83 enxDHHIST, /* BAR histogram */
84 enxDH, /* BAR raw delta H data */
86 enxNR /* Total number of extra blocks in the current code,
87 * note that the enxio code can read files written by
88 * future code which contain more blocks.
92 /* names for the above enum */
93 GMX_LIBGMX_EXPORT
94 extern const char *enx_block_id_name[];
97 /* the subblocks that are contained in energy file blocks. Each of these
98 has a number of values of a single data type in a .edr file. */
99 typedef struct
101 int nr; /* number of items in subblock */
102 xdr_datatype type; /* the block type */
104 /* the values: pointers for each type */
105 float* fval;
106 double* dval;
107 int* ival;
108 gmx_large_int_t* lval;
109 unsigned char* cval;
110 char** sval;
112 /* the allocated sizes, defined separately.
113 (nonzero sizes can be free()d later): */
114 int fval_alloc;
115 int dval_alloc;
116 int ival_alloc;
117 int lval_alloc;
118 int cval_alloc;
119 int sval_alloc;
120 } t_enxsubblock;
123 /* the energy file blocks. Each block contains a number of sub-blocks
124 of a single type that contain the actual data. */
125 typedef struct t_enxblock{
126 int id; /* block id, from the enx enums above */
127 int nsub; /* number of subblocks */
128 t_enxsubblock *sub; /* the subblocks */
129 int nsub_alloc; /* number of allocated subblocks */
130 } t_enxblock;
133 /* The frames that are read/written */
134 typedef struct {
135 double t; /* Timestamp of this frame */
136 gmx_large_int_t step; /* MD step */
137 gmx_large_int_t nsteps; /* The number of steps between frames */
138 double dt; /* The MD time step */
139 int nsum; /* The number of terms for the sums in ener */
140 int nre; /* Number of energies */
141 int e_size; /* Size (in bytes) of energies */
142 int e_alloc; /* Allocated size (in elements) of ener */
143 t_energy *ener; /* The energies */
144 int nblock; /* Number of following energy blocks */
145 t_enxblock *block; /* The blocks */
146 int nblock_alloc; /* The number of blocks allocated */
147 } t_enxframe;
149 /* file handle */
150 typedef struct ener_file *ener_file_t;
153 * An energy file is read like this:
155 * ener_file_t fp;
156 * t_enxframe *fr;
158 * fp = open_enx(...);
159 * do_enxnms(fp,...);
160 * snew(fr,1);
161 * while (do_enx(fp,fr)) {
162 * ...
164 * free_enxframe(fr);
165 * sfree(fr);
167 /* New energy reading and writing interface */
170 /* initialize a pre-allocated frame */
171 GMX_LIBGMX_EXPORT
172 void init_enxframe(t_enxframe *ef);
173 /* delete a frame's memory (except the ef itself) */
174 GMX_LIBGMX_EXPORT
175 void free_enxframe(t_enxframe *ef);
178 GMX_LIBGMX_EXPORT
179 ener_file_t open_enx(const char *fn, const char *mode);
181 GMX_LIBGMX_EXPORT
182 t_fileio *enx_file_pointer(const ener_file_t ef);
184 GMX_LIBGMX_EXPORT
185 void close_enx(ener_file_t ef);
187 GMX_LIBGMX_EXPORT
188 void do_enxnms(ener_file_t ef, int *nre, gmx_enxnm_t **enms);
190 GMX_LIBGMX_EXPORT
191 void free_enxnms(int n, gmx_enxnm_t *nms);
192 /* Frees nms and all strings in it */
194 GMX_LIBGMX_EXPORT
195 gmx_bool do_enx(ener_file_t ef, t_enxframe *fr);
196 /* Reads enx_frames, memory in fr is (re)allocated if necessary */
198 GMX_LIBGMX_EXPORT
199 void get_enx_state(const char *fn, real t,
200 gmx_groups_t *groups, t_inputrec *ir,
201 t_state *state);
203 * Reads state variables from enx file fn at time t.
204 * atoms and ir are required for determining which things must be read.
205 * Currently pcoupl and tcoupl state are read from enx.
209 /* block funtions */
211 /* allocate n blocks to a frame (if neccesary). Don't touch existing blocks */
212 GMX_LIBGMX_EXPORT
213 void add_blocks_enxframe(t_enxframe *ef, int n);
215 /* find a block by id number; if prev!=NULL, it searches from
216 that block's next block.
217 Returns NULL if no block is found with the given id. */
218 GMX_LIBGMX_EXPORT
219 t_enxblock *find_block_id_enxframe(t_enxframe *ef, int id, t_enxblock *prev);
222 /* allocate n subblocks to a block (if neccesary). Don't touch existing
223 subbblocks. */
224 GMX_LIBGMX_EXPORT
225 void add_subblocks_enxblock(t_enxblock *eb, int n);
229 #ifdef __cplusplus
231 #endif
233 #endif /* _enerio_h */