/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ #include "hdf5.h" #define FILE "test.h5" #define RANK 2 int main() { hid_t file_id, dataset_id, dataspace_id, memspace, dapl_id, dcpl_id; /* identifiers */ hsize_t dims[2]; hsize_t dimsext [2] = {1, 100}; hsize_t offset[2]; hsize_t chunk_dims[2]; hsize_t maxdims[2]; hsize_t size[2]; herr_t status; double t[100]; int i; H5PLprepend("plugins"); printf ("Constructing file..."); /* Create a new file using default properties. */ file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Create the data space for the dataset. */ dims[0] = 0; dims[1] = 100; maxdims[0]= H5S_UNLIMITED; maxdims[1]= 100; dataspace_id = H5Screate_simple(RANK, dims, maxdims); dcpl_id = H5Pcreate (H5P_DATASET_CREATE); chunk_dims[0]= 5000; chunk_dims[1]= 4; status = H5Pset_chunk (dcpl_id, RANK, chunk_dims); status = H5Pset_shuffle (dcpl_id); status = H5Pset_filter (dcpl_id, 32004, H5Z_FLAG_OPTIONAL, 0, NULL); dapl_id = H5Pcreate (H5P_DATASET_ACCESS); status = H5Pset_chunk_cache (dapl_id, 102407, 16*1024*1024, H5D_CHUNK_CACHE_W0_DEFAULT); /* Create the dataset. */ dataset_id = H5Dcreate2(file_id, "intensity", H5T_INTEL_F64, dataspace_id, H5P_DEFAULT, dcpl_id, dapl_id); status = H5Sclose (dataspace_id); status = H5Pclose (dapl_id); status = H5Pclose (dcpl_id); for (i=0;i<100;i++) t[i] = i; memspace = H5Screate_simple (RANK, dimsext, NULL); for (i=0;i<200;i++) { size[0] = dims[0] + dimsext[0]; size[1] = dims[1]; status = H5Dset_extent (dataset_id, size); dataspace_id = H5Dget_space (dataset_id); offset[0]= i; offset[1]= 0; status = H5Sselect_hyperslab (dataspace_id, H5S_SELECT_SET, offset, NULL, dimsext, NULL); status = H5Dwrite (dataset_id, H5T_NATIVE_DOUBLE, memspace, dataspace_id, H5P_DEFAULT, t); dims[0] = dims[0] + 1; status = H5Sclose (dataspace_id); } status = H5Sclose(memspace); printf ("done.\n"); printf ("Flushing..."); status = H5Fflush (file_id, H5F_SCOPE_GLOBAL); printf ("done.\n"); printf ("Copying..."); status = H5Ocopy (file_id, "/intensity", file_id, "test", H5P_DEFAULT, H5P_DEFAULT); printf ("done.\n"); printf ("Finalizing..."); status = H5Dclose(dataset_id); status = H5Fclose(file_id); printf ("done.\n"); }