Sort all includes in src/gromacs
[alexxy/gromacs.git] / src / gromacs / gmxana / anadih.c
index 5c854a93f3f0854e0d3e18f94205ebcb272e6174..c967c601c85b036aab9128d755a2531fc43dd813 100644 (file)
@@ -1,54 +1,58 @@
 /*
+ * 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 <stdio.h>
 #include <string.h>
-#include "physics.h"
-#include "smalloc.h"
-#include "macros.h"
-#include "txtdump.h"
-#include "bondf.h"
-#include "xvgr.h"
-#include "typedefs.h"
-#include "vec.h"
-#include "gstat.h"
-#include "confio.h"
+
+#include "gromacs/bonded/bonded.h"
+#include "gromacs/fileio/confio.h"
+#include "gromacs/fileio/trxio.h"
+#include "gromacs/fileio/xvgr.h"
+#include "gromacs/gmxana/gstat.h"
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/legacyheaders/txtdump.h"
+#include "gromacs/legacyheaders/typedefs.h"
+#include "gromacs/math/units.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/pbcutil/pbc.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/smalloc.h"
 
 void print_one(const output_env_t oenv, const char *base, const char *name,
                const char *title, const char *ylabel, int nf, real time[],
@@ -66,10 +70,10 @@ void print_one(const output_env_t oenv, const char *base, const char *name,
     {
         fprintf(fp, "%10g  %10g\n", time[k], data[k]);
     }
-    ffclose(fp);
+    gmx_ffclose(fp);
 }
 
-static int calc_RBbin(real phi, int multiplicity, real core_frac)
+static int calc_RBbin(real phi, int gmx_unused multiplicity, real gmx_unused core_frac)
 {
     /* multiplicity and core_frac NOT used,
      * just given to enable use of pt-to-fn in caller low_ana_dih_trans*/
@@ -296,7 +300,7 @@ void low_ana_dih_trans(gmx_bool bTrans, const char *fn_trans,
         {
             fprintf(fp, "%10.3f  %10d\n", time[j], tr_f[j]);
         }
-        ffclose(fp);
+        gmx_ffclose(fp);
     }
 
     /* Compute histogram from # transitions per dihedral */
@@ -326,7 +330,7 @@ void low_ana_dih_trans(gmx_bool bTrans, const char *fn_trans,
                 fprintf(fp, "%10.3f  %10d\n", ttime/i, tr_f[i]);
             }
         }
-        ffclose(fp);
+        gmx_ffclose(fp);
     }
 
     sfree(tr_f);
@@ -338,7 +342,7 @@ void low_ana_dih_trans(gmx_bool bTrans, const char *fn_trans,
 
 }
 
