MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / get_dataset_shape

Method get_dataset_shape

cpp/dolfinx/io/HDF5Interface.cpp:288–319  ·  view source on GitHub ↗

-----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

286}
287//-----------------------------------------------------------------------------
288std::vector<std::int64_t>
289io::hdf5::get_dataset_shape(hid_t handle, const std::string& dataset_path)
290{
291 // Open named dataset
292 const hid_t dset_id = H5Dopen2(handle, dataset_path.c_str(), H5P_DEFAULT);
293 if (dset_id < 0)
294 throw std::runtime_error("Failed to open HDF5 dataset by name");
295
296 const hid_t space = H5Dget_space(dset_id);
297 if (space < 0)
298 throw std::runtime_error("Failed to get dataspace of dataset");
299
300 // Get rank
301 const int rank = H5Sget_simple_extent_ndims(space);
302 if (rank < 0)
303 throw std::runtime_error("Failed to get dimensionality of dataspace");
304
305 // Get size in each dimension
306 std::vector<hsize_t> size(rank);
307 const int ndims = H5Sget_simple_extent_dims(space, size.data(), nullptr);
308 if (ndims < 0)
309 throw std::runtime_error("Failed to get dimensionality of dataspace");
310 assert(ndims == rank);
311
312 // Close dataspace and dataset
313 if (H5Sclose(space) < 0)
314 throw std::runtime_error("Call to H5Sclose unsuccessful");
315 if (H5Dclose(dset_id) < 0)
316 throw std::runtime_error("Call to H5Dclose unsuccessful");
317
318 return std::vector<std::int64_t>(size.begin(), size.end());
319}
320//-----------------------------------------------------------------------------
321void io::hdf5::set_mpi_atomicity(hid_t handle, bool atomic)
322{

Callers

nothing calls this directly

Calls 1

dataMethod · 0.80

Tested by

no test coverage detected