clean up HDF5 interface for v1.8+, hdf5readatt_octave.cc still needs to be done but has to wait for upstream Octave fix

pull/16/head
georgmichel 2016-08-26 10:06:24 +00:00
parent 4adf0842c0
commit 6a7db1917a
3 changed files with 9 additions and 12 deletions

View File

@ -112,9 +112,6 @@ find_package(HDF5 1.8 COMPONENTS C HL REQUIRED)
INCLUDE_DIRECTORIES (${HDF5_INCLUDE_DIR}) INCLUDE_DIRECTORIES (${HDF5_INCLUDE_DIR})
link_directories(${HDF5_LIBRARY_DIRS}) link_directories(${HDF5_LIBRARY_DIRS})
# hdf5 compat
ADD_DEFINITIONS( -DH5_USE_16_API )
# boost # boost
find_package(Boost 1.46 COMPONENTS find_package(Boost 1.46 COMPONENTS
thread thread

View File

@ -68,7 +68,7 @@ bool HDF5_File_Reader::OpenGroup(hid_t &file, hid_t &group, string groupName)
return 0; return 0;
} }
group = H5Gopen(file, groupName.c_str() ); group = H5Gopen(file, groupName.c_str(), H5P_DEFAULT );
if (group<0) if (group<0)
{ {
cerr << "HDF5_File_Reader::OpenGroup: can't open group """ << groupName << """" << endl; cerr << "HDF5_File_Reader::OpenGroup: can't open group """ << groupName << """" << endl;
@ -198,7 +198,7 @@ bool HDF5_File_Reader::ReadDataSet(string ds_name, hsize_t &nDim, hsize_t* &dims
return false; return false;
} }
hid_t dataset = H5Dopen(hdf5_file, ds_name.c_str() ); hid_t dataset = H5Dopen(hdf5_file, ds_name.c_str(), H5P_DEFAULT );
if (dataset<0) if (dataset<0)
{ {
cerr << "HDF5_File_Reader::ReadDataSet: dataset not found" << endl; cerr << "HDF5_File_Reader::ReadDataSet: dataset not found" << endl;

View File

@ -52,7 +52,7 @@ hid_t HDF5_File_Writer::OpenGroup(hid_t hdf5_file, string group)
vector<string> results; vector<string> results;
boost::split(results, group, boost::is_any_of("/")); boost::split(results, group, boost::is_any_of("/"));
hid_t grp=H5Gopen(hdf5_file,"/"); hid_t grp=H5Gopen(hdf5_file,"/", H5P_DEFAULT);
if (grp<0) if (grp<0)
{ {
cerr << "HDF5_File_Writer::OpenGroup: Error, opening root group " << endl; cerr << "HDF5_File_Writer::OpenGroup: Error, opening root group " << endl;
@ -66,7 +66,7 @@ hid_t HDF5_File_Writer::OpenGroup(hid_t hdf5_file, string group)
{ {
if (H5Lexists(grp, results.at(n).c_str(), H5P_DEFAULT)) if (H5Lexists(grp, results.at(n).c_str(), H5P_DEFAULT))
{ {
grp = H5Gopen(grp, results.at(n).c_str()); grp = H5Gopen(grp, results.at(n).c_str(), H5P_DEFAULT);
H5Gclose(old_grp); H5Gclose(old_grp);
if (grp<0) if (grp<0)
{ {
@ -76,7 +76,7 @@ hid_t HDF5_File_Writer::OpenGroup(hid_t hdf5_file, string group)
} }
else else
{ {
grp = H5Gcreate(grp,results.at(n).c_str(),0); grp = H5Gcreate(grp,results.at(n).c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
H5Gclose(old_grp); H5Gclose(old_grp);
if (grp<0) if (grp<0)
{ {
@ -140,7 +140,7 @@ bool HDF5_File_Writer::WriteRectMesh(unsigned int const* numLines, float const*
return false; return false;
} }
hid_t mesh_grp = H5Gcreate(hdf5_file,"/Mesh",0); hid_t mesh_grp = H5Gcreate(hdf5_file,"/Mesh", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
if (mesh_grp<0) if (mesh_grp<0)
{ {
cerr << "HDF5_File_Writer::WriteRectMesh: Error, creating group ""/Mesh"" failed" << endl; cerr << "HDF5_File_Writer::WriteRectMesh: Error, creating group ""/Mesh"" failed" << endl;
@ -165,7 +165,7 @@ bool HDF5_File_Writer::WriteRectMesh(unsigned int const* numLines, float const*
{ {
hsize_t dims[1]={numLines[n]}; hsize_t dims[1]={numLines[n]};
hid_t space = H5Screate_simple(1, dims, NULL); hid_t space = H5Screate_simple(1, dims, NULL);
hid_t dataset = H5Dcreate(mesh_grp, names[n].c_str(), H5T_NATIVE_FLOAT, space, H5P_DEFAULT); hid_t dataset = H5Dcreate(mesh_grp, names[n].c_str(), H5T_NATIVE_FLOAT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
float* array = new float[numLines[n]]; float* array = new float[numLines[n]];
for (unsigned int i=0; i<numLines[n]; ++i) for (unsigned int i=0; i<numLines[n]; ++i)
{ {
@ -408,7 +408,7 @@ bool HDF5_File_Writer::WriteData(std::string dataSetName, hid_t mem_type, void
for (size_t n=0;n<dim;++n) for (size_t n=0;n<dim;++n)
dims[n]=datasize[n]; dims[n]=datasize[n];
hid_t space = H5Screate_simple(dim, dims, NULL); hid_t space = H5Screate_simple(dim, dims, NULL);
hid_t dataset = H5Dcreate(group, dataSetName.c_str(), mem_type, space, H5P_DEFAULT); hid_t dataset = H5Dcreate(group, dataSetName.c_str(), mem_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
if (H5Dwrite(dataset, mem_type, space, H5P_DEFAULT, H5P_DEFAULT, field_buf)) if (H5Dwrite(dataset, mem_type, space, H5P_DEFAULT, H5P_DEFAULT, field_buf))
{ {
cerr << "HDF5_File_Writer::WriteData: Error, writing to dataset failed" << endl; cerr << "HDF5_File_Writer::WriteData: Error, writing to dataset failed" << endl;
@ -451,7 +451,7 @@ bool HDF5_File_Writer::WriteAtrribute(std::string locName, std::string attr_name
hid_t dataspace_id = H5Screate_simple(1, &size, NULL); hid_t dataspace_id = H5Screate_simple(1, &size, NULL);
/* Create a dataset attribute. */ /* Create a dataset attribute. */
hid_t attribute_id = H5Acreate(loc, attr_name.c_str(), mem_type, dataspace_id,H5P_DEFAULT); hid_t attribute_id = H5Acreate(loc, attr_name.c_str(), mem_type, dataspace_id, H5P_DEFAULT, H5P_DEFAULT);
if (attribute_id<0) if (attribute_id<0)
{ {
cerr << "HDF5_File_Writer::WriteAtrribute: Error, failed to create the attrbute" << endl; cerr << "HDF5_File_Writer::WriteAtrribute: Error, failed to create the attrbute" << endl;