Merge branch 'master' into pygromacs
[alexxy/gromacs.git] / src / gromacs / gmxana / gmx_spol.cpp
similarity index 96%
rename from src/gromacs/gmxana/gmx_spol.c
rename to src/gromacs/gmxana/gmx_spol.cpp
index 8c6c25034026515bf520b741e5d36cbf7769e676..78fe38ee9febb9c69530176dfd86c43e1a21bad9 100644 (file)
@@ -36,6 +36,8 @@
  */
 #include "gmxpre.h"
 
+#include <cmath>
+
 #include "gromacs/commandline/pargs.h"
 #include "gromacs/fileio/tpxio.h"
 #include "gromacs/fileio/trxio.h"
@@ -91,7 +93,7 @@ static void calc_com_pbc(int nrefat, t_topology *top, rvec x[], t_pbc *pbc,
                 rvec_add(xref, dx, xtest);
                 for (j = 0; (j < DIM); j++)
                 {
-                    if (fabs(xtest[j]-x[ai][j]) > tol)
+                    if (std::abs(xtest[j]-x[ai][j]) > tol)
                     {
                         /* Here we have used the wrong image for contributing to the COM */
                         xref[j] += mass*(xtest[j]-x[ai][j]);
@@ -148,11 +150,10 @@ int gmx_spol(int argc, char *argv[])
     t_topology  *top;
     t_inputrec  *ir;
     t_atom      *atom;
-    char         title[STRLEN];
     t_trxstatus *status;
     int          nrefat, natoms, nf, ntot;
     real         t;
-    rvec        *xtop, *x, xref, trial, dx = {0}, dip, dir;
+    rvec        *x, xref, trial, dx = {0}, dip, dir;
     matrix       box;
 
     FILE        *fp;
@@ -189,7 +190,7 @@ int gmx_spol(int argc, char *argv[])
     };
 
     output_env_t    oenv;
-    static gmx_bool bCom   = FALSE, bPBC = FALSE;
+    static gmx_bool bCom   = FALSE;
     static int      srefat = 1;
     static real     rmin   = 0.0, rmax = 0.32, refdip = 0, bw = 0.01;
     t_pargs         pa[]   = {
@@ -246,14 +247,14 @@ int gmx_spol(int argc, char *argv[])
     /* initialize reading trajectory:                         */
     natoms = read_first_x(oenv, &status, ftp2fn(efTRX, NFILE, fnm), &t, &x, box);
 
-    rcut  = 0.99*sqrt(max_cutoff2(ir->ePBC, box));
+    rcut  = 0.99*std::sqrt(max_cutoff2(ir->ePBC, box));
     if (rcut == 0)
     {
         rcut = 10*rmax;
     }
     rcut2 = sqr(rcut);
     invbw = 1/bw;
-    nbin  = (int)(rcut*invbw)+2;
+    nbin  = static_cast<int>(rcut*invbw)+2;
     snew(hist, nbin);
 
     rmin2 = sqr(rmin);
@@ -300,7 +301,7 @@ int gmx_spol(int argc, char *argv[])
             }
             if (rdx2 < rcut2)
             {
-                hist[(int)(sqrt(rdx2)*invbw)+1]++;
+                hist[static_cast<int>(std::sqrt(rdx2)*invbw)+1]++;
             }
             if (rdx2 >= rmin2 && rdx2 < rmax2)
             {
@@ -335,7 +336,7 @@ int gmx_spol(int argc, char *argv[])
 
                 svmul(ENM2DEBYE, dip, dip);
                 dip2   = norm2(dip);
-                sdip  += sqrt(dip2);
+                sdip  += std::sqrt(dip2);
                 sdip2 += dip2;
                 for (d = 0; d < DIM; d++)
                 {
@@ -358,7 +359,7 @@ int gmx_spol(int argc, char *argv[])
     close_trj(status);
 
     fprintf(stderr, "Average number of molecules within %g nm is %.1f\n",
-            rmax, (real)ntot/(real)nf);
+            rmax, static_cast<real>(ntot)/nf);
     if (ntot > 0)
     {
         sdip  /= ntot;
@@ -366,7 +367,7 @@ int gmx_spol(int argc, char *argv[])
         sinp  /= ntot;
         sdinp /= ntot;
         fprintf(stderr, "Average dipole:                               %f (D), std.dev. %f\n",
-                sdip, sqrt(sdip2-sqr(sdip)));
+                sdip, std::sqrt(sdip2-sqr(sdip)));
         fprintf(stderr, "Average radial component of the dipole:       %f (D)\n",
                 sinp);
         fprintf(stderr, "Average radial component of the polarization: %f (D)\n",