Make TPI use double precision exp
authorAleksei Iupinov <a.yupinov@gmail.com>
Thu, 1 Mar 2018 13:14:40 +0000 (14:14 +0100)
committerAleksei Iupinov <a.yupinov@gmail.com>
Fri, 2 Mar 2018 11:40:53 +0000 (12:40 +0100)
This makes borderline results reproducible with different
compilers (e.g. with MSVC).

Change-Id: I7b7c50c4f857b4fe2966f49a6ef685eab6598ff6

src/gromacs/mdlib/tpi.cpp

index a3ee8f368a58738ef80d349d3ef34c6f2ebf05ff..d02b4989b11e411958a4b4a37a0de011598f7775 100644 (file)
@@ -718,7 +718,8 @@ double do_tpi(FILE *fplog, t_commrec *cr,
             }
             else
             {
-                embU      = exp(-beta*epot);
+                // Exponent argument is fine in SP range, but output can be in DP range
+                embU      = exp(static_cast<double>(-beta*epot));
                 sum_embU += embU;
                 /* Determine the weighted energy contributions of each energy group */
                 e                = 0;