Add TNG writing and reading support
[alexxy/gromacs.git] / src / gromacs / mdlib / minimize.c
index d85905766b5d7ff6ed718c837682160a08a927b3..ed15e138ce0bfa670fe9f7b24976ef544f03152b 100644 (file)
@@ -314,7 +314,7 @@ void init_em(FILE *fplog, const char *title,
              t_graph **graph, t_mdatoms *mdatoms, gmx_global_stat_t *gstat,
              gmx_vsite_t *vsite, gmx_constr_t constr,
              int nfile, const t_filenm fnm[],
-             gmx_mdoutf_t **outf, t_mdebin **mdebin)
+             gmx_mdoutf_t *outf, t_mdebin **mdebin)
 {
     int  start, homenr, i;
     real dvdl_constr;
@@ -456,14 +456,14 @@ void init_em(FILE *fplog, const char *title,
     if (mdebin != NULL)
     {
         /* Init bin for energy stuff */
-        *mdebin = init_mdebin((*outf)->fp_ene, top_global, ir, NULL);
+        *mdebin = init_mdebin(mdoutf_get_fp_ene(*outf), top_global, ir, NULL);
     }
 
     clear_rvec(mu_tot);
     calc_shifts(ems->s.box, fr->shift_vec);
 }
 
-static void finish_em(t_commrec *cr, gmx_mdoutf_t *outf,
+static void finish_em(t_commrec *cr, gmx_mdoutf_t outf,
                       gmx_walltime_accounting_t walltime_accounting,
                       gmx_wallcycle_t wcycle)
 {
@@ -498,7 +498,7 @@ static void copy_em_coords(em_state_t *ems, t_state *state)
 }
 
 static void write_em_traj(FILE *fplog, t_commrec *cr,
-                          gmx_mdoutf_t *outf,
+                          gmx_mdoutf_t outf,
                           gmx_bool bX, gmx_bool bF, const char *confout,
                           gmx_mtop_t *top_global,
                           t_inputrec *ir, gmx_int64_t step,
@@ -522,9 +522,9 @@ static void write_em_traj(FILE *fplog, t_commrec *cr,
     {
         mdof_flags |= MDOF_F;
     }
-    write_traj(fplog, cr, outf, mdof_flags,
-               step, (double)step,
-               &state->s, state_global, state->f, f_global);
+    mdoutf_write_to_trajectory_files(fplog, cr, outf, mdof_flags,
+                                     top_global, step, (double)step,
+                                     &state->s, state_global, state->f, f_global);
 
     if (confout != NULL && MASTER(cr))
     {
@@ -992,7 +992,7 @@ double do_cg(FILE *fplog, t_commrec *cr,
     gmx_bool          do_log = FALSE, do_ene = FALSE, do_x, do_f;
     tensor            vir, pres;
     int               number_steps, neval = 0, nstcg = inputrec->nstcgsteep;
-    gmx_mdoutf_t     *outf;
+    gmx_mdoutf_t      outf;
     int               i, m, gf, step, nminstep;
     real              terminate = 0;
 
@@ -1043,7 +1043,7 @@ double do_cg(FILE *fplog, t_commrec *cr,
                    NULL, NULL, vir, pres, NULL, mu_tot, constr);
 
         print_ebin_header(fplog, step, step, s_min->s.lambda[efptFEP]);
-        print_ebin(outf->fp_ene, TRUE, FALSE, FALSE, fplog, step, step, eprNORMAL,
+        print_ebin(mdoutf_get_fp_ene(outf), TRUE, FALSE, FALSE, fplog, step, step, eprNORMAL,
                    TRUE, mdebin, fcd, &(top_global->groups), &(inputrec->opts));
     }
     where();
@@ -1478,7 +1478,7 @@ double do_cg(FILE *fplog, t_commrec *cr,
             {
                 print_ebin_header(fplog, step, step, s_min->s.lambda[efptFEP]);
             }
-            print_ebin(outf->fp_ene, do_ene, FALSE, FALSE,
+            print_ebin(mdoutf_get_fp_ene(outf), do_ene, FALSE, FALSE,
                        do_log ? fplog : NULL, step, step, eprNORMAL,
                        TRUE, mdebin, fcd, &(top_global->groups), &(inputrec->opts));
         }
@@ -1518,7 +1518,7 @@ double do_cg(FILE *fplog, t_commrec *cr,
         if (!do_ene || !do_log)
         {
             /* Write final energy file entries */
-            print_ebin(outf->fp_ene, !do_ene, FALSE, FALSE,
+            print_ebin(mdoutf_get_fp_ene(outf), !do_ene, FALSE, FALSE,
                        !do_log ? fplog : NULL, step, step, eprNORMAL,
                        TRUE, mdebin, fcd, &(top_global->groups), &(inputrec->opts));
         }
@@ -1607,7 +1607,7 @@ double do_lbfgs(FILE *fplog, t_commrec *cr,
     gmx_bool           do_log, do_ene, do_x, do_f, foundlower, *frozen;
     tensor             vir, pres;
     int                start, end, number_steps;
-    gmx_mdoutf_t      *outf;
+    gmx_mdoutf_t       outf;
     int                i, k, m, n, nfmax, gf, step;
     int                mdof_flags;
     /* not used */
@@ -1737,7 +1737,7 @@ double do_lbfgs(FILE *fplog, t_commrec *cr,
                    NULL, NULL, vir, pres, NULL, mu_tot, constr);
 
         print_ebin_header(fplog, step, step, state->lambda[efptFEP]);
-        print_ebin(outf->fp_ene, TRUE, FALSE, FALSE, fplog, step, step, eprNORMAL,
+        print_ebin(mdoutf_get_fp_ene(outf), TRUE, FALSE, FALSE, fplog, step, step, eprNORMAL,
                    TRUE, mdebin, fcd, &(top_global->groups), &(inputrec->opts));
     }
     where();
@@ -1811,8 +1811,8 @@ double do_lbfgs(FILE *fplog, t_commrec *cr,
             mdof_flags |= MDOF_F;
         }
 
-        write_traj(fplog, cr, outf, mdof_flags,
-                   step, (real)step, state, state, f, f);
+        mdoutf_write_to_trajectory_files(fplog, cr, outf, mdof_flags,
+                                         top_global, step, (real)step, state, state, f, f);
 
         /* Do the linesearching in the direction dx[point][0..(n-1)] */
 
@@ -2267,7 +2267,7 @@ double do_lbfgs(FILE *fplog, t_commrec *cr,
             {
                 print_ebin_header(fplog, step, step, state->lambda[efptFEP]);
             }
-            print_ebin(outf->fp_ene, do_ene, FALSE, FALSE,
+            print_ebin(mdoutf_get_fp_ene(outf), do_ene, FALSE, FALSE,
                        do_log ? fplog : NULL, step, step, eprNORMAL,
                        TRUE, mdebin, fcd, &(top_global->groups), &(inputrec->opts));
         }
@@ -2304,7 +2304,7 @@ double do_lbfgs(FILE *fplog, t_commrec *cr,
     }
     if (!do_ene || !do_log) /* Write final energy file entries */
     {
-        print_ebin(outf->fp_ene, !do_ene, FALSE, FALSE,
+        print_ebin(mdoutf_get_fp_ene(outf), !do_ene, FALSE, FALSE,
                    !do_log ? fplog : NULL, step, step, eprNORMAL,
                    TRUE, mdebin, fcd, &(top_global->groups), &(inputrec->opts));
     }
@@ -2377,7 +2377,7 @@ double do_steep(FILE *fplog, t_commrec *cr,
     t_graph          *graph;
     real              stepsize, constepsize;
     real              ustep, fnormn;
-    gmx_mdoutf_t     *outf;
+    gmx_mdoutf_t      outf;
     t_mdebin         *mdebin;
     gmx_bool          bDone, bAbort, do_x, do_f;
     tensor            vir, pres;
@@ -2472,7 +2472,7 @@ double do_steep(FILE *fplog, t_commrec *cr,
                 upd_mdebin(mdebin, FALSE, FALSE, (double)count,
                            mdatoms->tmass, enerd, &s_try->s, inputrec->fepvals, inputrec->expandedvals,
                            s_try->s.box, NULL, NULL, vir, pres, NULL, mu_tot, constr);
-                print_ebin(outf->fp_ene, TRUE,
+                print_ebin(mdoutf_get_fp_ene(outf), TRUE,
                            do_per_step(steps_accepted, inputrec->nstdisreout),
                            do_per_step(steps_accepted, inputrec->nstorireout),
                            fplog, count, count, eprNORMAL, TRUE,
@@ -2595,7 +2595,7 @@ double do_nm(FILE *fplog, t_commrec *cr,
              gmx_walltime_accounting_t walltime_accounting)
 {
     const char          *NM = "Normal Mode Analysis";
-    gmx_mdoutf_t        *outf;
+    gmx_mdoutf_t         outf;
     int                  natoms, atom, d;
     int                  nnodes, node;
     rvec                *f_global;