Free more memory in grompp and mdrun
authorMark Abraham <mark.j.abraham@gmail.com>
Sun, 11 Mar 2018 18:11:31 +0000 (19:11 +0100)
committerMark Abraham <mark.j.abraham@gmail.com>
Wed, 28 Mar 2018 11:49:28 +0000 (13:49 +0200)
This will be increasingly useful as we start adding more GoogleTest
cases that call grompp and mdrun repeatedly.

Refs #1793, #1868

Change-Id: Ic0faaa4c3dec2891d0cdc6166561f8ccd4391f44

21 files changed:
src/gromacs/gmxpreprocess/grompp-impl.h
src/gromacs/gmxpreprocess/grompp.cpp
src/gromacs/gmxpreprocess/toputil.cpp
src/gromacs/gmxpreprocess/toputil.h
src/gromacs/listed-forces/manage-threading.cpp
src/gromacs/listed-forces/manage-threading.h
src/gromacs/mdlib/forcerec.cpp
src/gromacs/mdlib/forcerec.h
src/gromacs/mdlib/mdatoms.cpp
src/gromacs/mdlib/mdatoms.h
src/gromacs/mdlib/mdebin.cpp
src/gromacs/mdlib/mdebin.h
src/gromacs/mdlib/mdebin_bar.cpp
src/gromacs/mdlib/mdebin_bar.h
src/gromacs/mdlib/mdsetup.cpp
src/gromacs/mdlib/mdsetup.h
src/gromacs/mdlib/ns.cpp
src/gromacs/mdlib/ns.h
src/gromacs/mdlib/nsgrid.cpp
src/programs/mdrun/md.cpp
src/programs/mdrun/runner.cpp

index d93b55b74a7c00ed2fb083ae42acb0bce1a09e3f..23cc5144c56868cf994d0561c144f452f8b25056 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2018, 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.
@@ -82,7 +82,7 @@ typedef struct {
 typedef struct {
     int          nr;    /* The number of bonds in this record   */
     int          maxnr; /* The amount of elements in the array  */
-    t_param     *param; /* Array of parameters (dim: nr)       */
+    t_param     *param; /* Array of parameters (dim: nr or nr*nr) */
 
     /* CMAP tmp data, there are probably better places for this */
     int         grid_spacing; /* Cmap grid spacing */
index 2133aa71948eaf57ac8f0afa65990d955cb299b3..394bf80086ab539049d14c4da27261f5c3c48e28 100644 (file)
@@ -479,6 +479,7 @@ static void renumber_moltypes(gmx_mtop_t *sys,
             minew[i] = (*molinfo)[mi];
         }
     }
+    sfree(order);
     sfree(*molinfo);
 
     *nmolinfo = norder;
@@ -2328,8 +2329,15 @@ int gmx_grompp(int argc, char *argv[])
     /* Output IMD group, if bIMD is TRUE */
     write_IMDgroup_to_file(ir->bIMD, ir, &state, sys, NFILE, fnm);
 
+    sfree(opts->define);
+    sfree(opts->include);
+    sfree(opts);
+    done_plist(plist);
+    sfree(plist);
+    sfree(mi);
     done_atomtype(atype);
     done_mtop(sys);
+    sfree(sys);
     done_inputrec_strings();
 
     return 0;
index 01766cfca83f688955b217efecba8df4269944f6..b35187d69d7bd865214dd6d06a22cdc7b9d95d1c 100644 (file)
@@ -131,6 +131,17 @@ void init_plist(t_params plist[])
     }
 }
 
