Question of combining computer cluster_atomandcoord_atom command

Hi steve, axel and developers,

When I combine compute cluster_atom command into the coord_atom command via modifying cpp file, I get a endless loop. I have checked the two cpp files. The new file is attached.
However, I can not find anything wrong in the new files.
I have modified the pack_forward_comm and unpack_forward_comm to comm ClusterID(carray[i][1]).

When I have printed info to check the reasons, I find it seems that the line ““carray[i][1] = carray[j][1] = MIN(carray[i][1],carray[j][1]);”” does not change the value of carray[j][1]

The endless loop appears when I add the if sentence to add a rule for cluster formation ( if (dot_product > threshold && carray[i][0] >= 11.0 ) ).

I have no idea to deal with this question. Any suggestion is appricated.

////////////////////////////
//loop until no more change on any proc
// acquire clusterID, ie, carry[i][1], of ghost atoms
// carry[i][0] is for storing the coord number
/////////////////////////////

int change,done,anychange;

while (1) {
comm->forward_comm_compute(this);
change = 0;

while (1) {

done = 1;

for (ii = 0; ii < inum; ii++) { //loop all of i atom in one proc
i = ilist[ii];
if (!(mask[i] & groupbit)) continue;

xtmp = x[i][0];
ytmp = x[i][1];
ztmp = x[i][2];
jlist = firstneigh[i];
jnum = numneigh[i];
for (jj = 0; jj < jnum; jj++) { //loop all neighbor of i;
j = jlist[jj];
//cout<< j<< " ";
j &= NEIGHMASK;
if (!(mask[j] & groupbit)) continue;
if (carray[i][1] == carray[j][1]) continue;

delx = xtmp - x[j][0];
dely = ytmp - x[j][1];
delz = ztmp - x[j][2];
rsq = delxdelx + delydely + delzdelz;
if (rsq < cutsq) {
double dot_product = 0.0;
for (int m=0; m < 2
(2*l+1); m++) {
dot_product += normv[i][nqlist+m]*normv[j][nqlist+m];
}
if (dot_product > threshold && carray[i][0] >= 11.0 ) {
//cout<<i<<" “<<j<<” “<<carray[i][0]<<” “<<carray[i][1]<<” "<< carray[j][1]<<endl;
carray[i][1] = carray[j][1] = MIN(carray[i][1],carray[j][1]);
done = 0;
}
}
}
}
if (!done) change = 1;
if (done) break;
}

MPI_Allreduce(&change,&anychange,1,MPI_INT,MPI_MAX,world);
if (!anychange) break;
}

Best Wishes!

Wade