Skip to content

Commit

Permalink
Merge pull request #994 from pnorbert/iotest_hdf5
Browse files Browse the repository at this point in the history
Remember and reuse dataset and filespace IDs at reading, too.
  • Loading branch information
pnorbert committed Nov 8, 2018
2 parents d2fe122 + 869b04e commit 6577a33
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions source/utils/adios_iotest/hdf5Stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,30 @@ void hdf5Stream::Write(CommandWrite *cmdW, Config &cfg,

void hdf5Stream::getHDF5Array(std::shared_ptr<VariableInfo> ov, size_t step)
{
hid_t dataset = H5Dopen2(h5file, ov->name.c_str(), H5P_DEFAULT);
if (dataset == -1)
hid_t dataset;
hid_t filespace;
if (step == 1)
{
std::cout << " Variable " << ov->name
<< " is not in the file: " << std::endl;
ov->readFromInput = false;
return;
dataset = H5Dopen2(h5file, ov->name.c_str(), H5P_DEFAULT);
if (dataset == -1)
{
std::cout << " Variable " << ov->name
<< " is not in the file: " << std::endl;
ov->readFromInput = false;
return;
}
filespace = H5Dget_space(dataset);
varmap.emplace(
std::make_pair(ov->name, hdf5VarInfo(dataset, filespace)));
}
hid_t filespace = H5Dget_space(dataset);
// hsize_t dims[ov->ndim + 1];
int ndim = H5Sget_simple_extent_ndims(filespace);
// H5Sget_simple_extent_dims(filespace, dims, NULL);
/* ndim == var->ndim+1 */
else
{
const auto it = varmap.find(ov->name);
hdf5VarInfo &vi = it->second;
dataset = vi.dataset;
filespace = vi.dataspace;
}
int ndim = ov->ndim + 1;

hsize_t start[ndim];
hsize_t count[ndim];
Expand All @@ -211,9 +222,7 @@ void hdf5Stream::getHDF5Array(std::shared_ptr<VariableInfo> ov, size_t step)
H5Dread(dataset, hdf5Type(ov->type), memspace, filespace, dxpl_id, buf);

H5Sclose(memspace);
H5Sclose(filespace);
H5Pclose(dxpl_id);
H5Dclose(dataset);
ov->readFromInput = true;
}

Expand Down

0 comments on commit 6577a33

Please sign in to comment.