Remove unnecessary config.h includes
[alexxy/gromacs.git] / src / gromacs / gmxana / gmx_trjcat.c
index 2f74331ffe32fa35eb58139d35ac0e7a37b939f9..5a011c992ccd64feb2f85ce8fd296b72ce1abaee 100644 (file)
  * 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 <string.h>
 #include <math.h>
-#include "macros.h"
-#include "sysstuff.h"
-#include "smalloc.h"
-#include "typedefs.h"
+#include <stdlib.h>
+#include <string.h>
+
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/utility/smalloc.h"
+#include "gromacs/legacyheaders/typedefs.h"
 #include "gromacs/fileio/gmxfio.h"
 #include "gromacs/fileio/tpxio.h"
 #include "gromacs/fileio/trxio.h"
 #include "gromacs/fileio/tngio.h"
 #include "gromacs/fileio/tngio_for_tools.h"
 #include "gromacs/commandline/pargs.h"
-#include "gromacs/fileio/futil.h"
+#include "gromacs/utility/futil.h"
 #include "gromacs/fileio/pdbio.h"
 #include "gromacs/fileio/confio.h"
-#include "names.h"
-#include "index.h"
-#include "vec.h"
+#include "gromacs/legacyheaders/names.h"
+#include "gromacs/topology/index.h"
+#include "gromacs/math/vec.h"
 #include "gromacs/fileio/xtcio.h"
-#include "do_fit.h"
-#include "rmpbc.h"
-#include "pbc.h"
-#include "xvgr.h"
-#include "gromacs/fileio/xdrf.h"
+#include "gromacs/fileio/xvgr.h"
 #include "gmx_ana.h"
 
+#include "gromacs/utility/fatalerror.h"
+
 #define TIME_EXPLICIT 0
 #define TIME_CONTINUE 1
 #define TIME_LAST     2
@@ -506,7 +503,7 @@ int gmx_trjcat(int argc, char *argv[])
 
 #define NFILE asize(fnm)
 
-    if (!parse_common_args(&argc, argv, PCA_BE_NICE | PCA_TIME_UNIT, NFILE, fnm,
+    if (!parse_common_args(&argc, argv, PCA_TIME_UNIT, NFILE, fnm,
                            asize(pa), pa, asize(desc), desc, 0, NULL, &oenv))
     {
         return 0;
@@ -590,7 +587,7 @@ int gmx_trjcat(int argc, char *argv[])
     {
         if (nfile_out != nset)
         {
-            char *buf = strdup(fnms_out[0]);
+            char *buf = gmx_strdup(fnms_out[0]);
             snew(fnms_out, nset);
             for (i = 0; (i < nset); i++)
             {
@@ -689,26 +686,9 @@ int gmx_trjcat(int argc, char *argv[])
                 /* Fails if last frame is incomplete
                  * We can't do anything about it without overwriting
                  * */
-                if (filetype == efXTC)
-                {
-                    lasttime =
-                        xdr_xtc_get_last_frame_time(gmx_fio_getfp(stfio),
-                                                    gmx_fio_getxdr(stfio),
-                                                    fr.natoms, &bOK);
-                    fr.time = lasttime;
-                    if (!bOK)
-                    {
-                        gmx_fatal(FARGS, "Error reading last frame. Maybe seek not supported." );
-                    }
-                }
-                else if (filetype == efTNG)
+                if (filetype == efXTC || filetype == efTNG)
                 {
-                    tng_trajectory_t tng = trx_get_tng(status);
-                    if (!tng)
-                    {
-                        gmx_fatal(FARGS, "Error opening TNG file.");
-                    }
-                    lasttime = gmx_tng_get_time_of_final_frame(tng);
+                    lasttime = trx_get_time_of_final_frame(status);
                     fr.time  = lasttime;
                 }
                 else
@@ -729,14 +709,8 @@ int gmx_trjcat(int argc, char *argv[])
                 {
                     gmx_fatal(FARGS, "Overwrite only supported for XTC." );
                 }
-                last_frame_time =
-                    xdr_xtc_get_last_frame_time(gmx_fio_getfp(stfio),
-                                                gmx_fio_getxdr(stfio),
-                                                fr.natoms, &bOK);
-                if (!bOK)
-                {
-                    gmx_fatal(FARGS, "Error reading last frame. Maybe seek not supported." );
-                }
+                last_frame_time = trx_get_time_of_final_frame(status);
+
                 /* xtc_seek_time broken for trajectories containing only 1 or 2 frames
                  *     or when seek time = 0 */
                 if (nfile_in > 1 && settime[1] < last_frame_time+timest[0]*0.5)