Why do I get an error from the HDF5 library when I try to create an HDF5 dataset with one of the dimensions set to 'H5S_UNLIMITED' in MATLAB?
17 views (last 30 days)
Show older comments
MathWorks Support Team
on 7 Nov 2014
Answered: MathWorks Support Team
on 7 Nov 2014
I am trying to create a dataset in the HDF5 format with an unspecified dimension (by using the 'H5S_UNLIMITED' option for one of my dimensions) using the following code:
dims = [60 30 10];
maxdims = {dims(1), dims(2), 'H5S_UNLIMITED'};
spaceID = H5S.create_simple(length(dims),fliplr(dims),fliplr(maxdims));
typeID = H5T.copy ('H5T_NATIVE_DOUBLE');
dset = H5D.create (fid, 'sourceName', typeID, spaceID, 'H5P_DEFAULT');
However, when I try to run this code, I get the following error:
Error using hdf5lib2
The HDF5 library encountered an error and produced the following stack trace information:
H5D_contig_construct extendible contiguous non-external dataset
H5D_create unable to construct layout information
H5O_dset_create unable to create dataset
H5O_obj_create unable to open object
H5L_link_cb unable to create object
H5G_traverse_real traversal operator failed
H5G_traverse internal path traversal failed
H5L_create_real can't insert link
H5L_link_object unable to create new link to object
H5D_create_named unable to create and link to dataset
H5Dcreate1 unable to create dataset
Error in H5D.create (line 59)
id = H5ML.hdf5lib2('H5Dcreate', varargin{:} );
Error in example2 (line 17)
dset = H5D.create (fid, '/psfSourceName', typeID, spaceID, 'H5P_DEFAULT');
How can I resolve this?
Accepted Answer
MathWorks Support Team
on 7 Nov 2014
This error occurs because if 'H5S_UNLIMITED' is specified for one of the dataset dimensions, the dataset must be chunked rather than contiguous. To resolve the error, one can simply define the dataset creation property list to specify that the dataset should be chunked. For the example in the question, this can be done as follows:
dims = [60 30 10];
maxdims = {dims(1), dims(2), 'H5S_UNLIMITED'};
spaceID = H5S.create_simple(length(dims),fliplr(dims),fliplr(maxdims));
typeID = H5T.copy ('H5T_NATIVE_DOUBLE');
dcpl = H5P.create('H5P_DATASET_CREATE');
chunk_dims = [60 30 10];
h5_chunk_dims = fliplr(chunk_dims);
H5P.set_chunk(dcpl,h5_chunk_dims);
dset = H5D.create (fid, 'sourceName', typeID, spaceID, dcpl);
For more information, please consult <http://www.hdfgroup.org/HDF5/doc/RM/RM_H5Front.html the API for the HDF5 library>.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!