Sort all includes in src/gromacs
[alexxy/gromacs.git] / src / gromacs / gmxana / gmx_current.c
index bb762e7beda1244928b6dbc5a6dadd825ddf3bc9..e27cf05233ae6e631a3a8f446de276a20f4295f3 100644 (file)
@@ -1,65 +1,61 @@
 /*
+ * This file is part of the GROMACS molecular simulation package.
  *
- *                This source code is part of
+ * Copyright (c) 2008,2009,2010,2011,2012,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.
  *
- *                 G   R   O   M   A   C   S
- *
- *          GROningen MAchine for Chemical Simulations
- *                        VERSION 3.0
- *
- * Copyright (c) 1991-2001
- * BIOSON Research Institute, Dept. of Biophysical Chemistry
- * University of Groningen, The Netherlands
- *
- * 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
+ * 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.
- *
- * 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.
- *
- * Do check out http://www.gromacs.org , or mail us at gromacs@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.
  *
- * And Hey:
- * Gyas ROwers Mature At Cryogenic Speed
+ * 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.
  *
- * finished FD 09/07/08
+ * 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.
  *
+ * 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 "statutil.h"
-#include "typedefs.h"
-#include "smalloc.h"
-#include "vec.h"
-#include "copyrite.h"
-#include "statutil.h"
-#include "tpxio.h"
-#include "xvgr.h"
-#include "rmpbc.h"
-#include "pbc.h"
-#include "physics.h"
-#include "index.h"
-#include "gmx_statistics.h"
-#include "gmx_ana.h"
-#include "macros.h"
+#include "gmxpre.h"
+
+#include <assert.h>
+#include <stdlib.h>
+
+#include "gromacs/commandline/pargs.h"
+#include "gromacs/fileio/tpxio.h"
+#include "gromacs/fileio/trxio.h"
+#include "gromacs/fileio/xvgr.h"
+#include "gromacs/gmxana/gmx_ana.h"
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/legacyheaders/typedefs.h"
+#include "gromacs/math/units.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/pbcutil/pbc.h"
+#include "gromacs/pbcutil/rmpbc.h"
+#include "gromacs/statistics/statistics.h"
+#include "gromacs/topology/index.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/smalloc.h"
 
 #define SQR(x) (pow(x, 2.0))
 #define EPSI0 (EPSILON0*E_CHARGE*E_CHARGE*AVOGADRO/(KILO*NANO)) /* EPSILON0 in SI units */
 
-
 static void index_atom2mol(int *n, int *index, t_block *mols)
 {
     int nat, i, nmol, mol, j;
@@ -142,7 +138,7 @@ static gmx_bool precalc(t_topology top, real mass2[], real qmol[])
         }
     }
 
