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, 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_GMXFIO_INT_H
38 #define GMX_FILEIO_GMXFIO_INT_H
40 /* This is the new improved and thread safe version of gmxfio. */
43 /* WARNING WARNING WARNING WARNING
44 The data types used here are PRIVATE to gmxfio routines. DO NOT use them
45 directly in your own code, but use the external functions provided in
48 If you don't heed this warning, your code will suddenly stop working
49 at some point in the not-so-distant future.
51 WARNING WARNING WARNING WARNING */
54 /* XDR should be available on all platforms now,
55 * but we keep the possibility of turning it off...
59 #include "gromacs/legacyheaders/thread_mpi/lock.h"
62 /* the reader/writer functions for t_iotype */
63 typedef gmx_bool read_func (t_fileio *fio, void *item, int nitem, int eio,
64 const char *desc, const char *srcfile, int line);
65 typedef gmx_bool write_func (t_fileio *fio, const void *item, int nitem, int eio,
66 const char *desc, const char *srcfile, int line);
69 /* these are pointers to the actual reading & writing functions */
80 FILE *fp; /* the file pointer */
81 const t_iotype *iotp; /* file type */
82 gmx_bool bOpen, /* the file is open */
83 bRead, /* the file is open for reading */
84 bDouble, /* write doubles instead of floats */
85 bDebug, /* the file ops should come with debug info */
86 bStdio, /* the file is actually stdin or stdout */
87 bReadWrite; /* the file is open for reading and writing */
88 char *fn; /* the file name */
89 XDR *xdr; /* the xdr data pointer */
90 enum xdr_op xdrmode; /* the xdr mode */
91 int iFTP; /* the file type identifier */
93 const char *comment; /* a comment string for debugging */
95 t_fileio *next, *prev; /* next and previous file pointers in the
97 tMPI_Lock_t mtx; /* content locking mutex. This is a fast lock
98 for performance reasons: in some cases every
99 single byte that gets read/written requires
105 extern const t_iotype asc_iotype;
106 extern const t_iotype bin_iotype;
107 extern const t_iotype xdr_iotype;
108 extern const t_iotype dummy_iotype;
110 extern const char *eioNames[eioNR];
114 #define GMX_FIO_BUFLEN 256
116 /* make a debug string if that is requested in the fio */
117 const char *gmx_fio_dbgstr(t_fileio *fio, const char *desc, char *buf);
118 /* check the number of items against the allowed number of items */
119 void gmx_fio_check_nitem(int eio, int nitem, const char *file,
121 /* check the output type against allowed values */
122 void gmx_fio_fe(t_fileio *fio, int eio, const char *desc, const char *srcfile,
125 /* lock/unlock the mutex associated with a fio */
126 void gmx_fio_lock(t_fileio *fio);
127 void gmx_fio_unlock(t_fileio *fio);