3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
9 * VERSION 3.3.99_development_20071104
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-2006, 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
33 * Groningen Machine for Chemical Simulation
44 #include "gromacs/utility/futil.h"
45 #include "gromacs/commandline/pargs.h"
48 #include "gromacs/utility/fatalerror.h"
49 #include "gromacs/fileio/xtcio.h"
50 #include "gromacs/fileio/enxio.h"
51 #include "gromacs/utility/smalloc.h"
52 #include "gromacs/fileio/gmxfio.h"
53 #include "gromacs/fileio/tpxio.h"
54 #include "gromacs/fileio/trnio.h"
56 #include "gromacs/math/vec.h"
58 static char *nm
[5] = { "OW", "HW1", "HW2", "DW", "SW" };
60 static void list_trn(char *fn
)
62 static real mass
[5] = { 15.9994, 1.008, 1.008, 0.0, 0.0 };
63 int i
,j
=0,m
,fpread
,fpwrite
,nframe
;
64 rvec
*x
,*v
,*f
,fmol
[2],xcm
[2],torque
[j
],dx
;
70 printf("Going to open %s\n",fn
);
71 fpread
= open_trn(fn
,"r");
72 fpwrite
= open_tpx(NULL
,"w");
73 gmx_fio_setdebug(fpwrite
,TRUE
);
75 mmm
=mass
[0]+2*mass
[1];
80 while (fread_trnheader(fpread
,&trn
,&bOK
)) {
84 if (fread_htrn(fpread
,&trn
,
85 trn
.box_size
? box
: NULL
,
86 trn
.x_size
? x
: NULL
,
87 trn
.v_size
? v
: NULL
,
88 trn
.f_size
? f
: NULL
)) {
90 if (trn
.x_size
&& trn
.f_size
) {
91 printf("There are %d atoms\n",trn
.natoms
);
92 for(j
=0; (j
<2); j
++) {
95 clear_rvec(torque
[j
]);
96 for(i
=5*j
; (i
<5*j
+5); i
++) {
97 rvec_inc(fmol
[j
],f
[i
]);
98 for(m
=0; (m
<DIM
); m
++)
99 xcm
[j
][m
] += mass
[i
%5]*x
[i
][m
];
101 for(i
=5*j
; (i
<5*j
+5); i
++) {
102 rvec_dec(x
[i
],xcm
[j
]);
104 rvec_inc(torque
[j
],dx
);
105 rvec_inc(x
[i
],xcm
[j
]);
108 pr_rvecs(stdout
,0,"FMOL ",fmol
,2);
109 pr_rvecs(stdout
,0,"TORQUE",torque
,2);
110 printf("Distance matrix Water1-Water2\n%5s","");
112 printf(" %10s",nm
[j
]);
114 for(j
=0; (j
<5); j
++) {
116 for(i
=5; (i
<10); i
++) {
117 rvec_sub(x
[i
],x
[j
],dx
);
118 len
= sqrt(iprod(dx
,dx
));
119 printf(" %10.7f",len
);
131 fprintf(stderr
,"\nWARNING: Incomplete frame header: nr %d, t=%g\n",
137 int main(int argc
,char *argv
[])
139 static char *desc
[] = {
140 "[TT]gmxdump[tt] reads a run input file ([TT].tpr[tt]),",
141 "a trajectory ([TT].trr[tt]/[TT].xtc[tt]) or an energy",
142 "file ([TT].edr[tt]) and prints that to standard",
143 "output in a readable format. This program is essential for",
144 "checking your run input file in case of problems.[PAR]"
147 { efTRN
, "-f", NULL
, ffOPTRD
}
149 #define NFILE asize(fnm)
152 /* Command line options */
154 CopyRight(stdout
,argv
[0]);
155 parse_common_args(&argc
,argv
,0,NFILE
,fnm
,0,NULL
,
156 asize(desc
),desc
,0,NULL
);
158 if (ftp2bSet(efTRN
,NFILE
,fnm
)) {
159 fn
= ftp2fn(efTRN
,NFILE
,fnm
);
160 printf("Going to open %s\n",fn
);