*
* 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.
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 */
minew[i] = (*molinfo)[mi];
}
}
+ sfree(order);
sfree(*molinfo);
*nmolinfo = norder;
/* 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;
}
}
+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;
/* 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 */
*
* 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.
/* INITIATE */
void init_plist(t_params plist[]);
+void done_plist(t_params *plist);
void init_molinfo(t_molinfo *mol);
*
* 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.
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;
}
}
+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)
{
*
* 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.
*/
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.
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,
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.
*/
*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,
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);
+}
/*! \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
{
}
+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);
*
* 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.
// TODO make this private
//! Constructor.
MDAtoms();
+ //! Destructor.
+ ~MDAtoms();
//! Getter.
t_mdatoms *mdatoms()
{
"Barostat"
};
- char **grpnms;
const gmx_groups_t *groups;
char **gnm;
char buf[256];
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++)
{
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)
{
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
*
* 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.
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;
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 */
*
* 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.
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)
{
}
}
+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,
*
* 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.
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
* 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);
+}
#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;
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
}
}
+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,
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,
void done_grid(t_grid *grid)
{
+ if (grid == nullptr)
+ {
+ return;
+ }
grid->nr = 0;
clear_ivec(grid->n);
grid->ncells = 0;
{
fprintf(debug, "Successfully freed memory for grid pointers.");
}
+ sfree(grid);
}
int xyz2ci_(int nry, int nrz, int x, int y, int z)
eprAVER, mdebin, fcd, groups, &(ir->opts), ir->awh);
}
}
- done_ebin(mdebin->ebin);
+ done_mdebin(mdebin);
done_mdoutf(outf);
if (bPMETune)
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;
}
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)
{
/* 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)