Fixing copyright issues and code contributors
[alexxy/gromacs.git] / include / tpxio.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5  * Copyright (c) 2001-2004, The GROMACS development team,
6  * check out http://www.gromacs.org for more information.
7  * Copyright (c) 2012,2013, by the GROMACS development team, led by
8  * David van der Spoel, Berk Hess, Erik Lindahl, and including many
9  * others, as listed in the AUTHORS file in the top-level source
10  * directory and at http://www.gromacs.org.
11  *
12  * GROMACS is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public License
14  * as published by the Free Software Foundation; either version 2.1
15  * of the License, or (at your option) any later version.
16  *
17  * GROMACS is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with GROMACS; if not, see
24  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
26  *
27  * If you want to redistribute modifications to GROMACS, please
28  * consider that scientific software is very special. Version
29  * control is crucial - bugs must be traceable. We will be happy to
30  * consider code for inclusion in the official distribution, but
31  * derived work must not be called official GROMACS. Details are found
32  * in the README & COPYING files - if they are missing, get the
33  * official version at http://www.gromacs.org.
34  *
35  * To help us fund GROMACS development, we humbly ask that you cite
36  * the research papers on the package. Check out http://www.gromacs.org.
37  */
38
39 #ifndef _tpxio_h
40 #define _tpxio_h
41
42
43   /**************************************************************
44    *
45    * The routines in the corresponding c-file tpxio.c
46    * are based on the lower level routines in gmxfio.c
47    * The integer file pointer returned from open_tpx
48    * can also be used with the routines in gmxfio.h
49    *
50    **************************************************************/
51 #include "visibility.h"
52 #include "typedefs.h"
53 #include "gmxfio.h"
54
55 #ifdef __cplusplus 
56 extern "C" {
57 #endif
58
59 typedef struct
60 {
61   int   bIr;            /* Non zero if input_rec is present             */
62   int   bBox;           /* Non zero if a box is present                 */
63   int   bTop;           /* Non zero if a topology is present            */
64   int   bX;             /* Non zero if coordinates are present          */
65   int   bV;             /* Non zero if velocities are present           */
66   int   bF;             /* Non zero if forces are present               */
67
68   int   natoms;         /* The total number of atoms                    */
69   int   ngtc;           /* The number of temperature coupling groups    */
70   real  lambda;         /* Current value of lambda                      */
71   int   fep_state;      /* Current value of the alchemical state --
72                          * not yet printed out.  */
73   /*a better decision will eventually (5.0 or later) need to be made
74     on how to treat the alchemical state of the system, which can now
75     vary through a simulation, and cannot be completely described
76     though a single lambda variable, or even a single state
77     index. Eventually, should probably be a vector. MRS*/
78 } t_tpxheader;
79
80 /* 
81  * These routines handle reading and writing of preprocessed
82  * topology files in any of the following formats:
83  * TPR : topology in XDR format, portable accross platforms
84  * TPB : binary topology, not portable accross platforms
85  * TPA : ascii topology (possibbly huge)
86  * TRR : trajectory in XDR format (non compressed)
87  * TRJ : trajectory in binary format
88  *
89  * Files are written in the precision with which the source are compiled,
90  * but double and single precision can be read by either.
91  */
92
93 GMX_LIBGMX_EXPORT
94 t_fileio *open_tpx(const char *fn, const char *mode);
95 /* Return an file pointer corresponding to the file you have just opened */
96   
97 GMX_LIBGMX_EXPORT
98 void close_tpx(t_fileio *fio);
99 /*  Close the file corresponding to fio */
100   
101 GMX_LIBGMX_EXPORT
102 void read_tpxheader(const char *fn, t_tpxheader *tpx, gmx_bool TopOnlyOK,
103                            int *version, int *generation);
104 /* Read the header from a tpx file and then close it again.
105  * By setting TopOnlyOK to true, it is possible to read future
106  * versions too (we skip the changed inputrec), provided we havent
107  * changed the topology description. If it is possible to read
108  * the inputrec it will still be done even if TopOnlyOK is TRUE.
109  *
110  * The version and generation if the topology (see top of tpxio.c)
111  * are returned in the two last arguments.
112  */
113
114 GMX_LIBGMX_EXPORT
115 void write_tpx_state(const char *fn,
116                             t_inputrec *ir,t_state *state,gmx_mtop_t *mtop);
117 /* Write a file, and close it again. 
118  * If fn == NULL, an efTPA file will be written to stdout (which
119  * will not be closed afterwards)
120  */
121
122 GMX_LIBGMX_EXPORT
123 void read_tpx_state(const char *fn,
124                            t_inputrec *ir,t_state *state,rvec *f,
125                            gmx_mtop_t *mtop);
126 GMX_LIBGMX_EXPORT
127 int read_tpx(const char *fn,
128                     t_inputrec *ir,matrix box,int *natoms,
129                     rvec *x,rvec *v,rvec *f,gmx_mtop_t *mtop);
130 /* Read a file, and close it again. 
131  * If fn == NULL, an efTPA file will be read from stdin (which
132  * will not be closed afterwards)
133  * When step, t or lambda are NULL they will not be stored.
134  * Returns ir->ePBC, if it could be read from the file.
135  */
136
137 GMX_LIBGMX_EXPORT
138 int read_tpx_top(const char *fn,
139                         t_inputrec *ir, matrix box,int *natoms,
140                         rvec *x,rvec *v,rvec *f,t_topology *top);
141 /* As read_tpx, but for the old t_topology struct */
142
143 GMX_LIBGMX_EXPORT
144 gmx_bool fn2bTPX(const char *file);
145 /* return if *file is one of the TPX file types */ 
146
147 GMX_LIBGMX_EXPORT
148 gmx_bool read_tps_conf(const char *infile,char *title,t_topology *top,
149                           int *ePBC, rvec **x,rvec **v,matrix box,gmx_bool bMass);
150 /* Read title, top.atoms, x, v (if not NULL) and box from an STX file,
151  * memory for atoms, x and v will be allocated.  
152  * Return TRUE if a complete topology was read. 
153  * If infile is a TPX file read the whole top,
154  * else if bMass=TRUE, read the masses into top.atoms from the mass database.
155  */
156
157 void tpx_make_chain_identifiers(t_atoms *atoms,t_block *mols);
158         
159 #ifdef __cplusplus
160 }
161 #endif
162
163 #endif