how to read metadata for dataset

Hi,

this is probably a stupid question. I looked at many of the examples and
googled quite a bit but could not figure out the following.
I want to read a dataset from a preexisting hdf5 file. However, to read
i need to use h5dread (if i am correct).
I need to pass in a pointer to a buffer to h5dread.

However, how can i get the size of the dataset such that i can
preallocate that buffer. In all the examples a found they usually write
a dataset and then read it,
however, doing that the buffer is already preallocated (due to it being
written first).

Are there examples that i missed? Am i missing something completely?

thanks
matt

I normally open a dataspace with H5Dget_space, then use the
H5Sget_simple_extent_ndims and H5Sget_simple_extent_dims to get the
dimensionality and dimensions..

This example http://www.hdfgroup.org/ftp/HDF5/examples/examples-by-api/hdf5-examples/1_8/C/H5D/h5ex_d_unlimadd.c
illustrates this.

I think you can also use H5Dget_storage_size directly if you don't
care about the array structure (or if it's 1D) and just want to dump
the data.

-John

Thank you,
it works.

matt

ยทยทยท

On 4/23/2010 10:53 AM, John Kua wrote:

I normally open a dataspace with H5Dget_space, then use the
H5Sget_simple_extent_ndims and H5Sget_simple_extent_dims to get the
dimensionality and dimensions..

This example http://www.hdfgroup.org/ftp/HDF5/examples/examples-by-api/hdf5-examples/1_8/C/H5D/h5ex_d_unlimadd.c
illustrates this.

I think you can also use H5Dget_storage_size directly if you don't
care about the array structure (or if it's 1D) and just want to dump
the data.

-John

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org