Remove unnecessary extensions in t_filenm defaults
[alexxy/gromacs.git] / src / gromacs / gmxana / gmx_cluster.c
index 693fbe9dcea62160e195695df5a0d6a2582ce5d7..d1984d58e5cb74aa4061a1c44bffb48c77691ad9 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, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, 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 <math.h>
+#include <stdlib.h>
 #include <string.h>
-#include <ctype.h>
-#include "macros.h"
-#include "smalloc.h"
-#include "typedefs.h"
+
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/utility/smalloc.h"
+#include "gromacs/legacyheaders/typedefs.h"
 #include "gromacs/commandline/pargs.h"
 #include "gromacs/fileio/tpxio.h"
 #include "gromacs/fileio/trxio.h"
-#include "string2.h"
-#include "vec.h"
-#include "macros.h"
-#include "index.h"
-#include "gmx_random.h"
-#include "pbc.h"
-#include "rmpbc.h"
-#include "xvgr.h"
-#include "gromacs/fileio/futil.h"
+#include "gromacs/utility/cstringutil.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/topology/index.h"
+#include "gromacs/random/random.h"
+#include "gromacs/pbcutil/pbc.h"
+#include "gromacs/pbcutil/rmpbc.h"
+#include "gromacs/fileio/xvgr.h"
+#include "gromacs/utility/futil.h"
 #include "gromacs/fileio/matio.h"
 #include "cmat.h"
-#include "do_fit.h"
 #include "gromacs/fileio/trnio.h"
-#include "viewit.h"
+#include "gromacs/legacyheaders/viewit.h"
 #include "gmx_ana.h"
 
 #include "gromacs/linearalgebra/eigensolver.h"
+#include "gromacs/math/do_fit.h"
+#include "gromacs/utility/fatalerror.h"
 
 /* print to two file pointers at once (i.e. stderr and log) */
-static inline
+static gmx_inline
 void lo_ffprintf(FILE *fp1, FILE *fp2, const char *buf)
 {
     fprintf(fp1, "%s", buf);
@@ -73,14 +74,14 @@ void lo_ffprintf(FILE *fp1, FILE *fp2, const char *buf)
 }
 
 /* just print a prepared buffer to fp1 and fp2 */
-static inline
+static gmx_inline
 void ffprintf(FILE *fp1, FILE *fp2, const char *buf)
 {
     lo_ffprintf(fp1, fp2, buf);
 }
 
 /* prepare buffer with one argument, then print to fp1 and fp2 */
-static inline
+static gmx_inline
 void ffprintf_d(FILE *fp1, FILE *fp2, char *buf, const char *fmt, int arg)
 {
     sprintf(buf, fmt, arg);
@@ -88,7 +89,7 @@ void ffprintf_d(FILE *fp1, FILE *fp2, char *buf, const char *fmt, int arg)
 }
 
 /* prepare buffer with one argument, then print to fp1 and fp2 */
-static inline
+static gmx_inline
 void ffprintf_g(FILE *fp1, FILE *fp2, char *buf, const char *fmt, real arg)
 {
     sprintf(buf, fmt, arg);
@@ -96,7 +97,7 @@ void ffprintf_g(FILE *fp1, FILE *fp2, char *buf, const char *fmt, real arg)
 }
 
 /* prepare buffer with one argument, then print to fp1 and fp2 */
