Remove unnecessary config.h includes
[alexxy/gromacs.git] / src / gromacs / gmxana / gmx_xpm2ps.c
index f46442a9f0a92de0d06cedb225579b05ee9522a8..0e2bd1f6767a3576d94682fa2ffd2a7007564017 100644 (file)
@@ -1,58 +1,57 @@
 /*
+ * 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 <stdio.h>
 #include <stdlib.h>
 #include <math.h>
-#include "string2.h"
-#include "copyrite.h"
-#include "typedefs.h"
-#include "macros.h"
-#include "statutil.h"
-#include "writeps.h"
-#include "futil.h"
-#include "gmx_fatal.h"
-#include "smalloc.h"
-#include "string2.h"
-#include "matio.h"
-#include "viewit.h"
+#include "gromacs/legacyheaders/typedefs.h"
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/smalloc.h"
+#include "gromacs/legacyheaders/viewit.h"
 #include "gmx_ana.h"
 
+#include "gromacs/commandline/pargs.h"
+#include "gromacs/utility/futil.h"
+#include "gromacs/fileio/matio.h"
+#include "gromacs/fileio/trxio.h"
+#include "gromacs/fileio/writeps.h"
+
 #define FUDGE 1.2
 #define DDD   2
 
@@ -118,7 +117,7 @@ void get_params(const char *mpin, const char *mpout, t_psrec *psr)
 
     if (mpin != NULL)
     {
-        inp = read_inpfile(mpin, &ninp, NULL, wi);
+        inp = read_inpfile(mpin, &ninp, wi);
     }
     else
     {
@@ -399,7 +398,7 @@ static void draw_boxes(t_psdata ps, real x0, real y0, real w,
         for (j = 0; (j < ntx); j++)
         {
             sprintf(buf, "%g", mat[i].axis_x[j]);
-            xtick[j] = strdup(buf);
+            xtick[j] = gmx_strdup(buf);
         }
         ps_strfont(ps, psr->X.tickfont, psr->X.tickfontsize);
         for (x = 0; (x < ntx); x++)
@@ -436,7 +435,7 @@ static void draw_boxes(t_psdata ps, real x0, real y0, real w,
         for (j = 0; (j < nty); j++)
         {
             sprintf(buf, "%g", mat[i].axis_y[j]);
-            ytick[j] = strdup(buf);
+            ytick[j] = gmx_strdup(buf);
         }
 
         for (y = 0; (y < nty); y++)
@@ -522,8 +521,8 @@ static void draw_zerolines(t_psdata out, real x0, real y0, real w,
                 xx = xx00+(x+0.7)*psr->xboxsize;
                 /* draw lines whenever tick label almost zero (e.g. next trajectory) */
                 if (x != 0 && x < mat[i].nx-1 &&
-                    abs(mat[i].axis_x[x]) <
-                    0.1*abs(mat[i].axis_x[x+1]-mat[i].axis_x[x]) )
+                    fabs(mat[i].axis_x[x]) <
+                    0.1*fabs(mat[i].axis_x[x+1]-mat[i].axis_x[x]) )
                 {
                     ps_line (out, xx, yy00, xx, yy00+dy+2);
                 }
@@ -537,8 +536,8 @@ static void draw_zerolines(t_psdata out, real x0, real y0, real w,
                 yy = yy00+(y+0.7)*psr->yboxsize;
                 /* draw lines whenever tick label almost zero (e.g. next trajectory) */
                 if (y != 0 && y < mat[i].ny-1 &&
-                    abs(mat[i].axis_y[y]) <
-                    0.1*abs(mat[i].axis_y[y+1]-mat[i].axis_y[y]) )
+                    fabs(mat[i].axis_y[y]) <
+                    0.1*fabs(mat[i].axis_y[y+1]-mat[i].axis_y[y]) )
                 {
                     ps_line (out, xx00, yy, xx00+w+2, yy);
                 }
