From fa60bf2620de49b0b202fea6d04a978f358312a6 Mon Sep 17 00:00:00 2001 From: Teemu Murtola Date: Tue, 6 Jan 2015 09:59:42 +0200 Subject: [PATCH] Use xvgrclose() for files opened with xvgropen() Most callers used gmx_ffclose(), but there were also several that just didn't close the file at all, or used plain fclose(). Not using gmx_fio_fclose() left internal data structures inconsistent, which could have an effect in unit test binaries that could execute some code more than once (in particular, if the checkpoint code was triggered, as it then got confused about the improperly closed files). For consistency, changed gmx_fio_fclose() to xvgrclose(), except in places where there were paths on which the file was not opened with xvgropen(). Fixed some logic issues with opening/closing files in different branches. Change-Id: Iefda6880b06391b73423156888aee1d436e38199 --- src/gromacs/correlationfunctions/autocorr.c | 6 +++--- src/gromacs/essentialdynamics/edsam.c | 3 ++- src/gromacs/fileio/mdoutf.c | 9 ++++++--- src/gromacs/gmxana/anadih.c | 12 ++++++------ src/gromacs/gmxana/cmat.c | 4 ++-- src/gromacs/gmxana/gmx_anadock.c | 4 ++-- src/gromacs/gmxana/gmx_anaeig.c | 6 +++--- src/gromacs/gmxana/gmx_analyze.c | 12 +++++++----- src/gromacs/gmxana/gmx_angle.c | 8 ++++---- src/gromacs/gmxana/gmx_bar.c | 8 ++++++-- src/gromacs/gmxana/gmx_bundle.c | 20 +++++++++---------- src/gromacs/gmxana/gmx_chi.c | 14 +++++++------- src/gromacs/gmxana/gmx_cluster.c | 11 ++++++----- src/gromacs/gmxana/gmx_clustsize.c | 12 ++++++------ src/gromacs/gmxana/gmx_covar.c | 4 ++-- src/gromacs/gmxana/gmx_current.c | 24 +++++++++++++---------- src/gromacs/gmxana/gmx_density.c | 4 ++-- src/gromacs/gmxana/gmx_dielectric.c | 6 +++--- src/gromacs/gmxana/gmx_dipoles.cpp | 18 ++++++++--------- src/gromacs/gmxana/gmx_disre.c | 25 ++++++++++++++---------- src/gromacs/gmxana/gmx_do_dssp.c | 8 ++++---- src/gromacs/gmxana/gmx_dyecoupl.c | 10 +++++----- src/gromacs/gmxana/gmx_enemat.c | 4 ++-- src/gromacs/gmxana/gmx_energy.c | 30 ++++++++++++++--------------- src/gromacs/gmxana/gmx_gyrate.c | 4 ++-- src/gromacs/gmxana/gmx_h2order.c | 4 ++-- src/gromacs/gmxana/gmx_hbond.c | 19 +++++++++--------- src/gromacs/gmxana/gmx_helix.c | 6 +++--- src/gromacs/gmxana/gmx_helixorient.c | 6 +++--- src/gromacs/gmxana/gmx_lie.c | 4 ++-- src/gromacs/gmxana/gmx_mdmat.c | 4 ++-- src/gromacs/gmxana/gmx_mindist.c | 13 +++++++++---- src/gromacs/gmxana/gmx_morph.c | 4 ++-- src/gromacs/gmxana/gmx_msd.c | 6 +++--- src/gromacs/gmxana/gmx_nmeig.c | 10 +++++----- src/gromacs/gmxana/gmx_order.c | 14 +++++++------- src/gromacs/gmxana/gmx_polystat.c | 10 +++++----- src/gromacs/gmxana/gmx_potential.c | 8 ++++---- src/gromacs/gmxana/gmx_rama.c | 4 ++-- src/gromacs/gmxana/gmx_rms.c | 10 +++++----- src/gromacs/gmxana/gmx_rmsdist.c | 4 ++-- src/gromacs/gmxana/gmx_rmsf.c | 10 +++++----- src/gromacs/gmxana/gmx_rotmat.c | 4 ++-- src/gromacs/gmxana/gmx_saltbr.c | 6 +++--- src/gromacs/gmxana/gmx_sans.c | 6 +++--- src/gromacs/gmxana/gmx_sham.c | 4 ++-- src/gromacs/gmxana/gmx_sigeps.c | 4 ++-- src/gromacs/gmxana/gmx_sorient.c | 12 ++++++------ src/gromacs/gmxana/gmx_spol.c | 4 ++-- src/gromacs/gmxana/gmx_tcaf.c | 12 ++++++------ src/gromacs/gmxana/gmx_traj.c | 20 +++++++++---------- src/gromacs/gmxana/gmx_trjorder.c | 4 ++-- src/gromacs/gmxana/gmx_vanhove.c | 6 +++--- src/gromacs/gmxana/gmx_wham.cpp | 20 +++++++++---------- src/gromacs/gmxana/sfactor.c | 4 ++-- src/gromacs/mdlib/tables.c | 10 +++++----- src/gromacs/mdlib/tpi.cpp | 6 +++--- 57 files changed, 275 insertions(+), 249 deletions(-) diff --git a/src/gromacs/correlationfunctions/autocorr.c b/src/gromacs/correlationfunctions/autocorr.c index d2df85a391..72966978ce 100644 --- a/src/gromacs/correlationfunctions/autocorr.c +++ b/src/gromacs/correlationfunctions/autocorr.c @@ -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, 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. @@ -704,7 +704,7 @@ void low_do_autocorr(const char *fn, const output_env_t oenv, const char *title, } if (debug) { - gmx_ffclose(gp); + xvgrclose(gp); } if (nitem > 1) { @@ -717,7 +717,7 @@ void low_do_autocorr(const char *fn, const output_env_t oenv, const char *title, } if (fp) { - gmx_ffclose(fp); + xvgrclose(fp); } sfree(fit); } diff --git a/src/gromacs/essentialdynamics/edsam.c b/src/gromacs/essentialdynamics/edsam.c index 5514403870..558eb13dad 100644 --- a/src/gromacs/essentialdynamics/edsam.c +++ b/src/gromacs/essentialdynamics/edsam.c @@ -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, 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. @@ -1202,6 +1202,7 @@ gmx_edsam_t ed_open(int natoms, edsamstate_t *EDstate, int nfile, const t_filenm init_edsamstate(ed, EDstate); /* The master opens the ED output file */ + /* TODO This file is never closed... */ if (Flags & MD_APPENDFILES) { ed->edo = gmx_fio_fopen(opt2fn("-eo", nfile, fnm), "a+"); diff --git a/src/gromacs/fileio/mdoutf.c b/src/gromacs/fileio/mdoutf.c index b986d4afaa..bda0a7ac85 100644 --- a/src/gromacs/fileio/mdoutf.c +++ b/src/gromacs/fileio/mdoutf.c @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * 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. @@ -185,8 +185,8 @@ gmx_mdoutf_t init_mdoutf(FILE *fplog, int nfile, const t_filenm fnm[], { if (bAppendFiles) { - of->fp_dhdl = gmx_fio_fopen(opt2fn("-field", nfile, fnm), - filemode); + of->fp_field = gmx_fio_fopen(opt2fn("-field", nfile, fnm), + filemode); } else { @@ -412,6 +412,9 @@ void done_mdoutf(gmx_mdoutf_t of) } if (of->fp_field != NULL) { + /* This is opened sometimes with xvgropen, sometimes with + * gmx_fio_fopen, so we use the least common denominator for closing. + */ gmx_fio_fclose(of->fp_field); } diff --git a/src/gromacs/gmxana/anadih.c b/src/gromacs/gmxana/anadih.c index cc2fef9873..a1fc18e8d1 100644 --- a/src/gromacs/gmxana/anadih.c +++ b/src/gromacs/gmxana/anadih.c @@ -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, 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. @@ -70,7 +70,7 @@ void print_one(const output_env_t oenv, const char *base, const char *name, { fprintf(fp, "%10g %10g\n", time[k], data[k]); } - gmx_ffclose(fp); + xvgrclose(fp); } static int calc_RBbin(real phi, int gmx_unused multiplicity, real gmx_unused core_frac) @@ -300,7 +300,7 @@ void low_ana_dih_trans(gmx_bool bTrans, const char *fn_trans, { fprintf(fp, "%10.3f %10d\n", time[j], tr_f[j]); } - gmx_ffclose(fp); + xvgrclose(fp); } /* Compute histogram from # transitions per dihedral */ @@ -330,7 +330,7 @@ void low_ana_dih_trans(gmx_bool bTrans, const char *fn_trans, fprintf(fp, "%10.3f %10d\n", ttime/i, tr_f[i]); } } - gmx_ffclose(fp); + xvgrclose(fp); } sfree(tr_f); @@ -588,7 +588,7 @@ void get_chi_product_traj (real **dih, int nframes, int nlist, } } fprintf(fp, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : ""); - gmx_ffclose(fp); + xvgrclose(fp); } /* and finally print out occupancies to a single file */ @@ -615,7 +615,7 @@ void get_chi_product_traj (real **dih, int nframes, int nlist, } sfree(chi_prtrj); - gmx_ffclose(fpall); + xvgrclose(fpall); fprintf(stderr, "\n"); } diff --git a/src/gromacs/gmxana/cmat.c b/src/gromacs/gmxana/cmat.c index 672a2b60b2..fab0b3444a 100644 --- a/src/gromacs/gmxana/cmat.c +++ b/src/gromacs/gmxana/cmat.c @@ -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, 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. @@ -231,7 +231,7 @@ void low_rmsd_dist(const char *fn, real maxrms, int nn, real **mat, { fprintf(fp, "%10g %10d\n", i/fac, histo[i]); } - gmx_ffclose(fp); + xvgrclose(fp); sfree(histo); } diff --git a/src/gromacs/gmxana/gmx_anadock.c b/src/gromacs/gmxana/gmx_anadock.c index 98675b5687..73832bb487 100644 --- a/src/gromacs/gmxana/gmx_anadock.c +++ b/src/gromacs/gmxana/gmx_anadock.c @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by + * Copyright (c) 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. @@ -196,7 +196,7 @@ static void analyse_em_all(int npdb, t_pdbfile *pdbf[], const char *edocked, { fprintf(fp, "%12lf\n", bFreeSort ? pdbf[i]->efree : pdbf[i]->edocked); } - gmx_ffclose(fp); + xvgrclose(fp); } } diff --git a/src/gromacs/gmxana/gmx_anaeig.c b/src/gromacs/gmxana/gmx_anaeig.c index d9ea3facf9..b7b83105f3 100644 --- a/src/gromacs/gmxana/gmx_anaeig.c +++ b/src/gromacs/gmxana/gmx_anaeig.c @@ -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, 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. @@ -484,7 +484,7 @@ static void overlap(const char *outfile, int natoms, fprintf(out, "%5d %5.3f\n", eignr2[x]+1, overlap/noutvec); } - gmx_ffclose(out); + xvgrclose(out); } static void project(const char *trajfile, t_topology *top, int ePBC, matrix topbox, @@ -670,7 +670,7 @@ static void project(const char *trajfile, t_topology *top, int ePBC, matrix topb } fprintf(xvgrout, "%10.5f %10.5f\n", inprod[0][i], inprod[noutvec-1][i]); } - gmx_ffclose(xvgrout); + xvgrclose(xvgrout); } if (threedplotfile) diff --git a/src/gromacs/gmxana/gmx_analyze.c b/src/gromacs/gmxana/gmx_analyze.c index 1c323e14b2..e02ce3650f 100644 --- a/src/gromacs/gmxana/gmx_analyze.c +++ b/src/gromacs/gmxana/gmx_analyze.c @@ -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, 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. @@ -156,7 +156,7 @@ static void plot_coscont(const char *ccfile, int n, int nset, real **val, } fprintf(stdout, "\n"); - gmx_ffclose(fp); + xvgrclose(fp); } static void regression_analysis(int n, gmx_bool bXYdy, @@ -296,7 +296,7 @@ void histogram(const char *distfile, real binwidth, int n, int nset, real **val, fprintf(fp, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : ""); } } - gmx_ffclose(fp); + xvgrclose(fp); } static int real_comp(const void *a, const void *b) @@ -696,7 +696,7 @@ static void estimate_error(const char *eefile, int nb_min, int resol, int n, sfree(fitsig); sfree(ybs); sfree(tbs); - gmx_ffclose(fp); + xvgrclose(fp); } static void luzar_correl(int nn, real *time, int nset, real **val, real temp, @@ -941,6 +941,7 @@ static void do_ballistic(const char *balFile, int nData, } sfree(ctd); sfree(td); + xvgrclose(fp); } else { @@ -1002,6 +1003,7 @@ static void do_geminate(const char *gemFile, int nData, sfree(ctd); sfree(ctdGem); sfree(td); + xvgrclose(fp); } int gmx_analyze(int argc, char *argv[]) @@ -1367,7 +1369,7 @@ int gmx_analyze(int argc, char *argv[]) fprintf(out, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : ""); } } - gmx_ffclose(out); + xvgrclose(out); fprintf(stderr, "\r%d, time=%g\n", j-1, (j-1)*dt); } if (ccfile) diff --git a/src/gromacs/gmxana/gmx_angle.c b/src/gromacs/gmxana/gmx_angle.c index 544842106f..abbe1f8820 100644 --- a/src/gromacs/gmxana/gmx_angle.c +++ b/src/gromacs/gmxana/gmx_angle.c @@ -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, 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. @@ -305,7 +305,7 @@ int gmx_g_angle(int argc, char *argv[]) } fprintf(out, "\n"); } - gmx_ffclose(out); + xvgrclose(out); } if (opt2bSet("-or", NFILE, fnm)) { @@ -323,7 +323,7 @@ int gmx_g_angle(int argc, char *argv[]) fprintf(out, "%10.5f %10.3f\n", time[i], trans_frac[i]); tfrac += trans_frac[i]; } - gmx_ffclose(out); + xvgrclose(out); tfrac /= nframes; fprintf(stderr, "Average trans fraction: %g\n", tfrac); @@ -465,7 +465,7 @@ int gmx_g_angle(int argc, char *argv[]) fprintf(out, "%10g %10f\n", 180.0, angstat[0]*norm_fac); } - gmx_ffclose(out); + xvgrclose(out); do_view(oenv, opt2fn("-od", NFILE, fnm), "-nxy"); if (bAver) diff --git a/src/gromacs/gmxana/gmx_bar.c b/src/gromacs/gmxana/gmx_bar.c index 2a2b8fd8cb..c500c62060 100644 --- a/src/gromacs/gmxana/gmx_bar.c +++ b/src/gromacs/gmxana/gmx_bar.c @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by + * Copyright (c) 2010,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. @@ -3971,7 +3971,11 @@ int gmx_bar(int argc, char *argv[]) { lambda_vec_print_short(results[nresults-1].b->native_lambda, buf); fprintf(fpi, xvg2format, buf, dg_tot); - gmx_ffclose(fpi); + xvgrclose(fpi); + } + if (fpb != NULL) + { + xvgrclose(fpb); } do_view(oenv, opt2fn_null("-o", NFILE, fnm), "-xydy"); diff --git a/src/gromacs/gmxana/gmx_bundle.c b/src/gromacs/gmxana/gmx_bundle.c index 4b55d0d406..c858b356ad 100644 --- a/src/gromacs/gmxana/gmx_bundle.c +++ b/src/gromacs/gmxana/gmx_bundle.c @@ -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, 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. @@ -425,17 +425,17 @@ int gmx_bundle(int argc, char *argv[]) { close_trx(fpdb); } - gmx_ffclose(flen); - gmx_ffclose(fdist); - gmx_ffclose(fz); - gmx_ffclose(ftilt); - gmx_ffclose(ftiltr); - gmx_ffclose(ftiltl); + xvgrclose(flen); + xvgrclose(fdist); + xvgrclose(fz); + xvgrclose(ftilt); + xvgrclose(ftiltr); + xvgrclose(ftiltl); if (bKink) { - gmx_ffclose(fkink); - gmx_ffclose(fkinkr); - gmx_ffclose(fkinkl); + xvgrclose(fkink); + xvgrclose(fkinkr); + xvgrclose(fkinkl); } return 0; diff --git a/src/gromacs/gmxana/gmx_chi.c b/src/gromacs/gmxana/gmx_chi.c index 3717abb12b..8756ac7bc1 100644 --- a/src/gromacs/gmxana/gmx_chi.c +++ b/src/gromacs/gmxana/gmx_chi.c @@ -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, 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. @@ -709,7 +709,7 @@ static void histogramming(FILE *log, int nbin, gmx_residuetype_t *rt, } fprintf(fp, "\n"); } - gmx_ffclose(fp); + xvgrclose(fp); for (i = 0; (i < NJC); i++) { sfree(leg[i]); @@ -809,7 +809,7 @@ static void histogramming(FILE *log, int nbin, gmx_residuetype_t *rt, } } fprintf(fp, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : ""); - gmx_ffclose(fp); + xvgrclose(fp); if (bSSHisto) { for (k = 0; (k < 3); k++) @@ -940,7 +940,7 @@ static void do_rama(int nf, int nlist, t_dlist dlist[], real **dih, { gmx_ffclose(gp); } - gmx_ffclose(fp); + xvgrclose(fp); if (bOm) { sprintf(fn, "ramomega%s.xpm", dlist[i].name); @@ -997,7 +997,7 @@ static void do_rama(int nf, int nlist, t_dlist dlist[], real **dih, { fprintf(fp, "%10g %10g\n", RAD2DEG*dih[Xi1][j], RAD2DEG*dih[Xi2][j]); } - gmx_ffclose(fp); + xvgrclose(fp); } else { @@ -1058,7 +1058,7 @@ static void print_transitions(const char *fn, int maxchi, int nlist, /* fprintf(fp,"%12s\n",dlist[i].name); this confuses xmgrace */ fprintf(fp, "\n"); } - gmx_ffclose(fp); + xvgrclose(fp); } static void order_params(FILE *log, @@ -1136,7 +1136,7 @@ static void order_params(FILE *log, fprintf(fp, "\n"); /* fprintf(fp,"%12s\n",dlist[i].name); this confuses xmgrace */ } - gmx_ffclose(fp); + xvgrclose(fp); if (NULL != pdbfn) { diff --git a/src/gromacs/gmxana/gmx_cluster.c b/src/gromacs/gmxana/gmx_cluster.c index e93a10f95e..3d0b0bef8d 100644 --- a/src/gromacs/gmxana/gmx_cluster.c +++ b/src/gromacs/gmxana/gmx_cluster.c @@ -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, 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. @@ -280,7 +280,7 @@ void mc_optimize(FILE *log, t_mat *m, real *time, if (NULL != fp) { - fclose(fp); + xvgrclose(fp); } } @@ -995,7 +995,7 @@ static void ana_trans(t_clusters *clust, int nf, { fprintf(fp, "%5d %5d\n", i+1, ntrans[i]); } - gmx_ffclose(fp); + xvgrclose(fp); } sfree(ntrans); for (i = 0; i < clust->ncl; i++) @@ -1104,10 +1104,11 @@ static void analyze_clusters(int nf, t_clusters *clust, real **rmsd, { fprintf(fp, "%8g %8d\n", time[i], clust->cl[i]); } - gmx_ffclose(fp); + xvgrclose(fp); } if (sizefn) { + /* FIXME: This file is never closed. */ fp = xvgropen(sizefn, "Cluster Sizes", "Cluster #", "# Structures", oenv); if (output_env_get_print_xvgr_codes(oenv)) { @@ -1870,7 +1871,7 @@ int gmx_cluster(int argc, char *argv[]) { fprintf(fp, "%10d %10g\n", i, eigenvalues[i]); } - gmx_ffclose(fp); + xvgrclose(fp); break; case m_monte_carlo: orig = init_mat(rms->nn, FALSE); diff --git a/src/gromacs/gmxana/gmx_clustsize.c b/src/gromacs/gmxana/gmx_clustsize.c index 0a2351a110..5e524f2dcf 100644 --- a/src/gromacs/gmxana/gmx_clustsize.c +++ b/src/gromacs/gmxana/gmx_clustsize.c @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2007, 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. @@ -330,10 +330,10 @@ static void clust_size(const char *ndx, const char *trx, const char *xpm, } while (read_next_frame(oenv, status, &fr)); close_trx(status); - gmx_ffclose(fp); - gmx_ffclose(gp); - gmx_ffclose(hp); - gmx_ffclose(tp); + xvgrclose(fp); + xvgrclose(gp); + xvgrclose(hp); + xvgrclose(tp); gmx_mtop_atomlookup_destroy(alook); @@ -376,7 +376,7 @@ static void clust_size(const char *ndx, const char *trx, const char *xpm, nhisto += (int)((j+1)*nelem/n_x); } fprintf(fp, "%5d %8.3f\n", j+1, 0.0); - gmx_ffclose(fp); + xvgrclose(fp); fprintf(stderr, "Total number of atoms in clusters = %d\n", nhisto); diff --git a/src/gromacs/gmxana/gmx_covar.c b/src/gromacs/gmxana/gmx_covar.c index 6154b3c3c5..2bde8f74b7 100644 --- a/src/gromacs/gmxana/gmx_covar.c +++ b/src/gromacs/gmxana/gmx_covar.c @@ -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, 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. @@ -564,7 +564,7 @@ int gmx_covar(int argc, char *argv[]) { fprintf (out, "%10d %g\n", (int)i+1, eigenvalues[ndim-1-i]); } - gmx_ffclose(out); + xvgrclose(out); if (bFit) { diff --git a/src/gromacs/gmxana/gmx_current.c b/src/gromacs/gmxana/gmx_current.c index e27cf05233..ead28e0a76 100644 --- a/src/gromacs/gmxana/gmx_current.c +++ b/src/gromacs/gmxana/gmx_current.c @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2008,2009,2010,2011,2012,2013,2014, by the GROMACS development team, led by + * Copyright (c) 2008,2009,2010,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. @@ -992,16 +992,20 @@ int gmx_current(int argc, char *argv[]) temp, trust, bfit, efit, bvit, evit, status, isize, nmols, nshift, index0, indexm, mass2, qmol, eps_rf, oenv); - gmx_ffclose(fmj); - gmx_ffclose(fmd); - gmx_ffclose(fmjdsp); - if (bACF) - { - gmx_ffclose(outf); - } - if (bINT) + xvgrclose(fmj); + xvgrclose(fmd); + xvgrclose(fmjdsp); + if (fr.bV) { - gmx_ffclose(mcor); + if (bACF) + { + xvgrclose(outf); + } + xvgrclose(fcur); + if (bINT) + { + xvgrclose(mcor); + } } return 0; diff --git a/src/gromacs/gmxana/gmx_density.c b/src/gromacs/gmxana/gmx_density.c index f74611b940..7d30ccce8e 100644 --- a/src/gromacs/gmxana/gmx_density.c +++ b/src/gromacs/gmxana/gmx_density.c @@ -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, 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. @@ -551,7 +551,7 @@ void plot_density(double *slDensity[], const char *afile, int nslices, fprintf(den, "\n"); } - gmx_ffclose(den); + xvgrclose(den); } int gmx_density(int argc, char *argv[]) diff --git a/src/gromacs/gmxana/gmx_dielectric.c b/src/gromacs/gmxana/gmx_dielectric.c index 18d1d4a38b..7561aece02 100644 --- a/src/gromacs/gmxana/gmx_dielectric.c +++ b/src/gromacs/gmxana/gmx_dielectric.c @@ -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, 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. @@ -239,8 +239,8 @@ void do_four(const char *fn, const char *cn, int nx, real x[], real dy[], } printf("MAXEPS = %10.5e at frequency %10.5e GHz (tauD = %8.1f ps)\n", maxeps, numax, 1000/(2*M_PI*numax)); - gmx_ffclose(fp); - gmx_ffclose(cp); + xvgrclose(fp); + xvgrclose(cp); sfree(tmp); } diff --git a/src/gromacs/gmxana/gmx_dipoles.cpp b/src/gromacs/gmxana/gmx_dipoles.cpp index f13e0da111..a73621310c 100644 --- a/src/gromacs/gmxana/gmx_dipoles.cpp +++ b/src/gromacs/gmxana/gmx_dipoles.cpp @@ -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, 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. @@ -404,7 +404,7 @@ static void print_gkrbin(const char *fn, t_gkrbin *gb, /* Swap x0 and x1 */ x0 = x1; } - gmx_ffclose(fp); + xvgrclose(fp); } gmx_bool read_mu_from_enx(ener_file_t fmu, int Vol, ivec iMu, rvec mu, real *vol, @@ -686,7 +686,7 @@ static void dump_slab_dipoles(const char *fn, int idim, int nslice, slab_dipole[i][ZZ]/nframes, mutot); } - gmx_ffclose(fp); + xvgrclose(fp); do_view(oenv, fn, "-autoscale xy -nxy"); } @@ -1336,18 +1336,18 @@ static void do_dip(t_topology *top, int ePBC, real volume, close_trj(status); } - gmx_ffclose(outmtot); - gmx_ffclose(outaver); - gmx_ffclose(outeps); + xvgrclose(outmtot); + xvgrclose(outaver); + xvgrclose(outeps); if (fnadip) { - gmx_ffclose(adip); + xvgrclose(adip); } if (cosaver) { - gmx_ffclose(caver); + xvgrclose(caver); } if (dip3d) @@ -1456,7 +1456,7 @@ static void do_dip(t_topology *top, int ePBC, real volume, fprintf(outdd, "%10g %10f\n", (i*mu_max)/ndipbin, dipole_bin[i]/(double)teller); } - gmx_ffclose(outdd); + xvgrclose(outdd); sfree(dipole_bin); } if (bGkr) diff --git a/src/gromacs/gmxana/gmx_disre.c b/src/gromacs/gmxana/gmx_disre.c index e6d0f29854..311e7a198d 100644 --- a/src/gromacs/gmxana/gmx_disre.c +++ b/src/gromacs/gmxana/gmx_disre.c @@ -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, 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. @@ -786,6 +786,8 @@ int gmx_disre(int argc, char *argv[]) if (ftp2bSet(efNDX, NFILE, fnm)) { + /* TODO: Nothing is written to this file if -c is provided, but it is + * still opened... */ rd_index(ftp2fn(efNDX, NFILE, fnm), 1, &isize, &index, &grpname); xvg = xvgropen(opt2fn("-dr", NFILE, fnm), "Individual Restraints", "Time (ps)", "nm", oenv); @@ -933,20 +935,23 @@ int gmx_disre(int argc, char *argv[]) } dump_disre_matrix(opt2fn_null("-x", NFILE, fnm), &dr, fcd.disres.nres, j, &top->idef, &mtop, max_dr, nlevels, bThird); - gmx_ffclose(out); - gmx_ffclose(aver); - gmx_ffclose(numv); - gmx_ffclose(maxxv); - if (isize > 0) - { - gmx_ffclose(xvg); - do_view(oenv, opt2fn("-dr", NFILE, fnm), "-nxy"); - } + xvgrclose(out); + xvgrclose(aver); + xvgrclose(numv); + xvgrclose(maxxv); do_view(oenv, opt2fn("-dn", NFILE, fnm), "-nxy"); do_view(oenv, opt2fn("-da", NFILE, fnm), "-nxy"); do_view(oenv, opt2fn("-ds", NFILE, fnm), "-nxy"); do_view(oenv, opt2fn("-dm", NFILE, fnm), "-nxy"); } + if (isize > 0) + { + xvgrclose(xvg); + if (!clust) + { + do_view(oenv, opt2fn("-dr", NFILE, fnm), "-nxy"); + } + } gmx_log_close(fplog); diff --git a/src/gromacs/gmxana/gmx_do_dssp.c b/src/gromacs/gmxana/gmx_do_dssp.c index 729348d208..9cc1300295 100644 --- a/src/gromacs/gmxana/gmx_do_dssp.c +++ b/src/gromacs/gmxana/gmx_do_dssp.c @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by + * Copyright (c) 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. @@ -425,7 +425,7 @@ void analyse_ss(const char *outfile, t_matrix *mat, const char *ss_string, } fprintf(fp, "\n"); - gmx_ffclose(fp); + xvgrclose(fp); sfree(leg); sfree(count); } @@ -682,7 +682,7 @@ int gmx_do_dssp(int argc, char *argv[]) close_trj(status); if (fTArea) { - gmx_ffclose(fTArea); + xvgrclose(fTArea); } gmx_rmpbc_done(gpbc); @@ -731,7 +731,7 @@ int gmx_do_dssp(int argc, char *argv[]) { fprintf(acc, "%5d %10g %10g\n", i+1, av_area[i], norm_av_area[i]); } - gmx_ffclose(acc); + xvgrclose(acc); } } diff --git a/src/gromacs/gmxana/gmx_dyecoupl.c b/src/gromacs/gmxana/gmx_dyecoupl.c index 57f2e47dca..0513f8f8a6 100644 --- a/src/gromacs/gmxana/gmx_dyecoupl.c +++ b/src/gromacs/gmxana/gmx_dyecoupl.c @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by + * Copyright (c) 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. @@ -358,7 +358,7 @@ int gmx_dyecoupl(int argc, char *argv[]) if (bRKout) { - gmx_ffclose(rkfp); + xvgrclose(rkfp); } if (bDatout) @@ -368,7 +368,7 @@ int gmx_dyecoupl(int argc, char *argv[]) if (bInstEffout) { - gmx_ffclose(iefp); + xvgrclose(iefp); } @@ -419,7 +419,7 @@ int gmx_dyecoupl(int argc, char *argv[]) fprintf(rhfp, "%12.7f %12.7f\n", (i + 0.5) * rincr + rmin, rhist[i]); } - gmx_ffclose(rhfp); + xvgrclose(rhfp); } if (bKhistout) @@ -456,7 +456,7 @@ int gmx_dyecoupl(int argc, char *argv[]) fprintf(khfp, "%12.7f %12.7f\n", (i + 0.5) * kincr + kmin, khist[i]); } - gmx_ffclose(khfp); + xvgrclose(khfp); } printf("\nAverages:\n"); diff --git a/src/gromacs/gmxana/gmx_enemat.c b/src/gromacs/gmxana/gmx_enemat.c index 576cb221eb..4eacc7347f 100644 --- a/src/gromacs/gmxana/gmx_enemat.c +++ b/src/gromacs/gmxana/gmx_enemat.c @@ -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, 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. @@ -581,7 +581,7 @@ int gmx_enemat(int argc, char *argv[]) } fprintf(out, "\n"); } - gmx_ffclose(out); + xvgrclose(out); } else { diff --git a/src/gromacs/gmxana/gmx_energy.c b/src/gromacs/gmxana/gmx_energy.c index eca1ca6166..98f8b715d0 100644 --- a/src/gromacs/gmxana/gmx_energy.c +++ b/src/gromacs/gmxana/gmx_energy.c @@ -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, 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. @@ -559,7 +559,7 @@ static void analyse_disre(const char *voutfn, int nframes, fprintf(vout, "%10d %10.5e\n", j, mypow(violaver[j]/nframes, minthird)); } #endif - gmx_ffclose(vout); + xvgrclose(vout); fprintf(stdout, "\nSum of violations averaged over simulation: %g nm\n", sumt); @@ -621,8 +621,8 @@ static void einstein_visco(const char *fn, const char *fni, int nsets, } fprintf(fp1, "\n"); } - gmx_ffclose(fp0); - gmx_ffclose(fp1); + xvgrclose(fp0); + xvgrclose(fp1); } typedef struct { @@ -1420,7 +1420,7 @@ static void analyse_ener(gmx_bool bCorr, const char *corrfn, intBulk += 0.5*(eneset[11][i-1] + eneset[11][i])*factor; fprintf(fp, "%10g %10g %10g\n", (i*Dt), integral, intBulk); } - gmx_ffclose(fp); + xvgrclose(fp); for (i = 0; i < 12; i++) { @@ -1583,7 +1583,7 @@ static void fec(const char *ene2fn, const char *runavgfn, } if (fp) { - gmx_ffclose(fp); + xvgrclose(fp); } sfree(fr); } @@ -2709,21 +2709,21 @@ int gmx_energy(int argc, char *argv[]) close_enx(fp); if (out) { - gmx_ffclose(out); + xvgrclose(out); } if (bDRAll) { - gmx_ffclose(fp_pairs); + xvgrclose(fp_pairs); } if (bORT) { - gmx_ffclose(fort); + xvgrclose(fort); } if (bODT) { - gmx_ffclose(fodt); + xvgrclose(fodt); } if (bORA) { @@ -2738,7 +2738,7 @@ int gmx_energy(int argc, char *argv[]) { fprintf(out, "%5d %g\n", or_label[i], orient[i]/norfr); } - gmx_ffclose(out); + xvgrclose(out); } if (bODA) { @@ -2753,7 +2753,7 @@ int gmx_energy(int argc, char *argv[]) { fprintf(out, "%5d %g\n", or_label[i], orient[i]/norfr-oobs[i]); } - gmx_ffclose(out); + xvgrclose(out); } if (bODR) { @@ -2768,11 +2768,11 @@ int gmx_energy(int argc, char *argv[]) { fprintf(out, "%5d %g\n", or_label[i], sqrt(odrms[i]/norfr)); } - gmx_ffclose(out); + xvgrclose(out); } if (bOTEN) { - gmx_ffclose(foten); + xvgrclose(foten); } if (bDisRe) @@ -2784,7 +2784,7 @@ int gmx_energy(int argc, char *argv[]) { if (fp_dhdl) { - gmx_ffclose(fp_dhdl); + gmx_fio_fclose(fp_dhdl); printf("\n\nWrote %d lambda values with %d samples as ", dh_lambdas, dh_samples); if (dh_hists > 0) diff --git a/src/gromacs/gmxana/gmx_gyrate.c b/src/gromacs/gmxana/gmx_gyrate.c index ebf112f286..6c70944e36 100644 --- a/src/gromacs/gmxana/gmx_gyrate.c +++ b/src/gromacs/gmxana/gmx_gyrate.c @@ -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, 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. @@ -377,7 +377,7 @@ int gmx_gyrate(int argc, char *argv[]) gmx_rmpbc_done(gpbc); } - gmx_ffclose(out); + xvgrclose(out); if (bACF) { diff --git a/src/gromacs/gmxana/gmx_h2order.c b/src/gromacs/gmxana/gmx_h2order.c index 284ca5517b..bab0785283 100644 --- a/src/gromacs/gmxana/gmx_h2order.c +++ b/src/gromacs/gmxana/gmx_h2order.c @@ -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, 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. @@ -254,7 +254,7 @@ void h2order_plot(rvec dipole[], real order[], const char *afile, factor*dipole[slice][ZZ], order[slice]); } - gmx_ffclose(ord); + xvgrclose(ord); } int gmx_h2order(int argc, char *argv[]) diff --git a/src/gromacs/gmxana/gmx_hbond.c b/src/gromacs/gmxana/gmx_hbond.c index 3e9acb11c9..2f9d4578f8 100644 --- a/src/gromacs/gmxana/gmx_hbond.c +++ b/src/gromacs/gmxana/gmx_hbond.c @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2008, 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. @@ -2233,7 +2233,7 @@ static void do_hblife(const char *fn, t_hbdata *hb, gmx_bool bMerge, gmx_bool bC integral += x1; } integral *= dt; - gmx_ffclose(fp); + xvgrclose(fp); printf("%s lifetime = %.2f ps\n", bContact ? "Contact" : "HB", integral); printf("Note that the lifetime obtained in this manner is close to useless\n"); printf("Use the -ac option instead and check the Forward lifetime\n"); @@ -3273,7 +3273,7 @@ static void do_hbac(const char *fn, t_hbdata *hb, fprintf(fp, "%10g %10g %10g %10g %10g\n", hb->time[j]-hb->time[0], ct[j], cct[j], ght[j], kt[j]); } - gmx_ffclose(fp); + xvgrclose(fp); analyse_corr(nn, hb->time, ct, ght, kt, NULL, NULL, NULL, fit_start, temp, smooth_tail_start, oenv); @@ -3341,6 +3341,7 @@ static void analyse_donor_props(const char *fn, t_hbdata *hb, int nframes, real } if (!fp) { + // 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); } @@ -4450,7 +4451,7 @@ int gmx_hbond(int argc, char *argv[]) close_trj(status); if (fpnhb) { - gmx_ffclose(fpnhb); + xvgrclose(fpnhb); } /* Compute maximum possible number of different hbonds */ @@ -4516,7 +4517,7 @@ int gmx_hbond(int argc, char *argv[]) aver_nhb += hb->nhb[i]; aver_dist += hb->ndist[i]; } - gmx_ffclose(fp); + xvgrclose(fp); aver_nhb /= nframes; aver_dist /= nframes; /* Print HB distance distribution */ @@ -4539,7 +4540,7 @@ int gmx_hbond(int argc, char *argv[]) { fprintf(fp, "%10g %10g\n", (i+0.5)*rbin, rdist[i]/(rbin*(real)sum)); } - gmx_ffclose(fp); + xvgrclose(fp); } /* Print HB angle distribution */ @@ -4560,7 +4561,7 @@ int gmx_hbond(int argc, char *argv[]) { fprintf(fp, "%10g %10g\n", (i+0.5)*abin, adist[i]/(abin*(real)sum)); } - gmx_ffclose(fp); + xvgrclose(fp); } /* Print HB in alpha-helix */ @@ -4578,7 +4579,7 @@ int gmx_hbond(int argc, char *argv[]) } fprintf(fp, "\n"); } - gmx_ffclose(fp); + xvgrclose(fp); } if (!bNN) { @@ -4775,7 +4776,7 @@ int gmx_hbond(int argc, char *argv[]) } fprintf(fp, "\n"); } - gmx_ffclose(fp); + xvgrclose(fp); } return 0; diff --git a/src/gromacs/gmxana/gmx_helix.c b/src/gromacs/gmxana/gmx_helix.c index 3d18d53f3c..29bab90a07 100644 --- a/src/gromacs/gmxana/gmx_helix.c +++ b/src/gromacs/gmxana/gmx_helix.c @@ -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, 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. @@ -289,10 +289,10 @@ int gmx_helix(int argc, char *argv[]) for (i = 0; (i < efhNR); i++) { - gmx_ffclose(xf[i].fp); + xvgrclose(xf[i].fp); if (xf[i].bfp2) { - gmx_ffclose(xf[i].fp2); + xvgrclose(xf[i].fp2); } do_view(oenv, xf[i].filenm, "-nxy"); } diff --git a/src/gromacs/gmxana/gmx_helixorient.c b/src/gromacs/gmxana/gmx_helixorient.c index 7946fd306f..0cb969d053 100644 --- a/src/gromacs/gmxana/gmx_helixorient.c +++ b/src/gromacs/gmxana/gmx_helixorient.c @@ -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, 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. @@ -511,8 +511,8 @@ int gmx_helixorient(int argc, char *argv[]) gmx_ffclose(fpaxis); gmx_ffclose(fpcenter); - gmx_ffclose(fptilt); - gmx_ffclose(fprotation); + xvgrclose(fptilt); + xvgrclose(fprotation); gmx_ffclose(fprise); gmx_ffclose(fpradius); gmx_ffclose(fptwist); diff --git a/src/gromacs/gmxana/gmx_lie.c b/src/gromacs/gmxana/gmx_lie.c index f6ab7c1033..83a35de3b5 100644 --- a/src/gromacs/gmxana/gmx_lie.c +++ b/src/gromacs/gmxana/gmx_lie.c @@ -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, 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. @@ -207,7 +207,7 @@ int gmx_lie(int argc, char *argv[]) } } close_enx(fp); - gmx_ffclose(out); + xvgrclose(out); fprintf(stderr, "\n"); if (nframes > 0) diff --git a/src/gromacs/gmxana/gmx_mdmat.c b/src/gromacs/gmxana/gmx_mdmat.c index 960049e5cf..d3a409ee28 100644 --- a/src/gromacs/gmxana/gmx_mdmat.c +++ b/src/gromacs/gmxana/gmx_mdmat.c @@ -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, 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. @@ -394,7 +394,7 @@ int gmx_mdmat(int argc, char *argv[]) fprintf(fp, "%3d %8.3f %3d %8.3f %3d %8.3f\n", i+1, ratio, tot_n[i], mean_n[i], natm[i], mean_n[i]/natm[i]); } - gmx_ffclose(fp); + xvgrclose(fp); } return 0; diff --git a/src/gromacs/gmxana/gmx_mindist.c b/src/gromacs/gmxana/gmx_mindist.c index 837ef92f00..3c96ffb2c6 100644 --- a/src/gromacs/gmxana/gmx_mindist.c +++ b/src/gromacs/gmxana/gmx_mindist.c @@ -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, 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. @@ -201,7 +201,7 @@ static void periodic_mindist_plot(const char *trxfn, const char *outfn, gmx_rmpbc_done(gpbc); } - gmx_ffclose(out); + xvgrclose(out); fprintf(stdout, "\nThe shortest periodic distance is %g (nm) at time %g (%s),\n" @@ -550,10 +550,10 @@ void dist_plot(const char *fn, const char *afile, const char *dfile, while (read_next_x(oenv, status, &t, x0, box)); close_trj(status); - gmx_ffclose(dist); + xvgrclose(dist); if (num) { - gmx_ffclose(num); + xvgrclose(num); } if (atm) { @@ -563,6 +563,10 @@ void dist_plot(const char *fn, const char *afile, const char *dfile, { close_trx(trxout); } + if (respertime) + { + xvgrclose(respertime); + } if (nres && !bEachResEachTime) { @@ -580,6 +584,7 @@ void dist_plot(const char *fn, const char *afile, const char *dfile, } fprintf(res, "\n"); } + xvgrclose(res); } sfree(x0); diff --git a/src/gromacs/gmxana/gmx_morph.c b/src/gromacs/gmxana/gmx_morph.c index fe1153db71..12c4269589 100644 --- a/src/gromacs/gmxana/gmx_morph.c +++ b/src/gromacs/gmxana/gmx_morph.c @@ -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, 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. @@ -197,7 +197,7 @@ int gmx_morph(int argc, char *argv[]) if (bRMS) { - gmx_ffclose(fp); + xvgrclose(fp); do_view(oenv, opt2fn("-or", NFILE, fnm), "-nxy"); } diff --git a/src/gromacs/gmxana/gmx_msd.c b/src/gromacs/gmxana/gmx_msd.c index 6913929759..eb36ac9e30 100644 --- a/src/gromacs/gmxana/gmx_msd.c +++ b/src/gromacs/gmxana/gmx_msd.c @@ -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, 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. @@ -213,7 +213,7 @@ static void corr_print(t_corr *curr, gmx_bool bTen, const char *fn, const char * } fprintf(out, "\n"); } - gmx_ffclose(out); + xvgrclose(out); } /* called from corr_loop, to do the main calculations */ @@ -607,7 +607,7 @@ void printmol(t_corr *curr, const char *fn, } } } - gmx_ffclose(out); + xvgrclose(out); do_view(oenv, fn, "-graphtype bar"); /* Compute variance, stddev and error */ diff --git a/src/gromacs/gmxana/gmx_nmeig.c b/src/gromacs/gmxana/gmx_nmeig.c index eb727c8fa2..4560444e68 100644 --- a/src/gromacs/gmxana/gmx_nmeig.c +++ b/src/gromacs/gmxana/gmx_nmeig.c @@ -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, 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. @@ -488,7 +488,7 @@ int gmx_nmeig(int argc, char *argv[]) { fprintf (out, "%6d %15g\n", begin+i, eigenvalues[i]); } - gmx_ffclose(out); + xvgrclose(out); if (opt2bSet("-qc", NFILE, fnm)) @@ -577,14 +577,14 @@ int gmx_nmeig(int argc, char *argv[]) qutot += qu; } } - gmx_ffclose(out); + xvgrclose(out); if (NULL != spec) { for (j = 0; (j < maxspec); j++) { fprintf(spec, "%10g %10g\n", 1.0*j, spectrum[j]); } - gmx_ffclose(spec); + xvgrclose(spec); } if (NULL != qc) { @@ -594,7 +594,7 @@ int gmx_nmeig(int argc, char *argv[]) nharm, nvsite); printf("Total correction to cV = %g J/mol K\n", qcvtot); printf("Total correction to H = %g kJ/mol\n", qutot); - gmx_ffclose(qc); + xvgrclose(qc); please_cite(stdout, "Caleman2011b"); } /* Writing eigenvectors. Note that if mass scaling was used, the eigenvectors diff --git a/src/gromacs/gmxana/gmx_order.c b/src/gromacs/gmxana/gmx_order.c index 28c3e77722..2c2bf83c4a 100644 --- a/src/gromacs/gmxana/gmx_order.c +++ b/src/gromacs/gmxana/gmx_order.c @@ -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, 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. @@ -325,8 +325,8 @@ static void calc_tetra_order_parm(const char *fnNDX, const char *fnTPS, sfree(index); sfree(isize); - gmx_ffclose(fpsg); - gmx_ffclose(fpsk); + xvgrclose(fpsg); + xvgrclose(fpsk); fpsg = xvgropen(sgslfn, "S\\sg\\N Angle Order Parameter / Slab", "(nm)", "S\\sg\\N", @@ -341,8 +341,8 @@ static void calc_tetra_order_parm(const char *fnNDX, const char *fnTPS, fprintf(fpsk, "%10g %10g\n", (i+0.5)*box[slice_dim][slice_dim]/nslice, sk_slice_tot[i]/nframes); } - gmx_ffclose(fpsg); - gmx_ffclose(fpsk); + xvgrclose(fpsg); + xvgrclose(fpsk); } @@ -830,9 +830,9 @@ void order_plot(rvec order[], real *slOrder[], const char *afile, const char *bf 0.333 * order[atom][YY])); } - gmx_ffclose(ord); - gmx_ffclose(slOrd); } + xvgrclose(ord); + xvgrclose(slOrd); } void write_bfactors(t_filenm *fnm, int nfile, atom_id *index, atom_id *a, int nslices, int ngrps, real **order, t_topology *top, real **distvals, output_env_t oenv) diff --git a/src/gromacs/gmxana/gmx_polystat.c b/src/gromacs/gmxana/gmx_polystat.c index ece18dc4d1..12c108da9f 100644 --- a/src/gromacs/gmxana/gmx_polystat.c +++ b/src/gromacs/gmxana/gmx_polystat.c @@ -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, 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. @@ -464,14 +464,14 @@ int gmx_polystat(int argc, char *argv[]) close_trx(status); - gmx_ffclose(out); + xvgrclose(out); if (outv) { - gmx_ffclose(outv); + xvgrclose(outv); } if (outp) { - gmx_ffclose(outp); + xvgrclose(outp); } sum_eed2_tot /= frame; @@ -514,7 +514,7 @@ int gmx_polystat(int argc, char *argv[]) { fprintf(outi, "%d %8.4f\n", i+1, intd[i]); } - gmx_ffclose(outi); + xvgrclose(outi); } do_view(oenv, opt2fn("-o", NFILE, fnm), "-nxy"); diff --git a/src/gromacs/gmxana/gmx_potential.c b/src/gromacs/gmxana/gmx_potential.c index 9991682a45..fb56240c3a 100644 --- a/src/gromacs/gmxana/gmx_potential.c +++ b/src/gromacs/gmxana/gmx_potential.c @@ -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, 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. @@ -398,9 +398,9 @@ void plot_potential(double *potential[], double *charge[], double *field[], fprintf(fie, "\n"); } - gmx_ffclose(pot); - gmx_ffclose(cha); - gmx_ffclose(fie); + xvgrclose(pot); + xvgrclose(cha); + xvgrclose(fie); } int gmx_potential(int argc, char *argv[]) diff --git a/src/gromacs/gmxana/gmx_rama.c b/src/gromacs/gmxana/gmx_rama.c index 5198b0c730..f48e3b6f8f 100644 --- a/src/gromacs/gmxana/gmx_rama.c +++ b/src/gromacs/gmxana/gmx_rama.c @@ -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, 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. @@ -113,7 +113,7 @@ int gmx_rama(int argc, char *argv[]) } while (new_data(xr)); fprintf(stderr, "\n"); - gmx_ffclose(out); + xvgrclose(out); do_view(oenv, ftp2fn(efXVG, NFILE, fnm), NULL); diff --git a/src/gromacs/gmxana/gmx_rms.c b/src/gromacs/gmxana/gmx_rms.c index dccad9e472..f399105e70 100644 --- a/src/gromacs/gmxana/gmx_rms.c +++ b/src/gromacs/gmxana/gmx_rms.c @@ -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, 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. @@ -1151,7 +1151,7 @@ int gmx_rms(int argc, char *argv[]) } fprintf(fp, "\n"); } - gmx_ffclose(fp); + xvgrclose(fp); if (bMirror) { @@ -1189,7 +1189,7 @@ int gmx_rms(int argc, char *argv[]) } fprintf(fp, "\n"); } - gmx_ffclose(fp); + xvgrclose(fp); } if (bAv) @@ -1201,7 +1201,7 @@ int gmx_rms(int argc, char *argv[]) { fprintf(fp, "%10d %10g\n", j, rlstot/teller); } - gmx_ffclose(fp); + xvgrclose(fp); } if (bNorm) @@ -1211,7 +1211,7 @@ int gmx_rms(int argc, char *argv[]) { fprintf(fp, "%10d %10g\n", j, rlsnorm[j]/teller); } - gmx_ffclose(fp); + xvgrclose(fp); } do_view(oenv, opt2fn_null("-a", NFILE, fnm), "-graphtype bar"); do_view(oenv, opt2fn("-o", NFILE, fnm), NULL); diff --git a/src/gromacs/gmxana/gmx_rmsdist.c b/src/gromacs/gmxana/gmx_rmsdist.c index ea98add60a..5616a4136e 100644 --- a/src/gromacs/gmxana/gmx_rmsdist.c +++ b/src/gromacs/gmxana/gmx_rmsdist.c @@ -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, 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. @@ -798,7 +798,7 @@ int gmx_rmsdist(int argc, char *argv[]) while (read_next_x(oenv, status, &t, x, box)); fprintf(stderr, "\n"); - gmx_ffclose(fp); + xvgrclose(fp); close_trj(status); diff --git a/src/gromacs/gmxana/gmx_rmsf.c b/src/gromacs/gmxana/gmx_rmsf.c index c4398533cd..f96663cb77 100644 --- a/src/gromacs/gmxana/gmx_rmsf.c +++ b/src/gromacs/gmxana/gmx_rmsf.c @@ -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, 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. @@ -102,7 +102,7 @@ void correlate_aniso(const char *fn, t_atoms *ref, t_atoms *calc, } } } - gmx_ffclose(fp); + xvgrclose(fp); } static void average_residues(double f[], double **U, int uind, @@ -497,7 +497,7 @@ int gmx_rmsf(int argc, char *argv[]) pdb_bfac); } } - gmx_ffclose(fp); + xvgrclose(fp); } else { @@ -511,7 +511,7 @@ int gmx_rmsf(int argc, char *argv[]) bRes ? top.atoms.resinfo[top.atoms.atom[index[i]].resind].nr : index[i]+1, sqrt(rmsf[i])); } } - gmx_ffclose(fp); + xvgrclose(fp); } for (i = 0; i < isize; i++) @@ -540,7 +540,7 @@ int gmx_rmsf(int argc, char *argv[]) bRes ? top.atoms.resinfo[top.atoms.atom[index[i]].resind].nr : index[i]+1, sqrt(rmsf[i])); } } - gmx_ffclose(fp); + xvgrclose(fp); } if (opt2bSet("-oq", NFILE, fnm)) diff --git a/src/gromacs/gmxana/gmx_rotmat.c b/src/gromacs/gmxana/gmx_rotmat.c index 3eddfe424c..c9f3dc16ee 100644 --- a/src/gromacs/gmxana/gmx_rotmat.c +++ b/src/gromacs/gmxana/gmx_rotmat.c @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2009,2010,2011,2012,2013,2014, by the GROMACS development team, led by + * Copyright (c) 2009,2010,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. @@ -304,7 +304,7 @@ int gmx_rotmat(int argc, char *argv[]) close_trj(status); - gmx_ffclose(out); + xvgrclose(out); do_view(oenv, ftp2fn(efXVG, NFILE, fnm), "-nxy"); diff --git a/src/gromacs/gmxana/gmx_saltbr.c b/src/gromacs/gmxana/gmx_saltbr.c index 46fd1409e1..11d7f1565a 100644 --- a/src/gromacs/gmxana/gmx_saltbr.c +++ b/src/gromacs/gmxana/gmx_saltbr.c @@ -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, 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. @@ -244,7 +244,7 @@ int gmx_saltbr(int argc, char *argv[]) { fprintf(fp, "%10g %10g\n", time[k], cgdist[i][j][k]); } - gmx_ffclose(fp); + xvgrclose(fp); } } } @@ -326,7 +326,7 @@ int gmx_saltbr(int argc, char *argv[]) } for (m = 0; (m < 3); m++) { - gmx_ffclose(out[m]); + xvgrclose(out[m]); if (nset[m] == 0) { remove(fn[m]); diff --git a/src/gromacs/gmxana/gmx_sans.c b/src/gromacs/gmxana/gmx_sans.c index 797652dd8d..fdff37b0ad 100644 --- a/src/gromacs/gmxana/gmx_sans.c +++ b/src/gromacs/gmxana/gmx_sans.c @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by + * Copyright (c) 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. @@ -306,7 +306,7 @@ int gmx_sans(int argc, char *argv[]) fprintf(fp, "%10.6f%10.6f\n", prframecurrent->r[i], prframecurrent->gr[i]); } done_filenms(NFILE, fnmdup); - fclose(fp); + xvgrclose(fp); sfree(hdr); sfree(suffix); sfree(fnmdup); @@ -327,7 +327,7 @@ int gmx_sans(int argc, char *argv[]) fprintf(fp, "%10.6f%10.6f\n", sqframecurrent->q[i], sqframecurrent->s[i]); } done_filenms(NFILE, fnmdup); - fclose(fp); + xvgrclose(fp); sfree(hdr); sfree(suffix); sfree(fnmdup); diff --git a/src/gromacs/gmxana/gmx_sham.c b/src/gromacs/gmxana/gmx_sham.c index 94430c03d9..5d8f47c117 100644 --- a/src/gromacs/gmxana/gmx_sham.c +++ b/src/gromacs/gmxana/gmx_sham.c @@ -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, 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. @@ -865,7 +865,7 @@ static void ehisto(const char *fh, int n, real **enerT, const output_env_t oenv) } fprintf(fp, "\n"); } - gmx_ffclose(fp); + xvgrclose(fp); } int gmx_sham(int argc, char *argv[]) diff --git a/src/gromacs/gmxana/gmx_sigeps.c b/src/gromacs/gmxana/gmx_sigeps.c index 4eaae62fb6..f426fe4e51 100644 --- a/src/gromacs/gmxana/gmx_sigeps.c +++ b/src/gromacs/gmxana/gmx_sigeps.c @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by + * Copyright (c) 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. @@ -187,7 +187,7 @@ int gmx_sigeps(int argc, char *argv[]) oldx = x; } - gmx_ffclose(fp); + xvgrclose(fp); do_view(oenv, ftp2fn(efXVG, NFILE, fnm), NULL); diff --git a/src/gromacs/gmxana/gmx_sorient.c b/src/gromacs/gmxana/gmx_sorient.c index a81a8265d5..7de848e5eb 100644 --- a/src/gromacs/gmxana/gmx_sorient.c +++ b/src/gromacs/gmxana/gmx_sorient.c @@ -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, 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. @@ -397,7 +397,7 @@ int gmx_sorient(int argc, char *argv[]) { fprintf(fp, "%g %g\n", (i+0.5)*binwidth-1, 2*normfac*hist1[i]); } - gmx_ffclose(fp); + xvgrclose(fp); sprintf(str, "Solvent normal orientation between %g and %g nm", rmin, rmax); fp = xvgropen(opt2fn("-no", NFILE, fnm), str, "cos(\\8q\\4\\s2\\N)", "", oenv); @@ -409,7 +409,7 @@ int gmx_sorient(int argc, char *argv[]) { fprintf(fp, "%g %g\n", (i+0.5)*binwidth, normfac*hist2[i]); } - gmx_ffclose(fp); + xvgrclose(fp); sprintf(str, "Solvent orientation"); @@ -425,7 +425,7 @@ int gmx_sorient(int argc, char *argv[]) histn[i] ? histi1[i]/histn[i] : 0, histn[i] ? histi2[i]/histn[i] : 0); } - gmx_ffclose(fp); + xvgrclose(fp); sprintf(str, "Cumulative solvent orientation"); fp = xvgropen(opt2fn("-co", NFILE, fnm), str, "r (nm)", "", oenv); @@ -444,7 +444,7 @@ int gmx_sorient(int argc, char *argv[]) c2 += histi2[i]*normfac; fprintf(fp, "%g %g %g\n", (i+1)*rbinw, c1, c2); } - gmx_ffclose(fp); + xvgrclose(fp); sprintf(str, "Solvent distribution"); fp = xvgropen(opt2fn("-rc", NFILE, fnm), str, "r (nm)", "molecules/nm", oenv); @@ -457,7 +457,7 @@ int gmx_sorient(int argc, char *argv[]) { fprintf(fp, "%g %g\n", (i+0.5)*rbinw, histn[i]*normfac); } - gmx_ffclose(fp); + xvgrclose(fp); do_view(oenv, opt2fn("-o", NFILE, fnm), NULL); do_view(oenv, opt2fn("-no", NFILE, fnm), NULL); diff --git a/src/gromacs/gmxana/gmx_spol.c b/src/gromacs/gmxana/gmx_spol.c index 2def7422e5..559aa2aa69 100644 --- a/src/gromacs/gmxana/gmx_spol.c +++ b/src/gromacs/gmxana/gmx_spol.c @@ -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, 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. @@ -380,7 +380,7 @@ int gmx_spol(int argc, char *argv[]) nmol += hist[i]; fprintf(fp, "%g %g\n", i*bw, nmol/nf); } - gmx_ffclose(fp); + xvgrclose(fp); do_view(oenv, opt2fn("-o", NFILE, fnm), NULL); diff --git a/src/gromacs/gmxana/gmx_tcaf.c b/src/gromacs/gmxana/gmx_tcaf.c index 668073ef65..d2a6b72d74 100644 --- a/src/gromacs/gmxana/gmx_tcaf.c +++ b/src/gromacs/gmxana/gmx_tcaf.c @@ -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, 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. @@ -101,7 +101,7 @@ static void process_tcaf(int nframes, real dt, int nkc, real **tc, rvec *kfac, } fprintf(fp, "\n"); } - gmx_ffclose(fp); + xvgrclose(fp); do_view(oenv, fn_trans, "-nxy"); } @@ -169,7 +169,7 @@ static void process_tcaf(int nframes, real dt, int nkc, real **tc, rvec *kfac, } fprintf(fp, "\n"); } - gmx_ffclose(fp); + xvgrclose(fp); do_view(oenv, fn_tc, "-nxy"); if (fn_cub) @@ -220,7 +220,7 @@ static void process_tcaf(int nframes, real dt, int nkc, real **tc, rvec *kfac, } fprintf(fp, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : ""); } - gmx_ffclose(fp); + xvgrclose(fp); do_view(oenv, fn_tcf, "-nxy"); if (fn_cub) @@ -247,10 +247,10 @@ static void process_tcaf(int nframes, real dt, int nkc, real **tc, rvec *kfac, fprintf(fp_cub, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : ""); } fprintf(fp_vk, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : ""); - gmx_ffclose(fp_cub); + xvgrclose(fp_cub); do_view(oenv, fn_cub, "-nxy"); } - gmx_ffclose(fp_vk); + xvgrclose(fp_vk); do_view(oenv, fn_vk, "-nxy"); } diff --git a/src/gromacs/gmxana/gmx_traj.c b/src/gromacs/gmxana/gmx_traj.c index cd3d0b5ccf..d737ccfdf2 100644 --- a/src/gromacs/gmxana/gmx_traj.c +++ b/src/gromacs/gmxana/gmx_traj.c @@ -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, 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. @@ -464,7 +464,7 @@ static void write_pdb_bfac(const char *fname, const char *xname, fprintf(fp, "%-5d %10.3f %10.3f %10.3f\n", 1+i, sum[index[i]][XX], sum[index[i]][YY], sum[index[i]][ZZ]); } - gmx_ffclose(fp); + xvgrclose(fp); max = 0; maxi = 0; for (i = 0; i < isize; i++) @@ -584,7 +584,7 @@ static void print_histo(const char *fn, int nhisto, int histo[], real binwidth, { fprintf(fp, "%10.3e %10d\n", i*binwidth, histo[i]); } - gmx_ffclose(fp); + xvgrclose(fp); } int gmx_traj(int argc, char *argv[]) @@ -1055,7 +1055,7 @@ int gmx_traj(int argc, char *argv[]) if (bOX) { - gmx_ffclose(outx); + xvgrclose(outx); } if (bOXT) { @@ -1063,27 +1063,27 @@ int gmx_traj(int argc, char *argv[]) } if (bOV) { - gmx_ffclose(outv); + xvgrclose(outv); } if (bOF) { - gmx_ffclose(outf); + xvgrclose(outf); } if (bOB) { - gmx_ffclose(outb); + xvgrclose(outb); } if (bOT) { - gmx_ffclose(outt); + xvgrclose(outt); } if (bEKT) { - gmx_ffclose(outekt); + xvgrclose(outekt); } if (bEKR) { - gmx_ffclose(outekr); + xvgrclose(outekr); } if (bVD) diff --git a/src/gromacs/gmxana/gmx_trjorder.c b/src/gromacs/gmxana/gmx_trjorder.c index ed383bf2f4..a43ce10dbd 100644 --- a/src/gromacs/gmxana/gmx_trjorder.c +++ b/src/gromacs/gmxana/gmx_trjorder.c @@ -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, 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. @@ -374,7 +374,7 @@ int gmx_trjorder(int argc, char *argv[]) } if (fp) { - gmx_ffclose(fp); + xvgrclose(fp); } gmx_rmpbc_done(gpbc); diff --git a/src/gromacs/gmxana/gmx_vanhove.c b/src/gromacs/gmxana/gmx_vanhove.c index fb372b77e1..fa3567f02f 100644 --- a/src/gromacs/gmxana/gmx_vanhove.c +++ b/src/gromacs/gmxana/gmx_vanhove.c @@ -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, 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. @@ -456,7 +456,7 @@ int gmx_vanhove(int argc, char *argv[]) } fprintf(fp, "\n"); } - gmx_ffclose(fp); + xvgrclose(fp); } if (otfile) @@ -471,7 +471,7 @@ int gmx_vanhove(int argc, char *argv[]) { fprintf(fp, "%g %g\n", f*dt, (real)pt[f]/(tcount[f]*isize)); } - gmx_ffclose(fp); + xvgrclose(fp); } do_view(oenv, matfile, NULL); diff --git a/src/gromacs/gmxana/gmx_wham.cpp b/src/gromacs/gmxana/gmx_wham.cpp index 7a5b0a4333..6b82c5d5b3 100644 --- a/src/gromacs/gmxana/gmx_wham.cpp +++ b/src/gromacs/gmxana/gmx_wham.cpp @@ -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, 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. @@ -1254,7 +1254,7 @@ void calc_cumulatives(t_UmbrellaWindow *window, int nWindows, fprintf(fp, "\n"); } printf("Wrote cumulative distribution functions to %s\n", fn); - gmx_ffclose(fp); + xvgrclose(fp); sfree(fn); sfree(buf); } @@ -1480,7 +1480,7 @@ void print_histograms(const char *fnhist, t_UmbrellaWindow * window, int nWindow fprintf(fp, "\n"); } - gmx_ffclose(fp); + xvgrclose(fp); printf("Wrote %s\n", fn); if (bs_index >= 0) { @@ -1724,7 +1724,7 @@ void do_bootstrapping(const char *fnres, const char* fnprof, const char *fnhist, } fprintf(fp, "%s\n", output_env_get_print_xvgr_codes(opt->oenv) ? "&" : ""); } - gmx_ffclose(fp); + xvgrclose(fp); /* write average and stddev */ fp = xvgropen(fnres, "Average and stddev from bootstrapping", xlabel, ylabel, opt->oenv); @@ -1740,7 +1740,7 @@ void do_bootstrapping(const char *fnres, const char* fnprof, const char *fnhist, stddev = (tmp >= 0.) ? sqrt(tmp) : 0.; /* Catch rouding errors */ fprintf(fp, "%e\t%e\t%e\n", (i+0.5)*opt->dz+opt->min, bsProfiles_av [i], stddev); } - gmx_ffclose(fp); + xvgrclose(fp); printf("Wrote boot strap result to %s\n", fnres); } @@ -2715,7 +2715,7 @@ void calcIntegratedAutocorrelationTimes(t_UmbrellaWindow *window, int nwins, printf(" done\n"); if (fpcorr) { - gmx_ffclose(fpcorr); + xvgrclose(fpcorr); } /* plot IACT along reaction coordinate */ @@ -2761,7 +2761,7 @@ void calcIntegratedAutocorrelationTimes(t_UmbrellaWindow *window, int nwins, } } } - gmx_ffclose(fp); + xvgrclose(fp); printf("Wrote %s\n", fn); } @@ -3000,7 +3000,7 @@ void guessPotByIntegration(t_UmbrellaWindow *window, int nWindows, t_UmbrellaOpt { fprintf(fp, "%g %g\n", (j+0.5)*dz+opt->min, pot[j]); } - gmx_ffclose(fp); + xvgrclose(fp); printf("verbose mode: wrote %s with PMF from interated forces\n", "pmfintegrated.xvg"); } @@ -3519,7 +3519,7 @@ int gmx_wham(int argc, char *argv[]) } fprintf(histout, "\n"); } - gmx_ffclose(histout); + xvgrclose(histout); printf("Wrote %s\n", opt2fn("-hist", NFILE, fnm)); if (opt.bHistOnly) { @@ -3620,7 +3620,7 @@ int gmx_wham(int argc, char *argv[]) { fprintf(profout, "%e\t%e\n", (double)(i+0.5)/opt.bins*(opt.max-opt.min)+opt.min, profile[i]); } - gmx_ffclose(profout); + xvgrclose(profout); printf("Wrote %s\n", opt2fn("-o", NFILE, fnm)); /* Bootstrap Method */ diff --git a/src/gromacs/gmxana/sfactor.c b/src/gromacs/gmxana/sfactor.c index 8cc7492d77..f5cf0eb787 100644 --- a/src/gromacs/gmxana/sfactor.c +++ b/src/gromacs/gmxana/sfactor.c @@ -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, 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. @@ -594,7 +594,7 @@ extern void save_data (structure_factor_t *sft, const char *file, int ngrps, } } - gmx_ffclose (fp); + xvgrclose (fp); } diff --git a/src/gromacs/mdlib/tables.c b/src/gromacs/mdlib/tables.c index 1c3389e493..ad8e473cf7 100644 --- a/src/gromacs/mdlib/tables.c +++ b/src/gromacs/mdlib/tables.c @@ -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, 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. @@ -1201,7 +1201,7 @@ static void fill_table(t_tabledata *td, int tp, const t_forcerec *fr, } #ifdef DEBUG_SWITCH - gmx_fio_fclose(fp); + xvgrclose(fp); #endif } @@ -1535,7 +1535,7 @@ t_forcetable make_tables(FILE *out, const output_env_t oenv, evaluate_table(table.data, 4*k, 12, table.scale, x0, &y0, &yp); fprintf(fp, "%15.10e %15.10e %15.10e\n", x0, y0, yp); } - gmx_fio_fclose(fp); + xvgrclose(fp); } done_tabledata(&(td[k])); } @@ -1645,7 +1645,7 @@ t_forcetable make_gb_table(const output_env_t oenv, fprintf(fp, "%15.10e %15.10e %15.10e\n", x0, y0, yp); } - gmx_fio_fclose(fp); + xvgrclose(fp); } /* @@ -1784,7 +1784,7 @@ t_forcetable make_atf_table(FILE *out, const output_env_t oenv, fprintf(fp, "%15.10e %15.10e %15.10e\n", x0, y0, yp); } - gmx_ffclose(fp); + xvgrclose(fp); } done_tabledata(&(td[0])); diff --git a/src/gromacs/mdlib/tpi.cpp b/src/gromacs/mdlib/tpi.cpp index 3d8a37fda2..4f855af49a 100644 --- a/src/gromacs/mdlib/tpi.cpp +++ b/src/gromacs/mdlib/tpi.cpp @@ -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, 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. @@ -835,7 +835,7 @@ double do_tpi(FILE *fplog, t_commrec *cr, if (fp_tpi != NULL) { - gmx_fio_fclose(fp_tpi); + xvgrclose(fp_tpi); } if (fplog != NULL) @@ -870,7 +870,7 @@ double do_tpi(FILE *fplog, t_commrec *cr, (int)(bin[i]+0.5), bin[i]*exp(-bUlogV)*V_all/VembU_all); } - gmx_fio_fclose(fp_tpi); + xvgrclose(fp_tpi); } sfree(bin); -- 2.11.4.GIT