4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
17 * GROMACS: A message-passing parallel molecular dynamics implementation
18 * H.J.C. Berendsen, D. van der Spoel and R. van Drunen
19 * Comp. Phys. Comm. 91, 43-56 (1995)
21 * Also check out our WWW page:
22 * http://md.chem.rug.nl/~gmx
27 * GRowing Old MAkes el Chrono Sweat
29 static char *SRCID_wnblist_c
= "$Id$";
41 #define header "Neighborlist:"
43 static void write_nblist(FILE *out
,t_nblist
*nblist
)
45 int i
,j
,j0
,k
,i_atom
,jid
;
47 fprintf(out
,"nri=%d nrj=%d\n",nblist
->nri
,nblist
->nrj
);
48 for(i
=0; i
<nblist
->nri
; i
++) {
49 fprintf(out
,"i: %d, shift: %d, gid: %d\n",
50 nblist
->iinr
[i
],nblist
->shift
[i
],nblist
->gid
[i
]);
51 for(j
=nblist
->jindex
[i
]; (j
<nblist
->jindex
[i
+1]); j
++)
52 fprintf(out
," j: %d\n",nblist
->jjnr
[j
]);
57 void read_nblist(FILE *in
,FILE *log
,int **mat
,int natoms
)
60 int i
,ii
,j
,nnbl
,full
,icmp
,nri
;
61 int iatom
,nrj
,nj
,shift
;
64 if (fgets2(buf
,255,in
) == NULL
)
65 fatal_error(0,"EOF when looking for '%s' in logfile",header
);
66 } while (strstr(buf
,header
) == NULL
);
67 if (fscanf(in
,"%d",&nnbl
) != 1)
68 fatal_error(0,"Not enough arguments read line %d",__LINE__
);
70 for(i
=0; (i
<nnbl
); i
++) {
71 if (fscanf(in
,"%*s%d",&nri
) != 1)
72 fatal_error(0,"Not enough arguments read line %d",__LINE__
);
74 for(ii
=0; (ii
<nri
); ii
++) {
75 if (fscanf(in
,"%*s%d%*s%d%*s%d",&iatom
,&nj
,&shift
) != 3)
76 fatal_error(0,"Not enough arguments read line %d",__LINE__
);
77 if ((iatom
< 0) || (iatom
>= natoms
))
78 fatal_error(0,"iatom = %d (max %d)\n",iatom
,natoms
);
81 for(i
=0; (i
<nj
); i
++) {
82 if (fscanf(in
,"%d",&j
) != 1)
83 fatal_error(0,"Not enough arguments read line %d",__LINE__
);
84 if ((j
< 0) || (j
>= natoms
))
85 fatal_error(0,"iatom = %d (max %d)\n",iatom
,natoms
);
86 if (mat
[iatom
][j
] != 0)
87 fprintf(log
,"mat[%d][%d] changing from %d to %d\n",
88 i
,j
,mat
[iatom
][j
],shift
+1);
89 mat
[iatom
][j
] = shift
+1;
92 fprintf(log
,"nri = %d nrj = %d\n",nri
,nrj
);
96 void dump_nblist(FILE *out
,t_forcerec
*fr
,int nDNL
)
100 fprintf(out
,"%s\n",header
);
102 for(i
=0; (i
<eNL_NR
); i
++)
103 write_nblist(out
,&fr
->nlist_sr
[i
]);