1 /* -*- mode: c; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- 2 * 3 * $Id$ 4 * 5 /* -*- mode: c; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- 6 * 7 * $Id$ 8 * 9 * Copyright (c) 2009-2014, Erik Lindahl & David van der Spoel 10 * All rights reserved. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions are met: 14 * 15 * 1. Redistributions of source code must retain the above copyright notice, 16 this 17 * list of conditions and the following disclaimer. 18 * 19 * 2. Redistributions in binary form must reproduce the above copyright notice, 20 * this list of conditions and the following disclaimer in the documentation 21 * and/or other materials provided with the distribution. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 ARE 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 */ 35 #ifndef _xdrfile_trr_h 36 #define _xdrfile_trr_h 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 #include "xdrfile.h" 43 44 /* All functions return exdrOK if succesfull. 45 * (error codes defined in xdrfile.h). 46 */ 47 48 typedef struct /* This struct describes the order and the */ 49 /* sizes of the structs in a trjfile, sizes are given in bytes. */ 50 { 51 mybool bDouble; /* Double precision? */ 52 int ir_size; /* Backward compatibility */ 53 int e_size; /* Backward compatibility */ 54 int box_size; /* Non zero if a box is present */ 55 int vir_size; /* Backward compatibility */ 56 int pres_size; /* Backward compatibility */ 57 int top_size; /* Backward compatibility */ 58 int sym_size; /* Backward compatibility */ 59 int x_size; /* Non zero if coordinates are present */ 60 int v_size; /* Non zero if velocities are present */ 61 int f_size; /* Non zero if forces are present */ 62 63 int natoms; /* The total number of atoms */ 64 int step; /* Current step number */ 65 int nre; /* Backward compatibility */ 66 float tf; /* Current time */ 67 float lambdaf; /* Current value of lambda */ 68 double td; /* Current time */ 69 double lambdad; /* Current value of lambda */ 70 } t_trnheader; 71 72 /* This function returns the number of atoms in the trr file in *natoms */ 73 extern int read_trr_natoms(char *fn, int *natoms); 74 75 /* Read one frame of an open trr file. If either of x,v,f,box are 76 NULL the arrays will be read from the file but not used. */ 77 extern int read_trr(XDRFILE *xd, int natoms, int *step, float *t, float *lambda, 78 matrix box, rvec *x, rvec *v, rvec *f, int *has_prop); 79 80 /* Write a frame to trr file */ 81 extern int write_trr(XDRFILE *xd, int natoms, int step, float t, float lambda, 82 matrix box, rvec *x, rvec *v, rvec *f); 83 84 /* unpack header of current frame */ 85 extern int do_trnheader(XDRFILE *xd, mybool bRead, t_trnheader *sh); 86 87 /* Flags to signal the update of pos/vel/forces */ 88 #define HASX 1 89 #define HASV 2 90 #define HASF 4 91 92 #ifdef __cplusplus 93 } 94 #endif 95 96 #endif 97