Move read_tps_conf() to confio.h
[alexxy/gromacs.git] / src / gromacs / gmxana / gmx_rms.c
index 13aeb6c807a88773a68b382568b3ee7dbaf598c3..3e32fa29e142e02a984e85440a548b00b222b100 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, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, 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.
  * To help us fund GROMACS development, we humbly ask that you cite
  * the research papers on the package. Check out http://www.gromacs.org.
  */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "gmxpre.h"
 
-#include "gromacs/utility/smalloc.h"
 #include <math.h>
-#include "macros.h"
-#include "typedefs.h"
-#include "xvgr.h"
-#include "copyrite.h"
+#include <stdlib.h>
+
 #include "gromacs/commandline/pargs.h"
-#include "vec.h"
-#include "index.h"
-#include "gmx_fatal.h"
-#include "gromacs/fileio/futil.h"
-#include "princ.h"
-#include "rmpbc.h"
+#include "gromacs/fileio/confio.h"
 #include "gromacs/fileio/matio.h"
-#include "gromacs/fileio/tpxio.h"
 #include "gromacs/fileio/trxio.h"
-#include "cmat.h"
-#include "viewit.h"
-#include "gmx_ana.h"
-
+#include "gromacs/fileio/xvgr.h"
+#include "gromacs/gmxana/cmat.h"
+#include "gromacs/gmxana/gmx_ana.h"
+#include "gromacs/gmxana/princ.h"
+#include "gromacs/legacyheaders/copyrite.h"
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/legacyheaders/typedefs.h"
+#include "gromacs/legacyheaders/viewit.h"
 #include "gromacs/math/do_fit.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/pbcutil/rmpbc.h"
+#include "gromacs/topology/index.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/futil.h"
+#include "gromacs/utility/smalloc.h"
 
 static void norm_princ(t_atoms *atoms, int isize, atom_id *index, int natoms,
                        rvec *x)
@@ -115,7 +114,7 @@ int gmx_rms(int argc, char *argv[])
         "Option [TT]-prev[tt] produces the comparison with a previous frame",
         "the specified number of frames ago.[PAR]",
 
-        "Option [TT]-m[tt] produces a matrix in [TT].xpm[tt] format of",
+        "Option [TT]-m[tt] produces a matrix in [REF].xpm[ref] format of",
         "comparison values of each structure in the trajectory with respect to",
         "each other structure. This file can be visualized with for instance",
         "[TT]xv[tt] and can be converted to postscript with [gmx-xpm2ps].[PAR]",
@@ -126,7 +125,7 @@ int gmx_rms(int argc, char *argv[])
 
         "Option [TT]-mw[tt] controls whether mass weighting is done or not.",
         "If you select the option (default) and ",
-        "supply a valid [TT].tpr[tt] file masses will be taken from there, ",
+        "supply a valid [REF].tpr[ref] file masses will be taken from there, ",
         "otherwise the masses will be deduced from the [TT]atommass.dat[tt] file in",
         "[TT]GMXLIB[tt]. This is fine for proteins, but not",
         "necessarily for other molecules. A default mass of 12.011 amu (carbon)",
@@ -228,7 +227,7 @@ int gmx_rms(int argc, char *argv[])
     int             ePBC;
     t_iatom        *iatom = NULL;
 
-    matrix          box;
+    matrix          box = {{0}};
     rvec           *x, *xp, *xm = NULL, **mat_x = NULL, **mat_x2, *mat_x2_j = NULL, vec1,
                     vec2;
     t_trxstatus    *status;
@@ -268,8 +267,8 @@ int gmx_rms(int argc, char *argv[])
     };
 #define NFILE asize(fnm)
 
-    if (!parse_common_args(&argc, argv, PCA_CAN_TIME | PCA_TIME_UNIT | PCA_CAN_VIEW
-                           | PCA_BE_NICE, NFILE, fnm, asize(pa), pa, asize(desc), desc, 0, NULL,
+    if (!parse_common_args(&argc, argv, PCA_CAN_TIME | PCA_TIME_UNIT | PCA_CAN_VIEW,
+                           NFILE, fnm, asize(pa), pa, asize(desc), desc, 0, NULL,
                            &oenv))
     {
         return 0;
@@ -322,6 +321,8 @@ int gmx_rms(int argc, char *argv[])
     bPrev = (prev > 0);
     if (bPrev)
     {
+        fprintf(stderr, "WARNING: using option -prev with large trajectories will\n"
+                "         require a lot of memory and could lead to crashes\n");
         prev = abs(prev);
         if (freq != 1)
         {
@@ -1135,9 +1136,9 @@ int gmx_rms(int argc, char *argv[])
     for (i = 0; (i < teller); i++)
     {
         if (bSplit && i > 0 &&
-            abs(time[bPrev ? freq*i : i]/output_env_get_time_factor(oenv)) < 1e-5)
+            fabs(time[bPrev ? freq*i : i]/output_env_get_time_factor(oenv)) < 1e-5)
         {
-            fprintf(fp, "&\n");
+            fprintf(fp, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
         }
         fprintf(fp, "%12.7f", time[bPrev ? freq*i : i]);
         for (j = 0; (j < nrms); j++)
@@ -1150,7 +1151,7 @@ int gmx_rms(int argc, char *argv[])
         }
         fprintf(fp, "\n");
     }
-    gmx_ffclose(fp);
+    xvgrclose(fp);
 
     if (bMirror)
     {
@@ -1177,9 +1178,9 @@ int gmx_rms(int argc, char *argv[])
         }
         for (i = 0; (i < teller); i++)
         {
-            if (bSplit && i > 0 && abs(time[i]) < 1e-5)
+            if (bSplit && i > 0 && fabs(time[i]) < 1e-5)
             {
-                fprintf(fp, "&\n");
+                fprintf(fp, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
             }
             fprintf(fp, "%12.7f", time[i]);
             for (j = 0; (j < nrms); j++)
@@ -1188,7 +1189,7 @@ int gmx_rms(int argc, char *argv[])
             }
             fprintf(fp, "\n");
         }
-        gmx_ffclose(fp);
+        xvgrclose(fp);
     }
 
     if (bAv)
@@ -1200,7 +1201,7 @@ int gmx_rms(int argc, char *argv[])
         {
             fprintf(fp, "%10d  %10g\n", j, rlstot/teller);
         }
-        gmx_ffclose(fp);
+        xvgrclose(fp);
     }
 
     if (bNorm)
@@ -1210,7 +1211,7 @@ int gmx_rms(int argc, char *argv[])
         {
             fprintf(fp, "%10d  %10g\n", j, rlsnorm[j]/teller);
         }
-        gmx_ffclose(fp);
+        xvgrclose(fp);
     }
     do_view(oenv, opt2fn_null("-a", NFILE, fnm), "-graphtype bar");
     do_view(oenv, opt2fn("-o", NFILE, fnm), NULL);