[hdf-forum] setting chunk dimensions

Natalie Happenhofer nataliehapp at hotmail.com
Tue Oct 21 04:10:25 EDT 2008


Hi!
I´m trying to write my data via hyperslabs, ad there is also a nice example how to do it on the HDF5.org webpage. I just don´t understand how to set the chunk_dims, or, more precisely, what do this chunking dimensions do?
Here is the part of the example code using the chunk-dims:

nt
main (void)
{
    hid_t       file;                          /* handles */
    hid_t       dataspace, dataset;
    hid_t       filespace;
    hid_t       cparms;
    hsize_t      dims[2]  = { 3, 3};            /*
                         * dataset dimensions
                         * at the creation time
                         */
    hsize_t      dims1[2] = { 3, 3};            /* data1 dimensions */
    hsize_t      dims2[2] = { 7, 1};            /* data2 dimensions */
    

    hsize_t      dims3[2] = { 2, 2};            /* data3 dimensions */

    hsize_t      maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
    hsize_t      chunk_dims[2] ={2, 5};
    hsize_t      size[2];
    hsize_t      offset[2];

    herr_t      status;

    int         data1[3][3] = { {1, 1, 1},       /* data to write */
                {1, 1, 1},
                {1, 1, 1} };

    int         data2[7]    = { 2, 2, 2, 2, 2, 2, 2};

    int         data3[2][2] = { {3, 3},
                {3, 3} };
    int fillvalue = 0;

    /*
     * Create the data space with unlimited dimensions.
     */
    dataspace = H5Screate_simple(RANK, dims, maxdims);

    /*
     * Create a new file. If file exists its contents will be overwritten.
     */
    file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);

    /*
     * Modify dataset creation properties, i.e. enable chunking.
     */
    cparms = H5Pcreate(H5P_DATASET_CREATE);
    status = H5Pset_chunk( cparms, RANK, chunk_dims);
    status = H5Pset_fill_value (cparms, H5T_NATIVE_INT, &fillvalue );

    

chunk_dims is set to {2,5}, which I don´t understand, because the initial dataset is 3x3 and is then extended to 10x3 - why the {2,5}?

thx,
NH


     * Create a new dataset within the file using cparms
     * creation properties.
     */
    dataset = H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT,
            cparms, H5P_DEFAULT);

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.hdfgroup.org/pipermail/hdf-forum_hdfgroup.org/attachments/20081021/cf3d68ff/attachment.html>


More information about the Hdf-forum mailing list