4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
12 * Copyright (c) 1991-2001
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
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.
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.
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.
31 * Do check out http://www.gromacs.org , or mail us at gromacs@gromacs.org .
34 * Good ROcking Metal Altar for Chronical Sinners
40 static char *SRCID_tpxio_h = "$Id$";
49 /**************************************************************
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
56 **************************************************************/
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 */
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 */
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
84 * Files are written in the precision with which the source are compiled,
85 * but double and single precision can be read by either.
88 extern int open_tpx(char *fn,char *mode);
89 /* Return an integer corresponding to the file you have just opened */
91 extern void close_tpx(int fp);
92 /* Close the file corresponding to fp */
94 extern void read_tpxheader(char *fn,t_tpxheader *tpx);
95 /* Read the header from a tpx file and then close it again */
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)
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)
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 */
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 */
123 extern bool fn2bTPX(char *file);
124 /* return if *file is one of the TPX file types */
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.