Remove unnecessary config.h includes
[alexxy/gromacs.git] / src / gromacs / gmxana / gmx_analyze.c
index fe3a4c5217e85b4c8c0f8afb4f44b4ecea1c1405..94400867e5f00bfd2efafa911010a57991817292 100644 (file)
@@ -1,57 +1,59 @@
-/*  -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*-
+/*
+ * This file is part of the GROMACS molecular simulation package.
  *
- *
- *                This source code is part of
- *
- *                 G   R   O   M   A   C   S
- *
- *          GROningen MAchine for Chemical Simulations
- *
- *                        VERSION 3.2.0
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
+ * Copyright (c) 2001-2004, The GROMACS development team.
+ * 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.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
  * of the License, or (at your option) any later version.
  *
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
  *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
  *
- * For more info, check our website at http://www.gromacs.org
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
  *
- * And Hey:
- * Green Red Orange Magenta Azure Cyan Skyblue
+ * 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 "gromacs/commandline/pargs.h"
-#include "sysstuff.h"
-#include "typedefs.h"
-#include "smalloc.h"
-#include "macros.h"
-#include "gmx_fatal.h"
-#include "vec.h"
-#include "copyrite.h"
-#include "gromacs/fileio/futil.h"
-#include "readinp.h"
-#include "txtdump.h"
+#include "gromacs/legacyheaders/typedefs.h"
+#include "gromacs/utility/smalloc.h"
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/legacyheaders/copyrite.h"
+#include "gromacs/utility/futil.h"
+#include "gromacs/legacyheaders/readinp.h"
+#include "gromacs/legacyheaders/txtdump.h"
 #include "gstat.h"
-#include "gmx_statistics.h"
-#include "xvgr.h"
+#include "gromacs/statistics/statistics.h"
+#include "gromacs/fileio/xvgr.h"
+#include "gromacs/legacyheaders/viewit.h"
 #include "gmx_ana.h"
 #include "geminate.h"
 
@@ -152,7 +154,7 @@ static void plot_coscont(const char *ccfile, int n, int nset, real **val,
     }
     fprintf(stdout, "\n");
 
-    ffclose(fp);
+    gmx_ffclose(fp);
 }
 
 static void regression_analysis(int n, gmx_bool bXYdy,
@@ -242,11 +244,7 @@ void histogram(const char *distfile, real binwidth, int n, int nset, real **val,
     int            i, s;
     double         min, max;
     int            nbin;
-#if (defined SIZEOF_LONG_LONG_INT) && (SIZEOF_LONG_LONG_INT >= 8)
-    long long int *histo;
-#else
-    double        *histo;
-#endif
+    gmx_int64_t   *histo;
 
     min = val[0][0];
     max = val[0][0];
@@ -293,10 +291,10 @@ void histogram(const char *distfile, real binwidth, int n, int nset, real **val,
         }
         if (s < nset-1)
         {
-            fprintf(fp, "&\n");
+            fprintf(fp, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
         }
     }
-    ffclose(fp);
+    gmx_ffclose(fp);
 }
 
 static int real_comp(const void *a, const void *b)
@@ -325,7 +323,7 @@ static void average(const char *avfile, int avbar_opt,
     double  av, var, err;
     real   *tmp = NULL;
 
-    fp = ffopen(avfile, "w");
+    fp = gmx_ffopen(avfile, "w");
     if ((avbar_opt == avbarERROR) && (nset == 1))
     {
         avbar_opt = avbarNONE;
@@ -386,7 +384,7 @@ static void average(const char *avfile, int avbar_opt,
         }
         fprintf(fp, "\n");
     }
-    ffclose(fp);
+    gmx_ffclose(fp);
 
     if (avbar_opt == avbar90)
     {
@@ -613,9 +611,16 @@ static void estimate_error(const char *eefile, int nb_min, int resol, int n,
         }
         fprintf(stdout, "Set %3d:  err.est. %g  a %g  tau1 %g  tau2 %g\n",
                 s+1, ee, a, tau1, tau2);
-        fprintf(fp, "@ legend string %d \"av %f\"\n", 2*s, av[s]);
-        fprintf(fp, "@ legend string %d \"ee %6g\"\n",
-                2*s+1, sig[s]*anal_ee_inf(fitparm, n*dt));
+        if (output_env_get_xvg_format(oenv) == exvgXMGR)
+        {
+            fprintf(fp, "@ legend string %d \"av %f\"\n", 2*s, av[s]);
+            fprintf(fp, "@ legend string %d \"ee %6g\"\n", 2*s+1, sig[s]*anal_ee_inf(fitparm, n*dt));
+        }
+        else if (output_env_get_xvg_format(oenv) == exvgXMGRACE)
+        {
+            fprintf(fp, "@ s%d legend \"av %f\"\n", 2*s, av[s]);
+            fprintf(fp, "@ s%d legend \"ee %6g\"\n", 2*s+1, sig[s]*anal_ee_inf(fitparm, n*dt));
+        }
         for (i = 0; i < nbs; i++)
         {
             fprintf(fp, "%g %g %g\n", tbs[i], sig[s]*sqrt(ybs[i]/(n*dt)),
@@ -671,7 +676,7 @@ static void estimate_error(const char *eefile, int nb_min, int resol, int n,
                     s+1, sig[s]*anal_ee_inf(ac_fit, n*dt),
                     ac_fit[1], ac_fit[0], ac_fit[2]);
 
-            fprintf(fp, "&\n");
+            fprintf(fp, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
             for (i = 0; i < nbs; i++)
             {
                 fprintf(fp, "%g %g\n", tbs[i],
@@ -682,13 +687,13 @@ static void estimate_error(const char *eefile, int nb_min, int resol, int n,
         }
         if (s < nset-1)
         {
-            fprintf(fp, "&\n");
+            fprintf(fp, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
         }
     }
     sfree(fitsig);
     sfree(ybs);
     sfree(tbs);
-    ffclose(fp);
+    gmx_ffclose(fp);
 }
 
 static void luzar_correl(int nn, real *time, int nset, real **val, real temp,
@@ -1268,7 +1273,7 @@ int gmx_analyze(int argc, char *argv[])
 
     if (fitfile != NULL)
     {
-        out_fit = ffopen(fitfile, "w");
+        out_fit = gmx_ffopen(fitfile, "w");
         if (bXYdy && nset >= 2)
         {
             do_fit(out_fit, 0, TRUE, n, t, val, npargs, ppa, oenv);
@@ -1280,7 +1285,7 @@ int gmx_analyze(int argc, char *argv[])
                 do_fit(out_fit, s, FALSE, n, t, val, npargs, ppa, oenv);
             }
         }
-        ffclose(out_fit);
+        gmx_ffclose(out_fit);
     }
 
     printf("                                      std. dev.    relative deviation of\n");
@@ -1355,10 +1360,10 @@ int gmx_analyze(int argc, char *argv[])
             }
             if (s < nset-1)
             {
-                fprintf(out, "&\n");
+                fprintf(out, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
             }
         }
-        ffclose(out);
+        gmx_ffclose(out);
         fprintf(stderr, "\r%d, time=%g\n", j-1, (j-1)*dt);
     }
     if (ccfile)