4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
17 * GROMACS: A message-passing parallel molecular dynamics implementation
18 * H.J.C. Berendsen, D. van der Spoel and R. van Drunen
19 * Comp. Phys. Comm. 91, 43-56 (1995)
21 * Also check out our WWW page:
22 * http://md.chem.rug.nl/~gmx
27 * Good ROcking Metal Altar for Chronical Sinners
33 static char *SRCID_binio_h
= "$Id$";
36 #ident "@(#) binio.h 1.5 11/23/92"
37 #endif /* HAVE_IDENT */
44 * Module to binary write and read.
49 * @ @ @ @@@ @@ @@@ @@ @@ @@@ @@ @@ @@ @@
50 * @ @ @ @ @ @@ @ @@ @ @ @@ @ @ @@
51 * @ @ @ @ @ @ @ @ @ @ @ @ @
52 * @@ @@ @@@@@ @ @ @ @ @ @ @ @
53 * @ @ @ @ @ @ @ @ @ @ @ @
54 * @ @ @ @@ @ @ @ @ @ @ @ @@
55 * @ @ @@@ @@ @@@@ @@@ @@@ @@@@@ @@@ @@@ @@ @
60 * Use this module only to write and read simple types or array(s)
61 * of simple types. STRUCTURES ARE DEFINITELY NOT ALLOWED.
64 #define nblockwrite(fp,nelem,data) \
65 _blockwrite(fp,nelem,sizeof(*data),(data),#data,__FILE__,__LINE__)
66 #define blockwrite(fp,data) \
67 _blockwrite(fp,1,sizeof(data),&(data),#data,__FILE__,__LINE__)
68 #define cblockwrite(fp,ptr,nchars) \
69 _blockwrite(fp,1,(nchars),(ptr),#ptr,__FILE__,__LINE__)
70 #define nblockread(fp,nelem,data) \
71 _blockread(fp,nelem,sizeof(*data),(data),#data,__FILE__,__LINE__)
72 #define blockread(fp,data) \
73 _blockread(fp,1,sizeof(data),&(data),#data,__FILE__,__LINE__)
74 #define cblockread(fp,ptr,nchars) \
75 _blockread(fp,1,(nchars),(ptr),#ptr,__FILE__,__LINE__)
77 #define patch(fp,fpos,write) \
83 if ((result=fseek(fp,fpos,SEEK_SET))!=0) \
84 fatal_error(errno,"could not seek to position %d from file %s, " \
85 "line %d, result=%d",(fpos),__FILE__,__LINE__,result); \
87 if ((result=fseek(fp,fhere,SEEK_SET))!=0) \
88 fatal_error(errno,"could not seek back to %d from file %s, line %d," \
89 " result=%d",fhere,__FILE__,__LINE__,result); \
93 extern void _blockwrite(FILE *fp
,int nelem
,int size
,void *data
,
94 char *what
,char *file
,int line
);
96 extern void _blockread(FILE *fp
,int nelem
,int size
,void *data
,
97 char *what
,char *file
,int line
);