Removed energyhistory code from typedefs to a separate file.
authorDavid van der Spoel <spoel@xray.bmc.uu.se>
Wed, 14 Oct 2015 14:47:57 +0000 (16:47 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Fri, 23 Oct 2015 17:46:32 +0000 (19:46 +0200)
Cleaning up of typedefs.h and typedefs.cpp. It turns out there is
a circular dependency since initiation is done in gmxlib while updating
is done in mdlib. Since energyhistory is also part of the t_state struct
it is needed in gmxlib for now though, therefore the mdlib routines
still have access to the innards of the structure. Moving the updating
to gmxlib would on the other hand involve access from gmxlib to the
mdebin stuff in mdlib which is a worse solution.

Change-Id: Id22283d6737bec371c833040b59e85770886abaa

12 files changed:
src/gromacs/gmxlib/checkpoint.cpp
src/gromacs/gmxlib/energyhistory.cpp [new file with mode: 0644]
src/gromacs/gmxlib/energyhistory.h [new file with mode: 0644]
src/gromacs/gmxlib/typedefs.cpp
src/gromacs/legacyheaders/typedefs.h
src/gromacs/legacyheaders/types/state.h
src/gromacs/mdlib/md_support.cpp
src/gromacs/mdlib/mdebin.cpp
src/gromacs/mdlib/mdebin.h
src/gromacs/mdlib/mdebin_bar.cpp
src/gromacs/mdlib/trajectory_writing.cpp
src/programs/mdrun/md.cpp

index 8c57fa2e38cf8f0fc4b4b001c179f1f0e71714ef..62751945ffcc609b8f3b8d92db3f85eba6294e6f 100644 (file)
@@ -58,6 +58,7 @@
 #include "gromacs/fileio/trx.h"
 #include "gromacs/fileio/xdr_datatype.h"
 #include "gromacs/fileio/xdrf.h"
+#include "gromacs/gmxlib/energyhistory.h"
 #include "gromacs/legacyheaders/copyrite.h"
 #include "gromacs/legacyheaders/names.h"
 #include "gromacs/legacyheaders/network.h"
@@ -1513,19 +1514,19 @@ void write_checkpoint(const char *fn, gmx_bool bNumberAndKeep,
     }
 
     flags_enh = 0;
-    if (state->enerhist.nsum > 0 || state->enerhist.nsum_sim > 0)
+    if (state->enerhist->nsum > 0 || state->enerhist->nsum_sim > 0)
     {
         flags_enh |= (1<<eenhENERGY_N) | (1<<eenhENERGY_NSTEPS) | (1<<eenhENERGY_NSTEPS_SIM);
-        if (state->enerhist.nsum > 0)
+        if (state->enerhist->nsum > 0)
         {
             flags_enh |= ((1<<eenhENERGY_AVER) | (1<<eenhENERGY_SUM) |
                           (1<<eenhENERGY_NSUM));
         }
-        if (state->enerhist.nsum_sim > 0)
+        if (state->enerhist->nsum_sim > 0)
         {
             flags_enh |= ((1<<eenhENERGY_SUM_SIM) | (1<<eenhENERGY_NSUM_SIM));
         }
-        if (state->enerhist.dht)
+        if (state->enerhist->dht)
         {
             flags_enh |= ( (1<< eenhENERGY_DELTA_H_NN) |
                            (1<< eenhENERGY_DELTA_H_LIST) |
@@ -1585,7 +1586,7 @@ void write_checkpoint(const char *fn, gmx_bool bNumberAndKeep,
 
     if ((do_cpt_state(gmx_fio_getxdr(fp), FALSE, state->flags, state, NULL) < 0)        ||
         (do_cpt_ekinstate(gmx_fio_getxdr(fp), flags_eks, &state->ekinstate, NULL) < 0) ||
-        (do_cpt_enerhist(gmx_fio_getxdr(fp), FALSE, flags_enh, &state->enerhist, NULL) < 0)  ||
+        (do_cpt_enerhist(gmx_fio_getxdr(fp), FALSE, flags_enh, state->enerhist, NULL) < 0)  ||
         (do_cpt_df_hist(gmx_fio_getxdr(fp), flags_dfh, &state->dfhist, NULL) < 0)  ||
         (do_cpt_EDstate(gmx_fio_getxdr(fp), FALSE, &state->edsamstate, NULL) < 0)      ||
         (do_cpt_swapstate(gmx_fio_getxdr(fp), FALSE, &state->swapstate, NULL) < 0) ||
@@ -2007,7 +2008,7 @@ static void read_checkpoint(const char *fn, FILE **pfplog,
                   ((flags_eks & (1<<eeksEKINSCALEF)) | (flags_eks & (1<<eeksEKINSCALEH)) | (flags_eks & (1<<eeksVSCALE))));
 
     ret = do_cpt_enerhist(gmx_fio_getxdr(fp), TRUE,
-                          flags_enh, &state->enerhist, NULL);
+                          flags_enh, state->enerhist, NULL);
     if (ret)
     {
         cp_error();
@@ -2022,8 +2023,8 @@ static void read_checkpoint(const char *fn, FILE **pfplog,
         {
             fprintf(fplog, "\nWARNING: %s\n\n", warn);
         }
-        state->enerhist.nsum     = *step;
-        state->enerhist.nsum_sim = *step;
+        state->enerhist->nsum     = *step;
+        state->enerhist->nsum_sim = *step;
     }
 
     ret = do_cpt_df_hist(gmx_fio_getxdr(fp), flags_dfh, &state->dfhist, NULL);
@@ -2314,7 +2315,7 @@ static void read_checkpoint_data(t_fileio *fp, int *simulation_part,
         cp_error();
     }
     ret = do_cpt_enerhist(gmx_fio_getxdr(fp), TRUE,
-                          flags_enh, &state->enerhist, NULL);
+                          flags_enh, state->enerhist, NULL);
     if (ret)
     {
         cp_error();
@@ -2462,7 +2463,7 @@ void list_checkpoint(const char *fn, FILE *out)
         cp_error();
     }
     ret = do_cpt_enerhist(gmx_fio_getxdr(fp), TRUE,
-                          flags_enh, &state.enerhist, out);
+                          flags_enh, state.enerhist, out);
 
     if (ret == 0)
     {
diff --git a/src/gromacs/gmxlib/energyhistory.cpp b/src/gromacs/gmxlib/energyhistory.cpp
new file mode 100644 (file)
index 0000000..409ab55
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2015, 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.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version 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.
+ */
+/* This file is completely threadsafe - keep it that way! */
+#include "gmxpre.h"
+
+#include "energyhistory.h"
+
+#include <cstring>
+
+#include <algorithm>
+
+#include "gromacs/math/vec.h"
+#include "gromacs/pbcutil/pbc.h"
+#include "gromacs/random/random.h"
+#include "gromacs/utility/smalloc.h"
+
+static void done_delta_h_history(delta_h_history_t *dht)
+{
+    int i;
+
+    for (i = 0; i < dht->nndh; i++)
+    {
+        sfree(dht->dh[i]);
+    }
+    sfree(dht->dh);
+    sfree(dht->ndh);
+}
+
+void init_energyhistory(energyhistory_t * enerhist)
+{
+    enerhist->nener = 0;
+
+    enerhist->ener_ave     = NULL;
+    enerhist->ener_sum     = NULL;
+    enerhist->ener_sum_sim = NULL;
+    enerhist->dht          = NULL;
+
+    enerhist->nsteps     = 0;
+    enerhist->nsum       = 0;
+    enerhist->nsteps_sim = 0;
+    enerhist->nsum_sim   = 0;
+
+    enerhist->dht = NULL;
+}
+
+void done_energyhistory(energyhistory_t * enerhist)
+{
+    sfree(enerhist->ener_ave);
+    sfree(enerhist->ener_sum);
+    sfree(enerhist->ener_sum_sim);
+
+    if (enerhist->dht != NULL)
+    {
+        done_delta_h_history(enerhist->dht);
+        sfree(enerhist->dht);
+    }
+}
diff --git a/src/gromacs/gmxlib/energyhistory.h b/src/gromacs/gmxlib/energyhistory.h
new file mode 100644 (file)
index 0000000..cbdb1a9
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2015, 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.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version 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.
+ */
+#ifndef GMX_MDLIB_ENERGYHISTORY_H
+#define GMX_MDLIB_ENERGYHISTORY_H
+
+#include "gromacs/utility/basedefinitions.h"
+#include "gromacs/utility/real.h"
+
+/* energy history for delta_h histograms */
+typedef struct delta_h_history_t
+{
+    int      nndh;             /* the number of energy difference lists */
+    int     *ndh;              /* the number in each energy difference list */
+    real   **dh;               /* the energy difference lists */
+
+    double   start_time;       /* the start time of these energy diff blocks */
+    double   start_lambda;     /* lambda at start time */
+
+    gmx_bool start_lambda_set; /* whether the lambda value is set. Here
+                                  For backward-compatibility. */
+} delta_h_history_t;
+
+
+typedef struct energyhistory_t
+{
+    gmx_int64_t        nsteps;       /* The number of steps in the history            */
+    gmx_int64_t        nsum;         /* The nr. of steps in the ener_ave and ener_sum */
+    double         *   ener_ave;     /* Energy term history sum to get fluctuations   */
+    double         *   ener_sum;     /* Energy term history sum to get fluctuations   */
+    int                nener;        /* Number of energy terms in two previous arrays */
+    gmx_int64_t        nsteps_sim;   /* The number of steps in ener_sum_sim      */
+    gmx_int64_t        nsum_sim;     /* The number of frames in ener_sum_sim     */
+    double         *   ener_sum_sim; /* Energy term history sum of the whole sim      */
+
+    delta_h_history_t *dht;          /* The BAR energy differences */
+}
+energyhistory_t;
+
+/* \brief Initialize an energy history structure
+ */
+void init_energyhistory(energyhistory_t * enerhist);
+
+/* \brief Destroy an energy history structure
+ */
+void done_energyhistory(energyhistory_t * enerhist);
+
+#endif
index 262d200f529083dc8f92f8b2a071133370d32752..3d46780264aa58042122f08ad0fe820076761d6d 100644 (file)
@@ -43,6 +43,7 @@
 
 #include <algorithm>
 
+#include "gromacs/gmxlib/energyhistory.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/pbcutil/pbc.h"
 #include "gromacs/random/random.h"
@@ -126,48 +127,6 @@ static void init_swapstate(swapstate_t *swapstate)
     swapstate->xc_old_whole_p[eChan1] = NULL;
 }
 
-void init_energyhistory(energyhistory_t * enerhist)
-{
-    enerhist->nener = 0;
-
-    enerhist->ener_ave     = NULL;
-    enerhist->ener_sum     = NULL;
-    enerhist->ener_sum_sim = NULL;
-    enerhist->dht          = NULL;
-
-    enerhist->nsteps     = 0;
-    enerhist->nsum       = 0;
-    enerhist->nsteps_sim = 0;
-    enerhist->nsum_sim   = 0;
-
-    enerhist->dht = NULL;
-}
-
-static void done_delta_h_history(delta_h_history_t *dht)
-{
-    int i;
-
-    for (i = 0; i < dht->nndh; i++)
-    {
-        sfree(dht->dh[i]);
-    }
-    sfree(dht->dh);
-    sfree(dht->ndh);
-}
-
-void done_energyhistory(energyhistory_t * enerhist)
-{
-    sfree(enerhist->ener_ave);
-    sfree(enerhist->ener_sum);
-    sfree(enerhist->ener_sum_sim);
-
-    if (enerhist->dht != NULL)
-    {
-        done_delta_h_history(enerhist->dht);
-        sfree(enerhist->dht);
-    }
-}
-
 void init_gtc_state(t_state *state, int ngtc, int nnhpres, int nhchainlength)
 {
     int i, j;
@@ -257,7 +216,8 @@ void init_state(t_state *state, int natoms, int ngtc, int nnhpres, int nhchainle
     state->cg_p = NULL;
     zero_history(&state->hist);
     zero_ekinstate(&state->ekinstate);
-    init_energyhistory(&state->enerhist);
+    snew(state->enerhist, 1);
+    init_energyhistory(state->enerhist);
     init_df_history(&state->dfhist, nlambda);
     init_swapstate(&state->swapstate);
     state->ddp_count       = 0;
index eb9c1b373d34680b7e8a7f4333144a8b450beb49..232c11f896d459088d9e1f40709feeb0d498e0c3 100644 (file)
@@ -62,8 +62,6 @@ int gmx_int64_to_int(gmx_int64_t step, const char *warn);
 /* Functions to initiate and delete structures *
  * These functions are defined in gmxlib/typedefs.c
  */
-void init_energyhistory(energyhistory_t * enerhist);
-void done_energyhistory(energyhistory_t * enerhist);
 void init_gtc_state(t_state *state, int ngtc, int nnhpres, int nhchainlength);
 void init_state(t_state *state, int natoms, int ngtc, int nnhpres, int nhchainlength, int nlambda);
 t_state *serial_init_local_state(t_state *state_global);
index 2148850cc2a30fdd358aced2b3690f6d9ec7d105..e9354e2465810a55df610f6e3630fc1d95c9de48 100644 (file)
@@ -42,6 +42,8 @@
 #include "gromacs/utility/basedefinitions.h"
 #include "gromacs/utility/real.h"
 
+struct energyhistory_t;
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -103,20 +105,6 @@ typedef struct
     real         mvcos;
 } ekinstate_t;
 
-/* energy history for delta_h histograms */
-typedef struct
-{
-    int      nndh;             /* the number of energy difference lists */
-    int     *ndh;              /* the number in each energy difference list */
-    real   **dh;               /* the energy difference lists */
-
-    double   start_time;       /* the start time of these energy diff blocks */
-    double   start_lambda;     /* lambda at start time */
-
-    gmx_bool start_lambda_set; /* whether the lambda value is set. Here
-                                  For backward-compatibility. */
-} delta_h_history_t;
-
 typedef struct
 {
     int      nlambda;        /* total number of lambda states - for history*/
@@ -141,21 +129,6 @@ typedef struct
 
 } df_history_t;
 
-typedef struct
-{
-    gmx_int64_t        nsteps;       /* The number of steps in the history            */
-    gmx_int64_t        nsum;         /* The nr. of steps in the ener_ave and ener_sum */
-    double         *   ener_ave;     /* Energy term history sum to get fluctuations   */
-    double         *   ener_sum;     /* Energy term history sum to get fluctuations   */
-    int                nener;        /* Number of energy terms in two previous arrays */
-    gmx_int64_t        nsteps_sim;   /* The number of steps in ener_sum_sim      */
-    gmx_int64_t        nsum_sim;     /* The number of frames in ener_sum_sim     */
-    double         *   ener_sum_sim; /* Energy term history sum of the whole sim      */
-
-    delta_h_history_t *dht;          /* The BAR energy differences */
-}
-energyhistory_t;
-
 typedef struct
 {
     /* If one uses essential dynamics or flooding on a group of atoms from
@@ -216,46 +189,46 @@ swapstate_t;
 
 typedef struct t_state
 {
-    int              natoms;
-    int              ngtc;
-    int              nnhpres;
-    int              nhchainlength;   /* number of nose-hoover chains               */
-    int              flags;           /* Flags telling which entries are present      */
-    int              fep_state;       /* indicates which of the alchemical states we are in                 */
-    real            *lambda;          /* lambda vector                               */
-    matrix           box;             /* box vector coordinates                         */
-    matrix           box_rel;         /* Relitaive box vectors to preserve shape        */
-    matrix           boxv;            /* box velocitites for Parrinello-Rahman pcoupl */
-    matrix           pres_prev;       /* Pressure of the previous step for pcoupl  */
-    matrix           svir_prev;       /* Shake virial for previous step for pcoupl */
-    matrix           fvir_prev;       /* Force virial of the previous step for pcoupl  */
-    double          *nosehoover_xi;   /* for Nose-Hoover tcoupl (ngtc)       */
-    double          *nosehoover_vxi;  /* for N-H tcoupl (ngtc)               */
-    double          *nhpres_xi;       /* for Nose-Hoover pcoupl for barostat     */
-    double          *nhpres_vxi;      /* for Nose-Hoover pcoupl for barostat     */
-    double          *therm_integral;  /* for N-H/V-rescale tcoupl (ngtc)     */
-    real             veta;            /* trotter based isotropic P-coupling             */
-    real             vol0;            /* initial volume,required for computing NPT conserverd quantity */
-    int              nalloc;          /* Allocation size for x, v and sd_x when !=NULL*/
-    rvec            *x;               /* the coordinates (natoms)                     */
-    rvec            *v;               /* the velocities (natoms)                      */
-    rvec            *sd_X;            /* random part of the x update for stoch. dyn.  */
-    rvec            *cg_p;            /* p vector for conjugate gradient minimization */
-
-    history_t        hist;            /* Time history for restraints                  */
-
-    ekinstate_t      ekinstate;       /* The state of the kinetic energy data      */
-
-    energyhistory_t  enerhist;        /* Energy history for statistics           */
-    swapstate_t      swapstate;       /* Position swapping                       */
-    df_history_t     dfhist;          /*Free energy history for free energy analysis  */
-    edsamstate_t     edsamstate;      /* Essential dynamics / flooding history */
-
-    int              ddp_count;       /* The DD partitioning count for this state  */
-    int              ddp_count_cg_gl; /* The DD part. count for index_gl     */
-    int              ncg_gl;          /* The number of local charge groups            */
-    int             *cg_gl;           /* The global cg number of the local cgs        */
-    int              cg_gl_nalloc;    /* Allocation size of cg_gl;              */
+    int                     natoms;
+    int                     ngtc;
+    int                     nnhpres;
+    int                     nhchainlength;   /* number of nose-hoover chains               */
+    int                     flags;           /* Flags telling which entries are present      */
+    int                     fep_state;       /* indicates which of the alchemical states we are in                 */
+    real                   *lambda;          /* lambda vector                               */
+    matrix                  box;             /* box vector coordinates                         */
+    matrix                  box_rel;         /* Relitaive box vectors to preserve shape        */
+    matrix                  boxv;            /* box velocitites for Parrinello-Rahman pcoupl */
+    matrix                  pres_prev;       /* Pressure of the previous step for pcoupl  */
+    matrix                  svir_prev;       /* Shake virial for previous step for pcoupl */
+    matrix                  fvir_prev;       /* Force virial of the previous step for pcoupl  */
+    double                 *nosehoover_xi;   /* for Nose-Hoover tcoupl (ngtc)       */
+    double                 *nosehoover_vxi;  /* for N-H tcoupl (ngtc)               */
+    double                 *nhpres_xi;       /* for Nose-Hoover pcoupl for barostat     */
+    double                 *nhpres_vxi;      /* for Nose-Hoover pcoupl for barostat     */
+    double                 *therm_integral;  /* for N-H/V-rescale tcoupl (ngtc)     */
+    real                    veta;            /* trotter based isotropic P-coupling             */
+    real                    vol0;            /* initial volume,required for computing NPT conserverd quantity */
+    int                     nalloc;          /* Allocation size for x, v and sd_x when !=NULL*/
+    rvec                   *x;               /* the coordinates (natoms)                     */
+    rvec                   *v;               /* the velocities (natoms)                      */
+    rvec                   *sd_X;            /* random part of the x update for stoch. dyn.  */
+    rvec                   *cg_p;            /* p vector for conjugate gradient minimization */
+
+    history_t               hist;            /* Time history for restraints                  */
+
+    ekinstate_t             ekinstate;       /* The state of the kinetic energy data      */
+
+    struct energyhistory_t *enerhist;        /* Energy history for statistics           */
+    swapstate_t             swapstate;       /* Position swapping                       */
+    df_history_t            dfhist;          /*Free energy history for free energy analysis  */
+    edsamstate_t            edsamstate;      /* Essential dynamics / flooding history */
+
+    int                     ddp_count;       /* The DD partitioning count for this state  */
+    int                     ddp_count_cg_gl; /* The DD part. count for index_gl     */
+    int                     ncg_gl;          /* The number of local charge groups            */
+    int                    *cg_gl;           /* The global cg number of the local cgs        */
+    int                     cg_gl_nalloc;    /* Allocation size of cg_gl;              */
 } t_state;
 
 typedef struct
index c5717c959ab699068cafec4837c6bcebce593b93..b9487fcf97027c4b85a5041f6f0fb3744dffed42 100644 (file)
@@ -43,6 +43,7 @@
 
 #include "gromacs/domdec/domdec.h"
 #include "gromacs/fileio/trx.h"
+#include "gromacs/gmxlib/energyhistory.h"
 #include "gromacs/gmxlib/md_logging.h"
 #include "gromacs/legacyheaders/names.h"
 #include "gromacs/legacyheaders/nrnb.h"
@@ -794,8 +795,8 @@ void set_state_entries(t_state *state, const t_inputrec *ir)
 
     init_gtc_state(state, state->ngtc, state->nnhpres, ir->opts.nhchainlength); /* allocate the space for nose-hoover chains */
     init_ekinstate(&state->ekinstate, ir);
-
-    init_energyhistory(&state->enerhist);
+    snew(state->enerhist, 1);
+    init_energyhistory(state->enerhist);
     init_df_history(&state->dfhist, ir->fepvals->n_lambda);
     state->swapstate.eSwapCoords = ir->eSwapCoords;
 }
index 85a5edc0a38003be412aba1118aad41d1423ae14..38b65794f7e29d803862fdebfb88704af9c708db 100644 (file)
@@ -46,6 +46,7 @@
 #include "gromacs/fileio/gmxfio.h"
 #include "gromacs/fileio/xvgr.h"
 #include "gromacs/gmxlib/disre.h"
+#include "gromacs/gmxlib/energyhistory.h"
 #include "gromacs/gmxlib/orires.h"
 #include "gromacs/legacyheaders/names.h"
 #include "gromacs/legacyheaders/network.h"
index 30f484407e74a8e4fc7a1190175e7cb4d0559e74..39d108d1cc2ff7e3adab5464beaf659385b7aebd 100644 (file)
@@ -60,7 +60,7 @@ typedef struct t_mde_delta_h_coll t_mde_delta_h_coll;
 
 /* This is the collection of energy averages collected during mdrun, and to
    be written out to the .edr file. */
-typedef struct {
+typedef struct t_mdebin {
     double              delta_t;
     t_ebin             *ebin;
     int                 ie, iconrmsd, ib, ivol, idens, ipv, ienthalpy;
index 05da3ea5a37e7394f653656013174cef3caad8b4..070f1815d053a7f9a375f230fb733117b2794c6e 100644 (file)
@@ -43,6 +43,7 @@
 #include <string.h>
 
 #include "gromacs/fileio/enxio.h"
+#include "gromacs/gmxlib/energyhistory.h"
 #include "gromacs/legacyheaders/typedefs.h"
 #include "gromacs/mdlib/mdebin.h"
 #include "gromacs/utility/fatalerror.h"
index ec7f0d83426292913b0e411a0e34764971ba4578..4d0c7d905686f5e44d3cd164e3d51f55b1946de9 100644 (file)
@@ -37,6 +37,7 @@
 #include "trajectory_writing.h"
 
 #include "gromacs/fileio/confio.h"
+#include "gromacs/gmxlib/energyhistory.h"
 #include "gromacs/legacyheaders/typedefs.h"
 #include "gromacs/legacyheaders/types/commrec.h"
 #include "gromacs/math/vec.h"
@@ -136,7 +137,7 @@ do_md_trajectory_writing(FILE           *fplog,
                     update_ekinstate(&state_global->ekinstate, ekind);
                     state_global->ekinstate.bUpToDate = TRUE;
                 }
-                update_energyhistory(&state_global->enerhist, mdebin);
+                update_energyhistory(state_global->enerhist, mdebin);
             }
         }
         mdoutf_write_to_trajectory_files(fplog, cr, outf, mdof_flags, top_global,
index 4849dbe313b2801a5de7ad242a5263104c839c27..b1e4da322f3ff122559860ffc0e2cc357612de38 100644 (file)
@@ -53,6 +53,7 @@
 #include "gromacs/fileio/filenm.h"
 #include "gromacs/fileio/trx.h"
 #include "gromacs/fileio/trxio.h"
+#include "gromacs/gmxlib/energyhistory.h"
 #include "gromacs/gmxlib/md_logging.h"
 #include "gromacs/gmxlib/sighandler.h"
 #include "gromacs/imd/imd.h"
@@ -456,19 +457,19 @@ double gmx::do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
             /* Update mdebin with energy history if appending to output files */
             if (Flags & MD_APPENDFILES)
             {
-                restore_energyhistory_from_state(mdebin, &state_global->enerhist);
+                restore_energyhistory_from_state(mdebin, state_global->enerhist);
             }
             else
             {
                 /* We might have read an energy history from checkpoint,
                  * free the allocated memory and reset the counts.
                  */
-                done_energyhistory(&state_global->enerhist);
-                init_energyhistory(&state_global->enerhist);
+                done_energyhistory(state_global->enerhist);
+                init_energyhistory(state_global->enerhist);
             }
         }
         /* Set the initial energy history in state by updating once */
-        update_energyhistory(&state_global->enerhist, mdebin);
+        update_energyhistory(state_global->enerhist, mdebin);
     }
 
     /* Initialize constraints */