add a new potential

Hi, guys. I am adding a new potential to LAMMPS. I found something is very weird. In the potential, I need to compute the coordination number of the atom in order to compute the force and energy. So I define a function for computing the coordination number. However, The weird thing is that when I print the information through:
printf(“cz %d %f %f %f %d\n”,i,xtmp,ytmp,ztmp,jnum);

The potential works well in the test.
However, if I delete this sentence and test the potential again, there are errors listed below. I don’t know why.

Scanning data file …
Reading data file …
orthogonal box = (-20.168 -20.187 -20.309) to (30.042 30.363 30.691)
1 by 1 by 1 processor grid
1350 atoms
1350 velocities
Finding 1-2 1-3 1-4 neighbors …
0 = max # of 1-2 neighbors
0 = max # of 1-3 neighbors
0 = max # of 1-4 neighbors
1 = max # of special neighbors
450 atoms in group si
900 atoms in group o
Setting up run …
Memory usage per processor = 2.40187 Mbytes
Step Temp Press PotEng KinEng TotEng Volume mypress[ mypress[ mypress[ mypress[ mypress[ mypress[
0 299.77761 -7394.9453 -5984.6744 52.272803 -5932.4016 129443.89 -8075.139 -6067.9747 -8041.7222 -647.46963 4458.6921 -810.14642
[node1:08774] *** Process received signal ***
[node1:08774] Signal: Segmentation fault (11)
[node1:08774] Signal code: Address not mapped (1)
[node1:08774] Failing at address: 0xca447f20
[node1:08774] [ 0] /lib64/libpthread.so.0 [0x2b1971c55c00]
[node1:08774] [ 1] ./lmp_linux(_ZN9LAMMPS_NS12PairWatanabe7computeEii+0x1121) [0x6e9123]
[node1:08774] [ 2] ./lmp_linux(_ZN9LAMMPS_NS6Verlet3runEi+0x4a9) [0x7489cb]
[node1:08774] [ 3] ./lmp_linux(_ZN9LAMMPS_NS3Run7commandEiPPc+0xb77) [0x726867]
[node1:08774] [ 4] ./lmp_linux(_ZN9LAMMPS_NS5Input15execute_commandEv+0x27b6) [0x5fe456]
[node1:08774] [ 5] ./lmp_linux(_ZN9LAMMPS_NS5Input4fileEv+0x299) [0x5ffcfd]
[node1:08774] [ 6] ./lmp_linux(main+0xa7) [0x6091a3]
[node1:08774] [ 7] /lib64/libc.so.6(__libc_start_main+0xf4) [0x2b19728ab184]
[node1:08774] [ 8] ./lmp_linux(_ZNSt8ios_base4InitD1Ev+0x41) [0x46e009]
[node1:08774] *** End of error message ***
Segmentation fault

/////////////////////////////////////////////////////////the function
double PairWatanabe::coordination(int i)
{
int jjj,jj,jnum,itype,jtype;
double xtmp,ytmp,ztmp,delx,dely,delz,rij,fc,c1,zi;
int jlist,numneigh,**firstneigh;
double **x = atom->x;
int type = atom->type;
numneigh = list->numneigh;
firstneigh = list->firstneigh;
xtmp = x[i][0];
ytmp = x[i][1];
ztmp = x[i][2];
itype = map[type[i]];
jlist = firstneigh[i];
jnum = numneigh[i];
zi=0.0;
//printf(“cz %d %f %f %f %d\n”,i,xtmp,ytmp,ztmp,jnum);
for (jj = 0; jj < jnum; jj++)
{
jjj = jlist[jj];
jtype = map[type[jjj]];
if(itype==jtype) continue; //the coordination only means the Si numbers bond O or O numbers around Si
delx = xtmp - x[jjj][0];
dely = ytmp - x[jjj][1];
delz = ztmp - x[jjj][2];
rij =sqrt(delx
delx+dely
dely+delz
delz);
if(rij<=(R-D)) fc=1.0;
else if(rij<(R+D))
{ c1=(rij-R+D)/D;
fc=1.0-0.5c1+sin(PIc1)/(2.0PI);//knordlund:fc=0.5(1.0+cos(c1/2.0*PI))
}
else fc=0.0;
zi+=fc;
// printf(“fc %d %f %f %f %f %f\n”,jjj,x[jjj][0],x[jjj][1],x[jjj][2],rij,fc);
}
return (zi);
}

Lisa