Use xvgrclose() for files opened with xvgropen()
authorTeemu Murtola <teemu.murtola@gmail.com>
Tue, 6 Jan 2015 07:59:42 +0000 (09:59 +0200)
committerTeemu Murtola <teemu.murtola@gmail.com>
Tue, 6 Jan 2015 07:59:42 +0000 (09:59 +0200)
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

57 files changed:
src/gromacs/correlationfunctions/autocorr.c
src/gromacs/essentialdynamics/edsam.c
src/gromacs/fileio/mdoutf.c
src/gromacs/gmxana/anadih.c
src/gromacs/gmxana/cmat.c
src/gromacs/gmxana/gmx_anadock.c
src/gromacs/gmxana/gmx_anaeig.c
src/gromacs/gmxana/gmx_analyze.c
src/gromacs/gmxana/gmx_angle.c
src/gromacs/gmxana/gmx_bar.c
src/gromacs/gmxana/gmx_bundle.c
src/gromacs/gmxana/gmx_chi.c
src/gromacs/gmxana/gmx_cluster.c
src/gromacs/gmxana/gmx_clustsize.c
src/gromacs/gmxana/gmx_covar.c
src/gromacs/gmxana/gmx_current.c
src/gromacs/gmxana/gmx_density.c
src/gromacs/gmxana/gmx_dielectric.c
src/gromacs/gmxana/gmx_dipoles.cpp
src/gromacs/gmxana/gmx_disre.c
src/gromacs/gmxana/gmx_do_dssp.c
src/gromacs/gmxana/gmx_dyecoupl.c
src/gromacs/gmxana/gmx_enemat.c
src/gromacs/gmxana/gmx_energy.c
src/gromacs/gmxana/gmx_gyrate.c
src/gromacs/gmxana/gmx_h2order.c
src/gromacs/gmxana/gmx_hbond.c
src/gromacs/gmxana/gmx_helix.c
src/gromacs/gmxana/gmx_helixorient.c
src/gromacs/gmxana/gmx_lie.c
src/gromacs/gmxana/gmx_mdmat.c
src/gromacs/gmxana/gmx_mindist.c
src/gromacs/gmxana/gmx_morph.c
src/gromacs/gmxana/gmx_msd.c
src/gromacs/gmxana/gmx_nmeig.c
src/gromacs/gmxana/gmx_order.c
src/gromacs/gmxana/gmx_polystat.c
src/gromacs/gmxana/gmx_potential.c
src/gromacs/gmxana/gmx_rama.c
src/gromacs/gmxana/gmx_rms.c
src/gromacs/gmxana/gmx_rmsdist.c
src/gromacs/gmxana/gmx_rmsf.c
src/gromacs/gmxana/gmx_rotmat.c
src/gromacs/gmxana/gmx_saltbr.c
src/gromacs/gmxana/gmx_sans.c
src/gromacs/gmxana/gmx_sham.c
src/gromacs/gmxana/gmx_sigeps.c
src/gromacs/gmxana/gmx_sorient.c
src/gromacs/gmxana/gmx_spol.c
src/gromacs/gmxana/gmx_tcaf.c
src/gromacs/gmxana/gmx_traj.c
src/gromacs/gmxana/gmx_trjorder.c
src/gromacs/gmxana/gmx_vanhove.c
src/gromacs/gmxana/gmx_wham.cpp
src/gromacs/gmxana/sfactor.c
src/gromacs/mdlib/tables.c
src/gromacs/mdlib/tpi.cpp

index d2df85a3913641a3d29766de8e81acf0da12e6ba..72966978ce38d0a90f5fef87c4e35d1f6ffbcf61 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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);
 }
index 5514403870b5a8fb29647276dbe46254230c55e2..558eb13dad1be2f3acb3a83e655fc5428761b7ff 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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+");
index b986d4afaa6345d31c351353304649a1be5c376e..bda0a7ac85d842308719eefc8e965be0711ee060 100644 (file)
@@ -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);
     }
 
index cc2fef9873f8306ad5157621775426f327d047a2..a1fc18e8d1b67861ccb9b9d72f17d280a773e659 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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");
 
 }
