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, 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.
39 #include "gromacs/fileio/gmxfio.h"
41 #include "gmxfio-impl.h"
43 /*******************************************************************
45 * READ/WRITE FUNCTIONS
47 *******************************************************************/
49 gmx_bool gmx_fio_writee_string(t_fileio *fio, const char *item,
50 const char *desc, const char *srcfile, int line)
53 void *it = (void*)item; /* ugh.. */
55 ret = do_xdr(fio, it, 1, eioSTRING, desc, srcfile, line);
60 gmx_bool gmx_fio_doe_real(t_fileio *fio, real *item,
61 const char *desc, const char *srcfile, int line)
65 ret = do_xdr(fio, item, 1, eioREAL, desc, srcfile, line);
71 gmx_bool gmx_fio_doe_float(t_fileio *fio, float *item,
72 const char *desc, const char *srcfile, int line)
76 ret = do_xdr(fio, item, 1, eioFLOAT, desc, srcfile, line);
81 gmx_bool gmx_fio_doe_double(t_fileio *fio, double *item,
82 const char *desc, const char *srcfile, int line)
86 ret = do_xdr(fio, item, 1, eioDOUBLE, desc, srcfile, line);
92 gmx_bool gmx_fio_doe_gmx_bool(t_fileio *fio, gmx_bool *item,
93 const char *desc, const char *srcfile, int line)
101 ret = do_xdr(fio, &itmp, 1, eioINT, desc, srcfile, line);
107 ret = do_xdr(fio, &itmp, 1, eioINT, desc, srcfile, line);
113 gmx_bool gmx_fio_doe_int(t_fileio *fio, int *item,
114 const char *desc, const char *srcfile, int line)
118 ret = do_xdr(fio, item, 1, eioINT, desc, srcfile, line);
123 gmx_bool gmx_fio_doe_int64(t_fileio *fio, gmx_int64_t *item,
124 const char *desc, const char *srcfile, int line)
128 ret = do_xdr(fio, item, 1, eioINT64, desc, srcfile, line);
133 gmx_bool gmx_fio_doe_uchar(t_fileio *fio, unsigned char *item,
134 const char *desc, const char *srcfile, int line)
138 ret = do_xdr(fio, item, 1, eioUCHAR, desc, srcfile, line);
143 gmx_bool gmx_fio_doe_ushort(t_fileio *fio, unsigned short *item,
144 const char *desc, const char *srcfile, int line)
148 ret = do_xdr(fio, item, 1, eioUSHORT, desc, srcfile, line);
153 gmx_bool gmx_fio_doe_rvec(t_fileio *fio, rvec *item,
154 const char *desc, const char *srcfile, int line)
158 ret = do_xdr(fio, item, 1, eioRVEC, desc, srcfile, line);
163 gmx_bool gmx_fio_doe_ivec(t_fileio *fio, ivec *item,
164 const char *desc, const char *srcfile, int line)
168 ret = do_xdr(fio, item, 1, eioIVEC, desc, srcfile, line);
173 gmx_bool gmx_fio_doe_string(t_fileio *fio, char *item,
174 const char *desc, const char *srcfile, int line)
178 ret = do_xdr(fio, item, 1, eioSTRING, desc, srcfile, line);
184 /* Array reading & writing */
186 gmx_bool gmx_fio_ndoe_real(t_fileio *fio, real *item, int n,
187 const char *desc, const char *srcfile, int line)
192 for (i = 0; i < n; i++)
194 ret = ret && do_xdr(fio, &(item[i]), 1, eioREAL, desc,
203 gmx_bool gmx_fio_ndoe_float(t_fileio *fio, float *item, int n,
204 const char *desc, const char *srcfile, int line)
209 for (i = 0; i < n; i++)
211 ret = ret && do_xdr(fio, &(item[i]), 1, eioFLOAT, desc,
220 gmx_bool gmx_fio_ndoe_double(t_fileio *fio, double *item, int n,
221 const char *desc, const char *srcfile, int line)
226 for (i = 0; i < n; i++)
228 ret = ret && do_xdr(fio, &(item[i]), 1, eioDOUBLE, desc,
237 gmx_bool gmx_fio_ndoe_gmx_bool(t_fileio *fio, gmx_bool *item, int n,
238 const char *desc, const char *srcfile, int line)
244 for (i = 0; i < n; i++)
248 ret = ret && do_xdr(fio, &itmp, 1, eioINT, desc,
255 ret = ret && do_xdr(fio, &itmp, 1, eioINT, desc,
263 gmx_bool gmx_fio_ndoe_int(t_fileio *fio, int *item, int n,
264 const char *desc, const char *srcfile, int line)
269 for (i = 0; i < n; i++)
271 ret = ret && do_xdr(fio, &(item[i]), 1, eioINT, desc,
280 gmx_bool gmx_fio_ndoe_int64(t_fileio *fio, gmx_int64_t *item, int n,
281 const char *desc, const char *srcfile, int line)
286 for (i = 0; i < n; i++)
288 ret = ret && do_xdr(fio, &(item[i]), 1, eioINT64, desc,
297 gmx_bool gmx_fio_ndoe_uchar(t_fileio *fio, unsigned char *item, int n,
298 const char *desc, const char *srcfile, int line)
302 ret = ret && do_xdr(fio, item, n, eioNUCHAR, desc,
310 gmx_bool gmx_fio_ndoe_ushort(t_fileio *fio, unsigned short *item, int n,
311 const char *desc, const char *srcfile, int line)
316 for (i = 0; i < n; i++)
318 ret = ret && do_xdr(fio, &(item[i]), 1, eioUSHORT, desc,
327 gmx_bool gmx_fio_ndoe_rvec(t_fileio *fio, rvec *item, int n,
328 const char *desc, const char *srcfile, int line)
332 ret = ret && do_xdr(fio, item, n, eioNRVEC, desc, srcfile, line);
339 gmx_bool gmx_fio_ndoe_ivec(t_fileio *fio, ivec *item, int n,
340 const char *desc, const char *srcfile, int line)
345 for (i = 0; i < n; i++)
347 ret = ret && do_xdr(fio, &(item[i]), 1, eioIVEC, desc,
356 gmx_bool gmx_fio_ndoe_string(t_fileio *fio, char *item[], int n,
357 const char *desc, const char *srcfile, int line)
362 for (i = 0; i < n; i++)
364 ret = ret && do_xdr(fio, &(item[i]), 1, eioSTRING, desc,