From 64d348d6faa47163a0be9f400206c61523e5ae4f Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Wed, 24 Oct 2012 18:10:01 -0400 Subject: CarpetIOF5: Free HDF5 data when closing files Use the "strong" file closing property and explicitly invoke a garbage collection when opening/closing files. --- CarpetDev/CarpetIOF5/src/iof5.cc | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'CarpetDev') diff --git a/CarpetDev/CarpetIOF5/src/iof5.cc b/CarpetDev/CarpetIOF5/src/iof5.cc index 9464682cd..1141a7471 100644 --- a/CarpetDev/CarpetIOF5/src/iof5.cc +++ b/CarpetDev/CarpetIOF5/src/iof5.cc @@ -100,6 +100,7 @@ namespace CarpetIOF5 { herr_t const herr = H5Fclose(file); assert(not herr); file = H5I_INVALID_HID; + H5garbage_collect(); } } @@ -295,11 +296,14 @@ namespace CarpetIOF5 { first_time and IO_TruncateOutputFiles(cctkGH) and myproc == myioproc; if (file < 0) { // Reuse file hid if file is already open + hid_t fapl = H5Pcreate(H5P_FILE_ACCESS); + H5Pset_fclose_degree(fapl, H5F_CLOSE_STRONG); file = truncate_file ? - H5Fcreate(name.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT) : - H5Fopen (name.c_str(), H5F_ACC_RDWR , H5P_DEFAULT); + H5Fcreate(name.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, fapl) : + H5Fopen (name.c_str(), H5F_ACC_RDWR , fapl); assert(file >= 0); + H5Pclose(fapl); } first_time = false; @@ -359,9 +363,12 @@ namespace CarpetIOF5 { create_filename(cctkGH, "checkpoint.tmp", cctkGH->cctk_iteration, proc, io_dir_checkpoint, true); + hid_t fapl = H5Pcreate(H5P_FILE_ACCESS); + H5Pset_fclose_degree(fapl, H5F_CLOSE_STRONG); hid_t const file = - H5Fcreate(tempname.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + H5Fcreate(tempname.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, fapl); assert(file >= 0); + H5Pclose(fapl); vector output_var(CCTK_NumVars(), false); for (int gindex=0; gindex= 0); + H5Pclose(fapl); // Iterate over all time slices bool const input_past_timelevels = in_recovery; @@ -554,6 +565,7 @@ namespace CarpetIOF5 { // Close file herr = H5Fclose(file); assert(not herr); + H5garbage_collect(); } } -- cgit v1.2.3