diff -Naur lammps-4Apr08/src/fix_viscosity.cpp lammps-5Apr08/src/fix_viscosity.cpp --- lammps-4Apr08/src/fix_viscosity.cpp 2008-03-28 09:47:41.000000000 -0600 +++ lammps-5Apr08/src/fix_viscosity.cpp 2008-04-02 14:32:07.000000000 -0600 @@ -158,7 +158,8 @@ slabhi_hi = boxlo + ((nbin-1)/2 + 1)*binsize; } - // make list of nswap atoms with velocity closest to +/- vtarget + // make 2 lists of up to nswap atoms with velocity closest to +/- vtarget + // lists are sorted by closeness to vtarget // only consider atoms in the bottom/middle slabs // map atoms back into periodic box if necessary // insert = location in list to insert new atom @@ -216,6 +217,7 @@ // loop over nswap pairs // find 2 global atoms with smallest delta in bottom/top slabs + // BIG values are for procs with no atom to contribute // MINLOC also communicates which procs own them // exchange momenta between the 2 particles // if I own both particles just swap, else point2point comm of vel,mass @@ -228,9 +230,7 @@ int ipositive = 0; int inegative = 0; - int nactual = MIN(nnegative,npositive); - - for (m = 0; m < nactual; m++) { + for (m = 0; m < nswap; m++) { if (ipositive < npositive) mine[0].value = pos_delta[ipositive]; else mine[0].value = BIG; if (inegative < nnegative) mine[1].value = neg_delta[inegative]; @@ -238,6 +238,8 @@ MPI_Allreduce(mine,all,2,MPI_DOUBLE_INT,MPI_MINLOC,world); + if (all[0].value == BIG || all[1].value == BIG) continue; + if (me == all[0].proc && me == all[1].proc) { ipos = pos_index[ipositive++]; ineg = neg_index[inegative++];