Tagged files with gromacs 3.0 header and added some license info
[alexxy/gromacs.git] / include / trnio.h
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 3.0
11  * 
12  * Copyright (c) 1991-2001
13  * BIOSON Research Institute, Dept. of Biophysical Chemistry
14  * University of Groningen, The Netherlands
15  * 
16  * This program is free software; you can redistribute it and/or
17  * modify it under the terms of the GNU General Public License
18  * as published by the Free Software Foundation; either version 2
19  * of the License, or (at your option) any later version.
20  * 
21  * If you want to redistribute modifications, please consider that
22  * scientific software is very special. Version control is crucial -
23  * bugs must be traceable. We will be happy to consider code for
24  * inclusion in the official distribution, but derived work must not
25  * be called official GROMACS. Details are found in the README & COPYING
26  * files - if they are missing, get the official version at www.gromacs.org.
27  * 
28  * To help us fund GROMACS development, we humbly ask that you cite
29  * the papers on the package - you can find them in the top README file.
30  * 
31  * Do check out http://www.gromacs.org , or mail us at gromacs@gromacs.org .
32  * 
33  * And Hey:
34  * Good ROcking Metal Altar for Chronical Sinners
35  */
36
37 #ifndef _trnio_h
38 #define _trnio_h
39
40 static char *SRCID_trnio_h = "$Id$";
41 #ifdef HAVE_CONFIG_H
42 #include <config.h>
43 #endif
44
45 /**************************************************************
46  *
47  * These routines handle trj (trajectory) I/O, they read and
48  * write trj/trr files. The routines should be able to read single
49  * and double precision files without the user noting it.
50  * The files are backward compatible, therefore the header holds
51  * some unused variables.
52  *
53  * The routines in the corresponding c-file trnio.c
54  * are based on the lower level routines in gmxfio.c
55  * The integer file pointer returned from open_trn
56  * can also be used with the routines in gmxfio.h
57  *
58  **************************************************************/
59         
60 #include "typedefs.h"
61
62 typedef struct          /* This struct describes the order and the      */
63   /* sizes of the structs in a trjfile, sizes are given in bytes.       */
64 {
65   int   ir_size;        /* Backward compatibility                       */
66   int   e_size;         /* Backward compatibility                       */
67   int   box_size;       /* Non zero if a box is present                 */
68   int   vir_size;       /* Backward compatibility                       */
69   int   pres_size;      /* Backward compatibility                       */
70   int   top_size;       /* Backward compatibility                       */
71   int   sym_size;       /* Backward compatibility                       */
72   int   x_size;         /* Non zero if coordinates are present          */
73   int   v_size;         /* Non zero if velocities are present           */
74   int   f_size;         /* Non zero if forces are present               */
75
76   int   natoms;         /* The total number of atoms                    */
77   int   step;           /* Current step number                          */
78   int   nre;            /* Backward compatibility                       */
79   real  t;              /* Current time                                 */
80   real  lambda;         /* Current value of lambda                      */
81 } t_trnheader;
82
83 extern int open_trn(char *fn,char *mode);
84 /* Open a trj / trr file */
85
86 extern void close_trn(int fp);
87 /* Close it */
88
89 extern bool fread_trnheader(int fp,t_trnheader *trn,bool *bOK);
90 /* Read the header of a trn file. Return FALSE if there is no frame.
91  * bOK will be FALSE when the header is incomplete.
92  */
93
94 extern void read_trnheader(char *fn,t_trnheader *header);
95 /* Read the header of a trn file from fn, and close the file afterwards. 
96  */
97
98 extern void pr_trnheader(FILE *fp,int indent,char *title,t_trnheader *sh);
99 /* Print the header of a trn file to fp */
100
101 extern bool is_trn(FILE *fp);
102 /* Return true when the file is a trn file. File will be rewound
103  * afterwards.
104  */
105
106 extern void fwrite_trn(int fp,int step,real t,real lambda,
107                        rvec *box,int natoms,rvec *x,rvec *v,rvec *f);
108 /* Write a trn frame to file fp, box, x, v, f may be NULL */
109
110 extern bool fread_htrn(int fp,t_trnheader *sh,
111                        rvec *box,rvec *x,rvec *v,rvec *f);
112 /* Extern read a frame except the header (that should be pre-read,
113  * using routine read_trnheader, see above) from a trn file.
114  * Return FALSE on error
115  */
116  
117 extern bool fread_trn(int fp,int *step,real *t,real *lambda,
118                       rvec *box,int *natoms,rvec *x,rvec *v,rvec *f);
119 /* Read a trn frame, including the header from fp. box, x, v, f may
120  * be NULL, in which case the data will be skipped over.
121  * return FALSE on error
122  */
123  
124 extern void write_trn(char *fn,int step,real t,real lambda,
125                       rvec *box,int natoms,rvec *x,rvec *v,rvec *f);
126 /* Write a single trn frame to file fn, which is closed afterwards */
127
128 extern void read_trn(char *fn,int *step,real *t,real *lambda,
129                      rvec *box,int *natoms,rvec *x,rvec *v,rvec *);
130 /* Read a single trn frame from file fn, which is closed afterwards 
131  */
132
133 #endif