/* ############################################################################## # # Copyright by The HDF Group. # All rights reserved. # # This file is part of the hl_region High-Level HDF5 APIs. The full copyright # notice, including terms governing use, modification, and redistribution, # is contained in the file COPYING, which can be found at the root of the # source code distribution tree and in the documentation directory (doc/html/). # If you do not have access to this file, you may request a copy of # "the hl_region High-Level HDF5 APIs copyright and license statement" from # help@hdfgroup.org. # ############################################################################## */ /* This example creates a file and writes a two dimensional integer dataset to it. Then it creates a region reference to a hyperslab. It then reopens the file, copies data from a dataset (pointed to by a region reference) to a new location and creates a new reference to it. Main illustrative function: H5LRcopy_reference */ #include "hdf5.h" #include "hdf5_hl.h" #include "h5hl_region.h" #define filename "ex_regref_copy_references.h5" #define dsetname "DS" /* dataset name */ #define dsetname_ref "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 */ hsize_t block_coord_dest[4] ={1, 2, 3, 3 }; /*destination hyperslab block coordinates */ herr_t status; size_t numelem_size; /* number of elements in hyperslab */ hdset_reg_ref_t ref[DIM_REF]; /* buffer of region references */ int data[DIM0][DIM1]; /* data */ int i, j; int rdata[DIM0][DIM1]; /* reading buffers */ int rdata2[3][2]; hdset_reg_ref_t ref_new; /* region reference */ hsize_t block_coord[4] ={ 1, 1, 3, 2}; /* hyperslab coordinates defining region references */ const char *path[1]; /* paths to the data for the region references */ path[0] = dsetname; /********************************************************* This writes data to the HDF5 file. *********************************************************/ /* * Data and output buffer initialization. */ printf("FULL 2D DATA:"); for (i=0; i [(%d,%d)-(%d,%d)]", (int)block_coord[0],(int)block_coord[1],(int)block_coord[2],(int)block_coord[3], (int)block_coord_dest[0], (int)block_coord_dest[1],(int)block_coord_dest[2], (int)block_coord_dest[3]); for (i=0; i