Merge branch release-2016
[alexxy/gromacs.git] / src / gromacs / gmxana / gmx_rmsf.cpp
index 9c3989a279ecb0018b11368faa684bb3e9a8234d..6c78ce216500c5b78ca063bbe0e77bbef84ee738 100644 (file)
@@ -325,6 +325,8 @@ int gmx_rmsf(int argc, char *argv[])
         snew(pdbatoms, 1);
         *pdbatoms = top_pdb->atoms;
         read_tps_conf(opt2fn("-q", NFILE, fnm), top_pdb, nullptr, &pdbx, nullptr, pdbbox, FALSE);
+        /* TODO Should this assert that top_pdb->atoms.nr == top.atoms.nr?
+         * See discussion at https://gerrit.gromacs.org/#/c/6430/1 */
         title = *top_pdb->name;
         snew(refatoms, 1);
         *refatoms = top_pdb->atoms;
@@ -554,24 +556,26 @@ int gmx_rmsf(int argc, char *argv[])
         /* Write a .pdb file with B-factors and optionally anisou records */
         for (i = 0; i < isize; i++)
         {
-            rvec_inc(xref[index[i]], xcm);
+            rvec_inc(pdbx[index[i]], xcm);
         }
         write_sto_conf_indexed(opt2fn("-oq", NFILE, fnm), title, pdbatoms, pdbx,
                                nullptr, ePBC, pdbbox, isize, index);
     }
     if (opt2bSet("-ox", NFILE, fnm))
     {
-        /* Misuse xref as a temporary array */
+        rvec *bFactorX;
+        snew(bFactorX, top.atoms.nr);
         for (i = 0; i < isize; i++)
         {
             for (d = 0; d < DIM; d++)
             {
-                xref[index[i]][d] = xcm[d] + xav[i*DIM + d];
+                bFactorX[index[i]][d] = xcm[d] + xav[i*DIM + d];
             }
         }
         /* Write a .pdb file with B-factors and optionally anisou records */
-        write_sto_conf_indexed(opt2fn("-ox", NFILE, fnm), title, pdbatoms, xref, nullptr,
+        write_sto_conf_indexed(opt2fn("-ox", NFILE, fnm), title, pdbatoms, bFactorX, nullptr,
                                ePBC, pdbbox, isize, index);
+        sfree(bFactorX);
     }
     if (bAniso)
     {