index 672a2b60b22a1795f414a289ff85bb1d52770a7c..fab0b3444a4d606d4551836efe410766b32f722b 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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);
 }
 
index 98675b56879fd89d976eff6c3b85c36b35add6f8..73832bb487c0d46972fbb7e80cc595d71d9b3a61 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2012,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);
     }
 }
 
index d9ea3facf922cdeae384fefee38d1df19f4c348b..b7b83105f39a30ebe5438b44466c47a69827eb51 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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)
index 1c323e14b23d6bdc14879c6e80ad3ba907d8d05a..e02ce3650f1fd899f9928c201b5f3920179f4b90 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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)
index 544842106f8522995744fbf9ce77b621fb2fd1bf..abbe1f8820ac9b7402ce2afaa225a0f3ada17597 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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)
index 2a2b8fd8cb212cfaa1f36a9d373cbf992afd0fac..c500c620604252e0f74f5e50ac193344afd7909f 100644 (file)
@@ -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");
index 4b55d0d4068a794c9fea6cbede726defc82155e9..c858b356adbba6598722fd48b9e7533e9783ada6 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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;
index 3717abb12b7aa429718327d7319bde4e3291c0f7..8756ac7bc17a9b90ab67c2a7e056d4aafa5909a5 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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)
     {
index e93a10f95ea4a38949ee8805dfa02ffdc8961d53..3d0b0bef8daf84cdf544fa2439f3bd55dd1420d0 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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);
index 0a2351a110d876a1abeec03f176c9ce992abd6d9..5e524f2dcff8ed0aa00684f7f74a1c9221cf2cbe 100644 (file)
@@ -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);
 
index 6154b3c3c5cf429e35bda32b64f73cf4a176acbb..2bde8f74b7152f09e254b129b78b2ed07926f489 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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)
     {
index e27cf05233ae6e631a3a8f446de276a20f4295f3..ead28e0a76c15563643d637d6eaf2df37b871e31 100644 (file)
@@ -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;
index f74611b940d81c0c1832b47449d222e4bbc24d41..7d30ccce8eabcde7bbbacfca4091deb2ca2bbbfd 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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[])
index 18d1d4a38bd2fe161a7e5f071789b1713fe21f3c..7561aece02dacae4842ef7da2e11a03e9e15dc48 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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);
 }
 
index f13e0da1116725fa664b8a687be5f0826e334fc0..a73621310cbfac484054871bb40745df032a197f 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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)
index e6d0f2985417e46b78b1f854d0bcf624245e5e8b..311e7a198d7bc44f532d065a763bf953d714287f 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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);
 
index 729348d20891552ed43e610f655165e9f373f407..9cc1300295704ca86527a0ac60e5ce1a8eb4a656 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2012,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);
         }
     }
 
index 57f2e47dca8b9ede552df98a1397cd453f999249..0513f8f8a63f76033f60ebbe177b1378fed0ff83 100644 (file)
@@ -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");
index 576cb221ebc4fde1261a8ea511e8c10aa6d200ac..4eacc7347fc7c19de49fb0bf558f086381897565 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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
     {
index eca1ca6166df976f507a728af3b8aeafe21c2783..98f8b715d073336354d1646a13be41d47d7195fd 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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)
index ebf112f28632756566046d7f7320f11e85547ce7..6c70944e368e1b0352d3a1fc2914575efb1d389a 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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)
     {
index 284ca5517b65b40a992ea4fc0432854c9cccd7c2..bab0785283cc3abd0d298345679ab18d53d11918 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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[])
index 3e9acb11c9acb90bc6720027a71e355ac34d623d..2f9d4578f8d3c17699892fea7936929122c81722 100644 (file)
@@ -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;
index 3d18d53f3cb9d84ee1041e840e2e46261a3e4ec2..29bab90a0742011d98fa6721915146a4c5585ea7 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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");
     }
