4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
11 * Copyright (c) 1991-2001, University of Groningen, The Netherlands
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * If you want to redistribute modifications, please consider that
18 * scientific software is very special. Version control is crucial -
19 * bugs must be traceable. We will be happy to consider code for
20 * inclusion in the official distribution, but derived work must not
21 * be called official GROMACS. Details are found in the README & COPYING
22 * files - if they are missing, get the official version at www.gromacs.org.
24 * To help us fund GROMACS development, we humbly ask that you cite
25 * the papers on the package - you can find them in the top README file.
27 * For more info, check our website at http://www.gromacs.org
30 * GROningen Mixture of Alchemy and Childrens' Stories
32 static char *SRCID_gmxdump_c
= "$Id$";
54 static void list_tpx(char *fn
)
56 int step
,natoms
,fp
,indent
,i
,j
,**gcount
,atot
;
64 read_tpxheader(fn
,&tpx
);
68 read_tpx(fn
,&step
,&t
,&lambda
,
70 tpx
.bBox
? box
: NULL
,
75 tpx
.bTop
? &top
: NULL
);
77 if (available(stdout
,&tpx
,fn
)) {
79 indent
=pr_title(stdout
,indent
,fn
);
80 pr_header(stdout
,indent
,"header",&(tpx
));
81 pr_inputrec(stdout
,indent
,"ir",&(ir
));
82 pr_rvecs(stdout
,indent
,"box",box
,DIM
);
83 pr_rvecs(stdout
,indent
,"x",x
,natoms
);
84 pr_rvecs(stdout
,indent
,"v",v
,natoms
);
85 pr_rvecs(stdout
,indent
,"f",f
,natoms
);
86 pr_top(stdout
,indent
,"topology",&(top
));
90 for(i
=0; (i
<egcNR
); i
++)
91 snew(gcount
[i
],top
.atoms
.grps
[i
].nr
);
93 for(i
=0; (i
<top
.atoms
.nr
); i
++) {
94 for(j
=0; (j
<egcNR
); j
++)
95 gcount
[j
][top
.atoms
.atom
[i
].grpnr
[j
]]++;
97 printf("Group statistics\n");
98 for(i
=0; (i
<egcNR
); i
++) {
100 printf("%-12s: ",gtypes
[i
]);
101 for(j
=0; (j
<top
.atoms
.grps
[i
].nr
); j
++) {
102 printf(" %5d",gcount
[i
][j
]);
105 printf(" (total %d atoms)\n",atot
);
115 static void list_trn(char *fn
)
117 int fpread
,fpwrite
,nframe
,indent
;
124 fpread
= open_trn(fn
,"r");
125 fpwrite
= open_tpx(NULL
,"w");
126 fio_setdebug(fpwrite
,TRUE
);
129 while (fread_trnheader(fpread
,&trn
,&bOK
)) {
133 if (fread_htrn(fpread
,&trn
,
134 trn
.box_size
? box
: NULL
,
135 trn
.x_size
? x
: NULL
,
136 trn
.v_size
? v
: NULL
,
137 trn
.f_size
? f
: NULL
)) {
138 sprintf(buf
,"%s frame %d",fn
,nframe
);
140 indent
=pr_title(stdout
,indent
,buf
);
141 pr_indent(stdout
,indent
);
142 fprintf(stdout
,"natoms=%10d step=%10d time=%10g lambda=%10g\n",
143 trn
.natoms
,trn
.step
,trn
.t
,trn
.lambda
);
145 pr_rvecs(stdout
,indent
,"box",box
,DIM
);
147 pr_rvecs(stdout
,indent
,"x",x
,trn
.natoms
);
149 pr_rvecs(stdout
,indent
,"v",v
,trn
.natoms
);
151 pr_rvecs(stdout
,indent
,"f",f
,trn
.natoms
);
154 fprintf(stderr
,"\nWARNING: Incomplete frame: nr %d, t=%g\n",
163 fprintf(stderr
,"\nWARNING: Incomplete frame header: nr %d, t=%g\n",
169 void list_xtc(char *fn
, bool bXVG
)
175 int nframe
,natoms
,step
;
179 xd
= open_xtc(fn
,"r");
180 read_first_xtc(xd
,&natoms
,&step
,&time
,box
,&x
,&prec
,&bOK
);
187 fprintf(stdout
,"%g",time
);
188 for(i
=0; i
<natoms
; i
++)
190 fprintf(stdout
," %g",x
[i
][d
]);
191 fprintf(stdout
,"\n");
193 sprintf(buf
,"%s frame %d",fn
,nframe
);
195 indent
=pr_title(stdout
,indent
,buf
);
196 pr_indent(stdout
,indent
);
197 fprintf(stdout
,"natoms=%10d step=%10d time=%10g prec=%10g\n",
198 natoms
,step
,time
,prec
);
199 pr_rvecs(stdout
,indent
,"box",box
,DIM
);
200 pr_rvecs(stdout
,indent
,"x",x
,natoms
);
203 } while (read_next_xtc(xd
,natoms
,&step
,&time
,box
,x
,&prec
,&bOK
));
205 fprintf(stderr
,"\nWARNING: Incomplete frame at time %g\n",time
);
209 void list_trx(char *fn
,bool bXVG
)
216 else if ((ftp
== efTRR
) || (ftp
== efTRJ
))
219 fprintf(stderr
,"File %s not supported. Try using more %s\n",
223 void list_ene(char *fn
)
232 printf("gmxdump: %s\n",fn
);
233 in
= open_enx(fn
,"r");
234 do_enxnms(in
,&nre
,&enm
);
236 printf("energy components:\n");
237 for(i
=0; (i
<nre
); i
++)
238 printf("%5d %s\n",i
,enm
[i
]);
244 assert(fr
->nre
==nre
);
247 printf("\n%24s %12.5e %12s %12d\n","time:",
248 fr
->t
,"step:",fr
->step
);
249 printf("%24s %12s %12s %12s\n",
250 "Component","Energy","Av. Energy","Sum Energy");
251 for(i
=0; (i
<nre
); i
++)
252 printf("%24s %12.5e %12.5e %12.5e\n",
253 enm
[i
],fr
->ener
[i
].e
,fr
->ener
[i
].eav
,fr
->ener
[i
].esum
);
254 if (fr
->ndisre
> 0) {
255 printf("Distance restraint %8s %8s\n","r(t)","< r >");
256 for(i
=0; i
<fr
->ndisre
; i
++) {
257 rav
=pow(fr
->rav
[i
],minthird
);
258 printf("%17d %8.4f %8.4f\n",i
,fr
->rt
[i
],rav
);
261 for(b
=0; b
<fr
->nblock
; b
++)
263 printf("Block data %2d (%4d elm.) %8s\n",b
,fr
->nr
[b
],"value");
264 for(i
=0; i
<fr
->nr
[b
]; i
++)
265 printf("%24d %8.4f\n",i
,fr
->block
[b
][i
]);
277 int main(int argc
,char *argv
[])
279 static char *desc
[] = {
280 "gmxdump reads a run input file ([TT].tpa[tt]/[TT].tpr[tt]/[TT].tpb[tt]),",
281 "a trajectory ([TT].trj[tt]/[TT].trr[tt]/[TT].xtc[tt]) or an energy",
282 "file ([TT].ene[tt]/[TT].edr[tt]) and prints that to standard",
283 "output in a readable format. This program is essential for",
284 "checking your run input file in case of problems.[PAR]"
287 { efTPX
, "-s", NULL
, ffOPTRD
},
288 { efTRX
, "-f", NULL
, ffOPTRD
},
289 { efENX
, "-e", NULL
, ffOPTRD
},
291 #define NFILE asize(fnm)
293 /* Command line options */
294 static bool bXVG
=FALSE
;
295 static bool bShowNumbers
=TRUE
;
297 { "-xvg", FALSE
, etBOOL
, {&bXVG
}, "HIDDENXVG layout for xtc" },
298 { "-nr",FALSE
, etBOOL
, {&bShowNumbers
},"Show index numbers in output (leaving them out makes comparison easier, but creates a useless topology)" }
301 CopyRight(stderr
,argv
[0]);
302 parse_common_args(&argc
,argv
,0,NFILE
,fnm
,asize(pa
),pa
,
303 asize(desc
),desc
,0,NULL
);
305 pr_shownumbers(bShowNumbers
);
306 if (ftp2bSet(efTPX
,NFILE
,fnm
))
307 list_tpx(ftp2fn(efTPX
,NFILE
,fnm
));
309 if (ftp2bSet(efTRX
,NFILE
,fnm
))
310 list_trx(ftp2fn(efTRX
,NFILE
,fnm
),bXVG
);
312 if (ftp2bSet(efENX
,NFILE
,fnm
))
313 list_ene(ftp2fn(efENX
,NFILE
,fnm
));