From c929d108f229daf124fd2bd309c295a202cfc5ea Mon Sep 17 00:00:00 2001 From: Anne de Jong Date: Wed, 8 Feb 2017 21:38:45 +0100 Subject: [PATCH] Added some error handling for HDF5 when file is in use by postprocessor --- src/duct/duct.cpp | 1 + src/sys/tasystem.cpp | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/duct/duct.cpp b/src/duct/duct.cpp index 90d7876..a07d2d9 100644 --- a/src/duct/duct.cpp +++ b/src/duct/duct.cpp @@ -5,6 +5,7 @@ // Description: // ////////////////////////////////////////////////////////////////////// +#define TRACERPLUS (-10) #include "duct.h" #include "tasystem.h" #include "tasmet_assert.h" diff --git a/src/sys/tasystem.cpp b/src/sys/tasystem.cpp index 057b702..e994aa4 100644 --- a/src/sys/tasystem.cpp +++ b/src/sys/tasystem.cpp @@ -437,13 +437,33 @@ void TaSystem::exportHDF5(const string& filename) const { TRACE(15,"TaSystem::exportHDF5"); hid_t file_id; herr_t status; + // hid_t error_stack = H5Eget_current_stack(); + + /* Save old error handler */ + // herr_t (*old_func)(void*); + // void *old_client_data; + + // H5Eget_auto(error_stack, &old_func, &old_client_data); + /* Turn off error handling */ + // H5Eset_auto(error_stack, NULL, NULL); + // H5Eset_auto( NULL, NULL); file_id = H5Fcreate (filename.c_str(), H5F_ACC_TRUNC, // Truncate any existing file H5P_DEFAULT, H5P_DEFAULT); - + /* Restore previous error handler */ + // H5Eset_auto(error_stack, old_func, old_client_data); /// Disable HDF5 error printing + + if(file_id < 0) + throw TaSMETError("Creation of export file failed. " + "This could mean that the file is blocked " + "by another program, or the user has insufficient " + "privileges to create the file at the given path." + ); + + /// Enable HDF5 error printing d freq = getfreq(); H5LTset_attribute_double(file_id, "/",