aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetIOHDF5
diff options
context:
space:
mode:
authorRoland Haas <roland.haas@physics.gatech.edu>2012-02-22 08:00:42 -0800
committerBarry Wardell <barry.wardell@gmail.com>2012-09-11 18:23:03 +0100
commitc81c943528090ac29f68a9bcceed9837795f9a43 (patch)
treeb6380bf46277bee9046dd9ab9b2b42874321f32a /Carpet/CarpetIOHDF5
parent07d12df03f216b25fef1d4b930cb3b1e9e68c108 (diff)
hdf5_slicer: close input files as soon as possible to conserve memory and file descriptors
--- Carpet/CarpetIOHDF5/src/util/hdf5_slicer.cc | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-)
Diffstat (limited to 'Carpet/CarpetIOHDF5')
-rw-r--r--Carpet/CarpetIOHDF5/src/util/hdf5_slicer.cc13
1 files changed, 5 insertions, 8 deletions
diff --git a/Carpet/CarpetIOHDF5/src/util/hdf5_slicer.cc b/Carpet/CarpetIOHDF5/src/util/hdf5_slicer.cc
index 5255bfb4f..6c6c995e2 100644
--- a/Carpet/CarpetIOHDF5/src/util/hdf5_slicer.cc
+++ b/Carpet/CarpetIOHDF5/src/util/hdf5_slicer.cc
@@ -236,7 +236,6 @@ int main (int argc, char *const argv[])
}
// browse though input file(s)
- vector<hid_t> filelist;
for (; i < argc-1; i++) {
hid_t file;
@@ -252,7 +251,10 @@ int main (int argc, char *const argv[])
cout << " iterating through input file '" << argv[i] << "'..." << endl;
CHECK_HDF5 (H5Giterate (file, "/", NULL, ProcessDataset, &file));
- filelist.push_back (file);
+ // close file
+ if (file >= 0) {
+ CHECK_HDF5 (H5Fclose (file));
+ }
}
if (slices_extracted == 0) {
@@ -260,12 +262,7 @@ int main (int argc, char *const argv[])
"slice parameters." << endl << endl;
}
- // close all files
- for (size_t j = 0; j < filelist.size(); j++) {
- if (filelist[j] >= 0) {
- CHECK_HDF5 (H5Fclose (filelist[j]));
- }
- }
+ // close output file
CHECK_HDF5 (H5Fclose (outfile));
cout << endl << "Done." << endl << endl;