4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
11 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
12 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
13 * Copyright (c) 2001-2004, The GROMACS development team,
14 * check out http://www.gromacs.org for more information.
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 * For more info, check our website at http://www.gromacs.org
34 * Giving Russians Opium May Alter Current Situation
57 static char *nm[5] = { "OW", "HW1", "HW2", "DW", "SW" };
59 static void list_trn(char *fn)
61 static real mass[5] = { 15.9994, 1.008, 1.008, 0.0, 0.0 };
62 int i,j=0,m,fpread,fpwrite,nframe;
63 rvec *x,*v,*f,fmol[2],xcm[2],torque[j],dx;
69 printf("Going to open %s\n",fn);
70 fpread = open_trn(fn,"r");
71 fpwrite = open_tpx(NULL,"w");
72 fio_setdebug(fpwrite,TRUE);
74 mmm=mass[0]+2*mass[1];
79 while (fread_trnheader(fpread,&trn,&bOK)) {
83 if (fread_htrn(fpread,&trn,
84 trn.box_size ? box : NULL,
85 trn.x_size ? x : NULL,
86 trn.v_size ? v : NULL,
87 trn.f_size ? f : NULL)) {
89 if (trn.x_size && trn.f_size) {
90 printf("There are %d atoms\n",trn.natoms);
91 for(j=0; (j<2); j++) {
94 clear_rvec(torque[j]);
95 for(i=5*j; (i<5*j+5); i++) {
96 rvec_inc(fmol[j],f[i]);
97 for(m=0; (m<DIM); m++)
98 xcm[j][m] += mass[i%5]*x[i][m];
100 for(i=5*j; (i<5*j+5); i++) {
101 rvec_dec(x[i],xcm[j]);
103 rvec_inc(torque[j],dx);
104 rvec_inc(x[i],xcm[j]);
107 pr_rvecs(stdout,0,"FMOL ",fmol,2);
108 pr_rvecs(stdout,0,"TORQUE",torque,2);
109 printf("Distance matrix Water1-Water2\n%5s","");
111 printf(" %10s",nm[j]);
113 for(j=0; (j<5); j++) {
115 for(i=5; (i<10); i++) {
116 rvec_sub(x[i],x[j],dx);
117 len = sqrt(iprod(dx,dx));
118 printf(" %10.7f",len);
130 fprintf(stderr,"\nWARNING: Incomplete frame header: nr %d, t=%g\n",
136 int main(int argc,char *argv[])
138 static char *desc[] = {
139 "gmxdump reads a run input file ([TT].tpa[tt]/[TT].tpr[tt]/[TT].tpb[tt]),",
140 "a trajectory ([TT].trj[tt]/[TT].trr[tt]/[TT].xtc[tt]) or an energy",
141 "file ([TT].ene[tt]/[TT].edr[tt]) and prints that to standard",
142 "output in a readable format. This program is essential for",
143 "checking your run input file in case of problems.[PAR]"
146 { efTRN, "-f", NULL, ffOPTRD }
148 #define NFILE asize(fnm)
151 /* Command line options */
153 CopyRight(stdout,argv[0]);
154 parse_common_args(&argc,argv,0,NFILE,fnm,0,NULL,
155 asize(desc),desc,0,NULL);
157 if (ftp2bSet(efTRN,NFILE,fnm)) {
158 fn = ftp2fn(efTRN,NFILE,fnm);
159 printf("Going to open %s\n",fn);