Sort includes outside src/gromacs
[alexxy/gromacs.git] / src / programs / mdrun / md.cpp
index 8c994cb7c2952490fc0a8529a01b7e7026e54b6b..9864f8789f9385d2e536ed33f5988bacff85186e 100644 (file)
 
 #include <stdlib.h>
 
-#include "gromacs/legacyheaders/typedefs.h"
-#include "gromacs/math/vec.h"
-#include "gromacs/legacyheaders/vcm.h"
-#include "gromacs/legacyheaders/mdebin.h"
-#include "gromacs/legacyheaders/nrnb.h"
+#include "gromacs/fileio/confio.h"
+#include "gromacs/fileio/mdoutf.h"
+#include "gromacs/fileio/trajectory_writing.h"
+#include "gromacs/fileio/trnio.h"
+#include "gromacs/fileio/trxio.h"
+#include "gromacs/fileio/xtcio.h"
+#include "gromacs/gmxpreprocess/compute_io.h"
+#include "gromacs/imd/imd.h"
+#include "gromacs/legacyheaders/bonded-threading.h"
 #include "gromacs/legacyheaders/calcmu.h"
-#include "gromacs/legacyheaders/vsite.h"
-#include "gromacs/legacyheaders/update.h"
-#include "gromacs/legacyheaders/ns.h"
-#include "gromacs/legacyheaders/mdrun.h"
-#include "gromacs/legacyheaders/md_support.h"
+#include "gromacs/legacyheaders/checkpoint.h"
+#include "gromacs/legacyheaders/constr.h"
+#include "gromacs/legacyheaders/coulomb.h"
+#include "gromacs/legacyheaders/disre.h"
+#include "gromacs/legacyheaders/domdec.h"
+#include "gromacs/legacyheaders/domdec_network.h"
+#include "gromacs/legacyheaders/force.h"
 #include "gromacs/legacyheaders/md_logging.h"
-#include "gromacs/legacyheaders/network.h"
+#include "gromacs/legacyheaders/md_support.h"
+#include "gromacs/legacyheaders/mdatoms.h"
+#include "gromacs/legacyheaders/mdebin.h"
+#include "gromacs/legacyheaders/mdrun.h"
 #include "gromacs/legacyheaders/names.h"
-#include "gromacs/legacyheaders/force.h"
-#include "gromacs/legacyheaders/disre.h"
+#include "gromacs/legacyheaders/network.h"
+#include "gromacs/legacyheaders/nrnb.h"
+#include "gromacs/legacyheaders/ns.h"
 #include "gromacs/legacyheaders/orires.h"
 #include "gromacs/legacyheaders/pme.h"
-#include "gromacs/legacyheaders/mdatoms.h"
-#include "repl_ex.h"
-#include "deform.h"
 #include "gromacs/legacyheaders/qmmm.h"
-#include "gromacs/legacyheaders/domdec.h"
-#include "gromacs/legacyheaders/domdec_network.h"
-#include "gromacs/legacyheaders/coulomb.h"
-#include "gromacs/legacyheaders/constr.h"
 #include "gromacs/legacyheaders/shellfc.h"
-#include "gromacs/gmxpreprocess/compute_io.h"
-#include "gromacs/legacyheaders/checkpoint.h"
-#include "gromacs/topology/mtop_util.h"
 #include "gromacs/legacyheaders/sighandler.h"
 #include "gromacs/legacyheaders/txtdump.h"
-#include "gromacs/utility/cstringutil.h"
-#include "pme_loadbal.h"
-#include "gromacs/legacyheaders/bonded-threading.h"
-#include "membed.h"
-#include "gromacs/legacyheaders/types/nlistheuristics.h"
+#include "gromacs/legacyheaders/typedefs.h"
+#include "gromacs/legacyheaders/update.h"
+#include "gromacs/legacyheaders/vcm.h"
+#include "gromacs/legacyheaders/vsite.h"
 #include "gromacs/legacyheaders/types/iteratedconstraints.h"
+#include "gromacs/legacyheaders/types/nlistheuristics.h"
+#include "gromacs/math/vec.h"
 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_data_mgmt.h"
-
-#include "gromacs/fileio/confio.h"
-#include "gromacs/fileio/mdoutf.h"
-#include "gromacs/fileio/trajectory_writing.h"
-#include "gromacs/fileio/trnio.h"
-#include "gromacs/fileio/trxio.h"
-#include "gromacs/fileio/xtcio.h"
-#include "gromacs/imd/imd.h"
 #include "gromacs/pbcutil/mshift.h"
 #include "gromacs/pbcutil/pbc.h"
 #include "gromacs/pulling/pull.h"
 #include "gromacs/swap/swapcoords.h"
 #include "gromacs/timing/wallcycle.h"
 #include "gromacs/timing/walltime_accounting.h"
+#include "gromacs/topology/mtop_util.h"
+#include "gromacs/utility/cstringutil.h"
 #include "gromacs/utility/gmxmpi.h"
 #include "gromacs/utility/smalloc.h"
 
+#include "deform.h"
+#include "membed.h"
+#include "pme_loadbal.h"
+#include "repl_ex.h"
+
 #ifdef GMX_FAHCORE
 #include "corewrap.h"
 #endif
@@ -291,7 +291,7 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
             &(state_global->fep_state), lam0,
             nrnb, top_global, &upd,
             nfile, fnm, &outf, &mdebin,
-            force_vir, shake_vir, mu_tot, &bSimAnn, &vcm, Flags);
+            force_vir, shake_vir, mu_tot, &bSimAnn, &vcm, Flags, wcycle);
 
     clear_mat(total_vir);
     clear_mat(pres);
@@ -1308,7 +1308,7 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
         do_md_trajectory_writing(fplog, cr, nfile, fnm, step, step_rel, t,
                                  ir, state, state_global, top_global, fr,
                                  outf, mdebin, ekind, f, f_global,
-                                 wcycle, &nchkpt,
+                                 &nchkpt,
                                  bCPT, bRerunMD, bLastStep, (Flags & MD_CONFOUT),
                                  bSumEkinhOld);
         /* Check if IMD step and do IMD communication, if bIMD is TRUE. */
@@ -1941,6 +1941,10 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
     /* End of main MD loop */
     debug_gmx();
 
+    /* Closing TNG files can include compressing data. Therefore it is good to do that
+     * before stopping the time measurements. */
+    mdoutf_tng_close(outf);
+
     /* Stop measuring walltime */
     walltime_accounting_end(walltime_accounting);