Merge release-5-0 into master
[alexxy/gromacs.git] / src / gromacs / mdlib / ns.c
index 9145929c475b11a0d5bda33347479803215ca818..3a1396cd40ac57bec8a893dedd78d758d470e6dc 100644 (file)
@@ -427,6 +427,14 @@ static gmx_inline void close_i_nblist(t_nblist *nlist)
         nlist->jindex[nri+1] = nlist->nrj;
 
         len = nlist->nrj -  nlist->jindex[nri];
+        /* If there are no j-particles we have to reduce the
+         * number of i-particles again, to prevent errors in the
+         * kernel functions.
+         */
+        if ((len == 0) && (nlist->nri > 0))
+        {
+            nlist->nri--;
+        }
     }
 }