From 3c04ce364b4c490cb8b092f8bc8b65243b06c293 Mon Sep 17 00:00:00 2001 From: Mark Abraham Date: Sat, 23 Jan 2016 20:32:58 +0100 Subject: [PATCH] Avoid FP exception clang 3.7 debug build throws an FP exception for ewtabhalfspace. Of course, it is never used if ewtabscale is zero, but the old code is improved by this. Change-Id: I7bd9fe499ea2c565d2292533c2e78543b49cadcb --- src/gromacs/gmxlib/nonbonded/nb_free_energy.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/gromacs/gmxlib/nonbonded/nb_free_energy.cpp b/src/gromacs/gmxlib/nonbonded/nb_free_energy.cpp index c2cf501bfa..f23eefbf37 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_free_energy.cpp +++ b/src/gromacs/gmxlib/nonbonded/nb_free_energy.cpp @@ -118,16 +118,16 @@ gmx_nb_free_energy_kernel(const t_nblist * gmx_restrict nlist, gmx_bool bExactElecCutoff, bExactVdwCutoff, bExactCutoffAll; gmx_bool bEwald, bEwaldLJ; real rcutoff_max2; - const real * tab_ewald_F_lj; - const real * tab_ewald_V_lj; + const real * tab_ewald_F_lj = nullptr; + const real * tab_ewald_V_lj = nullptr; real d, d2, sw, dsw, rinvcorr; real elec_swV3, elec_swV4, elec_swV5, elec_swF2, elec_swF3, elec_swF4; real vdw_swV3, vdw_swV4, vdw_swV5, vdw_swF2, vdw_swF3, vdw_swF4; gmx_bool bConvertEwaldToCoulomb, bConvertLJEwaldToLJ6; gmx_bool bComputeVdwInteraction, bComputeElecInteraction; - const real * ewtab; + const real * ewtab = nullptr; int ewitab; - real ewrt, eweps, ewtabscale, ewtabhalfspace, sh_ewald; + real ewrt, eweps, ewtabscale = 0, ewtabhalfspace = 0, sh_ewald = 0; const real onetwelfth = 1.0/12.0; const real onesixth = 1.0/6.0; @@ -138,13 +138,6 @@ gmx_nb_free_energy_kernel(const t_nblist * gmx_restrict nlist, const real six = 6.0; const real fourtyeight = 48.0; - sh_ewald = fr->ic->sh_ewald; - ewtab = fr->ic->tabq_coul_FDV0; - ewtabscale = fr->ic->tabq_scale; - ewtabhalfspace = half/ewtabscale; - tab_ewald_F_lj = fr->ic->tabq_vdw_F; - tab_ewald_V_lj = fr->ic->tabq_vdw_V; - x = xx[0]; f = ff[0]; @@ -268,6 +261,16 @@ gmx_nb_free_energy_kernel(const t_nblist * gmx_restrict nlist, bEwald = (icoul == GMX_NBKERNEL_ELEC_EWALD); bEwaldLJ = (ivdw == GMX_NBKERNEL_VDW_LJEWALD); + if (bEwald || bEwaldLJ) + { + sh_ewald = fr->ic->sh_ewald; + ewtab = fr->ic->tabq_coul_FDV0; + ewtabscale = fr->ic->tabq_scale; + ewtabhalfspace = half/ewtabscale; + tab_ewald_F_lj = fr->ic->tabq_vdw_F; + tab_ewald_V_lj = fr->ic->tabq_vdw_V; + } + /* For Ewald/PME interactions we cannot easily apply the soft-core component to * reciprocal space. When we use vanilla (not switch/shift) Ewald interactions, we * can apply the small trick of subtracting the _reciprocal_ space contribution -- 2.11.4.GIT