The HDF5 Lite API consists of higher-level functions which do more operations per call than the basic HDF5 interface. The purpose is to wrap intuitive functions around certain sets of features in the existing APIs. This version of the API has two sets of functions: dataset and attribute related functions.
The following functions are part of the HDF5 Lite API.
Programming Hints:
To use any of these functions or subroutines, you must first include the relevant include file (C) or module (Fortran) in your application.
The following line includes the HDF5 Lite package, H5LT,
in C applications:
#include "hdf5_hl.h"
This line includes the H5LT module in Fortran applications:
use h5lt
The C Interfaces:
The FORTRAN90 Interfaces:
In general, each FORTRAN90 subroutine performs exactly the same task
as the corresponding C function. There are four types supported: integer
,
real, double precision
and character
array. The
<TYPE> notation below is one of these four types. The
corresponding C functions are for the int, float, double
and string
cases.
Path and object function
Dataset functions
|
Attribute functions
|
H5LTpath_valid
checks the validity
of path
relative to the identifier of an object,
loc_id
.
Optionally, check_object_valid
can be set to determine
whether the final component of path
resolves to an HDF5 object; if not, the final component is a
dangling link.
The meaning of the function’s return value depends on the
value of check_object_valid
:
If check_object_valid
is set to FALSE
,
H5LTpath_valid
will check all links in path
to verify that they exist.
If all the links in path
exist,
the function will return TRUE
;
otherwise the function will return FALSE
.
If check_object_valid
is set to TRUE
,
H5LTpath_valid
will first check the links in
path
, as described above.
If all the links exist, check_object_valid
will then
determine whether the final component of path
resolves to an actual HDF5 object.
H5LTpath_valid
will return TRUE
if all the links in path
exist and the final component
resolves to an actual object;
otherwise, it will return FALSE
.
path
can be any one of the following:
/
)
indicating the file’s root group, followed by the membersloc_id
loc_id
is the object identifier
for the object itselfIf path
is an absolute path, then loc_id
can be an identifier for any object in the file as it is used
only to identify the file.
If path
is a relative path, then loc_id
must be a file or a group identifier.
H5LTpath_valid
was changed
in the 1.10.0 release in the case where the root group,
“/”, is the value of path
. This change is
described below:
loc_id
denote a valid HDF5 file identifier,
and let check_object_valid
be set to true or false.
A call to H5LTpath_valid
with arguments
loc_id
, “/”, and
check_object_valid
returns a positive value; in
other words,
H5LTpath_valid(loc_id, "/", check_object_valid)
returns a positive value.
In HDF5 version 1.8.16, this function returns 0.
check_object_valid
be set to true or false.
A call to H5LTpath_valid
with arguments
‘root’, “/”, and
check_object_valid
returns a positive value;
in other words,
H5LTpath_valid(root, "/", check_object_valid)
returns a postive value.
In HDF5 version 1.8.16, this function returns 0.
hid_t loc_id |
IN: An identifier of an object in the file. |
const char *path |
IN: The path to the object to check.
Links in path may be of any type.
|
hbool_t check_object_valid |
IN: If TRUE , determine whether
the final component of path
resolves to an object;
if FALSE , do not check. |
check_object_valid
is set to
FALSE
TRUE
if the path is valid;
otherwise returns FALSE
.check_object_valid
is set to
TRUE
TRUE
if the path is valid
and resolves to an HDF5 object;
otherwise returns FALSE
.SUBROUTINE h5ltpath_valid_f(loc_id, path, check_object_valid, path_valid, & errcode) INTEGER(HID_T) , INTENT(IN) :: loc_id ! An identifier of an object ! in the file CHARACTER(LEN=*), INTENT(IN) :: path ! Path to the object to check, ! relative to loc_id LOGICAL , INTENT(IN) :: check_object_valid ! Indicates whether to determine ! whether final component of path ! resolves to an object LOGICAL , INTENT(OUT) :: path_valid ! Object status INTEGER , INTENT(OUT) :: errcode ! Error code: 0 on success ! and -1 on failure END SUBROUTINE h5ltpath_valid_f
Release | Change |
1.10.0 | Function behavior changed in this release. See the “Note on Behavior Change” section above. |
H5LTopen_file_image
(
void *buf_ptr
,
size_t buf_size
,
unsigned flags
)
H5LTopen_file_image
and other elements of HDF5 are
used to load an image of an HDF5 file into system memory and open
that image as a regular HDF5 file.
An application can then use the file without the overhead of disk I/O.
See the “See Also” section below for links to other elements of HDF5 file image operations.
H5LTopen_file_image
opens the HDF5 file image that is located in system memory
at the address indicated by buf_ptr
of size buf_size
.
H5LTopen_file_image
opens a file image with the Core
driver, H5FD_CORE
.
The flags passed in flags
specify
whether to open the image read-only or read/write,
whether HDF5 is to take control of the buffer,
and instruction regarding releasing the buffer.
void *buf_ptr
| IN: A pointer to the supplied initial image
A value of | |
size_t buf_size
| IN: Size of the supplied buffer
A value of 0 is invalid and will cause the function to fail. | |
unsigned flags
| IN: Flags specifying
whether to open the image read-only or read/write,
whether HDF5 is to take control of the buffer, and
instruction regarding releasing the buffer
Valid values are:
|
H5LTopen_file_image
will fail if either
buf_ptr
is NULL
or
buf_size
equals 0
(zero).
H5Fget_file_image
H5Pset_file_image
H5Pget_file_image
H5Pset_file_image_callbacks
H5Pget_file_image_callbacks
| |
“HDF5
File Image Operations”
in Advanced Topics in HDF5
Within H5Pset_file_image_callbacks :
Callback struct H5_file_image_callbacks_t
Callback ENUM H5_file_image_op_t
|
Release | Change |
1.8.9 | C function introduced in this release. |
type_id
.
H5LT
make_dataset
creates and writes a
dataset named dset_name
attached to the object specified
by the identifier loc_id
.
The parameter type_id
can be any valid HDF5
predefined native datatype;
For example, setting type_id
to H5T_NATIVE_INT
will result in a dataset of signed integer datatype.
hid_t loc_id |
IN: Identifier of the file or group to create the dataset within. |
const char *dset_name |
IN: The name of the dataset to create. |
int rank |
IN: Number of dimensions of dataspace. |
const hsize_t * dims |
IN: An array of the size of each dimension. |
hid_t type_id |
IN: Identifier of the datatype to use when creating the dataset. |
const void * buffer |
IN: Buffer with data to be written to the dataset. |
subroutine h5ltmake_dataset_f(loc_id, dset_name, rank, dims, type_id, & buf, errcode) implicit none integer(HID_T), intent(IN) :: loc_id ! file or group identifier character(LEN=*), intent(IN) :: dset_name ! name of the dataset integer, intent(IN) :: rank ! rank integer(HSIZE_T), dimension(*), intent(IN) :: dims ! size of the bufffer buf integer(HID_T), intent(IN) :: type_id ! datatype identifier <TYPE>, intent(IN), dimension(*) :: buf ! data buffer integer :: errcode ! error code end subroutine h5ltmake_dataset_f
subroutine h5ltmake_dataset_f(loc_id, dset_name, rank, dims, type_id, & buf, errcode) implicit none integer(HID_T), intent(IN) :: loc_id ! file or group identifier character(LEN=*), intent(IN) :: dset_name ! name of the dataset integer, intent(IN) :: rank ! rank integer(HSIZE_T), dimension(*), intent(IN) :: dims ! size of the bufffer buf integer(HID_T), intent(IN) :: type_id ! datatype identifier type(C_PTR), intent(IN) :: buf ! data buffer integer :: errcode ! error code end subroutine h5ltmake_dataset_f
Release | Change |
1.8.7 | Fortran subroutine modified in this release to accomodate arrays with more than three dimensions. | 1.10.0 | Fortran 2003 subroutine added to accept a C address of the data buffer. |
H5LT
make_dataset_char
creates and writes
a dataset named dset_name
attached to the object specified
by the identifier loc_id
.
The dataset’s datatype will be character,
H5T_NATIVE_CHAR
.
hid_t loc_id |
IN: Identifier of the file or group to create the dataset within. |
const char *dset_name |
IN: The name of the dataset to create. |
int rank |
IN: Number of dimensions of dataspace. |
const hsize_t * dims |
IN: An array of the size of each dimension. |
const char * buffer |
IN: Buffer with data to be written to the dataset. |
H5LTmake_dataset_short
creates and writes a dataset
named dset_name
attached to the object specified by the
identifier loc_id
.
The dataset’s datatype will be short signed integer,
H5T_NATIVE_SHORT
.
hid_t loc_id |
IN: Identifier of the file or group to create the dataset within. |
const char *dset_name |
IN: The name of the dataset to create. |
int rank |
IN: Number of dimensions of dataspace. |
const hsize_t * dims |
IN: An array of the size of each dimension. |
const short * buffer |
IN: Buffer with data to be written to the dataset. |
H5LTmake_dataset_int
creates and writes a dataset
named dset_name
attached to
the object specified by the identifier loc_id
.
The dataset’s datatype will be native signed integer,
H5T_NATIVE_INT
.
loc_id
dset_name
rank
dims
buffer
subroutine h5ltmake_dataset_int_f(loc_id, dset_name, rank, dims, buf, errcode) implicit none integer(HID_T), intent(IN) :: loc_id ! file or group identifier character(LEN=*), intent(IN) :: dset_name ! name of the dataset integer, intent(IN) :: rank ! rank integer(HSIZE_T), dimension(*), intent(IN) :: dims ! size of the buffer buf integer, intent(IN), dimension(*) :: buf ! data buffer integer :: errcode ! error code end subroutine h5ltmake_dataset_int_f
Release | Change |
1.8.7 | Fortran subroutine modified in this release to accomodate arrays with more than three dimensions. |
H5LTmake_dataset
creates and writes a dataset
named dset_name
attached to
the object specified by the identifier loc_id
.
The dataset’s datatype will be long signed integer,
H5T_NATIVE_LONG
.
loc_id
dset_name
rank
dims
buffer
H5LTmake_dataset
creates and writes a dataset
named dset_name
attached to
the object specified by the identifier loc_id
.
The dataset’s datatype will be native floating point,
H5T_NATIVE_FLOAT
.
loc_id
dset_name
rank
dims
buffer
subroutine h5ltmake_dataset_float_f(loc_id, dset_name, rank, dims, & buf, errcode) implicit none integer(HID_T), intent(IN) :: loc_id ! file or group identifier character(LEN=*), intent(IN) :: dset_name ! name of the dataset integer, intent(IN) :: rank ! rank integer(HSIZE_T), dimension(*), intent(IN) :: dims ! size of the buffer buf real, intent(IN), dimension(*) :: buf ! data buffer integer :: errcode ! error code end subroutine h5ltmake_dataset_float_f
Release | Change |
1.8.7 | Fortran subroutine modified in this release to accomodate arrays with more than three dimensions. |
H5LTmake_dataset
creates and writes a dataset
named dset_name
attached to
the object specified by the identifier loc_id
.
The dataset’s datatype will be native floating-point
double, H5T_NATIVE_DOUBLE
.
loc_id
dset_name
rank
dims
buffer
subroutine h5ltmake_dataset_double_f(loc_id, dset_name, rank, dims, & buf, errcode) implicit none integer(HID_T), intent(IN) :: loc_id ! file or group identifier character(LEN=*), intent(IN) :: dset_name ! name of the dataset integer, intent(IN) :: rank ! rank integer(HSIZE_T), dimension(*), intent(IN) :: dims ! size of the buffer buf double precision, intent(IN), dimension(*) :: buf ! data buffer integer :: errcode ! error code end subroutine h5ltmake_dataset_double_f
Release | Change |
1.8.7 | Fortran subroutine modified in this release to accomodate arrays with more than three dimensions. |
H5LTmake_dataset_string
creates and writes a dataset
named dset_name
attached to
the object specified by the identifier loc_id
.
The dataset’s datatype will be C string,
H5T_C_S1
.
loc_id
dset_name
buffer
subroutine h5ltmake_dataset_string_f(loc_id, dset_name, buf, errcode) implicit none integer(HID_T), intent(IN) :: loc_id ! file or group identifier character(LEN=*), intent(IN) :: dset_name ! name of the dataset character(LEN=*), intent(IN), dimension(*) :: buf ! data buffer integer :: errcode ! error code end subroutine h5ltmake_dataset_string_f
H5LT
read_dataset
reads a dataset named dset_name
attached to
the object specified by the identifier loc_id
. loc_id
dset_name
type_id
buffer
subroutine h5ltread_dataset_f(loc_id, dset_name, type_id, buf, dims, errcode) implicit none integer(HID_T), intent(IN) :: loc_id ! file or group identifier character(LEN=*), intent(IN) :: dset_name ! name of the dataset integer(HID_T), intent(IN) :: type_id ! datatype identifier integer(HSIZE_T), dimension(*), intent(IN) :: dims ! size of the buffer buf <TYPE>, intent(INOUT), dimension(*) :: buf ! data buffer integer :: errcode ! error code end subroutine h5ltread_dataset_f
subroutine h5ltread_dataset_f(loc_id, dset_name, type_id, buf, errcode) implicit none integer(HID_T), intent(IN) :: loc_id ! file or group identifier character(LEN=*), intent(IN) :: dset_name ! name of the dataset integer(HID_T), intent(IN) :: type_id ! datatype identifier type(C_PTR) :: buf ! data buffer integer :: errcode ! error code end subroutine h5ltread_dataset_f
Release | Change |
1.8.7 | Fortran subroutine modified in this release to accomodate arrays with more than three dimensions. |
1.10.0 | Fortran 2003 subroutine added to accept a C address of the data buffer. |
H5LTread_dataset_char
reads a dataset named dset_name
attached to
the object specified by the identifier loc_id
. The HDF5
datatype is H5T_NATIVE_CHAR. loc_id
dset_name
buffer
H5LTread_dataset_short
reads a dataset named dset_name
attached to
the object specified by the identifier loc_id
. The HDF5
datatype is H5T_NATIVE_SHORT. loc_id
dset_name
buffer
H5LTread_dataset_int
reads a dataset named dset_name
attached to
the object specified by the identifier loc_id
. The HDF5
datatype is H5T_NATIVE_INT. loc_id
dset_name
buffer
subroutine h5ltread_dataset_int_f(loc_id, dset_name, buf, & dims, errcode) implicit none integer(HID_T), intent(IN) :: loc_id ! file or group identifier character(LEN=*), intent(IN) :: dset_name ! name of the dataset integer(HSIZE_T), dimension(*), intent(IN) :: dims ! size of the buffer buf integer, intent(INOUT), dimension(*) :: buf ! data buffer integer :: errcode ! error code end subroutine h5ltread_dataset_int_f
Release | Change |
1.8.7 | Fortran subroutine modified in this release to accomodate arrays with more than three dimensions. |
H5LTread_dataset_long
reads a dataset named dset_name
attached to
the object specified by the identifier loc_id
. The HDF5
datatype is H5T_NATIVE_LONG. loc_id
dset_name
buffer
H5LTread_dataset
reads a dataset named dset_name
attached to
the object specified by the identifier loc_id
. The HDF5
datatype is H5T_NATIVE_FLOAT. loc_id
dset_name
buffer
subroutine h5ltread_dataset_float_f(loc_id, dset_name, type_id, buf, & dims, errcode) implicit none integer(HID_T), intent(IN) :: loc_id ! file or group identifier character(LEN=*), intent(IN) :: dset_name ! name of the dataset integer(HSIZE_T), dimension(*), intent(IN) :: dims ! size of the buffer buf real, intent(INOUT), dimension(*) :: buf ! data buffer integer :: errcode ! error code end subroutine h5ltread_dataset_float_f
Release | Change |
1.8.7 | Fortran subroutine modified in this release to accomodate arrays with more than three dimensions. |
H5LTread_dataset
reads a dataset named dset_name
attached to
the object specified by the identifier loc_id
. The HDF5
datatype is H5T_NATIVE_DOUBLE. loc_id
dset_name
buffer
subroutine h5ltread_dataset_double_f(loc_id, dset_name, buf, & dims, errcode) implicit none integer(HID_T), intent(IN) :: loc_id ! file or group identifier character(LEN=*), intent(IN) :: dset_name ! name of the dataset integer(HSIZE_T), dimension(*), intent(IN) :: dims ! size of the buffer buf double precision, intent(INOUT), dimension(*) :: buf ! data buffer integer :: errcode ! error code end subroutine h5ltread_dataset_double_f
Release | Change |
1.8.7 | Fortran subroutine modified in this release to accomodate arrays with more than three dimensions. |
H5LTread_dataset_string
reads a dataset named dset_name
attached to
the object specified by the identifier loc_id
. The HDF5
datatype is H5T_C_S1. loc_id
dset_name
buffer
subroutine h5ltread_dataset_string_f(loc_id,dset_name,buf,errcode ) implicit none integer(hid_t), intent(in) :: loc_id ! file or group identifier character(len=*), intent(in) :: dset_name ! name of the dataset character(len=*), intent(inout) :: buf ! data buffer integer :: errcode ! error code end subroutine h5ltread_dataset_string_f
H5LTfind_dataset
determines whether
a dataset named dset_name
exists
in the group specified by loc_id
.
loc_id
must be a group identifier and
dset_name
must specify a dataset
that is a member of that group.
loc_id
dset_name
integer function h5ltfind_dataset_f(loc_id, dset_name) implicit none integer(HID_T), intent(IN) :: loc_id ! group identifier character(LEN=*), intent(IN) :: dset_name ! name of the dataset end function h5ltfind_dataset_fAn error code is passed back in the function’s return value.
H5LT
get_dataset_ndims
gets the dimensionality of a dataset named dset_name
exists attached to the object loc_id
.loc_id
dset_name
rank
subroutine h5ltget_dataset_ndims_f(loc_id, dset_name, rank, errcode) implicit none integer(HID_T), intent(IN) :: loc_id ! file or group identifier character(LEN=*), intent(IN) :: dset_name ! name of the dataset integer, intent(INOUT) :: rank ! rank integer :: errcode ! error code end subroutine h5ltget_dataset_ndims_f
H5LT
get_dataset_info
gets information about a dataset named dset_name
exists attached to the object loc_id
.loc_id
dset_name
dims
class_id
type_size
subroutine h5ltget_dataset_info_f(loc_id, dset_name, dims, type_class, & type_size, errcode) implicit none integer(HID_T), intent(IN) :: loc_id ! file or group identifier character(LEN=*), intent(IN) :: dset_name ! name of the dataset integer(HSIZE_T),dimension(*),intent(INOUT):: dims ! dimensions integer, intent(INOUT) :: type_class ! type class integer(SIZE_T), intent(INOUT) :: type_size ! type size integer :: errcode ! error code end subroutine h5ltget_dataset_info_f
H5LT
attach_attribute
creates and writes a string attribute named attr_name
and
attaches it to the object specified by the name obj_name
. If the attribute already exists, it is overwritten.loc_id
obj_name
attr_name
attr_data
subroutine h5ltset_attribute_string_f(loc_id, dset_name, attr_name, & buf, errcode ) implicit none integer(HID_T), intent(IN) :: loc_id ! file or group identifier character(LEN=*), intent(IN) :: dset_name ! name of the dataset character(LEN=*), intent(IN) :: attr_name ! name of the attribute integer :: errcode ! error code character(LEN=*), intent(IN) :: buf ! data buffer end subroutine h5ltset_attribute_string_f
H5LT
set_attribute_char
creates and writes a numerical attribute named attr_name
and
attaches it to the object specified by the name obj_name
. The attribute has
a dimensionality of 1. The HDF5
datatype of the attribute is H5T_NATIVE_CHAR.loc_id
obj_name
attr_name
buffer
size
H5Screate_simple
to create the
dataspace.H5LTset_attribute_short
creates and writes a numerical attribute named attr_name
and
attaches it to the object specified by the name obj_name
. The attribute has
a dimensionality of 1. The HDF5
datatype of the attribute is H5T_NATIVE_SHORT.loc_id
obj_name
attr_name
buffer
size
H5Screate_simple
to create the
dataspace.H5LTset_attribute_int
creates and writes a numerical integer attribute named attr_name
and
attaches it to the object specified by the name obj_name
. The attribute has
a dimensionality of 1. The HDF5
datatype of the attribute is H5T_NATIVE_INT.loc_id
obj_name
attr_name
buffer
size
H5Screate_simple
to create the
dataspace.subroutine h5ltset_attribute_int_f(loc_id, dset_name, attr_name, buf, & size, errcode) implicit none integer(HID_T), intent(IN) :: loc_id ! file or group identifier character(LEN=*), intent(IN) :: dset_name ! name of the dataset character(LEN=*), intent(IN) :: attr_name ! name of the attribute integer, intent(IN), dimension(*) :: buf ! data buffer integer(size_t), intent(IN) :: size ! size of attribute array integer :: errcode ! error code end subroutine h5ltset_attribute_int_f
H5LTset_attribute_long
creates and writes a numerical attribute named attr_name
and
attaches it to the object specified by the name obj_name
. The attribute has
a dimensionality of 1. The HDF5
datatype of the attribute is H5T_NATIVE_LONG.loc_id
obj_name
attr_name
buffer
size
H5Screate_simple
to create the
dataspace.H5LTset_attribute_long_long
(hid_t
loc_id
, const char *obj_name
,
const char *attr_name
,
const long_long *data
, size_t
size
)
H5LTset_attribute_long_long
creates and writes
a numerical attribute named attr_name
and attaches it
to the object specified by the name obj_name
.
The attribute has a dimensionality of 1 and its HDF5 datatype
is H5T_NATIVE_LLONG
.
hid_t loc_id |
Location of the object to which the attribute is to be attached. |
const char *obj_name |
That object’s name. |
const char *attr_name |
Attribute name. |
const long_long *data |
Attribute value. |
size_t size |
Attribute size. |
H5LT
set_attribute_float
creates and writes a numerical floating point attribute named attr_name
and
attaches it to the object specified by the name obj_name
. The attribute has
a dimensionality of 1. The HDF5
datatype of the attribute is H5T_NATIVE_FLOAT.loc_id
obj_name
attr_name
buffer
size
H5Screate_simple
to create the
dataspace.subroutine h5ltset_attribute_float_f(loc_id, dset_name, attr_name, & buf, size, errcode) implicit none integer(HID_T), intent(IN) :: loc_id ! file or group identifier character(LEN=*), intent(IN) :: dset_name ! name of the dataset character(LEN=*), intent(IN) :: attr_name ! name of the attribute real, intent(INOUT), dimension(*) :: buf ! data buffer integer(size_t), intent(in) :: size ! size of attribute array integer :: errcode ! error code end subroutine h5ltset_attribute_float_f
H5LTset_attribute_double
creates and writes a numerical attribute named attr_name
and
attaches it to the object specified by the name obj_name
. The attribute has
a dimensionality of 1. The HDF5
datatype of the attribute is H5T_NATIVE_DOUBLE.loc_id
obj_name
attr_name
buffer
size
H5Screate_simple
to create the
dataspace.subroutine h5ltset_attribute_double_f(loc_id, dset_name, attr_name, & buf, size, errcode ) implicit none integer(HID_T), intent(IN) :: loc_id ! file or group identifier character(LEN=*), intent(IN) :: dset_name ! name of the dataset character(LEN=*), intent(IN) :: attr_name ! name of the attribute integer(size_t), intent(IN) :: size ! size of attribute array integer :: errcode ! error code double precision, intent(INOUT), dimension(*) :: buf ! data buffer end subroutine h5ltset_attribute_double_f
subroutine h5ltset_attribute_f(loc_id, dset_name, attr_name, & buf, buf_type, SizeOf_buf_type, size, errcode ) implicit none integer(HID_T), intent(IN) :: loc_id ! file or group identifier character(LEN=*), intent(IN) :: dset_name ! name of the dataset character(LEN=*), intent(IN) :: attr_name ! name of the attribute type(C_PTR) :: buf ! data buffer character(LEN=*), INTENT(in) :: buf_type ! valid data types are: ! CHARACTER, INTEGER or REAL ! NOTE: only the first character matters and is case insensitive integer(size_t), intent(IN) :: size ! size of attribute array integer(size_t), intent(IN) :: SizeOf_buf_type ! size of buf's data type integer :: errcode ! error code end subroutine h5ltset_attribute_f
H5LT
get_attribute
reads an attribute named attr_name
with the memory type mem_type_id.
loc_id
obj_name
attr_name
mem_type_id
data
subroutine h5ltget_attribute_f(loc_id, dset_name, attr_name, buf, buf_type, SizeOf_buf_type, errcode) implicit none integer(HID_T), intent(IN) :: loc_id ! file or group identifier character(LEN=*), intent(IN) :: dset_name ! name of the dataset character(LEN=*), intent(IN) :: attr_name ! name of the attribute type(C_PTR) :: buf ! data buffer character(LEN=*), INTENT(in) :: buf_type ! valid data types are: ! CHARACTER, INTEGER or REAL ! NOTE: only the first character matters and is case insensitive integer(size_t), INTENT(in) :: SizeOf_buf_type ! size of buf's data type integer :: errcode ! error code end subroutine h5ltget_attribute_f
Release | Change |
1.10.0 |
Added Fortran interface.
|
H5LTget_attribute
reads an attribute named attr_name
that is attached to the object specified by the name obj_name.
loc_id
obj_name
attr_name
data
subroutine h5ltget_attribute_string_f(loc_id, dset_name, attr_name, & buf, errcode) implicit none integer(HID_T), intent(IN) :: loc_id ! file or group identifier character(LEN=*), intent(IN) :: dset_name ! name of the dataset character(LEN=*), intent(IN) :: attr_name ! name of the attribute integer :: errcode ! error code character(LEN=*), intent(INOUT) :: buf ! data buffer end subroutine h5ltget_attribute_string_f
Release | Change |
1.8.9 |
The content of the buffer returned by the Fortran subroutine
has changed in this release:
If the returned buffer requires padding, h5ltget_attribute_string_f now employs space padding;
this buffer was previously returned with a
C NULL terminator.
|
H5LTget_attribute
reads an attribute named attr_name
that is attached to the object specified by the name obj_name.
The HDF5
datatype of the attribute is H5T_NATIVE_CHAR. loc_id
obj_name
attr_name
data
H5LTget_attribute
reads an attribute named attr_name
that is attached to the object specified by the name obj_name.
The HDF5
datatype of the attribute is H5T_NATIVE_SHORT. loc_id
obj_name
attr_name
data
H5LTget_attribute
reads an attribute named attr_name
that is attached to the object specified by the name obj_name.
The HDF5
datatype of the attribute is H5T_NATIVE_INT. loc_id
obj_name
attr_name
data
subroutine h5ltget_attribute_int_f(loc_id, dset_name, attr_name, buf, errcode) implicit none integer(HID_T), intent(IN) :: loc_id ! file or group identifier character(LEN=*), intent(IN) :: dset_name ! name of the dataset character(LEN=*), intent(IN) :: attr_name ! name of the attribute integer :: errcode ! error code integer, intent(INOUT), dimension(*) :: buf ! data buffer end subroutine h5ltget_attribute_int_f
H5LTget_attribute
reads an attribute named attr_name
that is attached to the object specified by the name obj_name.
The HDF5
datatype of the attribute is H5T_NATIVE_LONG. loc_id
obj_name
attr_name
data
H5LTget_attribute_long_long
(hid_t
loc_id
, const char *obj_name
,
const char *attr_name
,
long_long *data
)
H5LTget_attribute_long_long
reads the attribute
specified by loc_id
and obj_name
.
hid_t loc_id |
Location of the object to which the attribute is attached. |
const char *obj_name |
That object's name. |
const char *attr_name |
Attribute name. |
long_long *data |
Attribute value. |
H5LTget_attribute
reads an attribute named attr_name
that is attached to the object specified by the name obj_name.
The HDF5
datatype of the attribute is H5T_NATIVE_FLOAT. loc_id
obj_name
attr_name
data
subroutine h5ltget_attribute_float_f(loc_id, dset_name, attr_name, & buf, errcode) implicit none integer(HID_T), intent(IN) :: loc_id ! file or group identifier character(LEN=*), intent(IN) :: dset_name ! name of the dataset character(LEN=*), intent(IN) :: attr_name ! name of the attribute integer :: errcode ! error code real, intent(INOUT), dimension(*) :: buf ! data buffer end subroutine h5ltget_attribute_float_f
H5LTget_attribute
reads an attribute named attr_name
that is attached to the object specified by the name obj_name.
The HDF5
datatype of the attribute is H5T_NATIVE_DOUBLE. loc_id
obj_name
attr_name
data
subroutine h5ltget_attribute_double_f(loc_id, dset_name, attr_name, & buf, errcode) implicit none integer(HID_T), intent(IN) :: loc_id ! file or group identifier character(LEN=*), intent(IN) :: dset_name ! name of the dataset character(LEN=*), intent(IN) :: attr_name ! name of the attribute integer :: errcode ! error code double precision, intent(INOUT), dimension(*) :: buf ! data buffer end subroutine h5ltget_attribute_double_f
H5LTfind_attribute
determines whether
an attribute named attr_name
exists
attached to the object specified by loc_id
.
loc_id
must be an object identifier and
attr_name
must specify an attribute
that is expected to be attached to that object.
loc_id
attr_name
H5LT
get_attribute_ndims
gets the dimensionality of an attribute named attr_name
that is
attached to the object specified by the name obj_name.
loc_id
obj_name
attr_name
rank
subroutine h5ltget_attribute_ndims_f(loc_id, dset_name, attr_name, & rank, errcode) implicit none integer(HID_T), intent(IN) :: loc_id ! file or group identifier character(LEN=*), intent(IN) :: dset_name ! name of the dataset character(LEN=*), intent(IN) :: attr_name ! name of the attribute integer, intent(INOUT) :: rank ! rank integer :: errcode ! error code integer :: namelen ! name length integer :: attrlen ! name length end subroutine h5ltget_attribute_ndims_f
H5LT
get_attribute_info
gets information about an attribute named attr_name
attached to the object specified by the name obj_name.
loc_id
obj_name
attr_name
dims
type_class
type_size
subroutine h5ltget_attribute_info_f(loc_id, dset_name, attr_name, & dims, type_class, type_size, errcode) implicit none integer(HID_T), intent(IN) :: loc_id ! file or group identifier character(LEN=*), intent(IN) :: dset_name ! name of the dataset character(LEN=*), intent(IN) :: attr_name ! name of the attribute integer(HSIZE_T),dimension(*),intent(INOUT):: dims ! dimensions integer, intent(INOUT) :: type_class ! type class integer(SIZE_T), intent(INOUT) :: type_size ! type size integer :: errcode ! error code end subroutine h5ltget_attribute_info_f
H5LTtext_to_dtype
(
const char *text
, H5LT_lang_t
lang_type
)
lang_type
definition of HDF5 datatypes. Currently,
only the DDL(H5LT_DDL
) is supported. The complete
DDL definition of HDF5 datatypes can be found in the last
chapter of the HDF5 User’s Guide.
An example of DDL definition of enum
type is
shown as follows.
“H5T_ENUM { H5T_NATIVE_INT; “Bob” 0; “Elena” 1; “Quincey” 2; “Frank” 3; }”
const char *str |
IN: A character string containing a DDL definition of the datatype to be created. |
H5LT_lang_t lang_type |
IN: The language used to describe the datatype.
The only currently supported language
is H5LT_DDL . |
H5LTdtype_to_text
(hid_t
datatype
, char* str
,
H5LT_lang_t lang_type
,
size_t* len
)
lang_type
language
format.
A preliminary H5LTdtype_to_text
call can be made
to determine the size of the buffer needed with a NULL
passed in for str
. This value is returned as len
.
That value can then be assigned to len
for a second
H5Ttype_to_text
call, which will retrieve the actual text
description for the datatype.
If len
is not big enough for the description,
the text description will be truncated to fit in the buffer.
Currently only DDL (H5LT_DDL
) is supported for
lang_type
. The complete DDL definition of HDF5 data
types can be found in the last chapter of the HDF5 User’s Guide.
An example of DDL definition of enum
type is shown as follows.
“H5T_ENUM { H5T_NATIVE_INT; “Bob” 0; “Elena” 1; “Quincey” 2; “Frank” 3; }”
hid_t datatype |
IN: Identifier of the datatype to be converted. |
char* str |
OUT: Buffer for the text description of the datatype. |
H5LT_lang_t lang_type |
IN: The language used to describe the datatype.
The currently supported language is H5LT_DDL. |
size_t* len |
OUT: the size of buffer needed to store the text description. |
size_t H5LDget_dset_type_size(
hid_t dset_id,
char *fields
)
hid_t dset_id |
IN: The dataset identifier |
char *fields |
IN: The pointer to a comma-separated list of fields for a compound datatype. |
H5LDget_dset_elmts
for the usage of this routine.
Release | Change |
1.10.0 | C function introduced with this release. |
herr_t H5LDget_dset_dims(
hid_t dset_id,
hsize_t *cur_dims
)
dset_id
through the parameter cur_dims
.
It will return failure if cur_dims
is NULL.hid_t dset_id |
IN: The dataset identifier |
hsize_t *cur_dims
|
OUT: The current dimension sizes of the dataset. |
H5LDget_dset_elmts
for the usage of this routine.
Release | Change |
1.10.0 | C function introduced with this release. |
herr_t H5LDget_dset_elmts(
hid_t dset_id,
hsize_t *prev_dims,
hsize_t *cur_dims,
char *fields,
void *buf
)
dset_id
and stores the data in the parameter buf
.
The difference between the parameters prev_dims
and
cur_dims
indicates the dimension sizes of the data to
be selected from the dataset. Note that cur_dims
must
have at least one dimension whose size is greater than the
corresponding dimension in prev_dims
.
Users can determine the size of buf
by multipling
the datatype size of the dataset by the number of selected
elements.
If the parameter fields
is NULL, this routine returns
data for the selected elements of the dataset.
If fields
is not NULL and the dataset has a compound
datatype, fields
is a string containing a comma-separated
list of fields.
Each name in fields
specifies a field in the compound
datatype, and this routine returns data of the selected fields for the
dataset's selected elements.
Note that ’,’ is the
separator for the fields of a compound datatype while ’.’
is the separator for a nested field. Use backslash to escape characters
in field names that conflict with these two separators.
hid_t dset_id |
IN: The dataset identifier |
hsize_t *prev_dims
|
IN: The previous dimension size of the dataset |
hsize_t *cur_dims |
IN: The current dimension size of the dataset |
char *fields |
IN: A string containing a comma-separated list of fields for a compound datatype. |
void *buf |
OUT: Buffer for storing data retrieved from the dataset |
DSET1
is a two-dimensional
chunked dataset with atomic type defined below:
DATASET "DSET1" { DATATYPE H5T_STD_I32LE DATASPACE SIMPLE { ( 4, 13 ) / ( 60, 100 ) } : : }The following coding sample illustrates the reading of data elements appended to the dataset
DSET1
:
/* open the HDF5 file */ fid = H5Fopen(FILE, H5F_ACC_RDWR, H5P_DEFAULT); /* open the dataset */ did = H5Dopen2(fid, "DSET1", H5P_DEFAULT); : : /* define hsize_t dims[2]; */ /* define hsize_t new_dims[2]; */ /* get the dataset's current dimension sizes */ H5LDget_dset_dims(did, dims); /* extend the dataset by 2 */ new_dims[0] = dims[0] + 2; new_dims[1] = dims[1] + 2; H5Dset_extent(did, new_dims) /* write data to the extended dataset */ : : /* get the size of the dataset's data type */ type_size = H5LDget_dset_type_size(did, NULL); : : /* allocate buffer for storing selected data elements from the dataset */ /* calculate # of selected elements from dims & new_dims */ /* buffer size = type_size * number of selected elements */ : : /* read the selected elements from the dataset into buf */ H5LDget_dset_elmts(did, dims, new_dims, NULL, buf); : : H5Dclose(did); H5Fclose(fid);The output buffer will contain data elements selected from
DSET1
as follows:
data for elements (0, 13), (0, 14) data for elements (1, 13), (1, 14) data for elements (2, 13), (2, 14) data for elements (3, 13), (3, 14) data for elements (4, 0), (4, 1), (4, 2)......................(4, 13), (4, 14) data for elements (5, 0), (5, 1), (5, 2)......................(5, 13), (5, 14)For the second example,
DSET2
is a one-dimensional
chunked dataset with compound type defined below:
DATASET "DSET2" { DATATYPE H5T_COMPOUND { H5T_STD_I32LE "a"; H5T_STD_I32LE "b"; H5T_ARRAY { [4] H5T_STD_I32LE } "c"; H5T_STD_I32LE "d"; H5T_STD_I32LE "e"; H5T_COMPOUND { H5T_STD_I32LE "a"; H5T_STD_I32LE "b"; H5T_ARRAY {[4] H5T_STD_I32LE} "c"; H5T_STD_I32LE "d"; H5T_STD_I32LE "e"; } "s2"; } DATASPACE SIMPLE { ( 5 ) / ( 5 ) } : : }The following coding sample illustrates the reading of data elements appended to the dataset
DSET2
with compound datatype
This example selects only 2 fields: the fourth field d
and a subfield of the sixth field s2.c
:
/* open the HDF5 file */ fid = H5Fopen(FILE, H5F_ACC_RDWR, H5P_DEFAULT); /* open the dataset */ did = H5Dopen2(fid, "DSET2", H5P_DEFAULT); /* define hsize_t dims[1]; */ /* define hsize_t new_dims[1]; */ : : /* get the dataset's current dimension size */ H5LDget_dset_dims(did, dims); /* extend the dataset by 2 */ new_dims[0] = dims[0] + 2; H5Dset_extent(did, new_dims); : : /* write data to the extended part of the dataset */ : : /* #define fields "d,s2.c" */ /* get the size of the dataset's data type for the selected fields */ type_size = H5LDget_dset_type_size(did, fields); : : /* allocate buffer for storing selected data elements from the dataset */ /* calculate # of selected elements from dims & new_dims */ /* buffer size = type_size * number of selected elements */ : : /* read the selected elements from the dataset into buf */ H5LD_get_dset_elmts(did, dims, new_dims, fields, buf); : : H5Dclose(did); H5Fclose(fid);The output buffer will contain data for
d
and
s2.c
selected from DSET2
as follows:
Data for element (5): integer value for "d", 4 integer values for array "s2.c" Data for element (6): integer value for "d", 4 integer values for array "s2.c"
Release | Change |
1.10.0 | C function introduced with this release. |
The HDF Group Help Desk:
Describes HDF5 Release 1.10. |
Copyright by
The HDF Group
and the Board of Trustees of the University of Illinois |