Merge branch 'master' into pygromacs
[alexxy/gromacs.git] / src / gromacs / gmxana / gmx_rmsf.cpp
similarity index 94%
rename from src/gromacs/gmxana/gmx_rmsf.c
rename to src/gromacs/gmxana/gmx_rmsf.cpp
index 223a1d7d5995684f3ace3de3cb19a4dfedb0b48d..3d08a0f3db4b55d11d3d19582ce2779813d33b52 100644 (file)
@@ -36,7 +36,8 @@
  */
 #include "gmxpre.h"
 
-#include <math.h>
+#include <cmath>
+#include <cstring>
 
 #include "gromacs/commandline/pargs.h"
 #include "gromacs/fileio/confio.h"
@@ -62,14 +63,14 @@ static real find_pdb_bfac(t_atoms *atoms, t_resinfo *ri, char *atomnm)
     char rresnm[8];
     int  i;
 
-    strcpy(rresnm, *ri->name);
+    std::strcpy(rresnm, *ri->name);
     rresnm[3] = '\0';
     for (i = 0; (i < atoms->nr); i++)
     {
         if ((ri->nr == atoms->resinfo[atoms->atom[i].resind].nr) &&
             (ri->ic == atoms->resinfo[atoms->atom[i].resind].ic) &&
-            (strcmp(*atoms->resinfo[atoms->atom[i].resind].name, rresnm) == 0) &&
-            (strstr(*atoms->atomname[i], atomnm) != NULL))
+            (std::strcmp(*atoms->resinfo[atoms->atom[i].resind].name, rresnm) == 0) &&
+            (std::strstr(*atoms->atomname[i], atomnm) != NULL))
         {
             break;
         }
@@ -211,7 +212,7 @@ int gmx_rmsf(int argc, char *argv[])
         "This shows the directions in which the atoms fluctuate the most and",
         "the least."
     };
-    static gmx_bool  bRes    = FALSE, bAniso = FALSE, bdevX = FALSE, bFit = TRUE;
+    static gmx_bool  bRes    = FALSE, bAniso = FALSE, bFit = TRUE;
     t_pargs          pargs[] = {
         { "-res", FALSE, etBOOL, {&bRes},
           "Calculate averages for each residue" },
@@ -221,20 +222,17 @@ int gmx_rmsf(int argc, char *argv[])
           "Do a least squares superposition before computing RMSF. Without this you must make sure that the reference structure and the trajectory match." }
     };
     int              natom;
-    int              step, nre, natoms, i, g, m, teller = 0;
-    real             t, lambda, *w_rls, *w_rms;
+    int              i, m, teller = 0;
+    real             t, *w_rls;
 
-    t_inputrec       ir;
     t_topology       top;
     int              ePBC;
     t_atoms         *pdbatoms, *refatoms;
-    gmx_bool         bCont;
 
     matrix           box, pdbbox;
     rvec            *x, *pdbx, *xref;
     t_trxstatus     *status;
-    int              npdbatoms, res0;
-    char             buf[256];
+    int              npdbatoms;
     const char      *label;
     char             title[STRLEN];
 
@@ -438,12 +436,12 @@ int gmx_rmsf(int argc, char *argv[])
         {
             aid = index[i];
             pdbatoms->pdbinfo[aid].bAnisotropic = TRUE;
-            pdbatoms->pdbinfo[aid].uij[U11]     = 1e6*U[i][XX*DIM + XX];
-            pdbatoms->pdbinfo[aid].uij[U22]     = 1e6*U[i][YY*DIM + YY];
-            pdbatoms->pdbinfo[aid].uij[U33]     = 1e6*U[i][ZZ*DIM + ZZ];
-            pdbatoms->pdbinfo[aid].uij[U12]     = 1e6*U[i][XX*DIM + YY];
-            pdbatoms->pdbinfo[aid].uij[U13]     = 1e6*U[i][XX*DIM + ZZ];
-            pdbatoms->pdbinfo[aid].uij[U23]     = 1e6*U[i][YY*DIM + ZZ];
+            pdbatoms->pdbinfo[aid].uij[U11]     = static_cast<int>(1e6*U[i][XX*DIM + XX]);
+            pdbatoms->pdbinfo[aid].uij[U22]     = static_cast<int>(1e6*U[i][YY*DIM + YY]);
+            pdbatoms->pdbinfo[aid].uij[U33]     = static_cast<int>(1e6*U[i][ZZ*DIM + ZZ]);
+            pdbatoms->pdbinfo[aid].uij[U12]     = static_cast<int>(1e6*U[i][XX*DIM + YY]);
+            pdbatoms->pdbinfo[aid].uij[U13]     = static_cast<int>(1e6*U[i][XX*DIM + ZZ]);
+            pdbatoms->pdbinfo[aid].uij[U23]     = static_cast<int>(1e6*U[i][YY*DIM + ZZ]);
         }
     }
     if (bRes)
@@ -507,7 +505,7 @@ int gmx_rmsf(int argc, char *argv[])
                 top.atoms.atom[index[i]].resind != top.atoms.atom[index[i+1]].resind)
             {
                 fprintf(fp, "%5d %8.4f\n",
-                        bRes ? top.atoms.resinfo[top.atoms.atom[index[i]].resind].nr : index[i]+1, sqrt(rmsf[i]));
+                        bRes ? top.atoms.resinfo[top.atoms.atom[index[i]].resind].nr : index[i]+1, std::sqrt(rmsf[i]));
             }
         }
         xvgrclose(fp);
@@ -536,7 +534,7 @@ int gmx_rmsf(int argc, char *argv[])
                 top.atoms.atom[index[i]].resind != top.atoms.atom[index[i+1]].resind)
             {
                 fprintf(fp, "%5d %8.4f\n",
-                        bRes ? top.atoms.resinfo[top.atoms.atom[index[i]].resind].nr : index[i]+1, sqrt(rmsf[i]));
+                        bRes ? top.atoms.resinfo[top.atoms.atom[index[i]].resind].nr : index[i]+1, std::sqrt(rmsf[i]));
             }
         }
         xvgrclose(fp);