Remove .tpa, .tpb, .tpx, .trj files. Part of #1500.
[alexxy/gromacs.git] / src / gromacs / fileio / trxio.c
index 52125a634baa2efe5bba9b2ce3ea843a1d030be4..0f39b6c46bff835fdae21542bea79b9e068c6095 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.
  */
+#include "gmxpre.h"
+
 #include "trxio.h"
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "config.h"
 
-#include <ctype.h>
-#include <math.h>
 #include <assert.h>
+#include <math.h>
 
-#include "sysstuff.h"
-#include "typedefs.h"
 #ifdef GMX_USE_PLUGINS
 #include "vmdio.h"
 #endif
-#include "string2.h"
-#include "smalloc.h"
-#include "pbc.h"
 #include "gmxfio.h"
 #include "trxio.h"
 #include "tpxio.h"
 #include "trnio.h"
 #include "tngio.h"
 #include "tngio_for_tools.h"
-#include "names.h"
-#include "vec.h"
-#include "futil.h"
+#include "gromacs/legacyheaders/names.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/utility/futil.h"
 #include "xtcio.h"
 #include "pdbio.h"
 #include "confio.h"
-#include "checkpoint.h"
+#include "gromacs/legacyheaders/checkpoint.h"
 #include "xdrf.h"
 
 #include "gromacs/fileio/timecontrol.h"
+#include "gromacs/fileio/trx.h"
+#include "gromacs/topology/atoms.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/smalloc.h"
 
 /* defines for frame counter output */
 #define SKIP1   10
@@ -283,6 +281,7 @@ void clear_trxframe(t_trxframe *fr, gmx_bool bFirst)
         fr->bDouble   = FALSE;
         fr->natoms    = -1;
         fr->t0        = 0;
+        fr->tf        = 0;
         fr->tpf       = 0;
         fr->tppf      = 0;
         fr->title     = NULL;
@@ -339,7 +338,6 @@ int write_trxframe_indexed(t_trxstatus *status, t_trxframe *fr, int nind,
 
     switch (ftp)
     {
-        case efTRJ:
         case efTRR:
         case efTNG:
             break;
@@ -354,7 +352,6 @@ int write_trxframe_indexed(t_trxstatus *status, t_trxframe *fr, int nind,
 
     switch (ftp)
     {
-        case efTRJ:
         case efTRR:
         case efTNG:
             if (fr->bV)
@@ -396,7 +393,6 @@ int write_trxframe_indexed(t_trxstatus *status, t_trxframe *fr, int nind,
         case efXTC:
             write_xtc(status->fio, nind, fr->step, fr->time, fr->box, xout, prec);
             break;
-        case efTRJ:
         case efTRR:
             fwrite_trn(status->fio, nframes_read(status),
                        fr->time, fr->step, fr->box, nind, xout, vout, fout);
@@ -434,8 +430,6 @@ int write_trxframe_indexed(t_trxstatus *status, t_trxframe *fr, int nind,
 
     switch (ftp)
     {
-        case efTRN:
-        case efTRJ:
         case efTRR:
         case efTNG:
             if (vout)
@@ -535,7 +529,6 @@ int write_trxframe(t_trxstatus *status, t_trxframe *fr, gmx_conect gc)
 
     switch (gmx_fio_getftp(status->fio))
     {
-        case efTRJ:
         case efTRR:
             break;
         default:
@@ -552,7 +545,6 @@ int write_trxframe(t_trxstatus *status, t_trxframe *fr, gmx_conect gc)
         case efXTC:
             write_xtc(status->fio, fr->natoms, fr->step, fr->time, fr->box, fr->x, prec);
             break;
-        case efTRJ:
         case efTRR:
             fwrite_trn(status->fio, fr->step, fr->time, fr->lambda, fr->box, fr->natoms,
                        fr->bX ? fr->x : NULL, fr->bV ? fr->v : NULL, fr->bF ? fr->f : NULL);
@@ -796,13 +788,13 @@ gmx_bool read_next_frame(const output_env_t oenv, t_trxstatus *status, t_trxfram
     int      ftp;
 
     bRet = FALSE;
-    pt   = fr->time;
+    pt   = fr->tf;
 
     do
     {
         clear_trxframe(fr, FALSE);
         fr->tppf = fr->tpf;
-        fr->tpf  = fr->time;
+        fr->tpf  = fr->tf;
 
         if (status->tng)
         {
@@ -815,7 +807,6 @@ gmx_bool read_next_frame(const output_env_t oenv, t_trxstatus *status, t_trxfram
         }
         switch (ftp)
         {
-            case efTRJ:
             case efTRR:
                 bRet = gmx_next_frame(status, fr);
                 break;
@@ -835,7 +826,7 @@ gmx_bool read_next_frame(const output_env_t oenv, t_trxstatus *status, t_trxfram
                 /* DvdS 2005-05-31: this has been fixed along with the increased
                  * accuracy of the control over -b and -e options.
                  */
-                if (bTimeSet(TBEGIN) && (fr->time < rTimeValue(TBEGIN)))
+                if (bTimeSet(TBEGIN) && (fr->tf < rTimeValue(TBEGIN)))
                 {
                     if (xtc_seek_time(status->fio, rTimeValue(TBEGIN), fr->natoms, TRUE))
                     {
@@ -876,6 +867,7 @@ gmx_bool read_next_frame(const output_env_t oenv, t_trxstatus *status, t_trxfram
                           gmx_fio_getname(status->fio));
 #endif
         }
+        fr->tf = fr->time;
 
         if (bRet)
         {
@@ -948,7 +940,6 @@ int read_first_frame(const output_env_t oenv, t_trxstatus **status,
     }
     switch (ftp)
     {
-        case efTRJ:
         case efTRR:
             break;
         case efCPT:
@@ -1045,6 +1036,7 @@ int read_first_frame(const output_env_t oenv, t_trxstatus **status,
 #endif
             break;
     }
+    fr->tf = fr->time;
 
     /* Return FALSE if we read a frame that's past the set ending time. */
     if (!bFirst && (!(fr->flags & TRX_DONT_SKIP) && check_times(fr->time) > 0))