Commit 0a2b981e authored by Dan Lipsa's avatar Dan Lipsa

Fix 'open an HDF5 file without H5F_CLOSE_SEMI' warning for Chombo and Enzo

parent 6de2bd2d
set(Kit_SRCS
vtkAvtFileFormatAlgorithm.h
vtkAvtFileFormatAlgorithm.cxx
vtkAvtMTSDFileFormatAlgorithm.h
vtkAvtMTSDFileFormatAlgorithm.cxx
vtkAvtMTMDFileFormatAlgorithm.h
vtkAvtMTMDFileFormatAlgorithm.cxx
vtkAvtSTSDFileFormatAlgorithm.h
vtkAvtSTSDFileFormatAlgorithm.cxx
vtkAvtSTMDFileFormatAlgorithm.h
vtkAvtSTMDFileFormatAlgorithm.cxx
vtkAvtFileFormatAlgorithm.cxx
vtkAvtMTSDFileFormatAlgorithm.cxx
vtkAvtMTMDFileFormatAlgorithm.cxx
vtkAvtSTSDFileFormatAlgorithm.cxx
vtkAvtSTMDFileFormatAlgorithm.cxx
)
set(FullPath_SRCS)
......
......@@ -956,5 +956,3 @@ void vtkAvtFileFormatAlgorithm::PrintSelf(ostream& os, vtkIndent indent)
this->Superclass::PrintSelf(os, indent);
os << indent << "Output Type: " << this->OutputType << "\n";
}
......@@ -30,8 +30,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================*/
#ifndef _vtkVisItReader_h
#define _vtkVisItReader_h
#ifndef _vtkAvtFileFormatAlgorithm_h
#define _vtkAvtFileFormatAlgorithm_h
#include "vtkIOVisItBridgeModule.h" //for export macro
......@@ -74,7 +74,7 @@ public:
static vtkAvtFileFormatAlgorithm *New();
vtkTypeMacro(vtkAvtFileFormatAlgorithm,vtkCompositeDataSetAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Get the number of point or cell arrays available in the input.
int GetNumberOfPointArrays();
......@@ -147,7 +147,7 @@ protected:
// see algorithm for more info
virtual int FillOutputPortInformation(int port, vtkInformation* info);
//methods that setup selection arrays that the client will interact with
//methods that setup selection arrays that the client will interact with
void SetupDataArraySelections();
void SetupMeshSelections();
void SetupMaterialSelections();
......@@ -155,8 +155,8 @@ protected:
//method to setup the proper block bounds for the data.
//this method is needed to support dynamic block loading
//for certain streaming pipelines
virtual void SetupBlockBoundsInformation(vtkInformation *outInfo);
virtual void SetupBlockBoundsInformation(vtkInformation *outInfo);
//method setups the number of timesteps that the file has
void SetupTemporalInformation(vtkInformation *outInfo);
......
#ifndef _vtkFileCloseSemiProperty_h
#define _vtkFileCloseSemiProperty_h
/*
* Needs <hdf5.h>, so include this header only after you include the
* hdf5 header. Because you might need to select the right API for hdf5 (such
* as with H5_USE_16_API) the hdf5 header is not included here.
*/
class vtkFileCloseSemiProperty
{
public:
vtkFileCloseSemiProperty ()
{
this->Fapl = H5Pcreate(H5P_FILE_ACCESS);
H5Pset_fclose_degree(this->Fapl, H5F_CLOSE_SEMI);
}
~vtkFileCloseSemiProperty ()
{
H5Pclose(this->Fapl);
}
operator hid_t() const
{
return this->Fapl;
}
private:
hid_t Fapl;
};
#endif
......@@ -95,6 +95,7 @@
#define H5_USE_16_API
#include <hdf5.h>
#include <visit-hdf5.h>
#include "vtkFileCloseSemiProperty.h"
#include <boost/cstdint.hpp>
// using boost::boost::int32_t; // This conflicts with Visual Studio 10
using std::string;
......@@ -448,7 +449,8 @@ avtChomboFileFormat::InitializeReader(void)
//
// Open file
//
file_handle = H5Fopen(filenames[0], H5F_ACC_RDONLY, H5P_DEFAULT);
file_handle = H5Fopen(filenames[0], H5F_ACC_RDONLY,
vtkFileCloseSemiProperty ());
if (file_handle < 0)
{
EXCEPTION1(InvalidDBTypeException, "Cannot be a Chombo file, since "
......@@ -1344,7 +1346,7 @@ avtChomboFileFormat::InitializeReader(void)
VisItStat_t fs;
if (VisItStat(mappingFilename.c_str(), &fs) == 0)
{
hid_t mapping_file_handle = H5Fopen(mappingFilename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
hid_t mapping_file_handle = H5Fopen(mappingFilename.c_str(), H5F_ACC_RDONLY, vtkFileCloseSemiProperty ());
if (mapping_file_handle > 0)
{
hid_t slash = H5Gopen(mapping_file_handle, "/");
......@@ -2620,7 +2622,8 @@ avtChomboFileFormat::GetMesh(int patch, const char *meshname)
if (file_handle < 0)
{
file_handle = H5Fopen(filenames[0], H5F_ACC_RDONLY, H5P_DEFAULT);
file_handle = H5Fopen(filenames[0], H5F_ACC_RDONLY,
vtkFileCloseSemiProperty ());
if (file_handle < 0)
{
EXCEPTION1(InvalidDBTypeException, "Cannot be a Chombo file, since "
......@@ -3084,7 +3087,8 @@ avtChomboFileFormat::GetVar(int patch, const char *varname)
SNPRINTF(name, 1024, "level_%d", level);
if (file_handle < 0)
{
file_handle = H5Fopen(filenames[0], H5F_ACC_RDONLY, H5P_DEFAULT);
file_handle = H5Fopen(filenames[0], H5F_ACC_RDONLY,
vtkFileCloseSemiProperty ());
if (file_handle < 0)
{
EXCEPTION1(InvalidDBTypeException, "Cannot be a Chombo file, since "
......@@ -3189,7 +3193,8 @@ avtChomboFileFormat::GetVar(int patch, const char *varname)
{
if (file_handle < 0)
{
file_handle = H5Fopen(filenames[0], H5F_ACC_RDONLY, H5P_DEFAULT);
file_handle = H5Fopen(filenames[0], H5F_ACC_RDONLY,
vtkFileCloseSemiProperty ());
if (file_handle < 0)
{
EXCEPTION1(InvalidDBTypeException, "Cannot be a Chombo file, since "
......@@ -3425,7 +3430,8 @@ avtChomboFileFormat::GetVectorVar(int patch, const char *varname)
SNPRINTF(name, 1024, "level_%d", level);
if (file_handle < 0)
{
file_handle = H5Fopen(filenames[0], H5F_ACC_RDONLY, H5P_DEFAULT);
file_handle = H5Fopen(filenames[0], H5F_ACC_RDONLY,
vtkFileCloseSemiProperty ());
if (file_handle < 0)
{
EXCEPTION1(InvalidDBTypeException, "Cannot be a Chombo file, since "
......
......@@ -80,6 +80,7 @@
#define H5_USE_16_API
#include <hdf5.h>
#include <visit-hdf5.h>
#include "vtkFileCloseSemiProperty.h"
#endif
using std::string;
......@@ -629,7 +630,8 @@ avtEnzoFileFormat::DetermineVariablesFromGridFile()
#endif
{
#ifdef HAVE_LIBHDF5
hid_t fileId = H5Fopen(gridFileName.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
hid_t fileId = H5Fopen(gridFileName.c_str(), H5F_ACC_RDONLY,
vtkFileCloseSemiProperty ());
if (fileId < 0)
{
#ifdef HAVE_LIBHDF4
......@@ -1434,7 +1436,8 @@ avtEnzoFileFormat::GetMesh(int domain, const char *meshname)
return NULL;
}
hid_t fileId = H5Fopen(particleFileName.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
hid_t fileId = H5Fopen(particleFileName.c_str(), H5F_ACC_RDONLY,
vtkFileCloseSemiProperty ());
if (fileId < 0)
{
EXCEPTION1(InvalidFilesException, particleFileName.c_str());
......@@ -1870,7 +1873,8 @@ avtEnzoFileFormat::GetVar(int domain, const char *varname)
// HDF5 STUFF
string gridFileName = grids[domain+1].gridFileName;
hid_t fileId = H5Fopen(gridFileName.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
hid_t fileId = H5Fopen(gridFileName.c_str(), H5F_ACC_RDONLY,
vtkFileCloseSemiProperty ());
if (fileId < 0)
{
EXCEPTION1(InvalidFilesException, gridFileName.c_str());
......
This diff is collapsed.
......@@ -34,7 +34,92 @@
class avtLAMMPSDumpFileFormat : public avtMTSDFileFormat
{
public:
private:
struct AtomInfo
{
AtomInfo():vars(),names(),types(),ids(),
enableType(false),enableIds(false),numVars(0){}
void Clear()
{ vars.resize(0); names.resize(0); types.resize(0); ids.resize(0);
enableType = false; enableIds = false; numVars = 0;
};
void AddVariable(const std::string& name)
{
//if it is id or type we don't push back since it is stored separately
if(name == "id")
{
enableIds = true;
}
if(name == "type")
{
enableType = true;
}
else
{
names.push_back(name);
vars.resize(names.size());
}
++numVars;
}
int GetNumberOfVariables() const
{
return numVars;
}
void SetNumberOfAtoms(std::size_t size)
{
if(HasIds()) { ids.resize(size); }
if(HasTypes()) { types.resize(size); }
for(std::size_t i=0; i < vars.size(); ++i) { vars[i].resize(size); }
}
//helper methods to get the variable names
typedef std::vector<std::string>::const_iterator name_iterator;
name_iterator GetVariableNamesBegin() const { return names.begin(); }
name_iterator GetVariableNamesEnd() const { return names.end(); }
int GetVarIndex(const std::string& n) const
{
for(int i=0; i < names.size(); ++i)
{
if(names[i] == n)
{ return i; }
}
return -1;
}
//helper methods for types
bool SetHasTypes(bool b) { enableType = b; }
bool HasTypes() const { return enableType; }
const std::vector<int>& GetTypes() const { return types; }
void SetType(std::size_t pos, int t) { types[pos]=t; }
//helper methods for ids
bool SetHasIds(bool b) { enableIds = b; }
bool HasIds() const { return enableIds; }
const std::vector<int>& GetIds() const { return ids; }
void SetId(std::size_t pos, int i) { ids[pos]=i; }
//operators to make this like you can access the vars easily
const std::vector<float> &operator[](std::size_t idx) const
{ return vars[idx]; }
std::vector<float>& operator[](std::size_t idx)
{ return vars[idx]; }
private:
std::vector < std::vector<float> > vars;
std::vector < std::string > names;
std::vector < int > types;
std::vector < int > ids;
bool enableType, enableIds;
int numVars;
};
public:
static bool FileExtensionIdentify(const std::string&);
static bool FileContentsIdentify(const std::string&);
static avtFileFormatInterface *CreateInterface(
......@@ -46,7 +131,7 @@ class avtLAMMPSDumpFileFormat : public avtMTSDFileFormat
virtual int GetNTimesteps(void);
virtual const char *GetType(void) { return "LAMMPS"; };
virtual void FreeUpResources(void);
virtual void FreeUpResources(void);
virtual vtkDataSet *GetMesh(int, const char *);
virtual vtkDataArray *GetVar(int, const char *);
......@@ -59,8 +144,7 @@ class avtLAMMPSDumpFileFormat : public avtMTSDFileFormat
std::string filename;
bool metaDataRead;
int nTimeSteps;
int nVars;
std::vector<int> nAtoms;
double xMin, xMax;
double yMin, yMax;
double zMin, zMax;
......@@ -69,9 +153,9 @@ class avtLAMMPSDumpFileFormat : public avtMTSDFileFormat
bool xScaled,yScaled,zScaled;
int xIndex, yIndex, zIndex;
int speciesIndex, idIndex;
std::vector< std::vector<float> > vars;
std::vector<int> speciesVar;
std::vector< std::string > varNames;
std::vector<int> nAtoms;
AtomInfo atomVars;
virtual void PopulateDatabaseMetaData(avtDatabaseMetaData *, int);
void OpenFileAtBeginning();
......
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