Sort all includes in src/gromacs
[alexxy/gromacs.git] / src / gromacs / fileio / trajectory_writing.c
index e109fc75ed9d3a2b93760a08ed230e0d1a149826..01b83b7de14a6aba03bb4fcfe95f21185761284a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * 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.
  * 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 "typedefs.h"
-#include "smalloc.h"
-#include "sysstuff.h"
-#include "vec.h"
-#include "sim_util.h"
-#include "mdrun.h"
-#include "confio.h"
 #include "trajectory_writing.h"
-#include "mdoutf.h"
 
+#include "gromacs/fileio/confio.h"
+#include "gromacs/fileio/mdoutf.h"
+#include "gromacs/legacyheaders/mdrun.h"
+#include "gromacs/legacyheaders/sim_util.h"
+#include "gromacs/legacyheaders/typedefs.h"
+#include "gromacs/legacyheaders/types/commrec.h"
+#include "gromacs/math/vec.h"
 #include "gromacs/timing/wallcycle.h"
+#include "gromacs/utility/smalloc.h"
 
 void
-do_trajectory_writing(FILE           *fplog,
-                      t_commrec      *cr,
-                      int             nfile,
-                      const t_filenm  fnm[],
-                      gmx_int64_t     step,
-                      gmx_int64_t     step_rel,
-                      double          t,
-                      t_inputrec     *ir,
-                      t_state        *state,
-                      t_state        *state_global,
-                      gmx_mtop_t     *top_global,
-                      t_forcerec     *fr,
-                      gmx_update_t    upd,
-                      gmx_mdoutf_t   *outf,
-                      t_mdebin       *mdebin,
-                      gmx_ekindata_t *ekind,
-                      rvec           *f,
-                      rvec           *f_global,
-                      gmx_wallcycle_t wcycle,
-                      gmx_rng_t       mcrng,
-                      int            *nchkpt,
-                      gmx_bool        bCPT,
-                      gmx_bool        bRerunMD,
-                      gmx_bool        bLastStep,
-                      gmx_bool        bDoConfOut,
-                      gmx_bool        bSumEkinhOld
-                      )
+do_md_trajectory_writing(FILE           *fplog,
+                         t_commrec      *cr,
+                         int             nfile,
+                         const t_filenm  fnm[],
+                         gmx_int64_t     step,
+                         gmx_int64_t     step_rel,
+                         double          t,
+                         t_inputrec     *ir,
+                         t_state        *state,
+                         t_state        *state_global,
+                         gmx_mtop_t     *top_global,
+                         t_forcerec     *fr,
+                         gmx_mdoutf_t    outf,
+                         t_mdebin       *mdebin,
+                         gmx_ekindata_t *ekind,
+                         rvec           *f,
+                         rvec           *f_global,
+                         int            *nchkpt,
+                         gmx_bool        bCPT,
+                         gmx_bool        bRerunMD,
+                         gmx_bool        bLastStep,
+                         gmx_bool        bDoConfOut,
+                         gmx_bool        bSumEkinhOld
+                         )
 {
     int   mdof_flags;
-    int   n_xtc    = -1;
-    rvec *x_xtc    = NULL;
 
     mdof_flags = 0;
     if (do_per_step(step, ir->nstxout))
@@ -94,9 +87,9 @@ do_trajectory_writing(FILE           *fplog,
     {
         mdof_flags |= MDOF_F;
     }
-    if (do_per_step(step, ir->nstxtcout))
+    if (do_per_step(step, ir->nstxout_compressed))
     {
-        mdof_flags |= MDOF_XTC;
+        mdof_flags |= MDOF_X_COMPRESSED;
     }
     if (bCPT)
     {
@@ -117,6 +110,10 @@ do_trajectory_writing(FILE           *fplog,
         fcReportProgress( ir->nsteps, step );
     }
 
+#if defined(__native_client__)
+    fcCheckin(MASTER(cr));
+#endif
+
     /* sync bCPT and fc record-keeping */
     if (bCPT && MASTER(cr))
     {
@@ -126,17 +123,9 @@ do_trajectory_writing(FILE           *fplog,
 
     if (mdof_flags != 0)
     {
-        wallcycle_start(wcycle, ewcTRAJ);
+        wallcycle_start(mdoutf_get_wcycle(outf), ewcTRAJ);
         if (bCPT)
         {
-            if (state->flags & (1<<estLD_RNG))
-            {
-                get_stochd_state(upd, state);
-            }
-            if (state->flags  & (1<<estMC_RNG))
-            {
-                get_mc_state(mcrng, state);
-            }
             if (MASTER(cr))
             {
                 if (bSumEkinhOld)
@@ -151,19 +140,18 @@ do_trajectory_writing(FILE           *fplog,
                 update_energyhistory(&state_global->enerhist, mdebin);
             }
         }
-        write_traj(fplog, cr, outf, mdof_flags, top_global,
-                   step, t, state, state_global, f, f_global, &n_xtc, &x_xtc);
+        mdoutf_write_to_trajectory_files(fplog, cr, outf, mdof_flags, top_global,
+                                         step, t, state, state_global, f, f_global);
         if (bCPT)
         {
             (*nchkpt)++;
-            bCPT = FALSE;
         }
         debug_gmx();
         if (bLastStep && step_rel == ir->nsteps &&
             bDoConfOut && MASTER(cr) &&
             !bRerunMD)
         {
-            /* x and v have been collected in write_traj,
+            /* x and v have been collected in mdoutf_write_to_trajectory_files,
              * because a checkpoint file will always be written
              * at the last step.
              */
@@ -179,6 +167,6 @@ do_trajectory_writing(FILE           *fplog,
                                 ir->ePBC, state->box);
             debug_gmx();
         }
-        wallcycle_stop(wcycle, ewcTRAJ);
+        wallcycle_stop(mdoutf_get_wcycle(outf), ewcTRAJ);
     }
 }