-    if (abs(qall) > 0.01)
+    if (fabs(qall) > 0.01)
     {
         printf("\n\nSystem not neutral (q=%f) will not calculate translational part of the dipole moment.\n", qall);
         bNEU = FALSE;
@@ -326,7 +322,7 @@ static real calc_cacf(FILE *fcacf, real prefactor, real cacf[], real time[], int
 
 }
 
-static void calc_mjdsp(FILE *fmjdsp, real vol, real temp, real prefactor, rvec mjdsp[], real dsp2[], real time[], int nfr, real refr[])
+static void calc_mjdsp(FILE *fmjdsp, real prefactor, real dsp2[], real time[], int nfr, real refr[])
 {
 
     int     i;
@@ -447,7 +443,7 @@ static void dielectric(FILE *fmj, FILE *fmd, FILE *outf, FILE *fcur, FILE *mcor,
     clear_rvec(mjd_tmp);
     clear_rvec(mdvec);
     clear_rvec(tmp);
-    gpbc = gmx_rmpbc_init(&top.idef, ePBC, fr.natoms, fr.box);
+    gpbc = gmx_rmpbc_init(&top.idef, ePBC, fr.natoms);
 
     do
     {
@@ -473,7 +469,7 @@ static void dielectric(FILE *fmj, FILE *fmd, FILE *outf, FILE *fcur, FILE *mcor,
                 xshfr[i] = 0.0;
             }
         }
-
+        assert(time != NULL);
 
 
         if (nfr == 0)
@@ -631,7 +627,7 @@ static void dielectric(FILE *fmj, FILE *fmd, FILE *outf, FILE *fcur, FILE *mcor,
 
     fprintf(stderr, "Prefactor fit E-H: 1 / 6.0*V*k_B*T: %g\n", prefactorav);
 
-    calc_mjdsp(fmjdsp, volume_av, temp, prefactorav, mjdsp, dsp2, time, nfr, xshfr);
+    calc_mjdsp(fmjdsp, prefactorav, dsp2, time, nfr, xshfr);
 
     /*
      * Now we can average and calculate the correlation functions
@@ -729,7 +725,7 @@ static void dielectric(FILE *fmj, FILE *fmd, FILE *outf, FILE *fcur, FILE *mcor,
 
 
 
-    if (bACF)
+    if (bACF && (ii < nvfr))
     {
         fprintf(stderr, "Integral and integrated fit to the current acf yields at t=%f:\n", time[vfr[ii]]);
         fprintf(stderr, "sigma=%8.3f (pure integral: %.3f)\n", sgk-malt*pow(time[vfr[ii]], sigma), sgk);
@@ -764,7 +760,7 @@ static void dielectric(FILE *fmj, FILE *fmd, FILE *outf, FILE *fcur, FILE *mcor,
     }
     else
     {
-        fprintf(stderr, "Too less points for a fit.\n");
+        fprintf(stderr, "Too few points for a fit.\n");
     }
 
 
@@ -861,19 +857,19 @@ int gmx_current(int argc, char *argv[])
         { efTPS,  NULL,  NULL, ffREAD }, /* this is for the topology */
         { efNDX, NULL, NULL, ffOPTRD },
         { efTRX, "-f", NULL, ffREAD },   /* and this for the trajectory */
-        { efXVG, "-o", "current.xvg", ffWRITE },
-        { efXVG, "-caf", "caf.xvg", ffOPTWR },
-        { efXVG, "-dsp", "dsp.xvg", ffWRITE },
-        { efXVG, "-md", "md.xvg", ffWRITE },
-        { efXVG, "-mj", "mj.xvg", ffWRITE},
-        { efXVG, "-mc", "mc.xvg", ffOPTWR }
+        { efXVG, "-o",   "current", ffWRITE },
+        { efXVG, "-caf", "caf",     ffOPTWR },
+        { efXVG, "-dsp", "dsp",     ffWRITE },
+        { efXVG, "-md",  "md",      ffWRITE },
+        { efXVG, "-mj",  "mj",      ffWRITE },
+        { efXVG, "-mc",  "mc",      ffOPTWR }
     };
 
 #define NFILE asize(fnm)
 
 
     const char *desc[] = {
-        "[TT]g_current[tt] is a tool for calculating the current autocorrelation function, the correlation",
+        "[THISMODULE] is a tool for calculating the current autocorrelation function, the correlation",
         "of the rotational and translational dipole moment of the system, and the resulting static",
         "dielectric constant. To obtain a reasonable result, the index group has to be neutral.",
         "Furthermore, the routine is capable of extracting the static conductivity from the current ",
@@ -909,8 +905,11 @@ int gmx_current(int argc, char *argv[])
 
 
     /* At first the arguments will be parsed and the system information processed */
-    parse_common_args(&argc, argv, PCA_CAN_TIME | PCA_CAN_VIEW,
-                      NFILE, fnm, asize(pa), pa, asize(desc), desc, 0, NULL, &oenv);
+    if (!parse_common_args(&argc, argv, PCA_CAN_TIME | PCA_CAN_VIEW,
+                           NFILE, fnm, asize(pa), pa, asize(desc), desc, 0, NULL, &oenv))
+    {
+        return 0;
+    }
 
     bACF = opt2bSet("-caf", NFILE, fnm);
     bINT = opt2bSet("-mc", NFILE, fnm);
@@ -993,19 +992,17 @@ int gmx_current(int argc, char *argv[])
                temp, trust, bfit, efit, bvit, evit, status, isize, nmols, nshift,
                index0, indexm, mass2, qmol, eps_rf, oenv);
 
-    ffclose(fmj);
-    ffclose(fmd);
-    ffclose(fmjdsp);
+    gmx_ffclose(fmj);
+    gmx_ffclose(fmd);
+    gmx_ffclose(fmjdsp);
     if (bACF)
     {
-        ffclose(outf);
+        gmx_ffclose(outf);
     }
     if (bINT)
     {
-        ffclose(mcor);
+        gmx_ffclose(mcor);
     }
 
-    thanx(stderr);
-
     return 0;
 }