+void done_plist(t_params *plist)
+{
+    for (int i = 0; i < F_NRE; i++)
+    {
+        t_params *pl = &plist[i];
+        sfree(pl->param);
+        sfree(pl->cmap);
+        sfree(pl->cmap_types);
+    }
+}
+
 void cp_param(t_param *dest, t_param *src)
 {
     int j;
@@ -182,22 +193,12 @@ void init_molinfo(t_molinfo *mol)
 
 /* FREEING MEMORY */
 
-static void done_bt (t_params *pl)
-{
-    sfree(pl->param);
-}
-
 void done_mi(t_molinfo *mi)
 {
-    int i;
-
     done_atom (&(mi->atoms));
     done_block(&(mi->cgs));
     done_block(&(mi->mols));
-    for (i = 0; (i < F_NRE); i++)
-    {
-        done_bt(&(mi->plist[i]));
-    }
+    done_plist(mi->plist);
 }
 
 /* PRINTING STRUCTURES */
index f25b3f4bf0448ed0b979ed575ce045aa157cf56f..5dab27282a37ed87910600816c12e793301e3413 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2012,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2012,2014,2015,2018, 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.
@@ -56,6 +56,7 @@ void add_param_to_list(t_params *list, t_param *b);
 /* INITIATE */
 
 void init_plist(t_params plist[]);
+void done_plist(t_params *plist);
 
 void init_molinfo(t_molinfo *mol);
 
index 9ad61308d655ec05bc753ee088a1938cdd70842c..197490e675cf00484d552408ea3b3e820a42d4c3 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018, 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.
@@ -204,7 +204,7 @@ static void divide_bondeds_over_threads(t_idef *idef,
     if (F_NRE*(nthread + 1) > idef->il_thread_division_nalloc)
     {
         idef->il_thread_division_nalloc = F_NRE*(nthread + 1);
-        snew(idef->il_thread_division, idef->il_thread_division_nalloc);
+        srenew(idef->il_thread_division, idef->il_thread_division_nalloc);
     }
 
     *haveBondeds = false;
@@ -477,6 +477,22 @@ void setup_bonded_threading(t_forcerec *fr, t_idef *idef)
     }
 }
 
