Sort all includes in src/gromacs
[alexxy/gromacs.git] / src / gromacs / gmxana / gmx_pme_error.cpp
index a9916ca2101106c32ff97979ad750d54ea69c74d..0b0373833e6f6f5de3b56712705aaa0dd8664cfe 100644 (file)
@@ -1,56 +1,63 @@
 /*
- *                This source code is part of
+ * This file is part of the GROMACS molecular simulation package.
  *
- *                 G   R   O   M   A   C   S
+ * Copyright (c) 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.
  *
- *          GROningen MAchine for Chemical Simulations
- *
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2008, 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
+ * 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:
- * Gallium Rubidium Oxygen Manganese Argon Carbon Silicon
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
  */
+#include "gmxpre.h"
+
+#include "config.h"
+
 #include <algorithm>
 
-#include "statutil.h"
-#include "typedefs.h"
-#include "smalloc.h"
-#include "vec.h"
-#include "copyrite.h"
-#include "tpxio.h"
-#include "string2.h"
-#include "readinp.h"
-#include "calcgrid.h"
-#include "checkpoint.h"
-#include "gmx_ana.h"
-#include "gmx_random.h"
-#include "physics.h"
-#include "mdatoms.h"
-#include "coulomb.h"
-#include "mtop_util.h"
-#include "network.h"
-#include "main.h"
-#include "macros.h"
+#include "gromacs/commandline/pargs.h"
+#include "gromacs/fileio/tpxio.h"
+#include "gromacs/gmxana/gmx_ana.h"
+#include "gromacs/legacyheaders/calcgrid.h"
+#include "gromacs/legacyheaders/checkpoint.h"
+#include "gromacs/legacyheaders/copyrite.h"
+#include "gromacs/legacyheaders/coulomb.h"
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/legacyheaders/main.h"
+#include "gromacs/legacyheaders/mdatoms.h"
+#include "gromacs/legacyheaders/network.h"
+#include "gromacs/legacyheaders/readinp.h"
+#include "gromacs/legacyheaders/typedefs.h"
+#include "gromacs/legacyheaders/types/commrec.h"
+#include "gromacs/math/units.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/random/random.h"
+#include "gromacs/topology/mtop_util.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/smalloc.h"
 
 /* We use the same defines as in mvdata.c here */
 #define  block_bc(cr,   d) gmx_bcast(     sizeof(d),     &(d), (cr))
@@ -75,7 +82,7 @@ enum {
 
 typedef struct
 {
-    gmx_large_int_t orig_sim_steps;  /* Number of steps to be done in the real simulation  */
+    gmx_int64_t     orig_sim_steps;  /* Number of steps to be done in the real simulation  */
     int             n_entries;       /* Number of entries in arrays                        */
     real            volume;          /* The volume of the box                              */
     matrix          recipbox;        /* The reciprocal box                                 */
@@ -417,16 +424,16 @@ static void calc_recipbox(matrix box, matrix recipbox)
 
 /* Estimate the reciprocal space part error of the SPME Ewald sum. */
 static real estimate_reciprocal(
-        t_inputinfo *info,
-        rvec         x[],   /* array of particles */
-        real         q[],   /* array of charges */
-        int          nr,    /* number of charges = size of the charge array */
+        t_inputinfo       *info,
+        rvec               x[], /* array of particles */
+        real               q[], /* array of charges */
+        int                nr,  /* number of charges = size of the charge array */
         FILE  gmx_unused  *fp_out,
-        gmx_bool     bVerbose,
-        unsigned int seed,     /* The seed for the random number generator */
-        int         *nsamples, /* Return the number of samples used if Monte Carlo
-                                * algorithm is used for self energy error estimate */
-        t_commrec   *cr)
+        gmx_bool           bVerbose,
+        unsigned int       seed,     /* The seed for the random number generator */
+        int               *nsamples, /* Return the number of samples used if Monte Carlo
+                                      * algorithm is used for self energy error estimate */
+        t_commrec         *cr)
 {
     real     e_rec   = 0; /* reciprocal error estimate */
     real     e_rec1  = 0; /* Error estimate term 1*/
@@ -668,7 +675,7 @@ static real estimate_reciprocal(
                     xtot, xtot == 1 ? "" : "s");
             if (PAR(cr))
             {
-                fprintf(stdout, " (%d sample%s per node)", x_per_core, x_per_core == 1 ? "" : "s");
+                fprintf(stdout, " (%d sample%s per rank)", x_per_core, x_per_core == 1 ? "" : "s");
             }
             fprintf(stdout, ".\n");
         }
@@ -759,7 +766,7 @@ static real estimate_reciprocal(
 #ifdef DEBUG
     if (PAR(cr))
     {
-        fprintf(stderr, "Node %3d: nx=[%3d...%3d]  e_rec3=%e\n",
+        fprintf(stderr, "Rank %3d: nx=[%3d...%3d]  e_rec3=%e\n",
                 cr->nodeid, startlocal, stoplocal, e_rec3);
     }
 #endif
@@ -873,7 +880,7 @@ static void read_tpr_file(const char *fn_sim_tpr, t_inputinfo *info, t_state *st
     }
     else
     {
-        info->ewald_beta[0]  = calc_ewaldcoeff(info->rcoulomb[0], info->ewald_rtol[0]);
+        info->ewald_beta[0]  = calc_ewaldcoeff_q(info->rcoulomb[0], info->ewald_rtol[0]);
     }
 
     /* Check if PME was chosen */
@@ -1072,7 +1079,7 @@ static void estimate_PME_error(t_inputinfo *info, t_state *state,
 int gmx_pme_error(int argc, char *argv[])
 {
     const char     *desc[] = {
-        "[TT]g_pme_error[tt] estimates the error of the electrostatic forces",
+        "[THISMODULE] estimates the error of the electrostatic forces",
         "if using the sPME algorithm. The flag [TT]-tune[tt] will determine",
         "the splitting parameter such that the error is equally",
         "distributed over the real and reciprocal space part.",
@@ -1098,9 +1105,9 @@ int gmx_pme_error(int argc, char *argv[])
 
 
     static t_filenm fnm[] = {
-        { efTPX, "-s",     NULL,    ffREAD },
+        { efTPR, "-s",     NULL,    ffREAD },
         { efOUT, "-o",    "error",  ffWRITE },
-        { efTPX, "-so",   "tuned",  ffOPTWR }
+        { efTPR, "-so",   "tuned",  ffOPTWR }
     };
 
     output_env_t    oenv = NULL;
@@ -1121,17 +1128,16 @@ int gmx_pme_error(int argc, char *argv[])
 
 #define NFILE asize(fnm)
 
-    cr = init_par();
-#ifdef GMX_LIB_MPI
-    MPI_Barrier(MPI_COMM_WORLD);
-#endif
+    cr = init_commrec();
 
     PCA_Flags  = PCA_NOEXIT_ON_ARGS;
-    PCA_Flags |= (MASTER(cr) ? 0 : PCA_QUIET);
 
-    parse_common_args(&argc, argv, PCA_Flags,
-                      NFILE, fnm, asize(pa), pa, asize(desc), desc,
-                      0, NULL, &oenv);
+    if (!parse_common_args(&argc, argv, PCA_Flags,
+                           NFILE, fnm, asize(pa), pa, asize(desc), desc,
+                           0, NULL, &oenv))
+    {
+        return 0;
+    }
 
     if (!bTUNE)
     {