2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2006, 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.
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.
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.
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.
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.
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.
52 #include "gmx_fatal.h"
62 static char *nm[5] = { "OW", "HW1", "HW2", "DW", "SW" };
64 static void list_trn(char *fn)
66 static real mass[5] = { 15.9994, 1.008, 1.008, 0.0, 0.0 };
67 int i,j=0,m,fpread,fpwrite,nframe;
68 rvec *x,*v,*f,fmol[2],xcm[2],torque[j],dx;
74 printf("Going to open %s\n",fn);
75 fpread = open_trn(fn,"r");
76 fpwrite = open_tpx(NULL,"w");
77 gmx_fio_setdebug(fpwrite,TRUE);
79 mmm=mass[0]+2*mass[1];
84 while (fread_trnheader(fpread,&trn,&bOK)) {
88 if (fread_htrn(fpread,&trn,
89 trn.box_size ? box : NULL,
90 trn.x_size ? x : NULL,
91 trn.v_size ? v : NULL,
92 trn.f_size ? f : NULL)) {
94 if (trn.x_size && trn.f_size) {
95 printf("There are %d atoms\n",trn.natoms);
96 for(j=0; (j<2); j++) {
99 clear_rvec(torque[j]);
100 for(i=5*j; (i<5*j+5); i++) {
101 rvec_inc(fmol[j],f[i]);
102 for(m=0; (m<DIM); m++)
103 xcm[j][m] += mass[i%5]*x[i][m];
105 for(i=5*j; (i<5*j+5); i++) {
106 rvec_dec(x[i],xcm[j]);
108 rvec_inc(torque[j],dx);
109 rvec_inc(x[i],xcm[j]);
112 pr_rvecs(stdout,0,"FMOL ",fmol,2);
113 pr_rvecs(stdout,0,"TORQUE",torque,2);
114 printf("Distance matrix Water1-Water2\n%5s","");
116 printf(" %10s",nm[j]);
118 for(j=0; (j<5); j++) {
120 for(i=5; (i<10); i++) {
121 rvec_sub(x[i],x[j],dx);
122 len = sqrt(iprod(dx,dx));
123 printf(" %10.7f",len);
135 fprintf(stderr,"\nWARNING: Incomplete frame header: nr %d, t=%g\n",
141 int main(int argc,char *argv[])
143 static char *desc[] = {
144 "[TT]gmxdump[tt] reads a run input file ([TT].tpa[tt]/[TT].tpr[tt]/[TT].tpb[tt]),",
145 "a trajectory ([TT].trj[tt]/[TT].trr[tt]/[TT].xtc[tt]) or an energy",
146 "file ([TT].ene[tt]/[TT].edr[tt]) and prints that to standard",
147 "output in a readable format. This program is essential for",
148 "checking your run input file in case of problems.[PAR]"
151 { efTRN, "-f", NULL, ffOPTRD }
153 #define NFILE asize(fnm)
156 /* Command line options */
158 CopyRight(stdout,argv[0]);
159 parse_common_args(&argc,argv,0,NFILE,fnm,0,NULL,
160 asize(desc),desc,0,NULL);
162 if (ftp2bSet(efTRN,NFILE,fnm)) {
163 fn = ftp2fn(efTRN,NFILE,fnm);
164 printf("Going to open %s\n",fn);