changed reading hint
[gromacs/adressmacs.git] / src / gmxlib / binio.c
blobf123d4ba61c914f74867b57461179aed69f6af4f
1 /*
2 * $Id$
3 *
4 * This source code is part of
5 *
6 * G R O M A C S
7 *
8 * GROningen MAchine for Chemical Simulations
9 *
10 * VERSION 2.0
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
16 * Please refer to:
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
23 * or e-mail to:
24 * gromacs@chem.rug.nl
26 * And Hey:
27 * Green Red Orange Magenta Azure Cyan Skyblue
29 static char *SRCID_binio_c = "$Id$";
31 #include <stdio.h>
32 #include <errno.h>
33 #include "sysstuff.h"
34 #include "main.h"
35 #include "fatal.h"
36 #include "binio.h"
38 void _blockwrite(FILE *fp,int nelem,int size,void *data,char *what,char *file,
39 int line)
41 int len;
43 #ifdef DEBUG
44 (void) fprintf(stderr,"blockwrite %s (file %s,line %d,size=%d, nelem=%d)\n",
45 what,file,line,size,nelem);
46 fflush(stderr);
47 #endif
48 if ((len=fwrite(data,size,nelem,fp))!=nelem)
49 fatal_error(errno,"writing %s (%dx%d, len=%d, pos=%d) from file %s, "
50 "line %d",what,nelem,size,len,ftell(fp),file,line);
53 void _blockread(FILE *fp,int nelem,int size,void *data,char *what,char *file,
54 int line)
56 int len;
58 #ifdef DEBUG
59 (void) fprintf(stderr,"blockread %s (file %s,line %d,size=%d, nelem=%d)\n",
60 what,file,line,size,nelem);
61 fflush(stderr);
62 #endif
63 if ((len=fread(data,size,nelem,fp))!=nelem)
64 fatal_error(errno,"reading %s (%dx%d, len=%d, pos=%d) from file %s, "
65 "line %d",what,nelem,size,len,ftell(fp),file,line);