From: Erik Lindahl Date: Wed, 19 Mar 2014 16:16:18 +0000 (+0100) Subject: Make sure water optimization is disabled for esoteric interactions X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=073519199e82f326cbd426ef2f44e2c4523c4cc6;p=alexxy%2Fgromacs.git Make sure water optimization is disabled for esoteric interactions 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 --- diff --git a/src/gmxlib/nonbonded/nonbonded.c b/src/gmxlib/nonbonded/nonbonded.c index 25cebfef99..74a472b62a 100644 --- a/src/gmxlib/nonbonded/nonbonded.c +++ b/src/gmxlib/nonbonded/nonbonded.c @@ -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); + } } } } diff --git a/src/mdlib/ns.c b/src/mdlib/ns.c index 6aa89cee38..7999e23155 100644 --- a/src/mdlib/ns.c +++ b/src/mdlib/ns.c @@ -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)