2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2004, The GROMACS development team,
6 * check out http://www.gromacs.org for more information.
7 * Copyright (c) 2012,2013, by the GROMACS development team, led by
8 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
9 * others, as listed in the AUTHORS file in the top-level source
10 * directory and at http://www.gromacs.org.
12 * GROMACS is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public License
14 * as published by the Free Software Foundation; either version 2.1
15 * of the License, or (at your option) any later version.
17 * GROMACS is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with GROMACS; if not, see
24 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
25 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 * If you want to redistribute modifications to GROMACS, please
28 * consider that scientific software is very special. Version
29 * control is crucial - bugs must be traceable. We will be happy to
30 * consider code for inclusion in the official distribution, but
31 * derived work must not be called official GROMACS. Details are found
32 * in the README & COPYING files - if they are missing, get the
33 * official version at http://www.gromacs.org.
35 * To help us fund GROMACS development, we humbly ask that you cite
36 * the research papers on the package. Check out http://www.gromacs.org.
53 int main(int argc,char *argv[])
55 static char *desc[] = {
56 "[TT]compnl[tt] compares two neighborlists as generated by [TT]mdrun[tt]",
57 "in the log file, when the environment variable DUMPNL is set to",
58 "a number larger than 0. [TT]compnl[tt] is mainly used for debugging the",
59 "[TT]mdrun[tt] internals and not for end-users."
74 { efLOG, "-f1", NULL, ffREAD },
75 { efLOG, "-f2", NULL, ffREAD },
76 { efOUT, "-o", "compnl", ffWRITE },
77 { efSTX, "-c", NULL, ffOPTRD }
79 #define NFILE asize(fnm)
80 static int natoms=648;
81 static gmx_bool bSymm=TRUE;
82 static t_pargs pa[] = {
83 { "-nat", FALSE, etINT, { &natoms }, "Number of atoms" },
84 { "-symm", FALSE, etBOOL,{ &bSymm }, "Symmetrize the matrices" },
87 CopyRight(stderr,argv[0]);
88 parse_common_args(&argc,argv,0,NFILE,fnm,asize(pa),pa,
89 asize(desc),desc,0,NULL);
91 bConf = (opt2bSet("-c",NFILE,fnm));
93 get_stx_coordnum (opt2fn("-c",NFILE,fnm),&natoms);
94 init_t_atoms(&atoms,natoms,FALSE);
96 read_stx_conf(opt2fn("-c",NFILE,fnm),title,&atoms,x,NULL,box);
100 fn[0] = opt2fn("-f1",NFILE,fnm);
101 fn[1] = opt2fn("-f2",NFILE,fnm);
104 out = gmx_fio_fopen(ftp2fn(efOUT,NFILE,fnm),"w");
105 mb = sizeof(int)*sqr(natoms/1024.0);
106 for(i=0; (i<2); i++) {
107 in = gmx_fio_fopen(fn[i],"r");
108 fprintf(stderr,"Reading %s\n",fn[i]);
109 fprintf(out, "Reading %s\n",fn[i]);
110 fprintf(stderr,"Going to allocate %.0f Mb of memory\n",mb);
111 fprintf(out, "Going to allocate %.0f Mb of memory\n",mb);
113 for(j=0; (j<natoms); j++)
114 snew(mat[i][j],natoms);
115 nnb = read_nblist(in,out,mat[i],natoms,bSymm);
117 fprintf(stderr,"Interaction matrix %d has %d entries\n",i,nnb);
118 fprintf(out, "Interaction matrix %d has %d entries\n",i,nnb);
120 fprintf(stderr,"Comparing Interaction Matrices\n");
123 for(i=0; (i<natoms); i+=mod) {
124 for(j=0; (j<natoms); j+=mod) {
125 if (mat[0][i][j] != mat[1][i][j]) {
126 fprintf(out,"i: %5d, j: %5d, shift[%s]: %3d, shift[%s]: %3d",
127 i,j,fn[0],mat[0][i][j]-1,fn[1],mat[1][i][j]-1);
129 pbc_dx(&pbc,x[i],x[j],dx);
130 fprintf(out," dist: %8.3f\n",norm(dx));
138 fprintf(out,"There were %d mismatches\n",nmiss);
139 fprintf(out,"Done.\n");
141 fprintf(stderr,"There were %d mismatches\n",nmiss);
142 fprintf(stderr,"Finished\n");