hdf5: some fixes and minor improvements for hdf5 reader & writer
parent
943995c48c
commit
f20a36863c
|
@ -102,6 +102,8 @@ bool HDF5_File_Reader::ReadDataSet(string ds_name, hsize_t &nDim, hsize_t* &dims
|
||||||
cerr << "HDF5_File_Reader::ReadDataSet: error reading data" << endl;
|
cerr << "HDF5_File_Reader::ReadDataSet: error reading data" << endl;
|
||||||
H5Dclose(dataset);
|
H5Dclose(dataset);
|
||||||
H5Fclose(hdf5_file);
|
H5Fclose(hdf5_file);
|
||||||
|
delete[] data;
|
||||||
|
data=NULL;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
H5Dclose(dataset);
|
H5Dclose(dataset);
|
||||||
|
@ -152,6 +154,7 @@ bool HDF5_File_Reader::ReadMesh(float** lines, unsigned int* numLines, int &mesh
|
||||||
{
|
{
|
||||||
cerr << "HDF5_File_Reader::ReadMesh: mesh dimension error" << endl;
|
cerr << "HDF5_File_Reader::ReadMesh: mesh dimension error" << endl;
|
||||||
delete[] dims;
|
delete[] dims;
|
||||||
|
delete[] data;
|
||||||
H5Fclose(hdf5_file);
|
H5Fclose(hdf5_file);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -175,7 +178,7 @@ unsigned int HDF5_File_Reader::GetNumTimeSteps()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (H5Lexists(hdf5_file, "/FieldData/TD", H5P_DEFAULT)<0)
|
if (H5Lexists(hdf5_file, "/FieldData/TD", H5P_DEFAULT)<=0)
|
||||||
{
|
{
|
||||||
H5Fclose(hdf5_file);
|
H5Fclose(hdf5_file);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -282,7 +285,7 @@ float**** HDF5_File_Reader::GetTDVectorData(size_t idx, float &time, unsigned in
|
||||||
}
|
}
|
||||||
|
|
||||||
time = 0;
|
time = 0;
|
||||||
if (H5Lexists(hdf5_file, "/FieldData/TD", H5P_DEFAULT)<0)
|
if (H5Lexists(hdf5_file, "/FieldData/TD", H5P_DEFAULT)<=0)
|
||||||
{
|
{
|
||||||
cerr << "HDF5_File_Reader::GetTDVectorData: can't open ""/FieldData/TD""" << endl;
|
cerr << "HDF5_File_Reader::GetTDVectorData: can't open ""/FieldData/TD""" << endl;
|
||||||
H5Fclose(hdf5_file);
|
H5Fclose(hdf5_file);
|
||||||
|
@ -404,6 +407,13 @@ complex<float>**** HDF5_File_Reader::GetFDVectorData(size_t idx, float &frequenc
|
||||||
bool HDF5_File_Reader::CalcFDVectorData(vector<float> &frequencies, vector<complex<float>****> &FD_data, unsigned int data_size[4])
|
bool HDF5_File_Reader::CalcFDVectorData(vector<float> &frequencies, vector<complex<float>****> &FD_data, unsigned int data_size[4])
|
||||||
{
|
{
|
||||||
FD_data.clear();
|
FD_data.clear();
|
||||||
|
|
||||||
|
if (GetNumTimeSteps()<=0)
|
||||||
|
{
|
||||||
|
cerr << "HDF5_File_Reader::CalcFDVectorData: error, no TD data found..." << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
float time;
|
float time;
|
||||||
//read first TD data
|
//read first TD data
|
||||||
float**** field = this->GetTDVectorData(0,time,data_size);
|
float**** field = this->GetTDVectorData(0,time,data_size);
|
||||||
|
|
|
@ -393,7 +393,7 @@ bool HDF5_File_Writer::WriteAtrribute(std::string locName, std::string attr_name
|
||||||
|
|
||||||
bool HDF5_File_Writer::WriteAtrribute(std::string locName, std::string attr_name, vector<double> values)
|
bool HDF5_File_Writer::WriteAtrribute(std::string locName, std::string attr_name, vector<double> values)
|
||||||
{
|
{
|
||||||
float val[values.size()];
|
double val[values.size()];
|
||||||
for (size_t n=0;n<values.size();++n)
|
for (size_t n=0;n<values.size();++n)
|
||||||
val[n]=values.at(n);
|
val[n]=values.at(n);
|
||||||
return HDF5_File_Writer::WriteAtrribute(locName, attr_name, val, values.size(), H5T_NATIVE_DOUBLE);
|
return HDF5_File_Writer::WriteAtrribute(locName, attr_name, val, values.size(), H5T_NATIVE_DOUBLE);
|
||||||
|
|
Loading…
Reference in New Issue