+void tear_down_bonded_threading(bonded_threading_t *bt,
+                                t_idef             *idef)
+{
+    for (int th = 0; th < bt->nthreads; th++)
+    {
+        sfree(bt->f_t[th].fshift);
+        for (int i = 0; i < egNR; i++)
+        {
+            sfree(bt->f_t[th].grpp.ener[i]);
+        }
+    }
+    sfree(bt->f_t);
+    sfree(bt);
+    sfree(idef->il_thread_division);
+}
+
 void init_bonded_threading(FILE *fplog, int nenergrp,
                            struct bonded_threading_t **bt_ptr)
 {
index a324ceff88302aca7eb481e079653919149dc327..5fb07ccc48dad8a006ab398210f576733a167054 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2018, 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.
@@ -62,6 +62,10 @@ extern "C" {
  */
 void setup_bonded_threading(t_forcerec *fr, t_idef *idef);
 
+//! Destructor.
+void tear_down_bonded_threading(bonded_threading_t *bt,
+                                t_idef             *idef);
+
 /*! \brief Initialize the bonded threading data structures
  *
  * Allocates and initializes a bonded threading data structure.
index d2618016fdc56e2a625932cc02ec818a02c8e626..5446b5151d7d155a95b5903bedb73a1d51004cd0 100644 (file)
@@ -864,6 +864,7 @@ static cginfo_mb_t *init_cginfo_mb(FILE *fplog, const gmx_mtop_t *mtop,
         cg_offset += molb->nmol*cgs->nr;
         a_offset  += molb->nmol*cgs->index[cgs->nr];
     }
+    sfree(type_VDW);
     sfree(bExcl);
 
     /* the solvent optimizer is called after the QM is initialized,
@@ -921,6 +922,19 @@ static int *cginfo_expand(int nmb, cginfo_mb_t *cgi_mb)
     return cginfo;
 }
 
+static void done_cginfo_mb(cginfo_mb_t *cginfo_mb, int numMolBlocks)
+{
+    if (cginfo_mb == nullptr)
+    {
+        return;
+    }
+    for (int mb = 0; mb < numMolBlocks; ++mb)
+    {
+        sfree(cginfo_mb[mb].cginfo);
+    }
+    sfree(cginfo_mb);
+}
+
 /* Sets the sum of charges (squared) and C6 in the system in fr.
  * Returns whether the system has a net charge.
  */
@@ -2147,6 +2161,15 @@ init_interaction_const(FILE                       *fp,
     *interaction_const = ic;
 }
 
+static void
+done_interaction_const(interaction_const_t *interaction_const)
+{
+    sfree_aligned(interaction_const->tabq_coul_FDV0);
+    sfree_aligned(interaction_const->tabq_coul_F);
+    sfree_aligned(interaction_const->tabq_coul_V);
+    sfree(interaction_const);
+}
+
 static void init_nb_verlet(const gmx::MDLogger     &mdlog,
                            nonbonded_verlet_t     **nb_verlet,
                            gmx_bool                 bFEP_NonBonded,
@@ -3139,3 +3162,21 @@ void free_gpu_resources(const t_forcerec                    *fr,
         physicalNodeCommunicator.barrier();
     }
 }
+
+void done_forcerec(t_forcerec *fr, int numMolBlocks, int numEnergyGroups)
+{
+    if (fr == nullptr)
+    {
+        // PME-only ranks don't have a forcerec
+        return;
+    }
+    done_cginfo_mb(fr->cginfo_mb, numMolBlocks);
+    sfree(fr->nbfp);
+    done_interaction_const(fr->ic);
+    sfree(fr->shift_vec);
+    sfree(fr->fshift);
+    sfree(fr->nblists);
+    done_ns(fr->ns, numEnergyGroups);
+    sfree(fr->ewc_t);
+    sfree(fr);
+}
index 5e1774a9f2127ef8f75122b1a72424a2cc45b0a9..c9b9308d5c26cfb407ce661afe29a0bbbe2ac9ce 100644 (file)
@@ -59,6 +59,9 @@ class MDLogger;
 /*! \brief Create a new forcerec structure */
 t_forcerec *mk_forcerec(void);
 
+//! Destroy a forcerec.
+void done_forcerec(t_forcerec *fr, int numMolBlocks, int numEnergyGroups);
+
 /*! \brief Print the contents of the forcerec to a file
  *
  * \param[in] fplog The log file to print to
index daffeaf7eacb0b1d95fe5ab8c706fe522e896f75..ec11dd096380787a7670b32e7e99802bd20c5942 100644 (file)
@@ -65,6 +65,39 @@ MDAtoms::MDAtoms()
 {
 }
 
+MDAtoms::~MDAtoms()
+{
+    if (mdatoms_ == nullptr)
+    {
+        return;
+    }
+    sfree(mdatoms_->massA);
+    sfree(mdatoms_->massB);
+    sfree(mdatoms_->massT);
+    gmx::AlignedAllocationPolicy::free(mdatoms_->invmass);
+    sfree(mdatoms_->invMassPerDim);
+    sfree(mdatoms_->typeA);
+    sfree(mdatoms_->chargeB);
+    sfree(mdatoms_->typeB);
+    sfree(mdatoms_->sqrt_c6A);
+    sfree(mdatoms_->sigmaA);
+    sfree(mdatoms_->sigma3A);
+    sfree(mdatoms_->sqrt_c6B);
+    sfree(mdatoms_->sigmaB);
+    sfree(mdatoms_->sigma3B);
+    sfree(mdatoms_->ptype);
+    sfree(mdatoms_->cTC);
+    sfree(mdatoms_->cENER);
+    sfree(mdatoms_->cACC);
+    sfree(mdatoms_->cFREEZE);
+    sfree(mdatoms_->cVCM);
+    sfree(mdatoms_->cORF);
+    sfree(mdatoms_->bPerturbed);
+    sfree(mdatoms_->cU1);
+    sfree(mdatoms_->cU2);
+    sfree(mdatoms_->bQM);
+}
+
 void MDAtoms::resize(int newSize)
 {
     chargeA_.resize(newSize);
index 8e708b3e0dde55f4cead60c7ae9b1101d44f26a4..2ceff719821afd5215ea122f7244a95f69c40687 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2010,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2010,2014,2015,2016,2017,2018, 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.
@@ -74,6 +74,8 @@ class MDAtoms
         // TODO make this private
         //! Constructor.
         MDAtoms();
+        //! Destructor.
+        ~MDAtoms();
         //! Getter.
         t_mdatoms *mdatoms()
         {
index b7c3513a4c67abaecb049e8be8cb70f03922a082..199f1705daee78aeeb5aae7e33365aec26eb358b 100644 (file)
@@ -135,7 +135,6 @@ t_mdebin *init_mdebin(ener_file_t       fp_ene,
         "Barostat"
     };
 
-    char              **grpnms;
     const gmx_groups_t *groups;
     char              **gnm;
     char                buf[256];
@@ -453,8 +452,8 @@ t_mdebin *init_mdebin(ener_file_t       fp_ene,
 
     snew(md->tmp_r, md->mde_n);
     snew(md->tmp_v, md->mde_n);
-    snew(md->grpnms, md->mde_n);
-    grpnms = md->grpnms;
+    char **grpnms;
+    snew(grpnms, md->mde_n);
 
     for (i = 0; (i < md->nTC); i++)
     {
@@ -530,9 +529,12 @@ t_mdebin *init_mdebin(ener_file_t       fp_ene,
         md->itc = get_ebin_space(md->ebin, md->mde_n, (const char **)grpnms, "");
     }
 
+    for (i = 0; i < md->mde_n; i++)
+    {
+        sfree(grpnms[i]);
+    }
     sfree(grpnms);
 
-
     md->nU = groups->grps[egcACC].nr;
     if (md->nU > 1)
     {
@@ -589,6 +591,18 @@ t_mdebin *init_mdebin(ener_file_t       fp_ene,
     return md;
 }
 
+void done_mdebin(t_mdebin *mdebin)
+{
+    sfree(mdebin->igrp);
+    sfree(mdebin->tmp_r);
+    sfree(mdebin->tmp_v);
+    done_ebin(mdebin->ebin);
+    done_mde_delta_h_coll(mdebin->dhc);
+    sfree(mdebin->dE);
+    sfree(mdebin->temperatures);
+    sfree(mdebin);
+}
+
 /* print a lambda vector to a string
    fep = the inputrec's FEP input data
    i = the index of the lambda vector
index 37a10a2f01e99b8a1fe4a37bb776d6e3632527b5..6c062a01204933304c4532debefb65466d7633e4 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018, 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.
@@ -77,7 +77,6 @@ typedef struct t_mdebin {
     int                 ivcos, ivisc;
     int                 nE, nEg, nEc, nTC, nTCP, nU, nNHC;
     int                *igrp;
-    char              **grpnms;
     int                 mde_n, mdeb_n;
     real               *tmp_r;
     rvec               *tmp_v;
@@ -125,6 +124,9 @@ t_mdebin *init_mdebin(ener_file_t       fp_ene,
                       FILE             *fp_dhdl);
 /* Initiate MD energy bin and write header to energy file. */
 
+//! Destroy mdebin
+void done_mdebin(t_mdebin *mdebin);
+
 FILE *open_dhdl(const char *filename, const t_inputrec *ir,
                 const gmx_output_env_t *oenv);
 /* Open the dhdl file for output */
index 56cee8a2324be0e7fbee8595395f2efda1ad17d8..1623b4ad7e93898943e2d6fafccaa33975b276ab 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018, 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.
@@ -110,6 +110,18 @@ static void mde_delta_h_init(t_mde_delta_h *dh, int nbins,
     mde_delta_h_reset(dh);
 }
 
+static void done_mde_delta_h(t_mde_delta_h *dh)
+{
+    sfree(dh->lambda);
+    sfree(dh->subblock_meta_d);
+    sfree(dh->dh);
+    sfree(dh->dhf);
+    for (int i = 0; i < dh->nhist; i++)
+    {
+        sfree(dh->bin[i]);
+    }
+}
+
 /* Add a value to the delta_h list */
 static void mde_delta_h_add_dh(t_mde_delta_h *dh, double delta_h)
 {
@@ -559,6 +571,24 @@ void mde_delta_h_coll_init(t_mde_delta_h_coll *dhc, const t_inputrec *ir)
     }
 }
 
+void done_mde_delta_h_coll(t_mde_delta_h_coll *dhc)
+{
+    if (dhc == nullptr)
+    {
+        return;
+    }
+    sfree(dhc->native_lambda_vec);
+    sfree(dhc->native_lambda_components);
+    sfree(dhc->subblock_d);
+    sfree(dhc->subblock_i);
+    for (int i = 0; i < dhc->ndh; ++i)
+    {
+        done_mde_delta_h(&dhc->dh[i]);
+    }
+    sfree(dhc->dh);
+    sfree(dhc);
+}
+
 /* add a bunch of samples - note fep_state is double to allow for better data storage */
 void mde_delta_h_coll_add_dh(t_mde_delta_h_coll *dhc,
                              double              fep_state,
index a506d7e0d23154511e2ef30c3f8d9d808ae6e66f..429447974602763781c0974d9533458edae6fbd9 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018, 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.
@@ -134,6 +134,9 @@ struct t_mde_delta_h_coll
 void mde_delta_h_coll_init(t_mde_delta_h_coll *dhc,
                            const t_inputrec   *ir);
 
+//! Destructor
+void done_mde_delta_h_coll(t_mde_delta_h_coll *dhc);
+
 /* add a bunch of samples to the delta_h collection
     dhc = the collection
     dhdl = the hamiltonian derivatives
index 08c325abfa6629edd77ab11c047db076a247fa11..218b076f07b8565f72dff3bb4f44f3aff8c396f6 100644 (file)
@@ -149,3 +149,9 @@ void mdAlgorithmsSetupAtomData(const t_commrec   *cr,
      * TODO: this also does not account for TPI.
      */
 }
+
+void mdAlgorithmsTearDownAtomData(bonded_threading_t *bt,
+                                  gmx_localtop_t     *top)
+{
+    tear_down_bonded_threading(bt, &top->idef);
+}
index 9e94b270dd14cb5f30e7e12ccbe39f4d0feb8f03..9631266ac4fa5fea89f01c2efe282cf264b25d4c 100644 (file)
@@ -35,6 +35,7 @@
 #ifndef GMX_MDLIB_MDSETUP_H
 #define GMX_MDLIB_MDSETUP_H
 
+struct bonded_threading_t;
 struct gmx_localtop_t;
 struct gmx_mtop_t;
 struct gmx_shellfc_t;
@@ -76,4 +77,12 @@ void mdAlgorithmsSetupAtomData(const t_commrec   *cr,
                                gmx_vsite_t       *vsite,
                                gmx_shellfc_t     *shellfc);
 
+/*! \brief Clean up after MD algorithms.
+ *
+ * \param[out] bt            Manages the bonded threading.
+ * \param[out] top           The local topology
+ */
+void mdAlgorithmsTearDownAtomData(bonded_threading_t *bt,
+                                  gmx_localtop_t     *top);
+
 #endif
index 2f6832aa6b1153472a97dc967ee6f4dcfbbc3839..d61f0c5f6091a772936fd75608bb2573db9600a7 100644 (file)
@@ -2157,6 +2157,22 @@ void init_ns(FILE *fplog, const t_commrec *cr,
     }
 }
 