index 7946fd306f844b724bfcbee13d6c4ad5cb36b094..0cb969d0533b3221a92d6ed8b4e0752c1fb808a8 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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);
index f6ab7c1033610a41a13e4cfc4e1b8ac5317e4651..83a35de3b541f8cf74baa023375ba2d3e6eb57f5 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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)
index 960049e5cf843a3d20e637a1a039c6ca823ef44b..d3a409ee28d6823409ca7449d7febf8935c8dc6a 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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;
index 837ef92f00551e28d7046c361cc991f19375e8b9..3c96ffb2c6a82b075ee849989d73701b512c78ee 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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);
index fe1153db71794105bd1fe58811d92c1744f9892e..12c4269589daa88511e37e17a34ddd0f80169641 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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");
     }
 
index 6913929759c83a52aaf579d3c62049646d2cfb85..eb36ac9e309189d85af0b87cd863a11b6f2ec41e 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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 */
index eb727c8fa2ef8ac41d81311b0f3b5162fbc83884..4560444e68827885052559546f1ce325b3c30aa9 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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
index 28c3e777226fe247b068cdc07656851a1192b767..2c2bf83c4ab3a2cf2f9c71f863ab9615c09e7078 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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)
index ece18dc4d198743cde35822d8b3ea3b3602aeab7..12c108da9fbf73e9b75e62504e4657372f2e3f78 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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");
index 9991682a450471ab97d4769602f5ee6047229d12..fb56240c3adee3119754814f5d9d2da34f635758 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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[])
index 5198b0c730502b0d05651f3a56a1a56cf19b5f67..f48e3b6f8fa2a3ed068089a5db42e95756e8cbff 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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);
 
index dccad9e472458a25f2b947ec369f7cb02bb08ac0..f399105e7094c4be9e24b4c920635f2a99ddacf1 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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);
index ea98add60a3ab047dba946a426f00be662aaaa28..5616a4136ec9e8be679268fe10439f86dc50705e 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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);
 
index c4398533cd3de8b584675a8e890b4782097e0cf0..f96663cb77f6665ed674c7bec00c0ba8c8a003b5 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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))
index 3eddfe424c22a3853be8afce61c412b4f7a73279..c9f3dc16ee2dedb68ccd7db3d54dfaa786465e90 100644 (file)
@@ -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");
 
index 46fd1409e178e628c4414ecc238a010bec8d4790..11d7f1565ad5438d17e253a76f93cbe4d466d5ae 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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]);
index 797652dd8d76d0c6fc689b3a03e3a450a0e4acff..fdff37b0ad33d8e99053e0e2eb56944ee6de0814 100644 (file)
@@ -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);
index 94430c03d99c08292de5282428e335bc8ab5c6f8..5d8f47c117eab52f9b60894283c233ee8e0bcce6 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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[])
index 4eaae62fb613f12cb7883be302717c6856f10eb4..f426fe4e5135a2e6d29f6320744ba205b2900907 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2012,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);
 
index a81a8265d581b86020a38cd757e1b369ffa82933..7de848e5ebe73c76276f13d020e7094b0b112742 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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);
index 2def7422e5720f45d407115844a82978cb89c263..559aa2aa69af0657f68e0663e100510d68e483e1 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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);
 
index 668073ef659691f694696b28299fc81a6fdf5e8d..d2a6b72d74d63c40746df6fcf16bc0080963d894 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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");
 }
 
index cd3d0b5ccf1ef7842f20faf4e7054bcd260e7d71..d737ccfdf2506ddb78188e38006da8b578b2373b 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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)
index ed383bf2f4cabde6f2af7cf4876c251ee01f6278..a43ce10dbd49e80dcf737439b7a8b714a5397570 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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);
 
index fb372b77e1fc777443db8b9d1333adf9c787a6b3..fa3567f02f62724442f08d8b0ec34c42d6fffad1 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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);
index 7a5b0a4333403b67af100b7fd78fb35d2466949f..6b82c5d5b38fa20020b044de425e3008e57aa13a 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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 */
index 8cc7492d771b83ab909984ba6f144ba551e689ba..f5cf0eb7878e27e1e60371d08ce30f72ae49a36c 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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);
 }
 
 
index 1c3389e493ed94f5a8b989ddec150101a54b4895..ad8e473cf7cfd90f1824d07de242f0471556dc5f 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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]));
index 3d8a37fda22aa7eeb81975182c084e2c2ad7970e..4f855af49a8f2f970de223b8fbc906ec71499d7c 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, 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);