Tagged files with gromacs 3.0 header and added some license info
[alexxy/gromacs.git] / include / tpxio.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 _tpxio_h
38 #define _tpxio_h
39
40 static char *SRCID_tpxio_h = "$Id$";
41 #ifdef HAVE_CONFIG_H
42 #include <config.h>
43 #endif
44
45 #ifdef CPLUSPLUS 
46 extern "C" {
47 #endif
48
49   /**************************************************************
50    *
51    * The routines in the corresponding c-file tpxio.c
52    * are based on the lower level routines in gmxfio.c
53    * The integer file pointer returned from open_tpx
54    * can also be used with the routines in gmxfio.h
55    *
56    **************************************************************/
57 #include "typedefs.h"
58 #include "xdrf.h"
59
60 typedef struct
61 {
62   int   bIr;            /* Non zero if input_rec is present             */
63   int   bBox;           /* Non zero if a box is present                 */
64   int   bTop;           /* Non zero if a topology is present            */
65   int   bX;             /* Non zero if coordinates are present          */
66   int   bV;             /* Non zero if velocities are present           */
67   int   bF;             /* Non zero if forces are present               */
68
69   int   natoms;         /* The total number of atoms                    */
70   int   step;           /* Current step number                          */
71   real  t;              /* Current time                                 */
72   real  lambda;         /* Current value of lambda                      */
73 } t_tpxheader;
74
75 /* 
76  * These routines handle reading and writing of preprocessed
77  * topology files in any of the following formats:
78  * TPR : topology in XDR format, portable accross platforms
79  * TPB : binary topology, not portable accross platforms
80  * TPA : ascii topology (possibbly huge)
81  * TRR : trajectory in XDR format (non compressed)
82  * TRJ : trajectory in binary format
83  *
84  * Files are written in the precision with which the source are compiled,
85  * but double and single precision can be read by either.
86  */
87
88 extern int open_tpx(char *fn,char *mode);
89 /* Return an integer corresponding to the file you have just opened */
90   
91 extern void close_tpx(int fp);
92 /*  Close the file corresponding to fp */
93   
94 extern void read_tpxheader(char *fn,t_tpxheader *tpx);
95 /* Read the header from a tpx file and then close it again */
96
97 extern void write_tpx(char *fn,int step,real t,real lambda,
98                       t_inputrec *ir,rvec *box,int natoms,
99                       rvec *x,rvec *v,rvec *f,t_topology *top);
100 /* Write a file, and close it again. 
101  * If fn == NULL, an efTPA file will be written to stdout (which
102  * will not be closed afterwards)
103  */
104
105 extern void read_tpx(char *fn,int *step,real *t,real *lambda,
106                      t_inputrec *ir,rvec *box,int *natoms,
107                      rvec *x,rvec *v,rvec *f,t_topology *top);
108 /* Read a file, and close it again. 
109  * If fn == NULL, an efTPA file will be read from stdin (which
110  * will not be closed afterwards)
111  */
112
113 extern void fwrite_tpx(int fp,int step,real t,real lambda,
114                        t_inputrec *ir,rvec *box,int natoms,
115                        rvec *x,rvec *v,rvec *f,t_topology *top);
116 /* Write a file, and do not close it */
117
118 extern void fread_tpx(int fp,int *step,real *t,real *lambda,
119                       t_inputrec *ir,rvec *box,int *natoms,
120                       rvec *x,rvec *v,rvec *f,t_topology *top);
121 /* Read a file, and do not close it */
122
123 extern bool fn2bTPX(char *file);
124 /* return if *file is one of the TPX file types */ 
125
126 extern bool read_tps_conf(char *infile,char *title,t_topology *top,
127                           rvec **x,rvec **v,matrix box,bool bMass);
128 /* Read title, top.atoms, x, v (if not NULL) and box from an STX file,
129  * memory for atoms, x and v will be allocated.  
130  * Return TRUE if a complete topology was read. 
131  * If infile is a TPX file read the whole top,
132  * else if bMass=TRUE, read the masses into top.atoms from the mass database.
133  */
134
135 #ifdef CPLUSPLUS
136 }
137 #endif
138
139 #endif