Commit 5ad83b83 authored by miller86's avatar miller86

This resolves #670 "enhance all HDF5 plugins to open with H5F_CLOSE_SEMI property"

Added macros to visit-hdf5.h to re-map H5Fopen and H5Fclose functions
to Visit-specific equivalents.

Added implementations of VisIt-specific H5Fopen and H5Fclose functions
to visit-hdf5.h. There is #ifndef NDEBUG conditional logic to print
error message on cerr if an HDF5 plugin is found NOT to use H5F_CLOSE_SEMI
when opening a file.

There is UNconditional logic in these functions to print error message
on cerr if an HDF5 plugin is found to return error from H5Fclose. The
latter indicates a potentialy serious problem because the offending plugin
can then wind up preventing all other HDF5 plugins from opening the file.

Added #include <visit-hdf5.h> to all HDF5 plugins to ensure all plugins
will have their H5Fopen/H5Fclose methods re-mapped.

So far, only HDF5 plugin (that we also test) that appears to have problems
is Velodyne. I filed a ticket for it.

I discovered and removed some unnecessary #ifdef NDEBUG logic in Ensight
plugin.


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@16233 18c085ea-50e0-402c-830e-de6fd14e8384
parent 352e4eba
......@@ -3,6 +3,8 @@
#include <DebugStream.h>
#include <AMRreader.h>
#include <visit-hdf5.h>
#include <string.h>
#include <string>
......
......@@ -6,6 +6,8 @@ using std::setw;
#include <AMRreaderAgg.h>
#include <visit-hdf5.h>
const int kid2i[8] = {0,1,0,1,0,1,0,1};
const int kid2j[8] = {0,0,1,1,0,0,1,1};
......
......@@ -69,6 +69,8 @@
#include <InvalidVariableException.h>
#include <InvalidDBTypeException.h>
#include <visit-hdf5.h>
#define TRY_MIXED_SCALARS
using std::string;
......
......@@ -72,6 +72,7 @@
// is explicitly upgraded to the 1.8 API, this symbol should be removed.
#define H5_USE_16_API
#include <hdf5.h>
#include <visit-hdf5.h>
using std::vector;
using std::string;
......
......@@ -437,16 +437,10 @@ int vtkVisItEnSight6Reader::ReadMeasuredGeometryFile(const char* fileName, int t
for (i = 0; i < this->NumberOfMeasuredPoints; i++)
{
this->ReadLine(line);
#ifdef NDEBUG
vtkVisItEnSight6ReaderRead1(line, " %8d %12e %12e %12e",
&tempId, &coords[0],
&coords[1], &coords[2]);
#else
int entries = vtkVisItEnSight6ReaderRead1(line, " %8d %12e %12e %12e",
&tempId, &coords[0],
&coords[1], &coords[2]);
assert( entries == 4 );
#endif
id = tempId;
newPoints->InsertNextPoint(coords);
pd->InsertNextCell(VTK_VERTEX, 1, &id);
......
......@@ -79,6 +79,7 @@
// is explicitly upgraded to the 1.8 API, this symbol should be removed.
#define H5_USE_16_API
#include <hdf5.h>
#include <visit-hdf5.h>
#endif
using std::string;
......
......@@ -61,6 +61,7 @@
// is explicitly upgraded to the 1.8 API, this symbol should be removed.
#define H5_USE_16_API
#include <hdf5.h>
#include <visit-hdf5.h>
#include <DebugStream.h>
......
......@@ -62,6 +62,8 @@
#include <DebugStream.h>
#include <visit-hdf5.h>
using
std::string;
using
......
#include "hdf5_f.h"
#include <visit-hdf5.h>
H5F::H5F(){
valid = false;
......
......@@ -61,6 +61,8 @@
#include <UnexpectedValueException.h>
#include <DebugStream.h>
#include <visit-hdf5.h>
using namespace std;
static bool doPlanes = false;
......
......@@ -65,6 +65,8 @@
#include <InvalidVariableException.h>
#include <DebugStream.h>
#include <visit-hdf5.h>
using namespace std;
......
......@@ -73,6 +73,8 @@
#include <string>
#include <vector>
#include <visit-hdf5.h>
using std::map;
using std::string;
using std::vector;
......
......@@ -57,6 +57,7 @@
#include <vtkCSGGrid.h>
#include <VisItDataInterface_V2.h>
#include <VisItInterfaceTypes_V2.h>
#include <avtGhostData.h>
......
......@@ -56,6 +56,7 @@
#include <InvalidVariableException.h>
#include <InvalidTimeStepException.h>
#include <visit-hdf5.h>
typedef struct
{
......
......@@ -17,6 +17,8 @@ using std::cout;
#include <VelodyneReader.h>
#include <visit-hdf5.h>
#include <set>
#include <string>
......
......@@ -60,6 +60,8 @@
#include <InvalidVariableException.h>
#include <DebugStream.h>
#include <visit-hdf5.h>
#include <set>
#include <string>
......
......@@ -76,6 +76,7 @@
// is explicitly upgraded to the 1.8 API, this symbol should be removed.
#define H5_USE_16_API
#include <hdf5.h>
#include <visit-hdf5.h>
#include <visit-config.h>
......
......@@ -58,6 +58,7 @@
// is explicitly upgraded to the 1.8 API, this symbol should be removed.
#define H5_USE_16_API
#include <hdf5.h>
#include <visit-hdf5.h>
#endif
#include <silo.h>
......
......@@ -51,4 +51,95 @@
((H5_VERS_MAJOR==Maj) && (H5_VERS_MINOR>Min)) || \
(H5_VERS_MAJOR>Maj))
//
// Macros to re-map H5Fopen and H5Fclose so that HDF5 files are always handled
// using the H5F_CLOSE_SEMI property. This permits us to detect when attempts
// to close files fail due to a buggy plugin (e.g. one that fails to close all
// the objects in a file). This is a problematic issue when multiple HDF5
// plugins are attempted on the same HDF5 file and a buggy plugin winds up
// accidentally leaving the file open.
//
#ifndef VISIT_DONT_REDEFINE_H5FOPENCLOSE
#ifdef H5_VERS_MAJOR
#include <avtCallback.h>
static void VisIt_IssueH5Warning(int phase)
{
static bool haveIssuedOpenWarning = false;
static bool haveIssuedCloseWarning = false;
char msg[512];
if (phase == 0 && !haveIssuedOpenWarning)
{
#ifndef NDEBUG
SNPRINTF(msg, sizeof(msg), "Detected attempt to open an HDF5 file without H5F_CLOSE_SEMI.\n"
"Please contact VisIt developers to have this issue fixed.");
haveIssuedOpenWarning = true;
if (!avtCallback::IssueWarning(msg))
cerr << msg << endl;
#endif
}
else if (phase == 1 && !haveIssuedCloseWarning)
{
SNPRINTF(msg, sizeof(msg), "An attempt to close an HDF5 file failed, incidating a bug in the plugin.\n"
"Please contact VisIt developers to have this issue fixed.");
haveIssuedCloseWarning = true;
if (!avtCallback::IssueWarning(msg))
cerr << msg << endl;
}
}
static hid_t VisIt_H5Fopen(const char *name, int flags, hid_t fapl)
{
bool created_fapl = false;
if (fapl == H5P_DEFAULT)
{
// Issue error message indicating plugin is using default open
VisIt_IssueH5Warning(0);
fapl = H5Pcreate(H5P_FILE_ACCESS);
created_fapl = true;
// Build a fapl with semi close behavior
H5Pset_fclose_degree(fapl, H5F_CLOSE_SEMI);
}
else
{
H5F_close_degree_t cd;
H5Pget_fclose_degree(fapl, &cd);
if (cd != H5F_CLOSE_SEMI)
{
// Issue message if not
VisIt_IssueH5Warning(0);
// copy the fapl
fapl = H5Pcopy(fapl);
created_fapl = true;
// Add semi close property if not
H5Pset_fclose_degree(fapl, H5F_CLOSE_SEMI);
}
}
hid_t retval = H5Fopen(name, flags, fapl);
if (created_fapl) H5Pclose(fapl);
return retval;
}
static herr_t VisIt_H5Fclose(hid_t fid)
{
herr_t err = H5Fclose(fid);
if (err < 0)
VisIt_IssueH5Warning(1);
return err;
}
#define H5Fopen(NAME, FLAGS, FAPL) VisIt_H5Fopen(NAME, FLAGS, FAPL)
#define H5Fclose(FID) VisIt_H5Fclose(FID)
#endif
#endif
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment