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 * GROwing Monsters And Cloning Shrimps
40 #include "gromacs/utility/smalloc.h"
42 #include "gromacs/fileio/futil.h"
44 #include "gromacs/commandline/pargs.h"
46 #include "gromacs/fileio/confio.h"
50 int main(int argc,char *argv[])
52 static char *desc[] = {
53 "[TT]compnl[tt] compares two neighborlists as generated by [TT]mdrun[tt]",
54 "in the log file, when the environment variable DUMPNL is set to",
55 "a number larger than 0. [TT]compnl[tt] is mainly used for debugging the",
56 "[TT]mdrun[tt] internals and not for end-users."
71 { efLOG, "-f1", NULL, ffREAD },
72 { efLOG, "-f2", NULL, ffREAD },
73 { efOUT, "-o", "compnl", ffWRITE },
74 { efSTX, "-c", NULL, ffOPTRD }
76 #define NFILE asize(fnm)
77 static int natoms=648;
78 static gmx_bool bSymm=TRUE;
79 static t_pargs pa[] = {
80 { "-nat", FALSE, etINT, { &natoms }, "Number of atoms" },
81 { "-symm", FALSE, etBOOL,{ &bSymm }, "Symmetrize the matrices" },
84 CopyRight(stderr,argv[0]);
85 parse_common_args(&argc,argv,0,NFILE,fnm,asize(pa),pa,
86 asize(desc),desc,0,NULL);
88 bConf = (opt2bSet("-c",NFILE,fnm));
90 get_stx_coordnum (opt2fn("-c",NFILE,fnm),&natoms);
91 init_t_atoms(&atoms,natoms,FALSE);
93 read_stx_conf(opt2fn("-c",NFILE,fnm),title,&atoms,x,NULL,box);
97 fn[0] = opt2fn("-f1",NFILE,fnm);
98 fn[1] = opt2fn("-f2",NFILE,fnm);
101 out = gmx_fio_fopen(ftp2fn(efOUT,NFILE,fnm),"w");
102 mb = sizeof(int)*sqr(natoms/1024.0);
103 for(i=0; (i<2); i++) {
104 in = gmx_fio_fopen(fn[i],"r");
105 fprintf(stderr,"Reading %s\n",fn[i]);
106 fprintf(out, "Reading %s\n",fn[i]);
107 fprintf(stderr,"Going to allocate %.0f Mb of memory\n",mb);
108 fprintf(out, "Going to allocate %.0f Mb of memory\n",mb);
110 for(j=0; (j<natoms); j++)
111 snew(mat[i][j],natoms);
112 nnb = read_nblist(in,out,mat[i],natoms,bSymm);
114 fprintf(stderr,"Interaction matrix %d has %d entries\n",i,nnb);
115 fprintf(out, "Interaction matrix %d has %d entries\n",i,nnb);
117 fprintf(stderr,"Comparing Interaction Matrices\n");
120 for(i=0; (i<natoms); i+=mod) {
121 for(j=0; (j<natoms); j+=mod) {
122 if (mat[0][i][j] != mat[1][i][j]) {
123 fprintf(out,"i: %5d, j: %5d, shift[%s]: %3d, shift[%s]: %3d",
124 i,j,fn[0],mat[0][i][j]-1,fn[1],mat[1][i][j]-1);
126 pbc_dx(&pbc,x[i],x[j],dx);
127 fprintf(out," dist: %8.3f\n",norm(dx));
135 fprintf(out,"There were %d mismatches\n",nmiss);
136 fprintf(out,"Done.\n");
138 fprintf(stderr,"There were %d mismatches\n",nmiss);
139 fprintf(stderr,"Finished\n");