+void done_ns(gmx_ns_t *ns, int numEnergyGroups)
+{
+    sfree(ns->bExcludeAlleg);
+    if (ns->ns_buf)
+    {
+        for (int i = 0; i < numEnergyGroups; i++)
+        {
+            sfree(ns->ns_buf[i]);
+        }
+        sfree(ns->ns_buf);
+    }
+    sfree(ns->simple_aaj);
+    sfree(ns->bHaveVdW);
+    done_grid(ns->grid);
+    sfree(ns);
+}
 
 int search_neighbours(FILE *log, t_forcerec *fr,
                       matrix box,
index ab1b9057cf94ce000b7b2a0d40109eb72e97ffaa..06b51346a50e08fc4aaa697f59d6032ac5321d18 100644 (file)
@@ -83,6 +83,9 @@ void init_ns(FILE *fplog, const t_commrec *cr,
              gmx_ns_t *ns, t_forcerec *fr,
              const gmx_mtop_t *mtop);
 
+//! Destructor.
+void done_ns(gmx_ns_t *ns, int numEnergyGroups);
+
 int search_neighbours(FILE *log, t_forcerec *fr, matrix box,
                       gmx_localtop_t *top,
                       gmx_groups_t *groups,
index 8bada3b28959ed1215e0fa34a51d8875a2a836fc..600a944692b31dc8ccf8553fa88c952e2d237c53 100644 (file)
@@ -409,6 +409,10 @@ t_grid *init_grid(FILE *fplog, t_forcerec *fr)
 
 void done_grid(t_grid *grid)
 {
+    if (grid == nullptr)
+    {
+        return;
+    }
     grid->nr      = 0;
     clear_ivec(grid->n);
     grid->ncells  = 0;
@@ -426,6 +430,7 @@ void done_grid(t_grid *grid)
     {
         fprintf(debug, "Successfully freed memory for grid pointers.");
     }
+    sfree(grid);
 }
 
 int xyz2ci_(int nry, int nrz, int x, int y, int z)
index d302c1f425b37a62b3eb352e2802eb867e46dedb..0d6fa4ff29432fc588a8e8ee3c0c56c382cf0946 100644 (file)
@@ -1989,7 +1989,7 @@ double gmx::do_md(FILE *fplog, t_commrec *cr,
                        eprAVER, mdebin, fcd, groups, &(ir->opts), ir->awh);
         }
     }
