From 412e2974d00a02f0f7ee3c0a01bc543875e41073 Mon Sep 17 00:00:00 2001 From: Erik Lindahl Date: Tue, 2 Sep 2014 11:01:20 +0200 Subject: [PATCH] Fixed sc_power==48 crash in single precision A few summation variables in the free energy kernel need to be double to avoid overflows for 48th power softcore interactions. Fixes #1580. Change-Id: I3263e9eb83515ebaf9f6c04fd0e57ae179933d4e --- src/gromacs/gmxlib/nonbonded/nb_free_energy.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gromacs/gmxlib/nonbonded/nb_free_energy.c b/src/gromacs/gmxlib/nonbonded/nb_free_energy.c index 2bf8f90e3f..85d96a1233 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_free_energy.c +++ b/src/gromacs/gmxlib/nonbonded/nb_free_energy.c @@ -65,8 +65,9 @@ gmx_nb_free_energy_kernel(const t_nblist * gmx_restrict nlist, #define NSTATES 2 int i, j, n, ii, is3, ii3, k, nj0, nj1, jnr, j3, ggid; real shX, shY, shZ; - real Fscal, FscalC[NSTATES], FscalV[NSTATES], tx, ty, tz; - real Vcoul[NSTATES], Vvdw[NSTATES]; + real tx, ty, tz, Fscal; + double FscalC[NSTATES], FscalV[NSTATES]; /* Needs double for sc_power==48 */ + double Vcoul[NSTATES], Vvdw[NSTATES]; /* Needs double for sc_power==48 */ real rinv6, r, rt, rtC, rtV; real iqA, iqB; real qq[NSTATES], vctot, krsq; @@ -79,7 +80,7 @@ gmx_nb_free_energy_kernel(const t_nblist * gmx_restrict nlist, double dvdl_coul, dvdl_vdw; real lfac_coul[NSTATES], dlfac_coul[NSTATES], lfac_vdw[NSTATES], dlfac_vdw[NSTATES]; real sigma6[NSTATES], alpha_vdw_eff, alpha_coul_eff, sigma2_def, sigma2_min; - real rp, rpm2, rC, rV, rinvC, rpinvC, rinvV, rpinvV; + double rp, rpm2, rC, rV, rinvC, rpinvC, rinvV, rpinvV; /* Needs double for sc_power==48 */ real sigma2[NSTATES], sigma_pow[NSTATES], sigma_powm2[NSTATES], rs, rs2; int do_tab, tab_elemsize; int n0, n1C, n1V, nnn; -- 2.22.0