Remove .tpa, .tpb, .tpx, .trj files. Part of #1500.
[alexxy/gromacs.git] / src / gromacs / gmxana / gmx_order.c
index 97e83ee2d957a5d896723d8572e9d30fc0ae4489..7c2b600d058b57a4bb0481ef50c0c4a3c2c5dd17 100644 (file)
@@ -1,62 +1,63 @@
 /*
+ * 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 <ctype.h>
-
-#include "sysstuff.h"
 #include <string.h>
-#include "typedefs.h"
-#include "smalloc.h"
-#include "macros.h"
+
+#include "gromacs/legacyheaders/typedefs.h"
+#include "gromacs/legacyheaders/macros.h"
 #include "gstat.h"
-#include "vec.h"
-#include "xvgr.h"
-#include "pbc.h"
-#include "copyrite.h"
-#include "futil.h"
-#include "statutil.h"
-#include "index.h"
-#include "tpxio.h"
-#include "confio.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/legacyheaders/viewit.h"
+#include "gromacs/pbcutil/pbc.h"
+#include "gromacs/utility/futil.h"
+#include "gromacs/topology/index.h"
+#include "gromacs/fileio/tpxio.h"
+#include "gromacs/fileio/trxio.h"
+#include "gromacs/fileio/confio.h"
 #include "cmat.h"
 #include "gmx_ana.h"
 
+#include "gromacs/commandline/pargs.h"
+#include "gromacs/fileio/xvgr.h"
+#include "gromacs/pbcutil/rmpbc.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/smalloc.h"
 
 /****************************************************************************/
 /* This program calculates the order parameter per atom for an interface or */
 /* P.J. van Maaren, November 2005     Added tetrahedral stuff               */
 /****************************************************************************/
 
