Merge branch 'master' of git@git.gromacs.org:gromacs
[gromacs/rigid-bodies.git] / include / trnio.h
blob5e25e76a8a3784f9848feb71d3506d7eac66e06f
1 /*
2 *
3 * This source code is part of
4 *
5 * G R O M A C S
6 *
7 * GROningen MAchine for Chemical Simulations
8 *
9 * VERSION 3.2.0
10 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12 * Copyright (c) 2001-2004, The GROMACS development team,
13 * check out http://www.gromacs.org for more information.
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * If you want to redistribute modifications, please consider that
21 * scientific software is very special. Version control is crucial -
22 * bugs must be traceable. We will be happy to consider code for
23 * inclusion in the official distribution, but derived work must not
24 * be called official GROMACS. Details are found in the README & COPYING
25 * files - if they are missing, get the official version at www.gromacs.org.
27 * To help us fund GROMACS development, we humbly ask that you cite
28 * the papers on the package - you can find them in the top README file.
30 * For more info, check our website at http://www.gromacs.org
32 * And Hey:
33 * Gromacs Runs On Most of All Computer Systems
36 #ifndef _trnio_h
37 #define _trnio_h
39 #ifdef HAVE_CONFIG_H
40 #include <config.h>
41 #endif
43 /**************************************************************
45 * These routines handle trj (trajectory) I/O, they read and
46 * write trj/trr files. The routines should be able to read single
47 * and double precision files without the user noting it.
48 * The files are backward compatible, therefore the header holds
49 * some unused variables.
51 * The routines in the corresponding c-file trnio.c
52 * are based on the lower level routines in gmxfio.c
53 * The integer file pointer returned from open_trn
54 * can also be used with the routines in gmxfio.h
56 **************************************************************/
58 #include "typedefs.h"
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
64 typedef struct /* This struct describes the order and the */
65 /* sizes of the structs in a trjfile, sizes are given in bytes. */
67 bool bDouble; /* Double precision? */
68 int ir_size; /* Backward compatibility */
69 int e_size; /* Backward compatibility */
70 int box_size; /* Non zero if a box is present */
71 int vir_size; /* Backward compatibility */
72 int pres_size; /* Backward compatibility */
73 int top_size; /* Backward compatibility */
74 int sym_size; /* Backward compatibility */
75 int x_size; /* Non zero if coordinates are present */
76 int v_size; /* Non zero if velocities are present */
77 int f_size; /* Non zero if forces are present */
79 int natoms; /* The total number of atoms */
80 int step; /* Current step number */
81 int nre; /* Backward compatibility */
82 real t; /* Current time */
83 real lambda; /* Current value of lambda */
84 } t_trnheader;
86 extern int open_trn(const char *fn,const char *mode);
87 /* Open a trj / trr file */
89 extern void close_trn(int fp);
90 /* Close it */
92 extern bool fread_trnheader(int fp,t_trnheader *trn,bool *bOK);
93 /* Read the header of a trn file. Return FALSE if there is no frame.
94 * bOK will be FALSE when the header is incomplete.
97 extern void read_trnheader(const char *fn,t_trnheader *header);
98 /* Read the header of a trn file from fn, and close the file afterwards.
101 extern void pr_trnheader(FILE *fp,int indent,char *title,t_trnheader *sh);
102 /* Print the header of a trn file to fp */
104 extern bool is_trn(FILE *fp);
105 /* Return true when the file is a trn file. File will be rewound
106 * afterwards.
109 extern void fwrite_trn(int fp,int step,real t,real lambda,
110 rvec *box,int natoms,rvec *x,rvec *v,rvec *f);
111 /* Write a trn frame to file fp, box, x, v, f may be NULL */
113 extern bool fread_htrn(int fp,t_trnheader *sh,
114 rvec *box,rvec *x,rvec *v,rvec *f);
115 /* Extern read a frame except the header (that should be pre-read,
116 * using routine read_trnheader, see above) from a trn file.
117 * Return FALSE on error
120 extern bool fread_trn(int fp,int *step,real *t,real *lambda,
121 rvec *box,int *natoms,rvec *x,rvec *v,rvec *f);
122 /* Read a trn frame, including the header from fp. box, x, v, f may
123 * be NULL, in which case the data will be skipped over.
124 * return FALSE on error
127 extern void write_trn(const char *fn,int step,real t,real lambda,
128 rvec *box,int natoms,rvec *x,rvec *v,rvec *f);
129 /* Write a single trn frame to file fn, which is closed afterwards */
131 extern void read_trn(const char *fn,int *step,real *t,real *lambda,
132 rvec *box,int *natoms,rvec *x,rvec *v,rvec *f);
133 /* Read a single trn frame from file fn, which is closed afterwards
136 #ifdef __cplusplus
138 #endif
141 #endif