In HDF5, a property is a characteristic or feature associated with an HDF5 object (such as a group, dataset, datatype, or file). There are default properties associated with all HDF5 objects, which handle the most common needs. However, these default properties can be modified by use of the Property List interface and function parameters.
The Property List API supports unusual cases when:
There is a programming model for working with property lists in HDF5.
|
H5P_DEFAULT
(C) / H5P_DEFAULT_F
(F90) for
the property list parameter in those file or dataset functions for which
properties can be changed.
The programming model for changing a property list is as follows:
H5Pcreate
(C) / h5pcreate_f
(F90)
This will return a property list identifier.
The pre-defined property types are:
H5Pclose
(C) / h5pclose_f
(F90).H5Fcreate
and is used to control
the file metadata which is maintained in the super block of the file:
hid_t H5Fcreate (const char *name, unsigned flags, hid_t create_id, \ hid_t access_id )Following are properties you can change with the File Creation property list:
H5Pset_userblock
).
H5Pset_sizes
).
H5Pset_sym_k
).
H5Pset_istore_k
).For a complete list of File Creation properties, refer to Chapter 2.7 in the HDF5 User's Guide.
H5Fcreate
, you
would specify H5P_DEFAULT
(C) or H5P_DEFAULT_F
(F90)
for the third parameter. For example (in C):
file_id = H5Fcreate ("file.h5", H5_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);Some defaults are:
User Block Size | 0 |
Byte Size of offsets and lengths used to address objects | Same as sizeof (hsize_t) in the library (normally 8 bytes) |
Size of parameters controlling the symbol table nodes | 16 |
Size of parameters controlling B-trees for indexing chunked datasets | 32 |
fcpl = H5Pcreate (H5P_FILE_CREATE);
H5Pset_userblock
, H5Pset_sizes
, H5Pset_sym_k
, or H5Pset_istore_k
).status = H5Pset_userblock(fcpl, 512);
H5Fcreate
, passing in the identifier of the property
list that was just modified. For example:
file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT);
status = H5Pclose (fcpl);
The following example shows how to modify the File Creation property list to create a file with 64-bit object offsets and lengths. Note that it follows the programming model:
[ C program ]
- h5_filessize.c
[ F90 program ]
- filesetsize.f90
hid_t H5Fcreate (const char *name, unsigned flags, hid_t create_id, \ hid_t access_id ) hid_t H5Fopen(const char *name, unsigned flags, hid_t access_id )Use of File Access property functions can affect performance:
H5Pset_cache
H5Pset_meta_block_size
H5Pset_sieve_buf_size
H5Pset_fclose_degree
H5Fclose
closes objects within a file. The default
property is H5F_CLOSE_WEAK, which indicates that the file is not closed
until all objects in the file are closed.
The File Access property list also can modify the usage of the low-level I/O libraries and physical storage:
The VFL API allows users to design and implement their own mapping between the HDF5 format address space and storage, with each mapping being a separate file driver:
H5Pset_fapl_family
).
H5Pset_fapl_split
).
H5Fcreate
or H5Fopen
, you would specify H5P_DEFAULT
(C)
or H5P_DEFAULT_F
(F90)
for the access_id
parameter. Examples (in C) are:
file_id = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); file_id = H5Fopen (FILE, H5F_ACC_RDWR, H5P_DEFAULT);Default Sizes are:
Metadata and Raw Data Chunk Cache | 4MB, 1MB | Metadata Block Size | 2048 |
Maximum Size of Data Sieve Buffer | 64KB |
File Close Degree | H5F_CLOSE_WEAK (for all, except parallel, which is H5F_CLOSE_SEMI) |
fapl = H5Pcreate (H5P_FILE_ACCESS);
H5Pset_cache
, H5Pset_meta_block_size
, ...).
H5Fcreate
, passing in the identifier of the property
list that was just modified. For example (in C):
file_id = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
status = H5Pclose (fapl);
Following is an example of using the H5P_FILE_ACCESS property list for creating
HDF5 files with the metadata and data split into different files:
[ C program ]
- h5split.c
[ F90 program ]
- dsetsplit.f90
Following is an example of using the H5P_FILE_ACCESS property list to
create a family of files:
[ C program ]
- h5family.c
[ F90 program ]
- dsetfamily.f90
H5Dcreate
(C) / h5dcreate_f
(F90) call.
It is used to control information on how raw data is organized on disk:
hid_t H5Dcreate (hid_t loc_id, const char *name, hid_t type_id, \ hid_t space_id, hid_t create_plist_id )Following is a list of the properties that are affected by the Dataset Creation Property List. They are not mutually exclusive of each other: An explanation of these properties follows:
Following are the storage layouts in HDF5:
External Files:
However, users have to keep track of additional files to preserve the integrity of the HDF5 file:
A feature of external files is that a a dataset can be partitioned into different parts with each of those parts stored in a separate segment of an external file:
The C code to do this might look as follows:
plist = H5Pcreate (H5P_DATASET_CREATE); status = H5Pset_external (plist, "raw_data.ext", 3000, 1000); status = H5Pset_external (plist, "raw_data.ext", 0, 2500); status = H5Pset_external (plist, "raw_data.ext", 4500, 1500);
![]() |
Better subsetting access time; extendible |
![]() |
Only two chunks will be written/read |
There are pre-defined filters in HDF5 for using ZLIB and SZIP compression, as well as for using the shuffling and checksum filters. The H5P interface provides calls to work with these pre-defined filters.
Users can also set up their own user-defined filters, using the H5Z and H5P interfaces. The following is a demonstration of how to do this:
Adding BZIP2 Compression to HDF5General features of filters:
Purpose of the pre-defined filters in HDF5:
Compression |
|
![]() |
Checksum | Includes the Fletcher32 checksum algorithm for error detection. |
![]() |
Shuffling |
Changes the byte order in a stream of data.
Combined with compression, shuffling provides:
|
![]() |
H5Pset_alloc_time
and H5Pget_alloc_time
calls
give control over the space allocation in an HDF5 file.
This is important for both performance and the size of the files.
Sequential space can be allocated:
For Parallel HDF5 this property is ignored. The space is ALWAYS allocated early.
Fill value properties are defined with the H5Pset(get)_fill_value
and H5Pset(get)_fill_time
calls. The fill times that can be
specified with H5Pset(get)_fill_time
are:
How and when the fill value is written depends on the storage layout, allocation time setting and access method (sequential or parallel). See the documentation of fill value behavior for more details.
H5Dcreate
, you would specify
H5P_DEFAULT
(C) or H5P_DEFAULT_F
(F90)
for the create_plist_id
parameter. For example (in C):
did = H5Dcreate(fid, "/dset", H5T_STD_I32BE, dataspace_id, H5P_DEFAULT);
dcpl = H5Pcreate (H5P_DATASET_CREATE);
H5Pset_layout
or
H5Pset_chunk
call. For examples (in C):
Compact Datasets:
status = H5Pset_layout (dcpl, H5D_COMPACT);Chunked Datasets:
status = H5Pset_chunk (dcpl, rank, chunk_dims);Then any other properties would need to be set, using the same property list identifier (
dcpl
, in this case).
H5Dcreate
, passing in the identifier of the property
list that was just modified. For example:
dset_id = H5Dcreate ( file_id, DATASETNAME, H5T_NATIVE_INT, dataspace, dcpl );
status = H5Pclose (dcpl);
H5Pset_external
function. For example (in C):
status = H5Pset_external (dcpl, "raw_data.ext", offset, size);Example Program:
h5_crtextd.c
dsetexternal.f90
Chunked Data:
H5Screate_simple
and by using the H5Dextend
call. Following is an example:
h5_extend.c
chunk.f90
In order to use the pre-defined compression methods you must first have configured and built HDF5 with compression enabled. For example, this will configure and build HDF5 with ZLIB and SZIP compression enabled:
./configure --with-zlib=INCDIR, LIBDIR --with-szlib=INCDIR, LIBDIR make check >& check.out make installOnce HDF5 includes ZLIB or SZIP compression, a compressed dataset can be created with the
H5Pset_deflate
or H5Pset_szip
call.
Following are programming examples:
ZLIB Compression:
[ C program ]
- h5zip.c
[ F90 program ]
- dsetzlib.f90
SZIP Compression:
[ C program ]
- h5szip.c
[ F90 program ]
- dsetszip.f90
H5Pset_filter
call.
See the following example program:
[ C program ]
- h5cksum.c
[ F90 program ]
- dsetcksum.f90
H5Pset_shuffle
must be called, followed by the desired compression call (it will not work
if you set the compression method first).
See the following programming example:
[ C program ]
- h5shzip.c
[ F90 program ]
- dsetshuffle.f90
H5Dread
and H5Dwrite
. It is used to control
various aspects of I/O, such as caching hints or collective I/O information:
herr_t H5Dread (hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, \ hid_t file_space_id, hid_t xfer_plist_id, void * buf ) herr_t H5Dwrite (hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, \ hid_t file_space_id, hid_t xfer_plist_id, const void * buf )This property can be used to improve performance, with the following calls:
H5Pset_buffer
:
H5Pset_hyper_vector_size
:Following are other functions that can modify the Data Access/Transfer properties:
H5Pset_edc_check
:
H5Pset_dxpl_mpio
:H5P_DEFAULT
for C and H5P_DEFAULT_F
for F90,
when calling H5Dread
or H5Dwrite
. Examples in
C are:
status = H5Dwrite (dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_data); status = H5Dread (dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_data);
dtpl = H5Pcreate (H5P_DATASET_XFER);
H5Dread
or H5Dwrite
, passing in the
identifier of the property list that was just modified.
status = H5Pclose (dtpl);
Following is an example of using the Data Access/Transfer property to set the maximum size for the type conversion buffer and background buffer:
plist_xfer = H5Pcreate (H5P_DATASET_XFER); status H5Pset_buffer(plist_xfer, (hsize_t)NX*NY*NZ, NULL, NULL); status = H5Dread (dataset, H5T_NATIVE_UCHAR, memspace, dataspace, plist_xfer);The following example uses the Data Access/Transfer property list with the error detection filter.
h5cksum.c
dsetcksum.f90
The Parallel HDF5 tutorial covers Writing and Reading Hyperslabs which also uses the Data Access/Transfer property list.