-    done_ebin(mdebin->ebin);
+    done_mdebin(mdebin);
     done_mdoutf(outf);
 
     if (bPMETune)
@@ -2029,5 +2029,10 @@ double gmx::do_md(FILE *fplog, t_commrec *cr,
         walltime_accounting_set_valid_finish(walltime_accounting);
     }
 
+    destroy_enerdata(enerd);
+    sfree(enerd);
+    mdAlgorithmsTearDownAtomData(fr->bonded_threading, top);
+    fr->bonded_threading = nullptr;
+    sfree(top);
     return 0;
 }
index 705b56bda6e811bc6e71c92ca248033ad8d6b38d..306b21777e267e1d6908f3c2ee7abed74fd583ce 100644 (file)
@@ -1399,6 +1399,9 @@ int Mdrunner::mdrunner()
     free_gpu_resources(fr, physicalNodeComm);
     free_gpu(nonbondedDeviceInfo);
     free_gpu(pmeDeviceInfo);
+    done_forcerec(fr, mtop->nmolblock, mtop->groups.grps[egcENER].nr);
+    done_mtop(mtop);
+    sfree(fcd);
 
     if (doMembed)
     {
@@ -1410,6 +1413,7 @@ int Mdrunner::mdrunner()
     /* Does what it says */
     print_date_and_time(fplog, cr->nodeid, "Finished mdrun", gmx_gettime());
     walltime_accounting_destroy(walltime_accounting);
+    sfree(nrnb);
 
     /* Close logfile already here if we were appending to it */
     if (MASTER(cr) && continuationOptions.appendFiles)