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/fileio/futil.h"
45 #include "gromacs/commandline/pargs.h"
49 #include "gmx_fatal.h"
50 #include "gromacs/fileio/xtcio.h"
51 #include "gromacs/fileio/enxio.h"
53 #include "gromacs/fileio/gmxfio.h"
54 #include "gromacs/fileio/tpxio.h"
55 #include "gromacs/fileio/trnio.h"
59 static char *nm
[5] = { "OW", "HW1", "HW2", "DW", "SW" };
61 static void list_trn(char *fn
)
63 static real mass
[5] = { 15.9994, 1.008, 1.008, 0.0, 0.0 };
64 int i
,j
=0,m
,fpread
,fpwrite
,nframe
;
65 rvec
*x
,*v
,*f
,fmol
[2],xcm
[2],torque
[j
],dx
;
71 printf("Going to open %s\n",fn
);
72 fpread
= open_trn(fn
,"r");
73 fpwrite
= open_tpx(NULL
,"w");
74 gmx_fio_setdebug(fpwrite
,TRUE
);
76 mmm
=mass
[0]+2*mass
[1];
81 while (fread_trnheader(fpread
,&trn
,&bOK
)) {
85 if (fread_htrn(fpread
,&trn
,
86 trn
.box_size
? box
: NULL
,
87 trn
.x_size
? x
: NULL
,
88 trn
.v_size
? v
: NULL
,
89 trn
.f_size
? f
: NULL
)) {
91 if (trn
.x_size
&& trn
.f_size
) {
92 printf("There are %d atoms\n",trn
.natoms
);
93 for(j
=0; (j
<2); j
++) {
96 clear_rvec(torque
[j
]);
97 for(i
=5*j
; (i
<5*j
+5); i
++) {
98 rvec_inc(fmol
[j
],f
[i
]);
99 for(m
=0; (m
<DIM
); m
++)
100 xcm
[j
][m
] += mass
[i
%5]*x
[i
][m
];
102 for(i
=5*j
; (i
<5*j
+5); i
++) {
103 rvec_dec(x
[i
],xcm
[j
]);
105 rvec_inc(torque
[j
],dx
);
106 rvec_inc(x
[i
],xcm
[j
]);
109 pr_rvecs(stdout
,0,"FMOL ",fmol
,2);
110 pr_rvecs(stdout
,0,"TORQUE",torque
,2);
111 printf("Distance matrix Water1-Water2\n%5s","");
113 printf(" %10s",nm
[j
]);
115 for(j
=0; (j
<5); j
++) {
117 for(i
=5; (i
<10); i
++) {
118 rvec_sub(x
[i
],x
[j
],dx
);
119 len
= sqrt(iprod(dx
,dx
));
120 printf(" %10.7f",len
);
132 fprintf(stderr
,"\nWARNING: Incomplete frame header: nr %d, t=%g\n",
138 int main(int argc
,char *argv
[])
140 static char *desc
[] = {
141 "[TT]gmxdump[tt] reads a run input file ([TT].tpa[tt]/[TT].tpr[tt]/[TT].tpb[tt]),",
142 "a trajectory ([TT].trj[tt]/[TT].trr[tt]/[TT].xtc[tt]) or an energy",
143 "file ([TT].ene[tt]/[TT].edr[tt]) and prints that to standard",
144 "output in a readable format. This program is essential for",
145 "checking your run input file in case of problems.[PAR]"
148 { efTRN
, "-f", NULL
, ffOPTRD
}
150 #define NFILE asize(fnm)
153 /* Command line options */
155 CopyRight(stdout
,argv
[0]);
156 parse_common_args(&argc
,argv
,0,NFILE
,fnm
,0,NULL
,
157 asize(desc
),desc
,0,NULL
);
159 if (ftp2bSet(efTRN
,NFILE
,fnm
)) {
160 fn
= ftp2fn(efTRN
,NFILE
,fnm
);
161 printf("Going to open %s\n",fn
);