Make sure water optimization is disabled for esoteric interactions
authorErik Lindahl <erik@kth.se>
Wed, 19 Mar 2014 16:16:18 +0000 (17:16 +0100)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Mon, 7 Apr 2014 16:27:26 +0000 (18:27 +0200)
This fixes a bug where the generic NB kernel could be called with
a water-water neighborlist for a few special combinations where
no C kernels existed (e.g. switch/shifted plain-cutoff coulomb).
This would typically lead to virtually no nonbonded interactions
being calculated and the simulation crashing rapidly, so it is
unlikely to have affected any results silently, but was noticed
when testing interaction forms.

Change-Id: I634fc4ab78b54281c89333299975e25883dc1f2c

src/gmxlib/nonbonded/nonbonded.c
src/mdlib/ns.c

index 25cebfef99b7da2847c1d6d762d11e04ca54c133..74a472b62a91d75f4f50e11e5a85d318f74eaef1 100644 (file)
@@ -294,8 +294,11 @@ gmx_nonbonded_set_kernel_pointers(FILE *log, t_nblist *nl)
             }
         }
 
-        /* Give up, pick a generic one instead */
-        if (nl->kernelptr_vf == NULL)
+        /* Give up. If this was a water kernel, leave the pointer as NULL, which
+         * will disable water optimization in NS. If it is a particle kernel, set
+         * the pointer to the generic NB kernel.
+         */
+        if (nl->kernelptr_vf == NULL && !gmx_strcasecmp_min(geom,"Particle-Particle"))
         {
             nl->kernelptr_vf       = (void *) gmx_nb_generic_kernel;
             nl->kernelptr_f        = (void *) gmx_nb_generic_kernel;
@@ -419,7 +422,11 @@ void do_nonbonded(t_commrec *cr, t_forcerec *fr,
                         /* We don't need the non-perturbed interactions */
                         continue;
                     }
-                    (*kernelptr)(&(nlist[i]), x, f, fr, mdatoms, &kernel_data, nrnb);
+                    /* Neighborlists whose kernelptr==NULL will always be empty */
+                    if(kernelptr != NULL)
+                    {
+                        (*kernelptr)(&(nlist[i]), x, f, fr, mdatoms, &kernel_data, nrnb);
+                    }
                 }
             }
         }
index 6aa89cee38ec196df0f03ae1e64141e4cff356a4..7999e2315552a04578f1cdf15104b6bd05f0e3fc 100644 (file)
@@ -290,7 +290,10 @@ void init_neighbor_list(FILE *log, t_forcerec *fr, int homenr)
             )
         {
             fr->solvent_opt = esolNO;
-            fprintf(log, "Note: The available nonbonded kernels do not support water optimization - disabling.\n");
+            if (log != NULL)
+            {
+                fprintf(log, "Note: The available nonbonded kernels do not support water optimization - disabling.\n");
+            }
         }
 
         if (fr->efep != efepNO)