/* ############################################################################## # # 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. It then reopens the dataset and creates two region references to hyperslabs with coordinates (2,5)-(4,6) and (0,0)-(2,1). It then creates a new data set composed of data from the hyperslabs referenced by the newly created region references. The newly created dataset is then read and printed to the screen. */ #include "hdf5.h" #include "hdf5_hl.h" #include "h5hl_region.h" #define filename "ex_regref_create.h5" #define dsetname "DS" /* dataset name */ #define DIM0 8 /* dataset dimensions */ #define DIM1 7 #define rank 2 /* dataset rank */ int main(void) { hid_t file_id; /* file identifier */ hsize_t dims[rank] = {DIM0, DIM1}; /* dataset dimensions */ herr_t status; int data[DIM0][DIM1]; /* data */ int i, j; size_t i_size_t; int rdata[6][2]; /* buffer to read the data into */ size_t num_elem; /* number of region references to create */ const char *path[2]; /* paths to the data for the region references */ hsize_t block_coord[8] ={ 2, 5, 4, 6, 0, 0, 2, 1}; /* hyperslab coordinates defining region references */ hdset_reg_ref_t ref[2]; /* region references */ hid_t file_id_array[2]; /* file id of the region references */ num_elem = 2; /********************************************************* This writes data to the HDF5 file. *********************************************************/ path[0] ="/DS"; path[1] ="/DS"; /* * Data initialization. */ printf("FULL 2D DATA:"); for (i=0; i