MAIA bb96820c
Multiphysics at AIA
|
#include <parallelio_hdf5.h>
Public Member Functions | |
ParallelIoHdf5 (const MString &fileName, MInt fileMode, const MPI_Comm &mpiComm) | |
Creates a new object to read and write big data files. [MPI] More... | |
~ParallelIoHdf5 () override | |
Close open identifiers and release memory. [MPI] More... | |
template<> | |
void | b_setAttribute (const MString *value, const MString &name, const MString &datasetName, const size_type totalCount) |
Set an attribute in the file (string version). More... | |
template<> | |
void | b_getAttribute (MString *value, const MString &name, const MString &datasetName, const size_type totalCount) |
Retrieve an attribute from file (MString version). More... | |
template<> | |
void | b_writeArray (const MString *array, const MString &name, const size_type noDims, MPI_Offset *start, MPI_Offset *count, MPI_Offset memoryStride, const size_type noChunks, MPI_Offset diskStride) |
Writes array data to file (String version). [MPI] More... | |
template<> | |
void | b_readArray (MString *array, const MString &name, const size_type noDims, MPI_Offset *start, MPI_Offset *count, MPI_Offset memoryStride, const size_type noChunks, MPI_Offset diskStride) |
Read array data from file (string version). [MPI] More... | |
template<> | |
void | b_readScalar (MString *scalar, const MString &name) |
Read scalar data from file (float version). [MPI] More... | |
template<> | |
void | b_createAttribute (const MString *value, const MString &name, const MString &datasetName, hid_t dtype_id, const size_type totalCount) |
Creates an attribute in the file (string version). More... | |
Public Member Functions inherited from ParallelIoBase< ParallelIoHdf5 > | |
MBool | hasDataset (const MString &name, MInt dimension) |
Check if the file contains an dataset with the given name and dimension. More... | |
MBool | hasDataset (const MString &name, const MString &path) |
MBool | hasDataset (const MString &name) |
Check if the file contains an dataset with the given name. More... | |
MBool | hasObject (const MString &path) |
MInt | getDatasetType (const MString &name) |
Returns the data type of an array. More... | |
std::vector< MString > | getDatasetNames (const size_type dimensions=-1) |
Returns a vector with the names of all existing datasets with given dimensionality in the file. More... | |
std::vector< MString > | getDatasetNames (const MString &path) |
std::vector< MString > | getGroupNames (const MString &path) |
size_type | getDatasetNoDims (const MString &name) |
Get the number of dimensions of a dataset with given name. More... | |
size_type | getDatasetNoDims (const MString &name, const MString &path) |
std::vector< size_type > | getArrayDims (const MString &name) |
Get the lengths of all dimensions of a dataset with given name. More... | |
size_type | getArraySize (const MString &name, const size_type dimensionId=0) |
Get the length of an array in the file. More... | |
void | getArraySize (const MString &name, const MString &path, size_type *datasetSize) |
MBool | hasAttribute (const MString &name, const MString &path="") |
Check if a given attribute exists in the file. More... | |
maiabd_type | getAttributeType (const MString &name, const MString &datasetName="") |
Returns the data type of an attribute in the file. More... | |
void | defineArray (maiabd_type type, const MString &name, size_type totalCount) |
Create a new array in the file. More... | |
void | defineArray (maiabd_type type, const MString &name, size_type noDims, size_type *totalCount) |
Create a new array in the file. More... | |
void | defineArray (maiabd_type type, const std::vector< MString > &name, size_type totalCount) |
Create multiple new arrays in the file. More... | |
void | defineArray (maiabd_type type, const MString &datasetName, const MString &name, size_type noDims, size_type *totalCount) |
Creates new array in the file. More... | |
void | defineScalar (maiabd_type type, const MString &name) |
Create a new scalar in the file. More... | |
void | writeArray (const T *array, const MString &name, size_type memoryStride=-1, size_type diskStride=-1) |
Write array data to file. [MPI] More... | |
void | writeArray (const T *array, const std::vector< MString > &names, size_type memoryStride=-1, size_type diskStride=-1) |
Write array data to file (multi-array version). [MPI] More... | |
void | writeArray (const T *array, const MString &path, const MString &name, const size_type noDims, size_type *offset, size_type *localCount) |
Write multidimensional array data to file. [MPI] More... | |
void | writeArray (const T *array, const MString &path, const MString &name, const size_type noDims, size_type *offset, size_type *localCount, size_type *ghost) |
Write multidimensional array data to file [ghost cell version]. [MPI] More... | |
void | writeScalar (T scalar, const MString &name) |
Write scalar data to file. [MPI] More... | |
void | setAttribute (const T &value, const MString &name, const MString &datasetName="") |
Set a file or dataset attribute. [MPI] More... | |
void | setAttribute (const MChar *value, const MString &name, const MString &datasetName="") |
void | setAttributes (const T *value, const MString &name, size_type totalCount, const MString &datasetName="") |
void | readArray (T *array, const MString &name, size_type memoryStride=-1, size_type diskStride=-1) |
Read array data from file. [MPI] More... | |
void | readArray (std::vector< T > &array, const MString &name, size_type memoryStride=-1, size_type diskStride=-1) |
void | readArray (T *array, const std::vector< MString > &names, size_type memoryStride=-1, size_type diskStride=-1) |
Read array data from file (multi-array version). [MPI] More... | |
void | readArray (T *array, const MString &datasetName, const MString &name, const size_type noDims, const size_type *offset, const size_type *localCount) |
Read array data from file. [MPI] More... | |
void | readArray (T *array, const MString &datasetName, const MString &name, const size_type noDims, const size_type *localCount) |
Read array data from file [no offset version]. [MPI] More... | |
void | readScalar (T *scalar, const MString &name) |
Read scalar data from file. [MPI] More... | |
void | getAttribute (T *value, const MString &name, const MString &datasetName="") |
Retrieve a file or dataset attribute. More... | |
void | getAttribute (T *value, const MString &name, const size_type totalCount, const MString &datasetName="") |
void | getAttributeCount (const MString &name, size_type *totalCount, const MString &datasetName="") |
void | setOffset (const size_type localCount, const size_type offset, const size_type noDims, const size_type noChunks) |
Set the local and global counts, as well the local offset for array operations. More... | |
void | setOffset (const size_type localCount, const size_type offset, const size_type noDims) |
Set the local and global counts, as well the local offset for array operations (overload). More... | |
void | setOffset (size_type localCount, size_type offset) |
Set the local and global counts, as well the local offset for array operations (overload). More... | |
Private Member Functions | |
void | b_open () |
void | b_saveHeader () |
Adds all additional header information that are needed in the file. More... | |
void | b_addAdditionalHeader () |
Write additional headers to file (e.g. grid file name, creation date etc.). [MPI] More... | |
void | b_writeAdditionalData () |
Write additional data to file. [MPI] More... | |
void | b_defineArray (maiabd_type type, const MString &name, size_type noDims, size_type *totalCount) |
Defines an array in the file. [MPI] More... | |
void | b_defineArray (maiabd_type, const MString &, const MString &, const size_type, const size_type *) |
void | b_defineScalar (maiabd_type type, const MString &name) |
Defines a scalar in the file. [MPI] More... | |
void | b_createGroup (const MString &path) |
Creates an HDF5 group [MPI] More... | |
size_type | b_getNoDatasets (const MString &path) |
Gets the number of datasetes in the given group [MPI] More... | |
size_type | b_getNoGroups (const MString &path) |
Gets the number of groups in the given group [MPI] More... | |
MBool | b_hasDataset (const MString &name, const size_type dimension) |
Check if the file contains a dataset with the given name and number of dimensions. More... | |
MBool | b_hasDataset (const MString &name, const MString &path) |
Check if dataset exists. [MPI] More... | |
MBool | b_hasObject (const MString &path) |
MInt | b_getDatasetType (const MString &name) |
Returns the data type of a dataset in the file (can be array, multi-D array or scalar). More... | |
void | b_getDatasetNames (std::vector< MString > &names, const size_type dimension) |
Returns a vector of all existing datasets with the given number of dimensions in the file (if any). [MPI] More... | |
void | b_getDatasetNames (std::vector< MString > &names, const MString &path) |
Gets the dataset names in the given group [MPI] More... | |
void | b_getGroupNames (std::vector< MString > &names, const MString &path) |
Gets the groups in the given group [MPI] More... | |
size_type | b_getDatasetNoDims (const MString &name) |
Get number of dimensions of a dataset with the given name. More... | |
size_type | b_getDatasetNoDims (const MString &path, const MString &name) |
Returns number of dimensions of dataset [MPI] More... | |
size_type | b_getDatasetSize (const MString &name, const size_type dimensionId=0) |
Get the length of one dimension of an arbitrary array in the file. More... | |
void | b_getDatasetSize (const MString &name, const MString &path, size_type noDims, size_type *data) |
Gets the size of a dataset in space directions. [MPI] More... | |
MBool | b_hasAttribute (const MString &name, const MString &path="") |
Check if object exists. [MPI] More... | |
MInt | b_getAttributeType (const MString &name, const MString &datasetName="") |
Returns the data type of an attribute in the file. More... | |
template<class T > | |
void | b_writeArray (const T *array, const MString &name, const size_type noDims, MPI_Offset *start, MPI_Offset *count, MPI_Offset memoryStride, const size_type noChunks, MPI_Offset diskStride) |
Writes array data to file (Hdf5 version). [MPI] More... | |
template<class T > | |
void | b_writeArray (const T *, const MString &, const MString &, const size_type, const size_type *, const size_type *, const size_type *) |
Write data array, ghost cell version. [MPI] More... | |
template<class T > | |
void | b_writeScalar (T scalar, const MString &name) |
Writes scalar data to file (Hdf5 version). [MPI] More... | |
template<class T > | |
void | b_readArray (T *, const MString &, const size_type, MPI_Offset *, MPI_Offset *, MPI_Offset, const size_type, MPI_Offset) |
Read array data from file (float version). [MPI] More... | |
template<class T > | |
void | b_readArray (T *, const MString &, const MString &, const size_type, const size_type *, const size_type *) |
Read double data from file. [MPI] More... | |
template<class T > | |
void | b_readScalar (T *scalar, const MString &name) |
Read scalar data from file (float version). [MPI] More... | |
template<class T > | |
void | b_setAttribute (const T *value, const MString &name, const MString &datasetName="", const size_type totalCount=1) |
Set an attribute in the file (generic version). More... | |
template<class T > | |
void | b_createAttribute (const T *value, const MString &name, const MString &datasetName, hid_t type_id, const size_type totalCount) |
Creates an attribute in the file (generic version). More... | |
template<class T > | |
void | b_getAttribute (T *value, const MString &name, const MString &datasetName="", const size_type totalCount=1) |
Retrieve an attribute from file (float version). More... | |
void | b_getAttributeCount (const MString &name, size_type *totalCount, const MString &datasetName="") |
Static Private Member Functions | |
static MBool | b_isValidFile (const MString &name, const MPI_Comm &mpiComm) |
Check if specified file is a valid HDF5 file (i.e. can be opened). [MPI] More... | |
static const MString | b_fileExt () |
Returns backend-specific ending of filename (either ".Netcdf" or ".Hdf5") More... | |
static void | b_error (MInt status, const MString &name, const MString &location) |
Check the status code of a HDF5 operation and output a meaningful message. More... | |
static void | b_warning (MInt status, const MString &name, const MString &location) |
Check the status code of a HDF5 operation and output a meaningful message (Warning) More... | |
Private Attributes | |
friend | ParallelIoBase< ParallelIoHdf5 > |
hid_t | b_h5Id = -1 |
hid_t | b_h5DatasetXferHandle |
hid_t | b_h5FileXferHandle |
Additional Inherited Members | |
Public Types inherited from ParallelIoBase< ParallelIoHdf5 > | |
using | size_type = MLong |
Type used for all size- and offset-related values. More... | |
using | maiabd_type = maia::parallel_io::maiabd_type |
Type used for all constants that are defined in maia::parallel_io. More... | |
Static Public Member Functions inherited from ParallelIoBase< ParallelIoHdf5 > | |
static MBool | fileExists (const MString &name, const MPI_Comm &mpiComm) |
Check whether a file exists. [MPI] More... | |
static void | deleteFile (const MString &name) |
Deletes the specified file. [MPI] More... | |
static MBool | isParallelIoFile (const MString &name, const MPI_Comm &mpiComm) |
Check if specified file is a valid ParallelIoHdf5 file. [MPI] More... | |
static MString | fileExt () |
Returns backend-specific ending of filename (either ".Netcdf" or ".Hdf5") More... | |
static void | calcOffset (size_type localCount, size_type *offset, size_type *totalCount, const MPI_Comm &mpiComm, size_type *noChunks=nullptr) |
Calculates the totalCount and offset information needed in setOffset(). [MPI] More... | |
Protected Member Functions inherited from ParallelIoBase< ParallelIoHdf5 > | |
ParallelIoBase (MString fileName, MInt fileMode, const MPI_Comm &mpiComm) | |
Creates a new object to read and write big data files. [MPI] More... | |
virtual | ~ParallelIoBase () |
empty destructor. [MPI] More... | |
void | validateType (const maiabd_type type) const |
Auxiliary method that aborts MAIA if type is not a valid type constant for ParallelIo. More... | |
Protected Attributes inherited from ParallelIoBase< ParallelIoHdf5 > | |
const MString | m_fileName |
const MInt | m_fileMode |
MBool | m_isHeaderSaved |
MInt | m_domainId |
MInt | m_noDomains |
MPI_Comm | m_mpiComm |
MPI_Info | m_mpiInfo |
MBool | m_offsetsAreSet |
std::vector< size_type > | m_localCount |
std::vector< size_type > | m_offset |
size_type | m_noChunks |
MFloat | m_creationTime |
std::set< MString > | m_unwrittenArrays |
std::set< MString > | m_unwrittenScalars |
std::set< MString > | m_writtenArrays |
std::set< MString > | m_writtenScalars |
std::set< MString > | m_readArrays |
std::set< MString > | m_readScalars |
Static Protected Attributes inherited from ParallelIoBase< ParallelIoHdf5 > | |
static const size_type | s_maxChunkSize |
static const MPI_Datatype | s_mpiSizeType |
Definition at line 19 of file parallelio_hdf5.h.
ParallelIoHdf5::ParallelIoHdf5 | ( | const MString & | fileName, |
MInt | fileMode, | ||
const MPI_Comm & | mpiComm | ||
) |
[in] | fileName | |
[in] | fileMode | The file mode can be either maia::parallel_io::PIO_CREATE, maia::parallel_io::PIO_APPEND, or maia::parallel_io::PIO_READ. |
[in] | mpiComm | The MPI communicator that should be used to open/create the file. |
Definition at line 185 of file parallelio_hdf5.cpp.
|
override |
Definition at line 238 of file parallelio_hdf5.cpp.
|
private |
Definition at line 294 of file parallelio_hdf5.cpp.
void ParallelIoHdf5::b_createAttribute | ( | const MString * | value, |
const MString & | name, | ||
const MString & | datasetName, | ||
hid_t | dtype_id, | ||
const size_type | totalCount | ||
) |
[in] | value | Attribute value. |
[in] | name | Attribute name. |
[in] | datasetName | Dataset (scalar or array) to which the attribute is attached (leave empty for file attributes). |
Definition at line 1533 of file parallelio_hdf5.cpp.
|
private |
[in] | value | Attribute value. |
[in] | name | Attribute name. |
[in] | datasetName | Dataset (scalar or array) to which the attribute is attached (leave empty for file attributes). |
Definition at line 1461 of file parallelio_hdf5.cpp.
|
private |
[in] | path | of group |
Definition at line 2407 of file parallelio_hdf5.cpp.
|
private |
[in] | type | Data type of the array (may be either maia::parallel_io::PIO_FLOAT or maia::parallel_io::PIO_INT or maia::parallel_io::PIO_STRING maia::parallel_io::PIO_UCHAR). |
[in] | name | Name of the array (must not be empty). |
[in] | noDims | Number of array dimensions |
[in] | totalCount | Total size of the array in each dimension. |
Definition at line 426 of file parallelio_hdf5.cpp.
|
private |
|
private |
[in] | type | Data type of the scalar (may be either maia::parallel_io::PIO_FLOAT or maia::parallel_io::PIO_INT). |
[in] | name | Name of the scalar (must not be empty). |
Definition at line 494 of file parallelio_hdf5.cpp.
|
staticprivate |
[in] | status | HDF5 status code (negative if unexspected behaviour) |
[in] | name | Name of the file / variable / attribute |
[in] | location | Function which called the error message |
Definition at line 1671 of file parallelio_hdf5.cpp.
|
staticprivate |
Definition at line 161 of file parallelio_hdf5.cpp.
void ParallelIoHdf5::b_getAttribute | ( | MString * | value, |
const MString & | name, | ||
const MString & | datasetName, | ||
const size_type | totalCount | ||
) |
[out] | value | Attribute value |
[in] | name | Attribute name |
[in] | datasetName | Dataset (scalar or array) to which the attribute is attached (leave empty for file attributes). |
Definition at line 855 of file parallelio_hdf5.cpp.
|
private |
[out] | value | Attribute value |
[in] | name | Attribute name |
[in] | datasetName | Dataset (scalar or array) to which the attribute is attached (leave empty for file attributes). |
Definition at line 905 of file parallelio_hdf5.cpp.
|
private |
Definition at line 1012 of file parallelio_hdf5.cpp.
|
private |
[in] | name | Name of the attribute to be checked. |
[in] | datasetName | Name of the dataset for which the attribute is checked. If empty, a file attribute is checked. |
Definition at line 1052 of file parallelio_hdf5.cpp.
|
private |
[out] | name | of datasets in given group |
[in] | path | of group |
Definition at line 2559 of file parallelio_hdf5.cpp.
|
private |
[in] | dimension | Match only datasets with given number of dimensions, default -1 which will return all datasets, 0 will only return scalars, 1 arrays with one dimension, ... |
[out] | names | List of dataset names. |
Definition at line 716 of file parallelio_hdf5.cpp.
|
private |
[in] | name | Dataset name for which the number of dimensions is returned |
The number of dimensions of a dataset is returned, 0 is a scalar, 1 an array with one dimension, ...
Definition at line 775 of file parallelio_hdf5.cpp.
|
private |
[out] | number | of space dimensions of dataset |
[in] | name | of dataset |
[in] | preceding | path of dataset |
Definition at line 2352 of file parallelio_hdf5.cpp.
|
private |
[in] | name | of dataset |
[in] | preceding | path of dataset |
[in] | number | of dimensions |
[out] | number | of cells in different space directions |
Definition at line 2300 of file parallelio_hdf5.cpp.
|
private |
[in] | name | Name of the array to check. |
[in] | dimensionId | dimension of the array to check. |
Definition at line 809 of file parallelio_hdf5.cpp.
[in] | name | Name of the dataset to check. |
Definition at line 666 of file parallelio_hdf5.cpp.
|
private |
[out] | name | of the groups inside the given group |
[in] | path | of group |
Definition at line 2473 of file parallelio_hdf5.cpp.
|
private |
[out] | number | of datasets in given group |
[in] | path | of group |
Definition at line 2602 of file parallelio_hdf5.cpp.
|
private |
[out] | number | of groups inside given group |
[in] | path | of group |
Definition at line 2516 of file parallelio_hdf5.cpp.
[out] | attribute | exists or not |
[in] | name | of the attribute |
[in] | preceding | path of attribute |
Definition at line 953 of file parallelio_hdf5.cpp.
[out] |
param [in]
Definition at line 618 of file parallelio_hdf5.cpp.
[in] | name | The name of the dataset that should be checked. |
[in] | noDimensions | Number of dimensions of the dataset to match, default -1 which is any dimensionality, 0 will only check scalars, 1 arrays with one dimension, ... |
Definition at line 569 of file parallelio_hdf5.cpp.
Definition at line 989 of file parallelio_hdf5.cpp.
|
staticprivate |
[in] | name | Name of the file that is to be checked. |
[in] | Not | used by Hdf5 specific version. |
Definition at line 129 of file parallelio_hdf5.cpp.
|
private |
void ParallelIoHdf5::b_readArray | ( | MString * | array, |
const MString & | name, | ||
const size_type | noDims, | ||
MPI_Offset * | start, | ||
MPI_Offset * | count, | ||
MPI_Offset | memoryStride, | ||
const size_type | noChunks, | ||
MPI_Offset | diskStride | ||
) |
[in] | array | Pointer to data in memory. |
[in] | name | Name of the dataset. |
[in] | noDims | Number of array dimensions |
[in] | start | Start offset in the file (i.e. the domain should start reading from here). |
[in] | count | Number of elements read from this domain. |
[in] | memoryStride | Stride in memory between data values. |
This method is the exact counterpart to h5WriteArray().
Definition at line 1262 of file parallelio_hdf5.cpp.
|
private |
[in] | array | to read |
[in] | preceding | path of dataset |
[in] | name | of dataset |
[in] | number | of dimensions |
[in] | offset | in different space directions |
[in] | number | of cells in different space directions |
Definition at line 2040 of file parallelio_hdf5.cpp.
|
private |
[in] | array | Pointer to data in memory. |
[in] | name | Name of the dataset. |
[in] | noDims | Number of array dimensions |
[in] | start | Start offset in the file (i.e. the domain should start reading from here). |
[in] | count | Number of elements read from this domain. |
[in] | memoryStride | Stride in memory between data values. |
[in] | noChunks | Number of Chunks for chunked IO. |
This method is the exact counterpart to h5WriteArray().
Definition at line 1885 of file parallelio_hdf5.cpp.
[out] | scalar | Value to read. |
[in] | name | Name of the dataset. |
This method is the exact counterpart to h5WriteScalar().
Definition at line 1414 of file parallelio_hdf5.cpp.
|
private |
[out] | scalar | Value to read. |
[in] | name | Name of the dataset. |
This method is the exact counterpart to h5WriteScalar().
Definition at line 2006 of file parallelio_hdf5.cpp.
|
private |
This method must be called exactly once for newly created files.
Definition at line 273 of file parallelio_hdf5.cpp.
void ParallelIoHdf5::b_setAttribute | ( | const MString * | value, |
const MString & | name, | ||
const MString & | datasetName, | ||
const size_type | totalCount | ||
) |
[in] | value | Attribute value. |
[in] | name | Attribute name. |
[in] | datasetName | Dataset (scalar or array) to which the attribute is attached (leave empty for file attributes). |
Definition at line 1639 of file parallelio_hdf5.cpp.
|
private |
[in] | value | Attribute value. |
[in] | name | Attribute name. |
[in] | datasetName | Dataset (scalar or array) to which the attribute is attached (leave empty for file attributes). |
Definition at line 1615 of file parallelio_hdf5.cpp.
|
staticprivate |
[in] | status | HDF5 status code (negative if unexspected behaviour) |
[in] | name | Name of the file / variable / attribute |
[in] | location | Function which called the error message |
Definition at line 1699 of file parallelio_hdf5.cpp.
|
private |
Definition at line 403 of file parallelio_hdf5.cpp.
void ParallelIoHdf5::b_writeArray | ( | const MString * | array, |
const MString & | name, | ||
const size_type | noDims, | ||
MPI_Offset * | start, | ||
MPI_Offset * | count, | ||
MPI_Offset | memoryStride, | ||
const size_type | noChunks, | ||
MPI_Offset | diskStride | ||
) |
[in] | array | Pointer to data in memory. |
[in] | name | Name of the dataset. |
[in] | noDims | Number of array dimensions |
[in] | start | Start offset in the file (i.e. the domain should start writing from here). |
[in] | count | Number of elements written from this domain. |
[in] | memoryStride | Stride in memory between data values. |
Definition at line 1127 of file parallelio_hdf5.cpp.
|
private |
[in] | array | to write |
[in] | preceding | path of dataset |
[in] | name | of dataset |
[in] | number | of dimensions |
[in] | offset | in different space directions |
[in] | number | of cells in different space directions |
[in] | number | of ghost cells |
Definition at line 2111 of file parallelio_hdf5.cpp.
|
private |
[in] | array | Pointer to data in memory. |
[in] | name | Name of the dataset. |
[in] | noDims | Number of array dimensions |
[in] | start | Start offset in the file (i.e. the domain should start writing from here). |
[in] | count | Number of elements written from this domain. |
[in] | memoryStride | Stride in memory between data values. |
[in] | noChunks | Number of Chunks for chunked IO. |
Definition at line 1731 of file parallelio_hdf5.cpp.
|
private |
[in] | scalar | Value to write. |
[in] | name | Name of the dataset. |
Definition at line 1848 of file parallelio_hdf5.cpp.
|
private |
Definition at line 105 of file parallelio_hdf5.h.
|
private |
Definition at line 106 of file parallelio_hdf5.h.
|
private |
Definition at line 103 of file parallelio_hdf5.h.
|
private |
Definition at line 20 of file parallelio_hdf5.h.