NAMD
dcdlib.h
Go to the documentation of this file.
1 
7 /*
8  dcdlib contains C routines used for reading and writing binary
9  dcd files. The format of these files is from binary FORTRAN output,
10  so its pretty ugly. If you're squimish, don't look!!
11 */
12 
13 #ifndef DCDLIB_H
14 #define DCDLIB_H
15 
16 #include "largefiles.h" // must be first!
17 #include "common.h" // for int32 definition
18 #include "Vector.h"
19 #include <stdio.h>
20 #include <string.h>
21 #ifndef _NO_MALLOC_H
22 #include <malloc.h>
23 #endif
24 #ifndef WIN32
25 #include <unistd.h>
26 #endif
27 #include <fcntl.h>
28 #include <sys/stat.h>
29 #include <sys/types.h>
30 #include <errno.h>
31 #ifndef WIN32
32 #include <pwd.h>
33 #endif
34 #include <time.h>
35 #ifdef WIN32
36 #include <io.h>
37 #endif
38 
39 #ifdef WIN32
40 #define OFF_T __int64
41 #else
42 #define OFF_T off_t
43 #endif
44 
45 
46 /* DEFINE ERROR CODES THAT MAY BE RETURNED BY DCD ROUTINES */
47 #define DCD_DNE -2 /* DCD file does not exist */
48 #define DCD_OPENFAILED -3 /* Open of DCD file failed */
49 #define DCD_BADREAD -4 /* read call on DCD file failed */
50 #define DCD_BADEOF -5 /* premature EOF found in DCD file */
51 #define DCD_BADFORMAT -6 /* format of DCD file is wrong */
52 #define DCD_FILEEXISTS -7 /* output file already exists */
53 #define DCD_BADMALLOC -8 /* malloc failed */
54 
55 /* FUNCTION ALLUSIONS */
56 int open_dcd_read(char *); /* Open a DCD file for reading */
57 int read_dcdheader(int, int*, int*, int*, int*, double*, int*, int**);
58  /* Read the DCD header */
59 int read_dcdstep(int, int, float*, float*, float*, int, int, int*);
60  /* Read a timestep's values */
61 int open_dcd_write(const char *); /* Open a DCD file for writing */
62 
63 int write_dcdstep(int, int, float *, float *, float *, double *unitcell);
64  /* Write out a timesteps values */
65 int write_dcdheader(int, const char*, int, int, int, int, int, double, int);
66  /* Write a dcd header */
67 int get_dcdheader_size();
68  /* Get the total size of the header */
69 void close_dcd_read(int, int, int *);
70  /* Close a dcd file open for reading */
71 void close_dcd_write(int); /* Close a dcd file open for writing */
72 
73 int open_dcd_write_par_slave(char *dcdname);
74 /* Slaves open existing file created by master */
75 int write_dcdstep_par_cell(int fd, double *cell);
76 int write_dcdstep_par_XYZUnits(int fd, int N);
77  /* Master writes unit cell and natom info */
78 int update_dcdstep_par_header(int fd);
79  /* Master updates header */
80 
81 /* Write out a timesteps values partially in parallel for part [parL, parU] */
82 int write_dcdstep_par_slave(int fd, int parL, int parU, int N, float *X, float *Y, float *Z);
83 
84 /* wrapper for seeking the dcd file */
85 OFF_T NAMD_seek(int file, OFF_T offset, int whence);
86 
87 #endif /* ! DCDLIB_H */
88 
#define OFF_T
Definition: dcdlib.h:42
int open_dcd_write_par_slave(char *dcdname)
Definition: dcdlib.C:689
int open_dcd_read(char *filename)
Definition: dcdlib.C:145
int update_dcdstep_par_header(int fd)
Definition: dcdlib.C:839
#define X
Definition: msm_defn.h:29
int open_dcd_write(const char *dcdname)
Definition: dcdlib.C:662
int read_dcdstep(int, int, float *, float *, float *, int, int, int *)
int write_dcdstep_par_XYZUnits(int fd, int N)
Definition: dcdlib.C:810
int get_dcdheader_size()
Definition: dcdlib.C:1005
int write_dcdstep_par_cell(int fd, double *cell)
Definition: dcdlib.C:785
OFF_T NAMD_seek(int file, OFF_T offset, int whence)
Definition: dcdlib.C:49
#define Z
Definition: msm_defn.h:33
void close_dcd_read(int fd, int num_fixed, int *indexes)
Definition: dcdlib.C:1033
int write_dcdstep(int fd, int N, float *X, float *Y, float *Z, double *cell)
Definition: dcdlib.C:736
int write_dcdheader(int fd, const char *filename, int N, int NFILE, int NPRIV, int NSAVC, int NSTEP, double DELTA, int with_unitcell)
Definition: dcdlib.C:915
int write_dcdstep_par_slave(int fd, int parL, int parU, int N, float *X, float *Y, float *Z)
Definition: dcdlib.C:864
#define Y
Definition: msm_defn.h:31
void close_dcd_write(int fd)
Definition: dcdlib.C:1063
int read_dcdheader(int, int *, int *, int *, int *, double *, int *, int **)