/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 illustrates how to append to a dataset by row */ #include "hdf5.h" #define FILENAME "append_by_row.h5" #define DATASETNAME "IntArray" #define RANK 2 #define DIM0_SUB 1 /* subset dimensions - by row (1x10) */ #define DIM1_SUB 10 #define DIM0 8 /* size of dataset */ #define DIM1 10 int main (void) { hsize_t dims[2], dimsm[2], maxdims[2]={H5S_UNLIMITED, DIM1}; int sdata[DIM0_SUB][DIM1_SUB]; /* subset to write */ hid_t file_id, dataset_id, prop_id, dataspace_id; hid_t memspace_id, filespace_id; herr_t status; hsize_t count[2]={DIM0_SUB, DIM1_SUB}; /* size of subset */ hsize_t offset[2]={0,0}; /* subset offset in the file */ hsize_t stride[2]={1,1}; hsize_t block[2]={1,1}; hsize_t newsize[2]; hsize_t chunk_dims[2]={DIM0_SUB, DIM1_SUB}; int i, j; /***************************************************************** * Create a new file with default creation and access properties.* * Then create a dataset and write data to it and close the file * * and dataset. * *****************************************************************/ file_id = H5Fcreate (FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Create a chunked, unlimited dimension dataset */ prop_id = H5Pcreate (H5P_DATASET_CREATE); status = H5Pset_chunk (prop_id, RANK, chunk_dims); dims[0] = 0; dims[1] = 0; dataspace_id = H5Screate_simple (RANK, dims, maxdims); dataset_id = H5Dcreate2 (file_id, DATASETNAME, H5T_STD_I32BE, dataspace_id, H5P_DEFAULT, prop_id, H5P_DEFAULT); status = H5Pclose (prop_id); status = H5Sclose (dataspace_id); /* Values to write to dataset */ for (i = 0; i < DIM0_SUB; i++) for (j = 0; j