-void mk_multiplicity_lookup (int *multiplicity, int maxchi, real **dih,
+void mk_multiplicity_lookup (int *multiplicity, int maxchi,
                              int nlist, t_dlist dlist[], int nangles)
 {
     /* new by grs - for dihedral j (as in dih[j]) get multiplicity from dlist
@@ -402,7 +406,7 @@ void mk_multiplicity_lookup (int *multiplicity, int maxchi, real **dih,
 
 }
 
-void mk_chi_lookup (int **lookup, int maxchi, real **dih,
+void mk_chi_lookup (int **lookup, int maxchi,
                     int nlist, t_dlist dlist[])
 {
 
@@ -414,7 +418,8 @@ void mk_chi_lookup (int **lookup, int maxchi, real **dih,
     int i, j, Dih, Chi;
 
     j = 0;
-    for (Dih = 0; (Dih < NONCHI+maxchi); Dih++)
+    /* NONCHI points to chi1, therefore we have to start counting there. */
+    for (Dih = NONCHI; (Dih < NONCHI+maxchi); Dih++)
     {
         for (i = 0; (i < nlist); i++)
         {
@@ -440,7 +445,7 @@ void mk_chi_lookup (int **lookup, int maxchi, real **dih,
 }
 
 
-void get_chi_product_traj (real **dih, int nframes, int nangles, int nlist,
+void get_chi_product_traj (real **dih, int nframes, int nlist,
                            int maxchi, t_dlist dlist[], real time[],
                            int **lookup, int *multiplicity, gmx_bool bRb, gmx_bool bNormalize,
                            real core_frac, gmx_bool bAll, const char *fnall,
@@ -565,9 +570,12 @@ void get_chi_product_traj (real **dih, int nframes, int nangles, int nlist,
                 sprintf(histitle, "cumulative rotamer distribution for %s", dlist[i].name);
                 fprintf(stderr, "  and %s  ", hisfile);
                 fp = xvgropen(hisfile, histitle, "number", "", oenv);
-                fprintf(fp, "@ xaxis tick on\n");
-                fprintf(fp, "@ xaxis tick major 1\n");
-                fprintf(fp, "@ type xy\n");
+                if (output_env_get_print_xvgr_codes(oenv))
+                {
+                    fprintf(fp, "@ xaxis tick on\n");
+                    fprintf(fp, "@ xaxis tick major 1\n");
+                    fprintf(fp, "@ type xy\n");
+                }
                 for (k = 0; (k < nbin); k++)
                 {
                     if (bNormalize)
@@ -579,8 +587,8 @@ void get_chi_product_traj (real **dih, int nframes, int nangles, int nlist,
                         fprintf(fp, "%5d  %10d\n", k, chi_prhist[k]);
                     }
                 }
-                fprintf(fp, "&\n");
-                ffclose(fp);
+                fprintf(fp, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
+                gmx_ffclose(fp);
             }
 
             /* and finally print out occupancies to a single file */
@@ -607,7 +615,7 @@ void get_chi_product_traj (real **dih, int nframes, int nangles, int nlist,
     }
 
     sfree(chi_prtrj);
-    ffclose(fpall);
+    gmx_ffclose(fpall);
     fprintf(stderr, "\n");
 
 }
@@ -667,7 +675,7 @@ void calc_distribution_props(int nh, int histo[], real start,
     *S2 = tdc*tdc+tds*tds;
 }
 
-static void calc_angles(FILE *log, t_pbc *pbc,
+static void calc_angles(struct t_pbc *pbc,
                         int n3, atom_id index[], real ang[], rvec x_s[])
 {
     int  i, ix, t1, t2;
@@ -721,7 +729,7 @@ static real calc_fraction(real angles[], int nangles)
     }
 }
 
-static void calc_dihs(FILE *log, t_pbc *pbc,
+static void calc_dihs(struct t_pbc *pbc,
                       int n4, atom_id index[], real ang[], rvec x_s[])
 {
     int  i, ix, t1, t2, t3;
@@ -809,15 +817,15 @@ void read_ang_dih(const char *trj_fn,
                   real *dih[],
                   const output_env_t oenv)
 {
-    t_pbc       *pbc;
-    t_trxstatus *status;
-    int          i, angind, natoms, total, teller;
-    int          nangles, n_alloc;
-    real         t, fraction, pifac, aa, angle;
-    real        *angles[2];
-    matrix       box;
-    rvec        *x;
-    int          cur = 0;
+    struct t_pbc *pbc;
+    t_trxstatus  *status;
+    int           i, angind, natoms, total, teller;
+    int           nangles, n_alloc;
+    real          t, fraction, pifac, aa, angle;
+    real         *angles[2];
+    matrix        box;
+    rvec         *x;
+    int           cur = 0;
 #define prev (1-cur)
 
     snew(pbc, 1);
@@ -870,11 +878,11 @@ void read_ang_dih(const char *trj_fn,
 
         if (bAngles)
         {
-            calc_angles(stdout, pbc, isize, index, angles[cur], x);
+            calc_angles(pbc, isize, index, angles[cur], x);
         }
         else
         {
-            calc_dihs(stdout, pbc, isize, index, angles[cur], x);
+            calc_dihs(pbc, isize, index, angles[cur], x);
 
             /* Trans fraction */
             fraction              = calc_fraction(angles[cur], nangles);
@@ -992,7 +1000,7 @@ void read_ang_dih(const char *trj_fn,
         /* Increment loop counter */
         teller++;
     }
-    while (read_next_x(oenv, status, &t, natoms, x, box));
+    while (read_next_x(oenv, status, &t, x, box));
     close_trj(status);
 
     sfree(x);