This class provides an interface to some HDF5 functionality.
More...
#include <HDF5Interface.h>
|
static hid_t | open_file (MPI_Comm comm, const std::filesystem::path &filename, const std::string &mode, const bool use_mpi_io) |
| Open HDF5 and return file descriptor. More...
|
|
static void | close_file (const hid_t handle) |
| Close HDF5 file. More...
|
|
static void | flush_file (const hid_t handle) |
| Flush data to file to improve data integrity after interruption. More...
|
|
static std::filesystem::path | get_filename (hid_t handle) |
| Get filename. More...
|
|
template<typename T > |
static void | write_dataset (const hid_t handle, const std::string &dataset_path, const T *data, const std::array< std::int64_t, 2 > &range, const std::vector< std::int64_t > &global_size, bool use_mpi_io, bool use_chunking) |
| Write data to existing HDF file as defined by range blocks on each process. More...
|
|
template<typename T > |
static std::vector< T > | read_dataset (const hid_t handle, const std::string &dataset_path, const std::array< std::int64_t, 2 > &range) |
| Read data from a HDF5 dataset "dataset_path" as defined by range blocks on each process. More...
|
|
static bool | has_dataset (const hid_t handle, const std::string &dataset_path) |
| Check for existence of dataset in HDF5 file. More...
|
|
static std::vector< std::int64_t > | get_dataset_shape (const hid_t handle, const std::string &dataset_path) |
| Get dataset shape (size of each dimension) More...
|
|
static void | set_mpi_atomicity (const hid_t handle, const bool atomic) |
| Set MPI atomicity. See https://support.hdfgroup.org/HDF5/doc/RM/RM_H5F.html#File-SetMpiAtomicity and https://www.open-mpi.org/doc/v2.0/man3/MPI_File_set_atomicity.3.php Writes must be followed by an MPI_Barrier on the communicator before any subsequent reads are guaranteed to return the same data.
|
|
static bool | get_mpi_atomicity (const hid_t handle) |
| Get MPI atomicity. See https://support.hdfgroup.org/HDF5/doc/RM/RM_H5F.html#File-GetMpiAtomicity and https://www.open-mpi.org/doc/v2.0/man3/MPI_File_get_atomicity.3.php.
|
|
This class provides an interface to some HDF5 functionality.
◆ close_file()
void close_file |
( |
const hid_t |
handle | ) |
|
|
static |
Close HDF5 file.
- Parameters
-
[in] | handle | HDF5 file handle |
◆ flush_file()
void flush_file |
( |
const hid_t |
handle | ) |
|
|
static |
Flush data to file to improve data integrity after interruption.
- Parameters
-
[in] | handle | HDF5 file handle |
◆ get_dataset_shape()
std::vector< std::int64_t > get_dataset_shape |
( |
const hid_t |
handle, |
|
|
const std::string & |
dataset_path |
|
) |
| |
|
static |
Get dataset shape (size of each dimension)
- Parameters
-
[in] | handle | HDF5 file handle |
[in] | dataset_path | Dataset path |
- Returns
- The shape of the dataset (row-major)
◆ get_filename()
std::filesystem::path get_filename |
( |
hid_t |
handle | ) |
|
|
static |
Get filename.
- Parameters
-
[in] | handle | HDF5 file handle return The filename |
◆ has_dataset()
bool has_dataset |
( |
const hid_t |
handle, |
|
|
const std::string & |
dataset_path |
|
) |
| |
|
static |
Check for existence of dataset in HDF5 file.
- Parameters
-
[in] | handle | HDF5 file handle |
[in] | dataset_path | Data set path |
- Returns
- True if
dataset_path
is in the file
◆ open_file()
hid_t open_file |
( |
MPI_Comm |
comm, |
|
|
const std::filesystem::path & |
filename, |
|
|
const std::string & |
mode, |
|
|
const bool |
use_mpi_io |
|
) |
| |
|
static |
Open HDF5 and return file descriptor.
- Parameters
-
[in] | comm | MPI communicator |
[in] | filename | Name of the HDF5 file to open |
[in] | mode | Mode in which to open the file (w, r, a) |
[in] | use_mpi_io | True if MPI-IO should be used |
◆ read_dataset()
static std::vector<T> read_dataset |
( |
const hid_t |
handle, |
|
|
const std::string & |
dataset_path, |
|
|
const std::array< std::int64_t, 2 > & |
range |
|
) |
| |
|
static |
Read data from a HDF5 dataset "dataset_path" as defined by range blocks on each process.
- Parameters
-
[in] | handle | HDF5 file handle |
[in] | dataset_path | Path for the dataset in the HDF5 file |
[in] | range | The local range on this processor |
- Returns
- Flattened 1D array of values. If range = {-1, -1}, then all data is read on this process.
◆ write_dataset()
static void write_dataset |
( |
const hid_t |
handle, |
|
|
const std::string & |
dataset_path, |
|
|
const T * |
data, |
|
|
const std::array< std::int64_t, 2 > & |
range, |
|
|
const std::vector< std::int64_t > & |
global_size, |
|
|
bool |
use_mpi_io, |
|
|
bool |
use_chunking |
|
) |
| |
|
static |
Write data to existing HDF file as defined by range blocks on each process.
- Parameters
-
[in] | handle | HDF5 file handle |
[in] | dataset_path | Path for the dataset in the HDF5 file |
[in] | data | Data to be written, flattened into 1D vector (row-major storage) |
[in] | range | The local range on this processor |
[in] | global_size | The global shape shape of the array |
[in] | use_mpi_io | True if MPI-IO should be used |
[in] | use_chunking | True if chunking should be used |
The documentation for this class was generated from the following files:
- /__w/dolfinx/dolfinx/cpp/dolfinx/io/HDF5Interface.h
- /__w/dolfinx/dolfinx/cpp/dolfinx/io/HDF5Interface.cpp