Fix trjconv -ndec
authorMark Abraham <mark.j.abraham@gmail.com>
Fri, 4 Jan 2019 17:07:57 +0000 (18:07 +0100)
committerPaul Bauer <paul.bauer.q@gmail.com>
Mon, 21 Jan 2019 15:39:15 +0000 (16:39 +0100)
This only works with XTC writing, but the documentation
and implementation was wrong. That mean that the terminal
feedback to the user was also wrong when writing a .gro file.

Fixes #2824
Refs #2037

Change-Id: I9f047d0b1042fa37e366ee8c99dabbb1f3458b0a

docs/release-notes/2018/2018.5.rst
src/gromacs/gmxana/gmx_trjconv.cpp

index 61573df4dd3bf66cdfa03f178ea1afd3629969e5..fa3524a1630e2d704079b7964c63ccc698e76bc4 100644 (file)
@@ -49,6 +49,16 @@ results when e.g. calculating viscosities.
 Fixes for ``gmx`` tools
 ^^^^^^^^^^^^^^^^^^^^^^^
 
+Fix trjconv -ndec
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+
+This only works for writing .xtc files. The code and documentation now
+works correctly with .gro files, which was changed in 2016 release series so that
+it would only write fixed-width columns.
+
+:issue: `2813`
+:issue: `2037`
+
 Fixes to improve portability
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
index 4556135d889fe30fbd1b1804fb239a443bffab12..623da03f49569275afaac9fd47e0bc3937b1f2fd 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -822,8 +822,7 @@ int gmx_trjconv(int argc, char *argv[])
           "Fit molecule to ref structure in the structure file" },
         { "-ndec", FALSE, etINT,
           { &ndec },
-          "Precision for .xtc and .gro writing in number of "
-          "decimal places" },
+          "Number of decimal places to write to .xtc output" },
         { "-vel", FALSE, etBOOL,
           { &bVels }, "Read and write velocities if possible" },
         { "-force", FALSE, etBOOL,
@@ -896,7 +895,7 @@ int gmx_trjconv(int argc, char *argv[])
     gmx_rmpbc_t       gpbc = nullptr;
     gmx_bool          bRmPBC, bPBCWhole, bPBCcomRes, bPBCcomMol, bPBCcomAtom, bPBC, bNoJump, bCluster;
     gmx_bool          bCopy, bDoIt, bIndex, bTDump, bSetTime, bTPS = FALSE, bDTset = FALSE;
-    gmx_bool          bExec, bTimeStep = FALSE, bDumpFrame = FALSE, bSetPrec, bNeedPrec;
+    gmx_bool          bExec, bTimeStep = FALSE, bDumpFrame = FALSE, bSetXtcPrec, bNeedPrec;
     gmx_bool          bHaveFirstFrame, bHaveNextFrame, bSetBox, bSetUR, bSplit = FALSE;
     gmx_bool          bSubTraj = FALSE, bDropUnder = FALSE, bDropOver = FALSE, bTrans = FALSE;
     gmx_bool          bWriteFrame, bSplitHere;
@@ -939,17 +938,17 @@ int gmx_trjconv(int argc, char *argv[])
     else
     {
         /* mark active cmdline options */
-        bSetBox    = opt2parg_bSet("-box", NPA, pa);
-        bSetTime   = opt2parg_bSet("-t0", NPA, pa);
-        bSetPrec   = opt2parg_bSet("-ndec", NPA, pa);
-        bSetUR     = opt2parg_bSet("-ur", NPA, pa);
-        bExec      = opt2parg_bSet("-exec", NPA, pa);
-        bTimeStep  = opt2parg_bSet("-timestep", NPA, pa);
-        bTDump     = opt2parg_bSet("-dump", NPA, pa);
-        bDropUnder = opt2parg_bSet("-dropunder", NPA, pa);
-        bDropOver  = opt2parg_bSet("-dropover", NPA, pa);
-        bTrans     = opt2parg_bSet("-trans", NPA, pa);
-        bSplit     = (split_t != 0);
+        bSetBox     = opt2parg_bSet("-box", NPA, pa);
+        bSetTime    = opt2parg_bSet("-t0", NPA, pa);
+        bSetXtcPrec = opt2parg_bSet("-ndec", NPA, pa);
+        bSetUR      = opt2parg_bSet("-ur", NPA, pa);
+        bExec       = opt2parg_bSet("-exec", NPA, pa);
+        bTimeStep   = opt2parg_bSet("-timestep", NPA, pa);
+        bTDump      = opt2parg_bSet("-dump", NPA, pa);
+        bDropUnder  = opt2parg_bSet("-dropunder", NPA, pa);
+        bDropOver   = opt2parg_bSet("-dropover", NPA, pa);
+        bTrans      = opt2parg_bSet("-trans", NPA, pa);
+        bSplit      = (split_t != 0);
 
         /* parse enum options */
         fit_enum      = nenum(fit);
@@ -1003,7 +1002,7 @@ int gmx_trjconv(int argc, char *argv[])
                       "results!");
         }
 
-        /* ndec is in nr of decimal places, prec is a multiplication factor: */
+        /* ndec for XTC writing is in nr of decimal places, prec is a multiplication factor: */
         prec = 1;
         for (i = 0; i < ndec; i++)
         {
@@ -1017,7 +1016,7 @@ int gmx_trjconv(int argc, char *argv[])
         out_file = opt2fn("-o", NFILE, fnm);
         int ftp  = fn2ftp(out_file);
         fprintf(stderr, "Will write %s: %s\n", ftp2ext(ftp), ftp2desc(ftp));
-        bNeedPrec = (ftp == efXTC || ftp == efGRO);
+        bNeedPrec = (ftp == efXTC);
         int ftpin = fn2ftp(in_file);
         if (bVels)
         {
@@ -1293,7 +1292,7 @@ int gmx_trjconv(int argc, char *argv[])
         }
         if (bNeedPrec)
         {
-            if (bSetPrec || !fr.bPrec)
+            if (bSetXtcPrec || !fr.bPrec)
             {
                 fprintf(stderr, "\nSetting output precision to %g (nm)\n", 1/prec);
             }
@@ -1719,7 +1718,7 @@ int gmx_trjconv(int argc, char *argv[])
                         frout.bV     = (frout.bV && bVels);
                         frout.bF     = (frout.bF && bForce);
                         frout.natoms = nout;
-                        if (bNeedPrec && (bSetPrec || !fr.bPrec))
+                        if (bNeedPrec && (bSetXtcPrec || !fr.bPrec))
                         {
                             frout.bPrec = TRUE;
                             frout.prec  = prec;