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 * Green Red Orange Magenta Azure Cyan Skyblue
33 static char *SRCID_trnio_h = "$Id$";
39 /**************************************************************
41 * These routines handle trj (trajectory) I/O, they read and
42 * write trj/trr files. The routines should be able to read single
43 * and double precision files without the user noting it.
44 * The files are backward compatible, therefore the header holds
45 * some unused variables.
47 * The routines in the corresponding c-file trnio.c
48 * are based on the lower level routines in gmxfio.c
49 * The integer file pointer returned from open_trn
50 * can also be used with the routines in gmxfio.h
52 **************************************************************/
56 typedef struct /* This struct describes the order and the */
57 /* sizes of the structs in a trjfile, sizes are given in bytes. */
59 int ir_size; /* Backward compatibility */
60 int e_size; /* Backward compatibility */
61 int box_size; /* Non zero if a box is present */
62 int vir_size; /* Backward compatibility */
63 int pres_size; /* Backward compatibility */
64 int top_size; /* Backward compatibility */
65 int sym_size; /* Backward compatibility */
66 int x_size; /* Non zero if coordinates are present */
67 int v_size; /* Non zero if velocities are present */
68 int f_size; /* Non zero if forces are present */
70 int natoms; /* The total number of atoms */
71 int step; /* Current step number */
72 int nre; /* Backward compatibility */
73 real t; /* Current time */
74 real lambda; /* Current value of lambda */
77 extern int open_trn(char *fn,char *mode);
78 /* Open a trj / trr file */
80 extern void close_trn(int fp);
83 extern bool fread_trnheader(int fp,t_trnheader *trn,bool *bOK);
84 /* Read the header of a trn file. Return FALSE if there is no frame.
85 * bOK will be FALSE when the header is incomplete.
88 extern void read_trnheader(char *fn,t_trnheader *header);
89 /* Read the header of a trn file from fn, and close the file afterwards.
92 extern void pr_trnheader(FILE *fp,int indent,char *title,t_trnheader *sh);
93 /* Print the header of a trn file to fp */
95 extern bool is_trn(FILE *fp);
96 /* Return true when the file is a trn file. File will be rewound
100 extern void fwrite_trn(int fp,int step,real t,real lambda,
101 rvec *box,int natoms,rvec *x,rvec *v,rvec *f);
102 /* Write a trn frame to file fp, box, x, v, f may be NULL */
104 extern bool fread_htrn(int fp,t_trnheader *sh,
105 rvec *box,rvec *x,rvec *v,rvec *f);
106 /* Extern read a frame except the header (that should be pre-read,
107 * using routine read_trnheader, see above) from a trn file.
108 * Return FALSE on error
111 extern bool fread_trn(int fp,int *step,real *t,real *lambda,
112 rvec *box,int *natoms,rvec *x,rvec *v,rvec *f);
113 /* Read a trn frame, including the header from fp. box, x, v, f may
114 * be NULL, in which case the data will be skipped over.
115 * return FALSE on error
118 extern void write_trn(char *fn,int step,real t,real lambda,
119 rvec *box,int natoms,rvec *x,rvec *v,rvec *f);
120 /* Write a single trn frame to file fn, which is closed afterwards */
122 extern void read_trn(char *fn,int *step,real *t,real *lambda,
123 rvec *box,int *natoms,rvec *x,rvec *v,rvec *);
124 /* Read a single trn frame from file fn, which is closed afterwards