diff options
author | Erik Schnetter <schnetter@gmail.com> | 2012-10-24 18:10:01 -0400 |
---|---|---|
committer | Erik Schnetter <schnetter@gmail.com> | 2012-10-24 18:10:01 -0400 |
commit | 64d348d6faa47163a0be9f400206c61523e5ae4f (patch) | |
tree | 1be4601b1c8212ed2deead67047c0b5c89181ba6 /CarpetDev | |
parent | 9dddc9b8820dce0051eaad08706a6d775e9a7477 (diff) |
CarpetIOF5: Free HDF5 data when closing files
Use the "strong" file closing property and explicitly invoke a garbage collection when opening/closing files.
Diffstat (limited to 'CarpetDev')
-rw-r--r-- | CarpetDev/CarpetIOF5/src/iof5.cc | 20 |
1 files changed, 16 insertions, 4 deletions
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<bool> output_var(CCTK_NumVars(), false); for (int gindex=0; gindex<CCTK_NumGroups(); ++gindex) { @@ -398,6 +405,7 @@ namespace CarpetIOF5 { // Close file herr_t const herr = H5Fclose(file); assert(not herr); + H5garbage_collect(); // Wait until all files have been written, then rename the // checkpoint files @@ -541,8 +549,11 @@ namespace CarpetIOF5 { indent_t indent; cout << indent << "I/O process=" << ioproc << "\n"; - hid_t const file = H5Fopen(name.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT); + hid_t fapl = H5Pcreate(H5P_FILE_ACCESS); + H5Pset_fclose_degree(fapl, H5F_CLOSE_STRONG); + hid_t const file = H5Fopen(name.c_str(), H5F_ACC_RDONLY, fapl); assert(file >= 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(); } } |