@@ -674,7 +673,7 @@ void xpm_mat(const char *outf, int nmat, t_matrix *mat, t_matrix *mat2,
     int        nmap;
     t_mapping *map = NULL;
 
-    out = ffopen(outf, "w");
+    out = gmx_ffopen(outf, "w");
 
     for (i = 0; i < nmat; i++)
     {
@@ -710,18 +709,18 @@ void xpm_mat(const char *outf, int nmat, t_matrix *mat, t_matrix *mat2,
             sfree(mat[i].map);
             mat[i].nmap = nmap;
             mat[i].map  = map;
-            if (mat2 && (strcmp(mat[i].title, mat2[i].title) != 0))
+            if (strcmp(mat[i].title, mat2[i].title) != 0)
             {
                 sprintf(mat[i].title+strlen(mat[i].title), " / %s", mat2[i].title);
             }
-            if (mat2 && (strcmp(mat[i].legend, mat2[i].legend) != 0))
+            if (strcmp(mat[i].legend, mat2[i].legend) != 0)
             {
                 sprintf(mat[i].legend+strlen(mat[i].legend), " / %s", mat2[i].legend);
             }
             write_xpm_m(out, mat[i]);
         }
     }
-    ffclose(out);
+    gmx_ffclose(out);
 }
 
 static void tick_spacing(int n, real axis[], real offset, char axisnm,
@@ -1134,7 +1133,7 @@ void zero_lines(int nmat, t_matrix *mat, t_matrix *mat2)
             }
             for (x = 0; x < mats[i].nx-1; x++)
             {
-                if (abs(mats[i].axis_x[x+1]) < 1e-5)
+                if (fabs(mats[i].axis_x[x+1]) < 1e-5)
                 {
                     for (y = 0; y < mats[i].ny; y++)
                     {
@@ -1144,7 +1143,7 @@ void zero_lines(int nmat, t_matrix *mat, t_matrix *mat2)
             }
             for (y = 0; y < mats[i].ny-1; y++)
             {
-                if (abs(mats[i].axis_y[y+1]) < 1e-5)
+                if (fabs(mats[i].axis_y[y+1]) < 1e-5)
                 {
                     for (x = 0; x < mats[i].nx; x++)
                     {
@@ -1166,7 +1165,7 @@ void write_combined_matrix(int ecombine, const char *fn,
     real     **rmat1, **rmat2;
     real       rhi, rlo;
 
-    out = ffopen(fn, "w");
+    out = gmx_ffopen(fn, "w");
     for (k = 0; k < nmat; k++)
     {
         if (mat2[k].nx != mat1[k].nx || mat2[k].ny != mat1[k].ny)
@@ -1237,7 +1236,7 @@ void write_combined_matrix(int ecombine, const char *fn,
                       rmat1, rlo, rhi, white, black, &nlevels);
         }
     }
-    ffclose(out);
+    gmx_ffclose(out);
 }
 
 void do_mat(int nmat, t_matrix *mat, t_matrix *mat2,
@@ -1379,11 +1378,11 @@ void rainbow_mat(gmx_bool bBlue, int nmat, t_matrix mat[])
 int gmx_xpm2ps(int argc, char *argv[])
 {
     const char     *desc[] = {
-        "[TT]xpm2ps[tt] makes a beautiful color plot of an XPixelMap file.",
+        "[THISMODULE] makes a beautiful color plot of an XPixelMap file.",
         "Labels and axis can be displayed, when they are supplied",
         "in the correct matrix format.",
-        "Matrix data may be generated by programs such as [TT]do_dssp[tt], [TT]g_rms[tt] or",
-        "[TT]g_mdmat[tt].[PAR]",
+        "Matrix data may be generated by programs such as [gmx-do_dssp], [gmx-rms] or",
+        "[gmx-mdmat].[PAR]",
         "Parameters are set in the [TT].m2p[tt] file optionally supplied with",
         "[TT]-di[tt]. Reasonable defaults are provided. Settings for the [IT]y[it]-axis",
         "default to those for the [IT]x[it]-axis. Font names have a defaulting hierarchy:",
@@ -1485,9 +1484,12 @@ int gmx_xpm2ps(int argc, char *argv[])
     };
 #define NFILE asize(fnm)
 
-    parse_common_args(&argc, argv, PCA_CAN_VIEW,
-                      NFILE, fnm, NPA, pa,
-                      asize(desc), desc, 0, NULL, &oenv);
+    if (!parse_common_args(&argc, argv, PCA_CAN_VIEW,
+                           NFILE, fnm, NPA, pa,
+                           asize(desc), desc, 0, NULL, &oenv))
+    {
+        return 0;
+    }
 
     etitle   = nenum(title);
     elegend  = nenum(legend);
@@ -1611,7 +1613,5 @@ int gmx_xpm2ps(int argc, char *argv[])
 
     view_all(oenv, NFILE, fnm);
 
-    thanx(stderr);
-
     return 0;
 }