Remove unnecessary extensions in t_filenm defaults
[alexxy/gromacs.git] / src / gromacs / gmxana / gmx_confrms.c
index f7f38337dc3141ecbd1830fcb0bda718abc3aaea..8923544657bdfe61c10c9b314b994aa1706af9d6 100644 (file)
@@ -1,64 +1,62 @@
 /*
+ * 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 "filenm.h"
-#include "smalloc.h"
-#include "macros.h"
 #include <math.h>
-#include "typedefs.h"
-#include "xvgr.h"
-#include "copyrite.h"
-#include "statutil.h"
-#include "tpxio.h"
-#include "string2.h"
-#include "vec.h"
-#include "index.h"
-#include "pbc.h"
-#include "gmx_fatal.h"
-#include "futil.h"
-#include "confio.h"
-#include "pdbio.h"
-#include "txtdump.h"
-#include "do_fit.h"
-#include "viewit.h"
-#include "rmpbc.h"
+#include <string.h>
+
+#include "gromacs/fileio/filenm.h"
+#include "gromacs/utility/smalloc.h"
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/legacyheaders/typedefs.h"
+#include "gromacs/commandline/pargs.h"
+#include "gromacs/fileio/tpxio.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/topology/index.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/futil.h"
+#include "gromacs/fileio/confio.h"
+#include "gromacs/fileio/pdbio.h"
+#include "gromacs/legacyheaders/txtdump.h"
+#include "gromacs/legacyheaders/viewit.h"
+#include "gromacs/pbcutil/rmpbc.h"
 #include "gmx_ana.h"
 
+#include "gromacs/math/do_fit.h"
 
 void calc_rm_cm(int isize, atom_id index[], t_atoms *atoms, rvec x[], rvec xcm)
 {
@@ -124,9 +122,9 @@ int debug_strcmp(char s1[], char s2[])
     return strcmp(s1, s2);
 }
 
-int find_next_match_atoms_in_res(int *i1, int isize1, atom_id index1[],
+int find_next_match_atoms_in_res(int *i1, atom_id index1[],
                                  int m1, char **atnms1[],
-                                 int *i2, int isize2, atom_id index2[],
+                                 int *i2, atom_id index2[],
                                  int m2, char **atnms2[])
 {
     int      dx, dy, dmax, cmp;
@@ -175,7 +173,7 @@ int find_next_match_atoms_in_res(int *i1, int isize1, atom_id index1[],
     {
         if (debug)
         {
-            fprintf(debug, "{%d %d}", *i1+bFW ? dx : dy, *i2+bFW ? dy : dx );
+            fprintf(debug, "{%d %d}", *i1 + (bFW ? dx : dy), *i2 + (bFW ? dy : dx) );
         }
         if (bFW)
         {
@@ -389,8 +387,8 @@ void find_matching_names(int *isize1, atom_id index1[], t_atoms *atoms1,
             {
                 fprintf(debug, " [%d<%d %d<%d]", i1, m1, i2, m2);
             }
-            atcmp = find_next_match_atoms_in_res(&i1, *isize1, index1, m1, atnms1,
-                                                 &i2, *isize2, index2, m2, atnms2);
+            atcmp = find_next_match_atoms_in_res(&i1, index1, m1, atnms1,
+                                                 &i2, index2, m2, atnms2);
             if (debug)
             {
                 fprintf(debug, " -> %d %d %s-%s", i1, i2,
@@ -426,8 +424,8 @@ void find_matching_names(int *isize1, atom_id index1[], t_atoms *atoms1,
             {
                 fprintf(debug, " [%d<%d %d<%d]", i1, m1, i2, m2);
             }
-            atcmp = find_next_match_atoms_in_res(&i1, *isize1, index1, m1, atnms1,
-                                                 &i2, *isize2, index2, m2, atnms2);
+            atcmp = find_next_match_atoms_in_res(&i1, index1, m1, atnms1,
+                                                 &i2, index2, m2, atnms2);
             if (debug)
             {
                 fprintf(debug, " -> %d %d %s-%s", i1, i2,
@@ -485,7 +483,7 @@ void find_matching_names(int *isize1, atom_id index1[], t_atoms *atoms1,
 int gmx_confrms(int argc, char *argv[])
 {
     const char     *desc[] = {
-        "[TT]g_confrms[tt] computes the root mean square deviation (RMSD) of two",
+        "[THISMODULE] computes the root mean square deviation (RMSD) of two",
         "structures after least-squares fitting the second structure on the first one.",
         "The two structures do NOT need to have the same number of atoms,",
         "only the two index groups used for the fit need to be identical.",
@@ -518,9 +516,9 @@ int gmx_confrms(int argc, char *argv[])
         { efTPS, "-f1",  "conf1.gro", ffREAD  },
         { efSTX, "-f2",  "conf2",     ffREAD  },
         { efSTO, "-o",   "fit.pdb",   ffWRITE },
-        { efNDX, "-n1", "fit1.ndx",  ffOPTRD },
-        { efNDX, "-n2", "fit2.ndx",  ffOPTRD },
-        { efNDX, "-no", "match.ndx", ffOPTWR }
+        { efNDX, "-n1",  "fit1",      ffOPTRD },
+        { efNDX, "-n2",  "fit2",      ffOPTRD },
+        { efNDX, "-no",  "match",     ffOPTWR }
     };
 #define NFILE asize(fnm)
 
@@ -554,8 +552,11 @@ int gmx_confrms(int argc, char *argv[])
     real    *msds;
 
 
-    parse_common_args(&argc, argv, PCA_BE_NICE | PCA_CAN_VIEW,
-                      NFILE, fnm, asize(pa), pa, asize(desc), desc, 0, NULL, &oenv);
+    if (!parse_common_args(&argc, argv, PCA_CAN_VIEW,
+                           NFILE, fnm, asize(pa), pa, asize(desc), desc, 0, NULL, &oenv))
+    {
+        return 0;
+    }
     matchndxfile = opt2fn_null("-no", NFILE, fnm);
     conf1file    = ftp2fn(efTPS, NFILE, fnm);
     conf2file    = ftp2fn(efSTX, NFILE, fnm);
@@ -605,7 +606,7 @@ int gmx_confrms(int argc, char *argv[])
         find_matching_names(&isize1, index1, atoms1, &isize2, index2, atoms2);
         if (matchndxfile)
         {
-            fp = ffopen(matchndxfile, "w");
+            fp = gmx_ffopen(matchndxfile, "w");
             fprintf(fp, "; Matching atoms between %s from %s and %s from %s\n",
                     groupnames1, conf1file, groupnames2, conf2file);
             fprintf(fp, "[ Match_%s_%s ]\n", conf1file, groupnames1);
@@ -794,26 +795,26 @@ int gmx_confrms(int argc, char *argv[])
 /*    atoms2->resinfo[atoms2->atom[index2[i]].resind].chain = 'B'; */
                 }
             }
-            fp = ffopen(outfile, "w");
+            fp = gmx_ffopen(outfile, "w");
             if (!bOne)
             {
                 write_pdbfile(fp, title1, atoms1, x1, ePBC1, box1, ' ', 1, NULL, TRUE);
             }
             write_pdbfile(fp, title2, atoms2, x2, ePBC2, box2, ' ', bOne ? -1 : 2, NULL, TRUE);
-            ffclose(fp);
+            gmx_ffclose(fp);
             break;
         case efGRO:
             if (bBfac)
             {
                 fprintf(stderr, "WARNING: cannot write B-factor values to gro file\n");
             }
-            fp = ffopen(outfile, "w");
+            fp = gmx_ffopen(outfile, "w");
             if (!bOne)
             {
                 write_hconf_p(fp, title1, atoms1, 3, x1, v1, box1);
             }
             write_hconf_p(fp, title2, atoms2, 3, x2, v2, box2);
-            ffclose(fp);
+            gmx_ffclose(fp);
             break;
         default:
             if (bBfac)
@@ -833,7 +834,5 @@ int gmx_confrms(int argc, char *argv[])
 
     view_all(oenv, NFILE, fnm);
 
-    thanx(stderr);
-
     return 0;
 }