-static void find_nearest_neighbours(t_topology top, int ePBC,
+static void find_nearest_neighbours(int ePBC,
                                     int natoms, matrix box,
                                     rvec x[], int maxidx, atom_id index[],
-                                    real time,
                                     real *sgmean, real *skmean,
                                     int nslice, int slice_dim,
                                     real sgslice[], real skslice[],
@@ -303,11 +303,11 @@ static void calc_tetra_order_parm(const char *fnNDX, const char *fnTPS,
                     oenv);
 
     /* loop over frames */
-    gpbc    = gmx_rmpbc_init(&top.idef, ePBC, natoms, box);
+    gpbc    = gmx_rmpbc_init(&top.idef, ePBC, natoms);
     nframes = 0;
     do
     {
-        find_nearest_neighbours(top, ePBC, natoms, box, x, isize[0], index[0], t,
+        find_nearest_neighbours(ePBC, natoms, box, x, isize[0], index[0],
                                 &sg, &sk, nslice, slice_dim, sg_slice, sk_slice, gpbc);
         for (i = 0; (i < nslice); i++)
         {
@@ -318,7 +318,7 @@ static void calc_tetra_order_parm(const char *fnNDX, const char *fnTPS,
         fprintf(fpsk, "%f %f\n", t, sk);
         nframes++;
     }
-    while (read_next_x(oenv, status, &t, natoms, x, box));
+    while (read_next_x(oenv, status, &t, x, box));
     close_trj(status);
     gmx_rmpbc_done(gpbc);
 
@@ -326,8 +326,8 @@ static void calc_tetra_order_parm(const char *fnNDX, const char *fnTPS,
     sfree(index);
     sfree(isize);
 
-    ffclose(fpsg);
-    ffclose(fpsk);
+    gmx_ffclose(fpsg);
+    gmx_ffclose(fpsk);
 
     fpsg = xvgropen(sgslfn,
                     "S\\sg\\N Angle Order Parameter / Slab", "(nm)", "S\\sg\\N",
@@ -342,8 +342,8 @@ static void calc_tetra_order_parm(const char *fnNDX, const char *fnTPS,
         fprintf(fpsk, "%10g  %10g\n", (i+0.5)*box[slice_dim][slice_dim]/nslice,
                 sk_slice_tot[i]/nframes);
     }
-    ffclose(fpsg);
-    ffclose(fpsk);
+    gmx_ffclose(fpsg);
+    gmx_ffclose(fpsk);
 }
 
 
@@ -356,7 +356,7 @@ static void print_types(atom_id index[], atom_id a[], int ngrps,
     fprintf(stderr, "Using following groups: \n");
     for (i = 0; i < ngrps; i++)
     {
-        fprintf(stderr, "Groupname: %s First atomname: %s First atomnr %u\n",
+        fprintf(stderr, "Groupname: %s First atomname: %s First atomnr %d\n",
                 groups[i], *(top->atoms.atomname[a[index[i]]]), a[index[i]]);
     }
     fprintf(stderr, "\n");
@@ -490,7 +490,7 @@ void calc_order(const char *fn, atom_id *index, atom_id *a, rvec **order,
 
     teller = 0;
 
-    gpbc = gmx_rmpbc_init(&top->idef, ePBC, natoms, box);
+    gpbc = gmx_rmpbc_init(&top->idef, ePBC, natoms);
     /*********** Start processing trajectory ***********/
     do
     {
@@ -704,7 +704,7 @@ void calc_order(const char *fn, atom_id *index, atom_id *a, rvec **order,
         nr_frames++;
 
     }
-    while (read_next_x(oenv, status, &t, natoms, x0, box));
+    while (read_next_x(oenv, status, &t, x0, box));
     /*********** done with status file **********/
 
     fprintf(stderr, "\nRead trajectory. Printing parameters to file\n");
@@ -831,8 +831,8 @@ void order_plot(rvec order[], real *slOrder[], const char *afile, const char *bf
                                                         0.333 * order[atom][YY]));
         }
 
-        ffclose(ord);
-        ffclose(slOrd);
+        gmx_ffclose(ord);
+        gmx_ffclose(slOrd);
     }
 }
 
@@ -898,14 +898,14 @@ void write_bfactors(t_filenm  *fnm, int nfile, atom_id *index, atom_id *a, int n
 int gmx_order(int argc, char *argv[])
 {
     const char        *desc[] = {
-        "Compute the order parameter per atom for carbon tails. For atom i the",
+        "[THISMODULE] computes the order parameter per atom for carbon tails. For atom i the",
         "vector i-1, i+1 is used together with an axis. ",
         "The index file should contain only the groups to be used for calculations,",
         "with each group of equivalent carbons along the relevant acyl chain in its own",
         "group. There should not be any generic groups (like System, Protein) in the index",
         "file to avoid confusing the program (this is not relevant to tetrahedral order",
         "parameters however, which only work for water anyway).[PAR]",
-        "The program can also give all",
+        "[THISMODULE] can also give all",
         "diagonal elements of the order tensor and even calculate the deuterium",
         "order parameter Scd (default). If the option [TT]-szonly[tt] is given, only one",
         "order tensor component (specified by the [TT]-d[tt] option) is given and the",
@@ -961,7 +961,7 @@ int gmx_order(int argc, char *argv[])
         { efTRX, "-f", NULL,  ffREAD },               /* trajectory file              */
         { efNDX, "-n", NULL,  ffREAD },               /* index file           */
         { efNDX, "-nr", NULL,  ffREAD },              /* index for radial axis calculation       */
-        { efTPX, NULL, NULL,  ffREAD },               /* topology file                */
+        { efTPR, NULL, NULL,  ffREAD },               /* topology file                */
         { efXVG, "-o", "order", ffWRITE },            /* xvgr output file     */
         { efXVG, "-od", "deuter", ffWRITE },          /* xvgr output file           */
         { efPDB, "-ob", NULL, ffWRITE },              /* write Scd as B factors to PDB if permolecule           */
@@ -977,8 +977,11 @@ int gmx_order(int argc, char *argv[])
     const char   *sgfnm, *skfnm, *ndxfnm, *tpsfnm, *trxfnm;
     output_env_t  oenv;
 
-    parse_common_args(&argc, argv, PCA_CAN_VIEW | PCA_CAN_TIME | PCA_BE_NICE,
-                      NFILE, fnm, asize(pa), pa, asize(desc), desc, 0, NULL, &oenv);
+    if (!parse_common_args(&argc, argv, PCA_CAN_VIEW | PCA_CAN_TIME,
+                           NFILE, fnm, asize(pa), pa, asize(desc), desc, 0, NULL, &oenv))
+    {
+        return 0;
+    }
     if (nslices < 1)
     {
         gmx_fatal(FARGS, "Can not have nslices < 1");
@@ -986,7 +989,7 @@ int gmx_order(int argc, char *argv[])
     sgfnm  = opt2fn_null("-Sg", NFILE, fnm);
     skfnm  = opt2fn_null("-Sk", NFILE, fnm);
     ndxfnm = opt2fn_null("-n", NFILE, fnm);
-    tpsfnm = ftp2fn(efTPX, NFILE, fnm);
+    tpsfnm = ftp2fn(efTPR, NFILE, fnm);
     trxfnm = ftp2fn(efTRX, NFILE, fnm);
 
     /* Calculate axis */
@@ -1057,7 +1060,7 @@ int gmx_order(int argc, char *argv[])
             fprintf(stderr, "Taking carbons as unsaturated!\n");
         }
 
-        top = read_top(ftp2fn(efTPX, NFILE, fnm), &ePBC); /* read topology file */
+        top = read_top(ftp2fn(efTPR, NFILE, fnm), &ePBC); /* read topology file */
 
         block = init_index(ftp2fn(efNDX, NFILE, fnm), &grpname);
         index = block->index;                   /* get indices from t_block block */
@@ -1114,7 +1117,6 @@ int gmx_order(int argc, char *argv[])
         do_view(oenv, opt2fn("-od", NFILE, fnm), NULL); /* view xvgr file */
     }
 
-    thanx(stderr);
     if (distvals != NULL)
     {
         for (i = 0; i < nslices; ++i)