/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* This example shows how to create, store and read data associated with region references. It creates a file and writes a two dimensional integer dataset to it. Then it creates a region reference to a subset hyperslab region of the data. It then reopens the files, obtains information about the data associated with the region reference, creates an array to store the data, and then reads the hyperslab slab subset of the data and prints it to the screen. Main illustrative functions: H5LRget_region_info, H5LRread_region */ #include #include "hdf5.h" #include "hdf5_hl.h" #define filename "ex_regref_read.h5" #define dsetname "/DS" /* dataset name */ #define dsetname_ref "MY_REF" /* dataset name of region references */ #define DIM0 5 /* dataset dimensions */ #define DIM1 4 #define DIM_REF 1 #define rank 2 /* dataset rank */ #define rank_ref 1 /* region reference rank */ int main(void) { hid_t file_id; /* file identifier */ hid_t space_id_ref; /* region reference dataspace identifier */ hid_t dset_id_ref; /* region reference dataset identifier */ hsize_t dims[rank] = {DIM0, DIM1}; /* dataset dimensions */ hsize_t dims_ref[rank_ref] = {DIM_REF}; /* region reference dimensions */ herr_t status; hdset_reg_ref_t ref[DIM_REF]; /* region references */ int data[DIM0][DIM1]; /* data */ int i, j; size_t nlength; /* size of the buffer to store the path in */ int rank_out; /* the number of dimensions of the dataset pointed by region reference */ hid_t dtype; /* datatype of the dataset pointed by the region reference */ hsize_t *buf; /* contains the description of the region pointed by region reference */ hsize_t rdims[2]; char *name; /* full path that a region reference points to */ size_t numelem; /* number of coordinate blocks or selected elements */ const char *path[1]; /* paths to the data for the region references */ H5S_sel_type sel_type; /* type of selection (hyperslab or point) */ int **rdata; /* buffer to read data into */ size_t size_ref; hsize_t block_coord[4] ={ 1, 1, 3, 2}; /* hyperslab coordinates defining region references */ path[0] = dsetname; /********************************************************* This writes data to the HDF5 file. *********************************************************/ /* * Data initialization. */ printf("FULL 2D ARRAY:"); for (i=0; i