ed->bFirst = FALSE;
}
+
+void done_ed(gmx_edsam_t *ed)
+{
+ if (*ed)
+ {
+ /* ed->edo is opened sometimes with xvgropen, sometimes with
+ * gmx_fio_fopen, so we use the least common denominator for
+ * closing. */
+ gmx_fio_fclose((*ed)->edo);
+ }
+
+ /* TODO deallocate ed and set pointer to NULL */
+}
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,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.
void do_flood(t_commrec *cr, t_inputrec *ir, rvec x[], rvec force[], gmx_edsam_t ed,
matrix box, gmx_int64_t step, gmx_bool bNS);
+/*! \brief Clean up
+ *
+ * \param ed The essential dynamics data
+ */
+void done_ed(gmx_edsam_t *ed);
#ifdef __cplusplus
}
int *nb;
} t_nnb;
-void pr_energy(FILE *fp, real e)
-{
- fprintf(fp, "Energy: %8.4f\n", e);
-}
-
void cp_index(int nn, int from[], int to[])
{
int i;
gmx_bool bFit, FILE *log, t_rgb rlo, t_rgb rhi,
const output_env_t oenv)
{
- FILE *fp = NULL;
+ FILE *size_fp = NULL;
char buf[STRLEN], buf1[40], buf2[40], buf3[40], *trxsfn;
t_trxstatus *trxout = NULL;
t_trxstatus *trxsout = NULL;
if (clustidfn)
{
- fp = xvgropen(clustidfn, "Clusters", output_env_get_xvgr_tlabel(oenv), "Cluster #", oenv);
+ FILE *fp = xvgropen(clustidfn, "Clusters", output_env_get_xvgr_tlabel(oenv), "Cluster #", oenv);
if (output_env_get_print_xvgr_codes(oenv))
{
fprintf(fp, "@ s0 symbol 2\n");
}
if (sizefn)
{
- /* FIXME: This file is never closed. */
- fp = xvgropen(sizefn, "Cluster Sizes", "Cluster #", "# Structures", oenv);
+ size_fp = xvgropen(sizefn, "Cluster Sizes", "Cluster #", "# Structures", oenv);
if (output_env_get_print_xvgr_codes(oenv))
{
- fprintf(fp, "@g%d type %s\n", 0, "bar");
+ fprintf(size_fp, "@g%d type %s\n", 0, "bar");
}
}
snew(structure, nf);
}
if (sizefn)
{
- fprintf(fp, "%8d %8d\n", cl, nstr);
+ fprintf(size_fp, "%8d %8d\n", cl, nstr);
}
clrmsd = 0;
midstr = 0;
{
sfree(trxsfn);
}
+
+ if (size_fp)
+ {
+ xvgrclose(size_fp);
+ }
}
static void convert_mat(t_matrix *mat, t_mat *rms)
/*set_hb(hb->hbmap[i][j]->h[m],nframes-hb->hbmap[i][j]->n0,HB_NO);*/
}
-static void analyse_donor_props(const char *fn, t_hbdata *hb, int nframes, real t,
- const output_env_t oenv)
+static FILE *open_donor_properties_file(const char *fn,
+ t_hbdata *hb,
+ const output_env_t oenv)
{
- static FILE *fp = NULL;
- const char *leg[] = { "Nbound", "Nfree" };
- int i, j, k, nbound, nb, nhtot;
+ FILE *fp = NULL;
+ const char *leg[] = { "Nbound", "Nfree" };
- if (!fn)
+ if (!fn || !hb)
{
- return;
+ return NULL;
}
- if (!fp)
+
+ fp = xvgropen(fn, "Donor properties", output_env_get_xvgr_tlabel(oenv), "Number", oenv);
+ xvgr_legend(fp, asize(leg), leg, oenv);
+
+ return fp;
+}
+
+static void analyse_donor_properties(FILE *fp, t_hbdata *hb, int nframes, real t)
+{
+ int i, j, k, nbound, nb, nhtot;
+
+ if (!fp || !hb)
{
- // TODO: This file is never closed...
- fp = xvgropen(fn, "Donor properties", output_env_get_xvgr_tlabel(oenv), "Number", oenv);
- xvgr_legend(fp, asize(leg), leg, oenv);
+ return;
}
nbound = 0;
nhtot = 0;
int grp, nabin, nrbin, bin, resdist, ihb;
char **leg;
t_hbdata *hb, *hbptr;
- FILE *fp, *fpins = NULL, *fpnhb = NULL;
+ FILE *fp, *fpins = NULL, *fpnhb = NULL, *donor_properties = NULL;
t_gridcell ***grid;
t_ncell *icell, *jcell, *kcell;
ivec ngrid;
/*if (bSelected)
snew(donors[gr0D], dons[gr0D].nrd);*/
+ donor_properties = open_donor_properties_file(opt2fn_null("-don", NFILE, fnm), hb, oenv);
+
if (bHBmap)
{
printf("Making hbmap structure...");
#pragma omp barrier
#pragma omp single
{
- if (hb != NULL)
- {
- analyse_donor_props(opt2fn_null("-don", NFILE, fnm), hb, k, t, oenv);
- }
+ analyse_donor_properties(donor_properties, hb, k, t);
}
#pragma omp single
free_grid(ngrid, &grid);
close_trj(status);
+
+ if (donor_properties)
+ {
+ xvgrclose(donor_properties);
+ }
+
if (fpnhb)
{
xvgrclose(fpnhb);
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2011,2012,2013,2014,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.
rc = (int)gmx_get_stop_condition();
+ done_ed(&ed);
+
#ifdef GMX_THREAD_MPI
/* we need to join all threads. The sub-threads join when they
exit this function, but the master thread needs to be told to