3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
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-2004, 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 * Gallium Rubidium Oxygen Manganese Argon Carbon Silicon
50 #include "gmx_fatal.h"
60 #include "checkpoint.h"
61 #include "mtop_util.h"
62 #include "sparsematrix.h"
66 static void list_tpx(const char *fn, gmx_bool bShowNumbers,const char *mdpfn,
70 int fp,indent,i,j,**gcount,atot;
79 read_tpxheader(fn,&tpx,TRUE,NULL,NULL);
83 &state,tpx.bF ? f : NULL,
84 tpx.bTop ? &mtop: NULL);
86 if (mdpfn && tpx.bIr) {
87 gp = gmx_fio_fopen(mdpfn,"w");
88 pr_inputrec(gp,0,NULL,&(ir),TRUE);
94 top = gmx_mtop_t_to_t_topology(&mtop);
96 if (available(stdout,&tpx,0,fn)) {
98 indent=pr_title(stdout,indent,fn);
99 pr_inputrec(stdout,0,"inputrec",tpx.bIr ? &(ir) : NULL,FALSE);
102 pr_header(stdout,indent,"header",&(tpx));
105 pr_mtop(stdout,indent,"topology",&(mtop),bShowNumbers);
107 pr_top(stdout,indent,"topology",&(top),bShowNumbers);
109 pr_rvecs(stdout,indent,"box",tpx.bBox ? state.box : NULL,DIM);
110 pr_rvecs(stdout,indent,"box_rel",tpx.bBox ? state.box_rel : NULL,DIM);
111 pr_rvecs(stdout,indent,"boxv",tpx.bBox ? state.boxv : NULL,DIM);
112 pr_rvecs(stdout,indent,"pres_prev",tpx.bBox ? state.pres_prev : NULL,DIM);
113 pr_rvecs(stdout,indent,"svir_prev",tpx.bBox ? state.svir_prev : NULL,DIM);
114 pr_rvecs(stdout,indent,"fvir_prev",tpx.bBox ? state.fvir_prev : NULL,DIM);
115 /* leave nosehoover_xi in for now to match the tpr version */
116 pr_doubles(stdout,indent,"nosehoover_xi",state.nosehoover_xi,state.ngtc);
117 /*pr_doubles(stdout,indent,"nosehoover_vxi",state.nosehoover_vxi,state.ngtc);*/
118 /*pr_doubles(stdout,indent,"therm_integral",state.therm_integral,state.ngtc);*/
119 pr_rvecs(stdout,indent,"x",tpx.bX ? state.x : NULL,state.natoms);
120 pr_rvecs(stdout,indent,"v",tpx.bV ? state.v : NULL,state.natoms);
122 pr_rvecs(stdout,indent,"f",f,state.natoms);
126 groups = &mtop.groups;
129 for(i=0; (i<egcNR); i++)
130 snew(gcount[i],groups->grps[i].nr);
132 for(i=0; (i<mtop.natoms); i++) {
133 for(j=0; (j<egcNR); j++)
134 gcount[j][ggrpnr(groups,j,i)]++;
136 printf("Group statistics\n");
137 for(i=0; (i<egcNR); i++) {
139 printf("%-12s: ",gtypes[i]);
140 for(j=0; (j<groups->grps[i].nr); j++) {
141 printf(" %5d",gcount[i][j]);
144 printf(" (total %d atoms)\n",atot);
153 static void list_top(const char *fn)
159 char *cppopts[] = { NULL };
161 status = cpp_open_file(fn,&handle,cppopts);
163 gmx_fatal(FARGS,cpp_error(&handle,status));
165 status = cpp_read_line(&handle,BUFLEN,buf);
166 done = (status == eCPP_EOF);
168 if (status != eCPP_OK)
169 gmx_fatal(FARGS,cpp_error(&handle,status));
174 status = cpp_close_file(&handle);
175 if (status != eCPP_OK)
176 gmx_fatal(FARGS,cpp_error(&handle,status));
179 static void list_trn(const char *fn)
181 t_fileio *fpread, *fpwrite;
189 fpread = open_trn(fn,"r");
190 fpwrite = open_tpx(NULL,"w");
191 gmx_fio_setdebug(fpwrite,TRUE);
194 while (fread_trnheader(fpread,&trn,&bOK)) {
198 if (fread_htrn(fpread,&trn,
199 trn.box_size ? box : NULL,
200 trn.x_size ? x : NULL,
201 trn.v_size ? v : NULL,
202 trn.f_size ? f : NULL)) {
203 sprintf(buf,"%s frame %d",fn,nframe);
205 indent=pr_title(stdout,indent,buf);
206 pr_indent(stdout,indent);
207 fprintf(stdout,"natoms=%10d step=%10d time=%12.7e lambda=%10g\n",
208 trn.natoms,trn.step,trn.t,trn.lambda);
210 pr_rvecs(stdout,indent,"box",box,DIM);
212 pr_rvecs(stdout,indent,"x",x,trn.natoms);
214 pr_rvecs(stdout,indent,"v",v,trn.natoms);
216 pr_rvecs(stdout,indent,"f",f,trn.natoms);
219 fprintf(stderr,"\nWARNING: Incomplete frame: nr %d, t=%g\n",
228 fprintf(stderr,"\nWARNING: Incomplete frame header: nr %d, t=%g\n",
234 void list_xtc(const char *fn, gmx_bool bXVG)
241 int nframe,natoms,step;
245 xd = open_xtc(fn,"r");
246 read_first_xtc(xd,&natoms,&step,&time,box,&x,&prec,&bOK);
253 fprintf(stdout,"%g",time);
254 for(i=0; i<natoms; i++)
256 fprintf(stdout," %g",x[i][d]);
257 fprintf(stdout,"\n");
259 sprintf(buf,"%s frame %d",fn,nframe);
261 indent=pr_title(stdout,indent,buf);
262 pr_indent(stdout,indent);
263 fprintf(stdout,"natoms=%10d step=%10d time=%12.7e prec=%10g\n",
264 natoms,step,time,prec);
265 pr_rvecs(stdout,indent,"box",box,DIM);
266 pr_rvecs(stdout,indent,"x",x,natoms);
269 } while (read_next_xtc(xd,natoms,&step,&time,box,x,&prec,&bOK));
271 fprintf(stderr,"\nWARNING: Incomplete frame at time %g\n",time);
275 void list_trx(const char *fn,gmx_bool bXVG)
282 else if ((ftp == efTRR) || (ftp == efTRJ))
285 fprintf(stderr,"File %s is of an unsupported type. Try using the command\n 'less %s'\n",
289 void list_ene(const char *fn)
294 gmx_enxnm_t *enm=NULL;
300 printf("gmxdump: %s\n",fn);
301 in = open_enx(fn,"r");
302 do_enxnms(in,&nre,&enm);
305 printf("energy components:\n");
306 for(i=0; (i<nre); i++)
307 printf("%5d %-24s (%s)\n",i,enm[i].name,enm[i].unit);
316 printf("\n%24s %12.5e %12s %12s\n","time:",
317 fr->t,"step:",gmx_step_str(fr->step,buf));
318 printf("%24s %12s %12s %12s\n",
319 "","","nsteps:",gmx_step_str(fr->nsteps,buf));
320 printf("%24s %12.5e %12s %12s\n",
321 "delta_t:",fr->dt,"sum steps:",gmx_step_str(fr->nsum,buf));
322 if (fr->nre == nre) {
323 printf("%24s %12s %12s %12s\n",
324 "Component","Energy","Av. Energy","Sum Energy");
326 for(i=0; (i<nre); i++)
327 printf("%24s %12.5e %12.5e %12.5e\n",
328 enm[i].name,fr->ener[i].e,fr->ener[i].eav,
331 for(i=0; (i<nre); i++)
332 printf("%24s %12.5e\n",
333 enm[i].name,fr->ener[i].e);
336 for(b=0; b<fr->nblock; b++)
338 const char *typestr="";
340 t_enxblock *eb=&(fr->block[b]);
341 printf("Block data %2d (%3d subblocks, id=%d)\n",
342 b, eb->nsub, eb->id);
345 typestr=enx_block_id_name[eb->id];
346 printf(" id='%s'\n", typestr);
347 for(i=0;i<eb->nsub;i++)
349 t_enxsubblock *sb=&(eb->sub[i]);
350 printf(" Sub block %3d (%5d elems, type=%s) values:\n",
351 i, sb->nr, xdr_datatype_names[sb->type]);
355 case xdr_datatype_float:
356 for(j=0;j<sb->nr;j++)
357 printf("%14d %8.4f\n",j, sb->fval[j]);
359 case xdr_datatype_double:
360 for(j=0;j<sb->nr;j++)
361 printf("%14d %10.6f\n",j, sb->dval[j]);
363 case xdr_datatype_int:
364 for(j=0;j<sb->nr;j++)
365 printf("%14d %10d\n",j, sb->ival[j]);
367 case xdr_datatype_large_int:
368 for(j=0;j<sb->nr;j++)
370 j, gmx_step_str(sb->lval[j],buf));
372 case xdr_datatype_char:
373 for(j=0;j<sb->nr;j++)
374 printf("%14d %1c\n",j, sb->cval[j]);
376 case xdr_datatype_string:
377 for(j=0;j<sb->nr;j++)
378 printf("%14d %80s\n",j, sb->sval[j]);
381 gmx_incons("Unknown subblock type");
395 static void list_mtx(const char *fn)
398 real *full=NULL,value;
399 gmx_sparsematrix_t * sparse=NULL;
401 gmx_mtxio_read(fn,&nrow,&ncol,&full,&sparse);
404 snew(full,nrow*ncol);
405 for(i=0;i<nrow*ncol;i++) {
409 for(i=0;i<sparse->nrow;i++) {
410 for(j=0;j<sparse->ndata[i];j++) {
411 k = sparse->data[i][j].col;
412 value = sparse->data[i][j].value;
413 full[i*ncol+k] = value;
414 full[k*ncol+i] = value;
417 gmx_sparsematrix_destroy(sparse);
420 printf("%d %d\n",nrow,ncol);
421 for(i=0; i<nrow; i++) {
422 for(j=0; j<ncol; j++) {
423 printf(" %g",full[i*ncol+j]);
431 int cmain(int argc,char *argv[])
433 const char *desc[] = {
434 "[TT]gmxdump[tt] reads a run input file ([TT].tpa[tt]/[TT].tpr[tt]/[TT].tpb[tt]),",
435 "a trajectory ([TT].trj[tt]/[TT].trr[tt]/[TT].xtc[tt]), an energy",
436 "file ([TT].ene[tt]/[TT].edr[tt]), or a checkpoint file ([TT].cpt[tt])",
437 "and prints that to standard output in a readable format.",
438 "This program is essential for checking your run input file in case of",
440 "The program can also preprocess a topology to help finding problems.",
441 "Note that currently setting [TT]GMXLIB[tt] is the only way to customize",
442 "directories used for searching include files.",
445 { efTPX, "-s", NULL, ffOPTRD },
446 { efTRX, "-f", NULL, ffOPTRD },
447 { efEDR, "-e", NULL, ffOPTRD },
448 { efCPT, NULL, NULL, ffOPTRD },
449 { efTOP, "-p", NULL, ffOPTRD },
450 { efMTX, "-mtx", "hessian", ffOPTRD },
451 { efMDP, "-om", NULL, ffOPTWR }
453 #define NFILE asize(fnm)
456 /* Command line options */
457 static gmx_bool bXVG=FALSE;
458 static gmx_bool bShowNumbers=TRUE;
459 static gmx_bool bSysTop=FALSE;
461 { "-xvg", FALSE, etBOOL, {&bXVG}, "HIDDENXVG layout for xtc" },
462 { "-nr",FALSE, etBOOL, {&bShowNumbers},"Show index numbers in output (leaving them out makes comparison easier, but creates a useless topology)" },
463 { "-sys", FALSE, etBOOL, {&bSysTop}, "List the atoms and bonded interactions for the whole system instead of for each molecule type" }
466 CopyRight(stderr,argv[0]);
467 parse_common_args(&argc,argv,0,NFILE,fnm,asize(pa),pa,
468 asize(desc),desc,0,NULL,&oenv);
471 if (ftp2bSet(efTPX,NFILE,fnm))
472 list_tpx(ftp2fn(efTPX,NFILE,fnm),bShowNumbers,
473 ftp2fn_null(efMDP,NFILE,fnm),bSysTop);
474 else if (ftp2bSet(efTRX,NFILE,fnm))
475 list_trx(ftp2fn(efTRX,NFILE,fnm),bXVG);
476 else if (ftp2bSet(efEDR,NFILE,fnm))
477 list_ene(ftp2fn(efEDR,NFILE,fnm));
478 else if (ftp2bSet(efCPT,NFILE,fnm))
479 list_checkpoint(ftp2fn(efCPT,NFILE,fnm),stdout);
480 else if (ftp2bSet(efTOP,NFILE,fnm))
481 list_top(ftp2fn(efTOP,NFILE,fnm));
482 else if (ftp2bSet(efMTX,NFILE,fnm))
483 list_mtx(ftp2fn(efMTX,NFILE,fnm));