-static inline
+static gmx_inline
 void ffprintf_s(FILE *fp1, FILE *fp2, char *buf, const char *fmt, const char *arg)
 {
     sprintf(buf, fmt, arg);
@@ -104,7 +105,7 @@ void ffprintf_s(FILE *fp1, FILE *fp2, char *buf, const char *fmt, const char *ar
 }
 
 /* prepare buffer with two arguments, then print to fp1 and fp2 */
-static inline
+static gmx_inline
 void ffprintf_dd(FILE *fp1, FILE *fp2, char *buf, const char *fmt, int arg1, int arg2)
 {
     sprintf(buf, fmt, arg1, arg2);
@@ -112,7 +113,7 @@ void ffprintf_dd(FILE *fp1, FILE *fp2, char *buf, const char *fmt, int arg1, int
 }
 
 /* prepare buffer with two arguments, then print to fp1 and fp2 */
-static inline
+static gmx_inline
 void ffprintf_gg(FILE *fp1, FILE *fp2, char *buf, const char *fmt, real arg1, real arg2)
 {
     sprintf(buf, fmt, arg1, arg2);
@@ -120,7 +121,7 @@ void ffprintf_gg(FILE *fp1, FILE *fp2, char *buf, const char *fmt, real arg1, re
 }
 
 /* prepare buffer with two arguments, then print to fp1 and fp2 */
-static inline
+static gmx_inline
 void ffprintf_ss(FILE *fp1, FILE *fp2, char *buf, const char *fmt, const char *arg1, const char *arg2)
 {
     sprintf(buf, fmt, arg1, arg2);
@@ -980,13 +981,13 @@ static void ana_trans(t_clusters *clust, int nf,
                 "max %d between two specific clusters\n", ntranst, maxtrans);
     if (transfn)
     {
-        fp = ffopen(transfn, "w");
+        fp = gmx_ffopen(transfn, "w");
         i  = min(maxtrans+1, 80);
         write_xpm(fp, 0, "Cluster Transitions", "# transitions",
                   "from cluster", "to cluster",
                   clust->ncl, clust->ncl, axis, axis, trans,
                   0, maxtrans, rlo, rhi, &i);
-        ffclose(fp);
+        gmx_ffclose(fp);
     }
     if (ntransfn)
     {
@@ -996,7 +997,7 @@ static void ana_trans(t_clusters *clust, int nf,
         {
             fprintf(fp, "%5d %5d\n", i+1, ntrans[i]);
         }
-        ffclose(fp);
+        gmx_ffclose(fp);
     }
     sfree(ntrans);
     for (i = 0; i < clust->ncl; i++)
@@ -1095,19 +1096,25 @@ static void analyze_clusters(int nf, t_clusters *clust, real **rmsd,
     if (clustidfn)
     {
         fp = xvgropen(clustidfn, "Clusters", output_env_get_xvgr_tlabel(oenv), "Cluster #", oenv);
-        fprintf(fp, "@    s0 symbol 2\n");
-        fprintf(fp, "@    s0 symbol size 0.2\n");
-        fprintf(fp, "@    s0 linestyle 0\n");
+        if (output_env_get_print_xvgr_codes(oenv))
+        {
+            fprintf(fp, "@    s0 symbol 2\n");
+            fprintf(fp, "@    s0 symbol size 0.2\n");
+            fprintf(fp, "@    s0 linestyle 0\n");
+        }
         for (i = 0; i < nf; i++)
         {
             fprintf(fp, "%8g %8d\n", time[i], clust->cl[i]);
         }
-        ffclose(fp);
+        gmx_ffclose(fp);
     }
     if (sizefn)
     {
         fp = xvgropen(sizefn, "Cluster Sizes", "Cluster #", "# Structures", oenv);
-        fprintf(fp, "@g%d type %s\n", 0, "bar");
+        if (output_env_get_print_xvgr_codes(oenv))
+        {
+            fprintf(fp, "@g%d type %s\n", 0, "bar");
+        }
     }
     snew(structure, nf);
     fprintf(log, "\n%3s | %3s  %4s | %6s %4s | cluster members\n",
@@ -1510,13 +1517,13 @@ int gmx_cluster(int argc, char *argv[])
         { efXVG, "-sz",   "clust-size", ffOPTWR},
         { efXPM, "-tr",   "clust-trans", ffOPTWR},
         { efXVG, "-ntr",  "clust-trans", ffOPTWR},
-        { efXVG, "-clid", "clust-id.xvg", ffOPTWR},
+        { efXVG, "-clid", "clust-id",   ffOPTWR},
         { efTRX, "-cl",   "clusters.pdb", ffOPTWR }
     };
 #define NFILE asize(fnm)
 
     if (!parse_common_args(&argc, argv,
-                           PCA_CAN_VIEW | PCA_CAN_TIME | PCA_TIME_UNIT | PCA_BE_NICE,
+                           PCA_CAN_VIEW | PCA_CAN_TIME | PCA_TIME_UNIT,
                            NFILE, fnm, asize(pa), pa, asize(desc), desc, 0, NULL,
                            &oenv))
     {
@@ -1865,7 +1872,7 @@ int gmx_cluster(int argc, char *argv[])
             {
                 fprintf(fp, "%10d  %10g\n", i, eigenvalues[i]);
             }
-            ffclose(fp);
+            gmx_ffclose(fp);
             break;
         case m_monte_carlo:
             orig     = init_mat(rms->nn, FALSE);
@@ -1921,7 +1928,7 @@ int gmx_cluster(int argc, char *argv[])
                          bAverage, write_ncl, write_nst, rmsmin, bFit, log,
                          rlo_bot, rhi_bot, oenv);
     }
-    ffclose(log);
+    gmx_ffclose(log);
 
     if (bBinary && !bAnalyze)
     {
@@ -1966,7 +1973,7 @@ int gmx_cluster(int argc, char *argv[])
         }
     }
     fprintf(stderr, "\n");
-    ffclose(fp);
+    gmx_ffclose(fp);
     if (NULL != orig)
     {
         fp = opt2FILE("-om", NFILE, fnm, "w");
@@ -1975,7 +1982,7 @@ int gmx_cluster(int argc, char *argv[])
         write_xpm(fp, 0, title, "RMSD (nm)", buf, buf,
                   nf, nf, time, time, orig->mat, 0.0, orig->maxrms,
                   rlo_top, rhi_top, &nlevels);
-        ffclose(fp);
+        gmx_ffclose(fp);
         done_mat(&orig);
         sfree(orig);
     }