Abstraction layer around HDF5. Link this module against -lhdf5 and
-lhdf5_fortran.
The module provides wrapper procedures to HDF5 in order to read and write derived types as 1-dimensional compound data sets. Only nodes, observations, sensors, and targets are supported.
The following example writes and reads eight empty observations as group
timeseries to and from file sample.hdf5:
integer, parameter :: NOBSERVS = 8
integer :: rc
type(hdf5_file_type) :: file
type(hdf5_group_type) :: group
type(observ_type), allocatable :: input(:), output(:)
allocate (output(N))
! Initialise HDF5, create file and group.
rc = dm_hdf5_init()
rc = dm_hdf5_open(file, 'sample.hdf5', create=.true.)
rc = dm_hdf5_open(file, group, 'timeseries', create=.true.)
! Write array to file, then read array back from file.
rc = dm_hdf5_write(group, output)
rc = dm_hdf5_read(group, input)
! Clean-up.
rc = dm_hdf5_close(group)
rc = dm_hdf5_close(file)
rc = dm_hdf5_destroy()
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| character(len=*), | public, | parameter | :: | HDF5_DATASET_NODE | = | 'node_type' |
Default name of node data set. |
| character(len=*), | public, | parameter | :: | HDF5_DATASET_OBSERV | = | 'observ_type' |
Default name of observation data set. |
| character(len=*), | public, | parameter | :: | HDF5_DATASET_SENSOR | = | 'sensor_type' |
Default name of sensor data set. |
| character(len=*), | public, | parameter | :: | HDF5_DATASET_TARGET | = | 'target_type' |
Default name of target data set. |
| integer, | public, | parameter | :: | HDF5_RDONLY | = | 0 |
Read-only access. |
| integer, | public, | parameter | :: | HDF5_RDWR | = | 1 |
Read/write access. |
| integer, | public, | parameter | :: | HDF5_FILTER_DEFLATE | = | 1 |
gzip or deflate compression ( |
| integer, | public, | parameter | :: | HDF5_FILTER_SHUFFLE | = | 2 |
Shuffle algorithm ( |
| integer, | public, | parameter | :: | HDF5_FILTER_FLETCHER32 | = | 3 |
Fletcher32 checksum ( |
| integer, | public, | parameter | :: | HDF5_FILTER_SZIP | = | 4 |
SZIP compression ( |
Generic HDF5 close function.
Closes HDF5 file. Returns E_INVALID if the passed HDF5 file is not
opened. Returns E_HDF5 if closing the file failed.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(hdf5_file_type), | intent(inout) | :: | file |
HDF5 file type. |
Closes HDF5 group. Returns E_INVALID if the passed HDF5 group
is not opened. Returns E_HDF5 if closing the group failed.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(hdf5_group_type), | intent(inout) | :: | group |
HDF5 group type. |
Generic HDF5 open function.
Opens HDF5 file, by default in read/write access mode, unless mode
is passed. If create is .true., a new file will be created.
The function returns the following error codes:
E_EXIST if the file to create already exists.E_HDF5 if opening or creating the file failed.E_INVALID if the file is opened already or argument mode is invalid.E_NOT_FOUND if the file was not found.| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(hdf5_file_type), | intent(out) | :: | file |
HDF5 file type. |
||
| character(len=*), | intent(in) | :: | path |
Path to HDF5 file. |
||
| integer, | intent(in), | optional | :: | mode |
Open mode ( |
|
| logical, | intent(in), | optional | :: | create |
Create HDF5 file. |
Opens or creates group of name name. The function returns
E_INVALID if the file is not opened, and E_HDF5 if the group
operation failed.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hdf5_id_type), | intent(inout) | :: | id |
HDF5 file or group type. |
||
| type(hdf5_group_type), | intent(out) | :: | group |
HDF5 group type. |
||
| character(len=*), | intent(in) | :: | name |
Group name. |
||
| logical, | intent(in), | optional | :: | create |
Create group. |
Generic HDF5 read function.
Reads array of node_type from compound data in HDF5 file. If
data_set is not passed, the name will be set to the value of
HDF5_DATASET_NODE.
The function returns the following error codes:
E_INVALID if the passed id is invalid.E_ALLOC if allocation of array nodes failed.E_HDF5 if the HDF5 library call failed.| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hdf5_id_type), | intent(inout) | :: | id |
HDF5 file or group type. |
||
| type(node_type), | intent(out), | allocatable, target | :: | nodes(:) |
Node type array. |
|
| character(len=*), | intent(in), | optional | :: | data_set |
Name of data set. |
Reads array of observ_type from compound data in HDF5 file. If
data_set is not passed, the name will be set to the value of
HDF5_DATASET_OBSERV.
The function returns the following error codes:
E_INVALID if the passed id is invalid.E_ALLOC if allocation of array observs failed.E_HDF5 if the HDF5 library call failed.| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hdf5_id_type), | intent(inout) | :: | id |
HDF5 file or group type. |
||
| type(observ_type), | intent(out), | allocatable, target | :: | observs(:) |
Observation type array. |
|
| character(len=*), | intent(in), | optional | :: | data_set |
Name of data set. |
Reads array of sensor_type from compound data in HDF5 file. If
data_set is not passed, the name will be set to the value of
HDF5_DATASET_SENSOR.
The function returns the following error codes:
E_INVALID if the passed id is invalid.E_ALLOC if allocation of array sensors failed.E_HDF5 if the HDF5 library call failed.| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hdf5_id_type), | intent(inout) | :: | id |
HDF5 file or group type. |
||
| type(sensor_type), | intent(out), | allocatable, target | :: | sensors(:) |
Sensor type array. |
|
| character(len=*), | intent(in), | optional | :: | data_set |
Name of data set. |
Reads array of target_type from compound data in HDF5 file. If
data_set is not passed, the name will be set to the value of
HDF5_DATASET_TARGET.
The function returns the following error codes:
E_INVALID if the passed id is invalid.E_ALLOC if allocation of array targets failed.E_HDF5 if the HDF5 library call failed.| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hdf5_id_type), | intent(inout) | :: | id |
HDF5 file or group type. |
||
| type(target_type), | intent(out), | allocatable, target | :: | targets(:) |
Target type array. |
|
| character(len=*), | intent(in), | optional | :: | data_set |
Name of data set. |
Generic HDF5 write function.
Creates HDF5 data space and writes nodes to HDF5 file or group. If
data_set is not passed, the name will be set to the value of
HDF5_DATASET_NODE.
The function returns the following error codes:
E_INVALID if the given HDF5 id type (file, group) is invalid.E_EMPTY if the passed node array is of size 0.E_HDF5 if the HDF5 library call failed.| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hdf5_id_type), | intent(inout) | :: | id |
HDF5 file or group type. |
||
| type(node_type), | intent(inout), | target | :: | nodes(:) |
Node type array. |
|
| character(len=*), | intent(in), | optional | :: | data_set |
Name of data set. |
Creates HDF5 data space and writes observations to HDF5 file or
group. If data_set is not passed, the name will be set to the
value of HDF5_DATASET_OBSERV.
The function returns the following error codes:
E_INVALID if the given HDF5 id type (file, group) is invalid.E_EMPTY if the passed observation array is of size 0.E_HDF5 if the HDF5 library call failed.| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hdf5_id_type), | intent(inout) | :: | id |
HDF5 file or group type. |
||
| type(observ_type), | intent(inout), | target | :: | observs(:) |
Observation type array. |
|
| character(len=*), | intent(in), | optional | :: | data_set |
Name of data set. |
Creates HDF5 data space and writes targets to HDF5 file or group. If
data_set is not passed, the name will be set to the value of
HDF5_DATASET_TARGET.
The function returns the following error codes:
E_INVALID if the given HDF5 id type (file, group) is invalid.E_EMPTY if the passed target array is of size 0.E_HDF5 if the HDF5 library call failed.| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hdf5_id_type), | intent(inout) | :: | id |
HDF5 file or group type. |
||
| type(target_type), | intent(inout), | target | :: | targets(:) |
Target type array. |
|
| character(len=*), | intent(in), | optional | :: | data_set |
Name of data set. |
Creates HDF5 data space and writes sensors to HDF5 file or group. If
data_set is not passed, the name will be set to the value of
HDF5_DATASET_SENSOR.
The function returns the following error codes:
E_INVALID if the given HDF5 id type (file, group) is invalid.E_EMPTY if the passed sensor array is of size 0.E_HDF5 if the HDF5 library call failed.| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hdf5_id_type), | intent(inout) | :: | id |
HDF5 file or group type. |
||
| type(sensor_type), | intent(inout), | target | :: | sensors(:) |
Sensor type array. |
|
| character(len=*), | intent(in), | optional | :: | data_set |
Name of data set. |
Opaque HDF5 file type.
Opaque HDF5 group type.
Destroys HDF5 Fortran interface. Returns E_HDF5 on error.
Returns amount of free space within a file in argument free_space.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(hdf5_file_type), | intent(inout) | :: | file |
HDF5 file type. |
||
| integer(kind=i8), | intent(out) | :: | free_space |
Free space in bytes. |
Returns .true. if file at given path is a valid HDF5 file.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path |
File path. |
Returns file path of given HDF5 file in path. The argument path
must be large enough to hold the full path. The actual length is
returned in optional argument n.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(hdf5_file_type), | intent(inout) | :: | file |
HDF5 file type. |
||
| character(len=*), | intent(inout) | :: | path |
Path of HDF5 file. |
||
| integer, | intent(out), | optional | :: | n |
Path length. |
Returns the status of the given filter. The following filters are supported:
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | filter |
Filter enumerator. |
||
| integer, | intent(out), | optional | :: | error |
Error code. |
Returns .true. if group of given name name exists in file or
group id. The function returns the following error codes in
error:
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hdf5_id_type), | intent(inout) | :: | id |
HDF5 file or group type. |
||
| character(len=*), | intent(in) | :: | name |
Group name. |
||
| integer, | intent(out), | optional | :: | error |
Error code. |
Initialises HDF5 Fortran interface. The function returns E_HDF5 on
error.
Returns HDF5 library version as allocatable string.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| logical, | intent(in), | optional | :: | name |
Add prefix |
Version string.
Returns version numbers of HDF5 library. The function returns
E_HDF5 on error.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(out), | optional | :: | major |
Major version of HDF5 library. |
|
| integer, | intent(out), | optional | :: | minor |
Minor version of HDF5 library. |
|
| integer, | intent(out), | optional | :: | release |
Release version of HDF5 library. |