diff options
author | Vailin Choi <vchoi@hdfgroup.org> | 2019-09-26 18:41:56 (GMT) |
---|---|---|
committer | Vailin Choi <vchoi@hdfgroup.org> | 2019-09-26 18:41:56 (GMT) |
commit | 52fef3c6d2b79399caa316cf7f380e61db95ba0e (patch) | |
tree | 674e43393bf837a1ac750a0d9766e948636245d5 /c++ | |
parent | c7b9d5acc69e22c153864e31f7422cd466da0b35 (diff) | |
parent | 0ea77179d507bd2c29f3b9b357a0c35d4077b29c (diff) | |
download | hdf5-52fef3c6d2b79399caa316cf7f380e61db95ba0e.zip hdf5-52fef3c6d2b79399caa316cf7f380e61db95ba0e.tar.gz hdf5-52fef3c6d2b79399caa316cf7f380e61db95ba0e.tar.bz2 |
Merge pull request #21 in ~VCHOI/my_third_fork from develop to bugfix/HDFFV-10585-investigate-slowness-of-regular
* commit '0ea77179d507bd2c29f3b9b357a0c35d4077b29c': (39 commits)
Fix the errors when updating the versions in the new 1.13 develop branch.
add missing version to list
Add new versioned filename to list
Update N_FSINFO_VERSION_BOUNDS to H5F_LIBVER_NBOUND.
Remove file script
Update versioning to next major version
Update develop branch version to 1.13.0 after creation of hdf5_1_12 branch.
Merge Binh-Minh's changes for code improvement to chunk_info.c (PR #1942) to develop branch.
Update to current external file population.
Revert else-if to single line.
Fix missing option and incorrect close
Revert "Moved NDEBUG guards to H5EA_DEBUG in H5EA package."
Revert "Fix for H5EA debug package when built in release mode."
Change print calls to HD-wrapped. Minor formatting tweaks (inc. regressions and in-file style-matching).
Refactor h5repackgentest to have more modular internals, for easier addition of new tests. Update manifest and test script for new hdf5 external-storage .h5 files.
Remove obsolete symbol
small syntax changes
Renamed get/set_time() calls in the tools library to avoid name clash when building static parallel HDF5 w/ static linking to OpenMPI.
Change unused variable to generic form
Whitespace cleanup
...
Diffstat (limited to 'c++')
-rw-r--r-- | c++/examples/chunks.cpp | 338 | ||||
-rw-r--r-- | c++/examples/compound.cpp | 16 | ||||
-rw-r--r-- | c++/examples/create.cpp | 12 | ||||
-rw-r--r-- | c++/examples/extend_ds.cpp | 24 | ||||
-rw-r--r-- | c++/examples/h5group.cpp | 288 | ||||
-rw-r--r-- | c++/examples/h5tutr_cmprss.cpp | 196 | ||||
-rw-r--r-- | c++/examples/h5tutr_crtatt.cpp | 58 | ||||
-rw-r--r-- | c++/examples/h5tutr_crtdat.cpp | 55 | ||||
-rw-r--r-- | c++/examples/h5tutr_crtgrp.cpp | 34 | ||||
-rw-r--r-- | c++/examples/h5tutr_crtgrpar.cpp | 54 | ||||
-rw-r--r-- | c++/examples/h5tutr_crtgrpd.cpp | 136 | ||||
-rw-r--r-- | c++/examples/h5tutr_extend.cpp | 218 | ||||
-rw-r--r-- | c++/examples/h5tutr_rdwt.cpp | 48 | ||||
-rw-r--r-- | c++/examples/h5tutr_subset.cpp | 192 | ||||
-rw-r--r-- | c++/examples/readdata.cpp | 36 | ||||
-rw-r--r-- | c++/examples/writedata.cpp | 518 | ||||
-rw-r--r-- | c++/src/H5FaccProp.cpp | 12 | ||||
-rw-r--r-- | c++/src/cpp_doc_config | 2 |
18 files changed, 1125 insertions, 1112 deletions
diff --git a/c++/examples/chunks.cpp b/c++/examples/chunks.cpp index 142e70f..03e2855 100644 --- a/c++/examples/chunks.cpp +++ b/c++/examples/chunks.cpp @@ -37,194 +37,194 @@ const int RANKC = 1; int main (void) { - hsize_t i, j; + hsize_t i, j; // Try block to detect exceptions raised by any of the calls inside it try { - /* - * Turn off the auto-printing when failure occurs so that we can - * handle the errors appropriately - */ - Exception::dontPrint(); - - /* - * Open the file and the dataset. - */ - H5File file( FILE_NAME, H5F_ACC_RDONLY ); - DataSet dataset = file.openDataSet( DATASET_NAME ); - - /* - * Get filespace for rank and dimension - */ - DataSpace filespace = dataset.getSpace(); - - /* - * Get number of dimensions in the file dataspace - */ - int rank = filespace.getSimpleExtentNdims(); - - /* - * Get and print the dimension sizes of the file dataspace - */ - hsize_t dims[2]; // dataset dimensions - rank = filespace.getSimpleExtentDims( dims ); - cout << "dataset rank = " << rank << ", dimensions " - << (unsigned long)(dims[0]) << " x " - << (unsigned long)(dims[1]) << endl; - - /* - * Define the memory space to read dataset. - */ - DataSpace mspace1(RANK, dims); - - /* - * Read dataset back and display. - */ - int data_out[NX][NY]; // buffer for dataset to be read - dataset.read( data_out, PredType::NATIVE_INT, mspace1, filespace ); - - cout << "\n"; - cout << "Dataset: \n"; - for (j = 0; j < dims[0]; j++) - { - for (i = 0; i < dims[1]; i++) - cout << data_out[j][i] << " "; - cout << endl; - } - - /* - * dataset rank 2, dimensions 10 x 5 - * chunk rank 2, dimensions 2 x 5 - - * Dataset: - * 1 1 1 3 3 - * 1 1 1 3 3 - * 1 1 1 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - */ - - /* - * Read the third column from the dataset. - * First define memory dataspace, then define hyperslab - * and read it into column array. - */ - hsize_t col_dims[1]; - col_dims[0] = 10; - DataSpace mspace2( RANKC, col_dims ); - - /* - * Define the column (hyperslab) to read. - */ - hsize_t offset[2] = { 0, 2 }; - hsize_t count[2] = { 10, 1 }; - int column[10]; // buffer for column to be read - - /* - * Define hyperslab and read. - */ - filespace.selectHyperslab( H5S_SELECT_SET, count, offset ); - dataset.read( column, PredType::NATIVE_INT, mspace2, filespace ); - - cout << endl; - cout << "Third column: " << endl; - for (i = 0; i < 10; i++) - cout << column[i] << endl; - - /* - * Third column: - * 1 - * 1 - * 1 - * 0 - * 0 - * 0 - * 0 - * 0 - * 0 - * 0 - */ - - /* - * Get creation properties list. - */ - DSetCreatPropList cparms = dataset.getCreatePlist(); - - /* - * Check if dataset is chunked. - */ - hsize_t chunk_dims[2]; - int rank_chunk; - if( H5D_CHUNKED == cparms.getLayout() ) - { - /* - * Get chunking information: rank and dimensions - */ - rank_chunk = cparms.getChunk( 2, chunk_dims); - cout << "chunk rank " << rank_chunk << "dimensions " - << (unsigned long)(chunk_dims[0]) << " x " - << (unsigned long)(chunk_dims[1]) << endl; - - /* - * Define the memory space to read a chunk. - */ - DataSpace mspace3( rank_chunk, chunk_dims ); - - /* - * Define chunk in the file (hyperslab) to read. - */ - offset[0] = 2; - offset[1] = 0; - count[0] = chunk_dims[0]; - count[1] = chunk_dims[1]; - filespace.selectHyperslab( H5S_SELECT_SET, count, offset ); - - /* - * Read chunk back and display. - */ - int chunk_out[2][5]; // buffer for chunk to be read - dataset.read( chunk_out, PredType::NATIVE_INT, mspace3, filespace ); - cout << endl; - cout << "Chunk:" << endl; - for (j = 0; j < chunk_dims[0]; j++) - { - for (i = 0; i < chunk_dims[1]; i++) - cout << chunk_out[j][i] << " "; - cout << endl; - } - /* - * Chunk: - * 1 1 1 0 0 - * 2 0 0 0 0 - */ - } + /* + * Turn off the auto-printing when failure occurs so that we can + * handle the errors appropriately + */ + Exception::dontPrint(); + + /* + * Open the file and the dataset. + */ + H5File file( FILE_NAME, H5F_ACC_RDONLY ); + DataSet dataset = file.openDataSet( DATASET_NAME ); + + /* + * Get filespace for rank and dimension + */ + DataSpace filespace = dataset.getSpace(); + + /* + * Get number of dimensions in the file dataspace + */ + int rank = filespace.getSimpleExtentNdims(); + + /* + * Get and print the dimension sizes of the file dataspace + */ + hsize_t dims[2]; // dataset dimensions + rank = filespace.getSimpleExtentDims( dims ); + cout << "dataset rank = " << rank << ", dimensions " + << (unsigned long)(dims[0]) << " x " + << (unsigned long)(dims[1]) << endl; + + /* + * Define the memory space to read dataset. + */ + DataSpace mspace1(RANK, dims); + + /* + * Read dataset back and display. + */ + int data_out[NX][NY]; // buffer for dataset to be read + dataset.read( data_out, PredType::NATIVE_INT, mspace1, filespace ); + + cout << "\n"; + cout << "Dataset: \n"; + for (j = 0; j < dims[0]; j++) + { + for (i = 0; i < dims[1]; i++) + cout << data_out[j][i] << " "; + cout << endl; + } + + /* + * dataset rank 2, dimensions 10 x 5 + * chunk rank 2, dimensions 2 x 5 + + * Dataset: + * 1 1 1 3 3 + * 1 1 1 3 3 + * 1 1 1 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + */ + + /* + * Read the third column from the dataset. + * First define memory dataspace, then define hyperslab + * and read it into column array. + */ + hsize_t col_dims[1]; + col_dims[0] = 10; + DataSpace mspace2( RANKC, col_dims ); + + /* + * Define the column (hyperslab) to read. + */ + hsize_t offset[2] = { 0, 2 }; + hsize_t count[2] = { 10, 1 }; + int column[10]; // buffer for column to be read + + /* + * Define hyperslab and read. + */ + filespace.selectHyperslab( H5S_SELECT_SET, count, offset ); + dataset.read( column, PredType::NATIVE_INT, mspace2, filespace ); + + cout << endl; + cout << "Third column: " << endl; + for (i = 0; i < 10; i++) + cout << column[i] << endl; + + /* + * Third column: + * 1 + * 1 + * 1 + * 0 + * 0 + * 0 + * 0 + * 0 + * 0 + * 0 + */ + + /* + * Get creation properties list. + */ + DSetCreatPropList cparms = dataset.getCreatePlist(); + + /* + * Check if dataset is chunked. + */ + hsize_t chunk_dims[2]; + int rank_chunk; + if( H5D_CHUNKED == cparms.getLayout() ) + { + /* + * Get chunking information: rank and dimensions + */ + rank_chunk = cparms.getChunk( 2, chunk_dims); + cout << "chunk rank " << rank_chunk << "dimensions " + << (unsigned long)(chunk_dims[0]) << " x " + << (unsigned long)(chunk_dims[1]) << endl; + + /* + * Define the memory space to read a chunk. + */ + DataSpace mspace3( rank_chunk, chunk_dims ); + + /* + * Define chunk in the file (hyperslab) to read. + */ + offset[0] = 2; + offset[1] = 0; + count[0] = chunk_dims[0]; + count[1] = chunk_dims[1]; + filespace.selectHyperslab( H5S_SELECT_SET, count, offset ); + + /* + * Read chunk back and display. + */ + int chunk_out[2][5]; // buffer for chunk to be read + dataset.read( chunk_out, PredType::NATIVE_INT, mspace3, filespace ); + cout << endl; + cout << "Chunk:" << endl; + for (j = 0; j < chunk_dims[0]; j++) + { + for (i = 0; i < chunk_dims[1]; i++) + cout << chunk_out[j][i] << " "; + cout << endl; + } + /* + * Chunk: + * 1 1 1 0 0 + * 2 0 0 0 0 + */ + } } // end of try block // catch failure caused by the H5File operations catch( FileIException error ) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } // catch failure caused by the DataSet operations catch( DataSetIException error ) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } // catch failure caused by the DataSpace operations catch( DataSpaceIException error ) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } return 0; } diff --git a/c++/examples/compound.cpp b/c++/examples/compound.cpp index 192a1cf..4b116e0 100644 --- a/c++/examples/compound.cpp +++ b/c++/examples/compound.cpp @@ -41,15 +41,15 @@ int main(void) { /* First structure and dataset*/ typedef struct s1_t { - int a; - float b; - double c; + int a; + float b; + double c; } s1_t; /* Second structure (subset of s1_t) and dataset*/ typedef struct s2_t { - double c; - int a; + double c; + int a; } s2_t; // Try block to detect exceptions raised by any of the calls inside it @@ -135,12 +135,12 @@ int main(void) */ cout << endl << "Field c : " << endl; for( i = 0; i < LENGTH; i++) - cout << s2[i].c << " "; + cout << s2[i].c << " "; cout << endl; cout << endl << "Field a : " << endl; for( i = 0; i < LENGTH; i++) - cout << s2[i].a << " "; + cout << s2[i].a << " "; cout << endl; /* @@ -161,7 +161,7 @@ int main(void) */ cout << endl << "Field b : " << endl; for( i = 0; i < LENGTH; i++) - cout << s3[i] << " "; + cout << s3[i] << " "; cout << endl; /* diff --git a/c++/examples/create.cpp b/c++/examples/create.cpp index 890fb03..06b981b 100644 --- a/c++/examples/create.cpp +++ b/c++/examples/create.cpp @@ -25,11 +25,11 @@ #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME( "SDS.h5" ); -const H5std_string DATASET_NAME( "IntArray" ); -const int NX = 5; // dataset dimensions -const int NY = 6; -const int RANK = 2; +const H5std_string FILE_NAME( "SDS.h5" ); +const H5std_string DATASET_NAME( "IntArray" ); +const int NX = 5; // dataset dimensions +const int NY = 6; +const int RANK = 2; int main (void) { @@ -41,7 +41,7 @@ int main (void) for (j = 0; j < NX; j++) { for (i = 0; i < NY; i++) - data[j][i] = i + j; + data[j][i] = i + j; } /* * 0 1 2 3 4 5 diff --git a/c++/examples/extend_ds.cpp b/c++/examples/extend_ds.cpp index 271100e..9e005c6 100644 --- a/c++/examples/extend_ds.cpp +++ b/c++/examples/extend_ds.cpp @@ -105,8 +105,8 @@ int main (void) * Write the data to the hyperslab. */ int data1[3][3] = { {1, 1, 1}, /* data to write */ - {1, 1, 1}, - {1, 1, 1} }; + {1, 1, 1}, + {1, 1, 1} }; dataset.write( data1, PredType::NATIVE_INT, mspace1, fspace1 ); /* @@ -179,16 +179,16 @@ int main (void) /* * Resulting dataset * - * 1 1 1 3 3 - * 1 1 1 3 3 - * 1 1 1 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 + * 1 1 1 3 3 + * 1 1 1 3 3 + * 1 1 1 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 */ /* * Display the result. diff --git a/c++/examples/h5group.cpp b/c++/examples/h5group.cpp index a8c9953..fab54cd 100644 --- a/c++/examples/h5group.cpp +++ b/c++/examples/h5group.cpp @@ -33,7 +33,7 @@ using std::endl; using namespace H5; const H5std_string FILE_NAME( "Group.h5" ); -const int RANK = 2; +const int RANK = 2; // Operator function extern "C" herr_t file_info(hid_t loc_id, const char *name, const H5L_info_t *linfo, @@ -48,169 +48,169 @@ int main(void) // Try block to detect exceptions raised by any of the calls inside it try { - /* - * Turn off the auto-printing when failure occurs so that we can - * handle the errors appropriately - */ - Exception::dontPrint(); - - /* - * Create the named file, truncating the existing one if any, - * using default create and access property lists. - */ - H5File *file = new H5File( FILE_NAME, H5F_ACC_TRUNC ); - - /* - * Create a group in the file - */ - Group* group = new Group( file->createGroup( "/Data" )); - - /* - * Create dataset "Compressed Data" in the group using absolute - * name. Dataset creation property list is modified to use - * GZIP compression with the compression effort set to 6. - * Note that compression can be used only when dataset is chunked. - */ - dims[0] = 1000; - dims[1] = 20; - cdims[0] = 20; - cdims[1] = 20; - DataSpace *dataspace = new DataSpace(RANK, dims); // create new dspace - DSetCreatPropList ds_creatplist; // create dataset creation prop list - ds_creatplist.setChunk( 2, cdims ); // then modify it for compression - ds_creatplist.setDeflate( 6 ); - - /* - * Create the first dataset. - */ - DataSet* dataset = new DataSet(file->createDataSet( - "/Data/Compressed_Data", PredType::NATIVE_INT, - *dataspace, ds_creatplist )); - - /* - * Close the first dataset. - */ - delete dataset; - delete dataspace; - - /* - * Create the second dataset. - */ - dims[0] = 500; - dims[1] = 20; - dataspace = new DataSpace(RANK, dims); // create second dspace - dataset = new DataSet(file->createDataSet("/Data/Float_Data", - PredType::NATIVE_FLOAT, *dataspace)); - - delete dataset; - delete dataspace; - delete group; - delete file; - - /* - * Now reopen the file and group in the file. - */ - file = new H5File(FILE_NAME, H5F_ACC_RDWR); - group = new Group(file->openGroup("Data")); - - /* - * Access "Compressed_Data" dataset in the group. - */ - try { // to determine if the dataset exists in the group - dataset = new DataSet( group->openDataSet( "Compressed_Data" )); - } - catch( GroupIException not_found_error ) { - cout << " Dataset is not found." << endl; - } - cout << "dataset \"/Data/Compressed_Data\" is open" << endl; - - /* - * Close the dataset. - */ - delete dataset; - - /* - * Create hard link to the Data group. - */ - file->link( H5L_TYPE_HARD, "Data", "Data_new" ); - - /* - * We can access "Compressed_Data" dataset using created - * hard link "Data_new". - */ - try { // to determine if the dataset exists in the file - dataset = new DataSet(file->openDataSet( "/Data_new/Compressed_Data" )); - } - catch( FileIException not_found_error ) - { - cout << " Dataset is not found." << endl; - } - cout << "dataset \"/Data_new/Compressed_Data\" is open" << endl; - - /* - * Close the dataset. - */ - delete dataset; - - /* - * Use iterator to see the names of the objects in the file - * root directory. - */ - cout << endl << "Iterating over elements in the file" << endl; - herr_t idx = H5Literate(file->getId(), H5_INDEX_NAME, H5_ITER_INC, NULL, file_info, NULL); - cout << endl; - - /* - * Unlink name "Data" and use iterator to see the names - * of the objects in the file root direvtory. - */ - cout << "Unlinking..." << endl; - try { // attempt to unlink the dataset - file->unlink( "Data" ); - } - catch( FileIException unlink_error ) - { - cout << " unlink failed." << endl; - } - cout << "\"Data\" is unlinked" << endl; - - cout << endl << "Iterating over elements in the file again" << endl; - idx = H5Literate(file->getId(), H5_INDEX_NAME, H5_ITER_INC, NULL, file_info, NULL); - cout << endl; - - /* - * Close the group and file. - */ - delete group; - delete file; + /* + * Turn off the auto-printing when failure occurs so that we can + * handle the errors appropriately + */ + Exception::dontPrint(); + + /* + * Create the named file, truncating the existing one if any, + * using default create and access property lists. + */ + H5File *file = new H5File( FILE_NAME, H5F_ACC_TRUNC ); + + /* + * Create a group in the file + */ + Group* group = new Group( file->createGroup( "/Data" )); + + /* + * Create dataset "Compressed Data" in the group using absolute + * name. Dataset creation property list is modified to use + * GZIP compression with the compression effort set to 6. + * Note that compression can be used only when dataset is chunked. + */ + dims[0] = 1000; + dims[1] = 20; + cdims[0] = 20; + cdims[1] = 20; + DataSpace *dataspace = new DataSpace(RANK, dims); // create new dspace + DSetCreatPropList ds_creatplist; // create dataset creation prop list + ds_creatplist.setChunk( 2, cdims ); // then modify it for compression + ds_creatplist.setDeflate( 6 ); + + /* + * Create the first dataset. + */ + DataSet* dataset = new DataSet(file->createDataSet( + "/Data/Compressed_Data", PredType::NATIVE_INT, + *dataspace, ds_creatplist )); + + /* + * Close the first dataset. + */ + delete dataset; + delete dataspace; + + /* + * Create the second dataset. + */ + dims[0] = 500; + dims[1] = 20; + dataspace = new DataSpace(RANK, dims); // create second dspace + dataset = new DataSet(file->createDataSet("/Data/Float_Data", + PredType::NATIVE_FLOAT, *dataspace)); + + delete dataset; + delete dataspace; + delete group; + delete file; + + /* + * Now reopen the file and group in the file. + */ + file = new H5File(FILE_NAME, H5F_ACC_RDWR); + group = new Group(file->openGroup("Data")); + + /* + * Access "Compressed_Data" dataset in the group. + */ + try { // to determine if the dataset exists in the group + dataset = new DataSet( group->openDataSet( "Compressed_Data" )); + } + catch( GroupIException not_found_error ) { + cout << " Dataset is not found." << endl; + } + cout << "dataset \"/Data/Compressed_Data\" is open" << endl; + + /* + * Close the dataset. + */ + delete dataset; + + /* + * Create hard link to the Data group. + */ + file->link( H5L_TYPE_HARD, "Data", "Data_new" ); + + /* + * We can access "Compressed_Data" dataset using created + * hard link "Data_new". + */ + try { // to determine if the dataset exists in the file + dataset = new DataSet(file->openDataSet( "/Data_new/Compressed_Data" )); + } + catch( FileIException not_found_error ) + { + cout << " Dataset is not found." << endl; + } + cout << "dataset \"/Data_new/Compressed_Data\" is open" << endl; + + /* + * Close the dataset. + */ + delete dataset; + + /* + * Use iterator to see the names of the objects in the file + * root directory. + */ + cout << endl << "Iterating over elements in the file" << endl; + herr_t idx = H5Literate(file->getId(), H5_INDEX_NAME, H5_ITER_INC, NULL, file_info, NULL); + cout << endl; + + /* + * Unlink name "Data" and use iterator to see the names + * of the objects in the file root direvtory. + */ + cout << "Unlinking..." << endl; + try { // attempt to unlink the dataset + file->unlink( "Data" ); + } + catch( FileIException unlink_error ) + { + cout << " unlink failed." << endl; + } + cout << "\"Data\" is unlinked" << endl; + + cout << endl << "Iterating over elements in the file again" << endl; + idx = H5Literate(file->getId(), H5_INDEX_NAME, H5_ITER_INC, NULL, file_info, NULL); + cout << endl; + + /* + * Close the group and file. + */ + delete group; + delete file; } // end of try block // catch failure caused by the H5File operations catch( FileIException error ) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } // catch failure caused by the DataSet operations catch( DataSetIException error ) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } // catch failure caused by the DataSpace operations catch( DataSpaceIException error ) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } // catch failure caused by the Attribute operations catch( AttributeIException error ) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } return 0; } diff --git a/c++/examples/h5tutr_cmprss.cpp b/c++/examples/h5tutr_cmprss.cpp index 9b1d2bc..9531bdd 100644 --- a/c++/examples/h5tutr_cmprss.cpp +++ b/c++/examples/h5tutr_cmprss.cpp @@ -1,8 +1,8 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * + * 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 COPYING file, which can be found at the root of the source code * @@ -24,130 +24,130 @@ using std::endl; #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME("h5tutr_cmprss.h5"); -const H5std_string DATASET_NAME("Compressed_Data"); -const int DIM0 = 100; -const int DIM1 = 20; +const H5std_string FILE_NAME("h5tutr_cmprss.h5"); +const H5std_string DATASET_NAME("Compressed_Data"); +const int DIM0 = 100; +const int DIM1 = 20; int main (void) { - hsize_t dims[2] = { DIM0, DIM1 }; // dataset dimensions - hsize_t chunk_dims[2] = { 20, 20 }; // chunk dimensions + hsize_t dims[2] = { DIM0, DIM1 }; // dataset dimensions + hsize_t chunk_dims[2] = { 20, 20 }; // chunk dimensions int i,j, buf[DIM0][DIM1]; // Try block to detect exceptions raised by any of the calls inside it try { - // Turn off the auto-printing when failure occurs so that we can - // handle the errors appropriately - Exception::dontPrint(); + // Turn off the auto-printing when failure occurs so that we can + // handle the errors appropriately + Exception::dontPrint(); - // Create a new file using the default property lists. - H5File file(FILE_NAME, H5F_ACC_TRUNC); + // Create a new file using the default property lists. + H5File file(FILE_NAME, H5F_ACC_TRUNC); - // Create the data space for the dataset. - DataSpace *dataspace = new DataSpace(2, dims); + // Create the data space for the dataset. + DataSpace *dataspace = new DataSpace(2, dims); - // Modify dataset creation property to enable chunking - DSetCreatPropList *plist = new DSetCreatPropList; - plist->setChunk(2, chunk_dims); + // Modify dataset creation property to enable chunking + DSetCreatPropList *plist = new DSetCreatPropList; + plist->setChunk(2, chunk_dims); - // Set ZLIB (DEFLATE) Compression using level 6. - // To use SZIP compression comment out this line. - plist->setDeflate(6); + // Set ZLIB (DEFLATE) Compression using level 6. + // To use SZIP compression comment out this line. + plist->setDeflate(6); - // Uncomment these lines to set SZIP Compression - // unsigned szip_options_mask = H5_SZIP_NN_OPTION_MASK; - // unsigned szip_pixels_per_block = 16; - // plist->setSzip(szip_options_mask, szip_pixels_per_block); + // Uncomment these lines to set SZIP Compression + // unsigned szip_options_mask = H5_SZIP_NN_OPTION_MASK; + // unsigned szip_pixels_per_block = 16; + // plist->setSzip(szip_options_mask, szip_pixels_per_block); - // Create the dataset. - DataSet *dataset = new DataSet(file.createDataSet( DATASET_NAME, - PredType::STD_I32BE, *dataspace, *plist) ); - - for (i = 0; i< DIM0; i++) - for (j=0; j<DIM1; j++) - buf[i][j] = i+j; - - // Write data to dataset. - dataset->write(buf, PredType::NATIVE_INT); - - // Close objects and file. Either approach will close the HDF5 item. - delete dataspace; - delete dataset; - delete plist; - file.close(); - - // ----------------------------------------------- - // Re-open the file and dataset, retrieve filter - // information for dataset and read the data back. - // ----------------------------------------------- - - int rbuf[DIM0][DIM1]; - int numfilt; - size_t nelmts={1}, namelen={1}; - unsigned flags, filter_info, cd_values[1], idx; - char name[1]; - H5Z_filter_t filter_type; - - // Open the file and the dataset in the file. - file.openFile(FILE_NAME, H5F_ACC_RDONLY); - dataset = new DataSet(file.openDataSet( DATASET_NAME)); - - // Get the create property list of the dataset. - plist = new DSetCreatPropList(dataset->getCreatePlist ()); - - // Get the number of filters associated with the dataset. - numfilt = plist->getNfilters(); - cout << "Number of filters associated with dataset: " << numfilt << endl; - - for (idx=0; idx < numfilt; idx++) { - nelmts = 0; - - filter_type = plist->getFilter(idx, flags, nelmts, cd_values, namelen, name , filter_info); - - cout << "Filter Type: "; - - switch (filter_type) { - case H5Z_FILTER_DEFLATE: - cout << "H5Z_FILTER_DEFLATE" << endl; - break; - case H5Z_FILTER_SZIP: - cout << "H5Z_FILTER_SZIP" << endl; - break; - default: - cout << "Other filter type included." << endl; - } - } - - // Read data. - dataset->read(rbuf, PredType::NATIVE_INT); - - delete plist; - delete dataset; - file.close(); // can be skipped + // Create the dataset. + DataSet *dataset = new DataSet(file.createDataSet( DATASET_NAME, + PredType::STD_I32BE, *dataspace, *plist) ); + + for (i = 0; i< DIM0; i++) + for (j=0; j<DIM1; j++) + buf[i][j] = i+j; + + // Write data to dataset. + dataset->write(buf, PredType::NATIVE_INT); + + // Close objects and file. Either approach will close the HDF5 item. + delete dataspace; + delete dataset; + delete plist; + file.close(); + + // ----------------------------------------------- + // Re-open the file and dataset, retrieve filter + // information for dataset and read the data back. + // ----------------------------------------------- + + int rbuf[DIM0][DIM1]; + int numfilt; + size_t nelmts={1}, namelen={1}; + unsigned flags, filter_info, cd_values[1], idx; + char name[1]; + H5Z_filter_t filter_type; + + // Open the file and the dataset in the file. + file.openFile(FILE_NAME, H5F_ACC_RDONLY); + dataset = new DataSet(file.openDataSet( DATASET_NAME)); + + // Get the create property list of the dataset. + plist = new DSetCreatPropList(dataset->getCreatePlist ()); + + // Get the number of filters associated with the dataset. + numfilt = plist->getNfilters(); + cout << "Number of filters associated with dataset: " << numfilt << endl; + + for (idx=0; idx < numfilt; idx++) { + nelmts = 0; + + filter_type = plist->getFilter(idx, flags, nelmts, cd_values, namelen, name , filter_info); + + cout << "Filter Type: "; + + switch (filter_type) { + case H5Z_FILTER_DEFLATE: + cout << "H5Z_FILTER_DEFLATE" << endl; + break; + case H5Z_FILTER_SZIP: + cout << "H5Z_FILTER_SZIP" << endl; + break; + default: + cout << "Other filter type included." << endl; + } + } + + // Read data. + dataset->read(rbuf, PredType::NATIVE_INT); + + delete plist; + delete dataset; + file.close(); // can be skipped } // end of try block // catch failure caused by the H5File operations catch(FileIException error) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } // catch failure caused by the DataSet operations catch(DataSetIException error) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } // catch failure caused by the DataSpace operations catch(DataSpaceIException error) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } return 0; // successfully terminated diff --git a/c++/examples/h5tutr_crtatt.cpp b/c++/examples/h5tutr_crtatt.cpp index f865501..fcf6c27 100644 --- a/c++/examples/h5tutr_crtatt.cpp +++ b/c++/examples/h5tutr_crtatt.cpp @@ -1,8 +1,8 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * + * 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 COPYING file, which can be found at the root of the source code * @@ -21,11 +21,11 @@ #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME( "h5tutr_dset.h5" ); -const H5std_string DATASET_NAME( "dset" ); -const H5std_string ATTR_NAME( "Units" ); +const H5std_string FILE_NAME( "h5tutr_dset.h5" ); +const H5std_string DATASET_NAME( "dset" ); +const H5std_string ATTR_NAME( "Units" ); -const int DIM1 = 2; +const int DIM1 = 2; int main (void) { @@ -36,52 +36,52 @@ int main (void) // Try block to detect exceptions raised by any of the calls inside it try { - // Turn off the auto-printing when failure occurs so that we can - // handle the errors appropriately - Exception::dontPrint(); + // Turn off the auto-printing when failure occurs so that we can + // handle the errors appropriately + Exception::dontPrint(); - // Open an existing file and dataset. - H5File file( FILE_NAME, H5F_ACC_RDWR ); - DataSet dataset = file.openDataSet( DATASET_NAME ); + // Open an existing file and dataset. + H5File file( FILE_NAME, H5F_ACC_RDWR ); + DataSet dataset = file.openDataSet( DATASET_NAME ); - // Create the data space for the attribute. - DataSpace attr_dataspace = DataSpace (1, dims ); + // Create the data space for the attribute. + DataSpace attr_dataspace = DataSpace (1, dims ); - // Create a dataset attribute. - Attribute attribute = dataset.createAttribute( ATTR_NAME, PredType::STD_I32BE, - attr_dataspace); + // Create a dataset attribute. + Attribute attribute = dataset.createAttribute( ATTR_NAME, PredType::STD_I32BE, + attr_dataspace); - // Write the attribute data. - attribute.write( PredType::NATIVE_INT, attr_data); + // Write the attribute data. + attribute.write( PredType::NATIVE_INT, attr_data); } // end of try block // catch failure caused by the H5File operations catch( DataSpaceIException error ) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } // catch failure caused by the H5File operations catch( AttributeIException error ) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } // catch failure caused by the H5File operations catch( FileIException error ) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } // catch failure caused by the DataSet operations catch( DataSetIException error ) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } return 0; // successfully terminated diff --git a/c++/examples/h5tutr_crtdat.cpp b/c++/examples/h5tutr_crtdat.cpp index 7cd49f8..985f6ac 100644 --- a/c++/examples/h5tutr_crtdat.cpp +++ b/c++/examples/h5tutr_crtdat.cpp @@ -1,8 +1,8 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * + * 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 COPYING file, which can be found at the root of the source code * @@ -18,57 +18,58 @@ #include <iostream> #include <string> + #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME("h5tutr_dset.h5"); -const H5std_string DATASET_NAME("dset"); -const int NX = 4; // dataset dimensions -const int NY = 6; -const int RANK = 2; +const H5std_string FILE_NAME("h5tutr_dset.h5"); +const H5std_string DATASET_NAME("dset"); +const int NX = 4; // dataset dimensions +const int NY = 6; +const int RANK = 2; int main (void) { // Try block to detect exceptions raised by any of the calls inside it try { - // Turn off the auto-printing when failure occurs so that we can - // handle the errors appropriately - Exception::dontPrint(); + // Turn off the auto-printing when failure occurs so that we can + // handle the errors appropriately + Exception::dontPrint(); - // Create a new file using the default property lists. - H5File file(FILE_NAME, H5F_ACC_TRUNC); + // Create a new file using the default property lists. + H5File file(FILE_NAME, H5F_ACC_TRUNC); - // Create the data space for the dataset. - hsize_t dims[2]; // dataset dimensions - dims[0] = NX; - dims[1] = NY; - DataSpace dataspace(RANK, dims); + // Create the data space for the dataset. + hsize_t dims[2]; // dataset dimensions + dims[0] = NX; + dims[1] = NY; + DataSpace dataspace(RANK, dims); - // Create the dataset. - DataSet dataset = file.createDataSet(DATASET_NAME, PredType::STD_I32BE, dataspace); + // Create the dataset. + DataSet dataset = file.createDataSet(DATASET_NAME, PredType::STD_I32BE, dataspace); } // end of try block // catch failure caused by the H5File operations catch(FileIException error) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } // catch failure caused by the DataSet operations catch(DataSetIException error) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } // catch failure caused by the DataSpace operations catch(DataSpaceIException error) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } return 0; // successfully terminated diff --git a/c++/examples/h5tutr_crtgrp.cpp b/c++/examples/h5tutr_crtgrp.cpp index 4bdb02c..e35cb46 100644 --- a/c++/examples/h5tutr_crtgrp.cpp +++ b/c++/examples/h5tutr_crtgrp.cpp @@ -1,8 +1,8 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * + * 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 COPYING file, which can be found at the root of the source code * @@ -31,31 +31,31 @@ int main(void) // Try block to detect exceptions raised by any of the calls inside it try { - // Turn off the auto-printing when failure occurs so that we can - // handle the errors appropriately - Exception::dontPrint(); + // Turn off the auto-printing when failure occurs so that we can + // handle the errors appropriately + Exception::dontPrint(); - // Create a new file using default property lists. - H5File file(FILE_NAME, H5F_ACC_TRUNC); - - // Create a group named "/MygGroup" in the file - Group group(file.createGroup("/MyGroup")); + // Create a new file using default property lists. + H5File file(FILE_NAME, H5F_ACC_TRUNC); + + // Create a group named "/MygGroup" in the file + Group group(file.createGroup("/MyGroup")); - // File and group will be closed as their instances go out of scope. + // File and group will be closed as their instances go out of scope. } // end of try block // catch failure caused by the H5File operations catch(FileIException error) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } // catch failure caused by the Group operations catch(GroupIException error) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } return 0; diff --git a/c++/examples/h5tutr_crtgrpar.cpp b/c++/examples/h5tutr_crtgrpar.cpp index 3e175d6..76ec9e5 100644 --- a/c++/examples/h5tutr_crtgrpar.cpp +++ b/c++/examples/h5tutr_crtgrpar.cpp @@ -1,8 +1,8 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * + * 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 COPYING file, which can be found at the root of the source code * @@ -33,50 +33,50 @@ int main(void) try { - // Turn off the auto-printing when failure occurs so that we can - // handle the errors appropriately. + // Turn off the auto-printing when failure occurs so that we can + // handle the errors appropriately. - Exception::dontPrint(); + Exception::dontPrint(); - // Create a new file using default properties. + // Create a new file using default properties. - H5File file(FILE_NAME, H5F_ACC_TRUNC); + H5File file(FILE_NAME, H5F_ACC_TRUNC); - // Create group "MyGroup" in the root group using an absolute name. - - Group group1(file.createGroup( "/MyGroup")); + // Create group "MyGroup" in the root group using an absolute name. + + Group group1(file.createGroup( "/MyGroup")); - // Create group "Group_A" in group "MyGroup" using an - // absolute name. + // Create group "Group_A" in group "MyGroup" using an + // absolute name. - Group group2(file.createGroup("/MyGroup/Group_A")); + Group group2(file.createGroup("/MyGroup/Group_A")); - // Create group "Group_B" in group "MyGroup" using a - // relative name. + // Create group "Group_B" in group "MyGroup" using a + // relative name. - Group group3(group1.createGroup ("Group_B")); + Group group3(group1.createGroup ("Group_B")); - // Close the groups and file. + // Close the groups and file. - group1.close(); - group2.close(); - group3.close(); - file.close(); + group1.close(); + group2.close(); + group3.close(); + file.close(); } // end of try block // catch failure caused by the File operations catch(FileIException error) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } // catch failure caused by the Group operations catch(GroupIException error) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } return 0; diff --git a/c++/examples/h5tutr_crtgrpd.cpp b/c++/examples/h5tutr_crtgrpd.cpp index 318ab1c..e3bb1b1 100644 --- a/c++/examples/h5tutr_crtgrpd.cpp +++ b/c++/examples/h5tutr_crtgrpd.cpp @@ -1,8 +1,8 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * + * 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 COPYING file, which can be found at the root of the source code * @@ -27,11 +27,11 @@ using namespace H5; const H5std_string FILE_NAME("h5tutr_groups.h5"); const H5std_string DATASET_NAME1("/MyGroup/dset1"); const H5std_string DATASET_NAME2("dset2"); -const int RANK = 2; -const int D1DIM1 = 3; -const int D1DIM2 = 3; -const int D2DIM1 = 2; -const int D2DIM2 = 10; +const int RANK = 2; +const int D1DIM1 = 3; +const int D1DIM2 = 3; +const int D2DIM1 = 2; +const int D2DIM2 = 10; int main(void) { @@ -41,93 +41,93 @@ int main(void) // Try block to catch exceptions raised by any of the calls inside it try { - // Turn off the auto-printing when failure occurs so that we can - // handle the errors appropriately - Exception::dontPrint(); + // Turn off the auto-printing when failure occurs so that we can + // handle the errors appropriately + Exception::dontPrint(); - // Initialize the first dataset. - for (i = 0; i < D1DIM1; i++) - for (j = 0; j < D1DIM2; j++) - dset1_data[i][j] = j + 1; + // Initialize the first dataset. + for (i = 0; i < D1DIM1; i++) + for (j = 0; j < D1DIM2; j++) + dset1_data[i][j] = j + 1; - // Initialize the second dataset. - for (i = 0; i < D2DIM1; i++) - for (j = 0; j < D2DIM2; j++) - dset2_data[i][j] = j + 1; + // Initialize the second dataset. + for (i = 0; i < D2DIM1; i++) + for (j = 0; j < D2DIM2; j++) + dset2_data[i][j] = j + 1; - // Open an existing file and dataset. - H5File file(FILE_NAME, H5F_ACC_RDWR); + // Open an existing file and dataset. + H5File file(FILE_NAME, H5F_ACC_RDWR); // Create the data space for the first dataset. Note the use of // pointer for the instance 'dataspace'. It can be deleted and // used again later for another data space. An HDF5 identifier is // closed by the destructor or the method 'close()'. - hsize_t dims[RANK]; // dataset dimensions - dims[0] = D1DIM1; - dims[1] = D1DIM2; - DataSpace *dataspace = new DataSpace (RANK, dims); - - // Create the dataset in group "MyGroup". Same note as for the - // dataspace above. - DataSet *dataset = new DataSet (file.createDataSet(DATASET_NAME1, - PredType::STD_I32BE, *dataspace)); - - // Write the data to the dataset using default memory space, file - // space, and transfer properties. - dataset->write(dset1_data, PredType::NATIVE_INT); - - // Close the current dataset and data space. - delete dataset; - delete dataspace; - - // Create the data space for the second dataset. - dims[0] = D2DIM1; - dims[1] = D2DIM2; - dataspace = new DataSpace (RANK, dims); - - // Create group "Group_A" in group "MyGroup". - Group group(file.openGroup("/MyGroup/Group_A")); - - // Create the second dataset in group "Group_A". - dataset = new DataSet (group.createDataSet(DATASET_NAME2, - PredType::STD_I32BE, *dataspace)); - - // Write the data to the dataset using default memory space, file - // space, and transfer properties. - dataset->write(dset2_data, PredType::NATIVE_INT); - - // Close all objects. - delete dataspace; - delete dataset; - group.close(); + hsize_t dims[RANK]; // dataset dimensions + dims[0] = D1DIM1; + dims[1] = D1DIM2; + DataSpace *dataspace = new DataSpace (RANK, dims); + + // Create the dataset in group "MyGroup". Same note as for the + // dataspace above. + DataSet *dataset = new DataSet (file.createDataSet(DATASET_NAME1, + PredType::STD_I32BE, *dataspace)); + + // Write the data to the dataset using default memory space, file + // space, and transfer properties. + dataset->write(dset1_data, PredType::NATIVE_INT); + + // Close the current dataset and data space. + delete dataset; + delete dataspace; + + // Create the data space for the second dataset. + dims[0] = D2DIM1; + dims[1] = D2DIM2; + dataspace = new DataSpace (RANK, dims); + + // Create group "Group_A" in group "MyGroup". + Group group(file.openGroup("/MyGroup/Group_A")); + + // Create the second dataset in group "Group_A". + dataset = new DataSet (group.createDataSet(DATASET_NAME2, + PredType::STD_I32BE, *dataspace)); + + // Write the data to the dataset using default memory space, file + // space, and transfer properties. + dataset->write(dset2_data, PredType::NATIVE_INT); + + // Close all objects. + delete dataspace; + delete dataset; + group.close(); } // end of try block // catch failure caused by the H5File operations catch(FileIException error) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } // catch failure caused by the DataSet operations catch(DataSetIException error) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } // catch failure caused by the DataSpace operations catch(DataSpaceIException error) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } // catch failure caused by the Group operations catch(GroupIException error) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } return 0; diff --git a/c++/examples/h5tutr_extend.cpp b/c++/examples/h5tutr_extend.cpp index 8c1bc03..b6927ea 100644 --- a/c++/examples/h5tutr_extend.cpp +++ b/c++/examples/h5tutr_extend.cpp @@ -1,8 +1,8 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * + * 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 COPYING file, which can be found at the root of the source code * @@ -24,17 +24,17 @@ using std::endl; #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME("h5tutr_extend.h5"); -const H5std_string DATASETNAME("ExtendibleArray"); +const H5std_string FILE_NAME("h5tutr_extend.h5"); +const H5std_string DATASETNAME("ExtendibleArray"); int main (void) { - hsize_t dims[2] = {3,3}; // dataset dimensions at creation + hsize_t dims[2] = {3,3}; // dataset dimensions at creation hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; hsize_t chunk_dims[2] ={2, 5}; - int data[3][3] = { {1, 1, 1}, // data to write - {1, 1, 1}, - {1, 1, 1} }; + int data[3][3] = { {1, 1, 1}, // data to write + {1, 1, 1}, + {1, 1, 1} }; // Variables used in extending and writing to the extended portion of dataset @@ -42,127 +42,127 @@ int main (void) hsize_t offset[2]; hsize_t dimsext[2] = {7, 3}; // extend dimensions int dataext[7][3] = { {2, 3, 4}, - {2, 3, 4}, - {2, 3, 4}, - {2, 3, 4}, - {2, 3, 4}, - {2, 3, 4}, - {2, 3, 4} }; + {2, 3, 4}, + {2, 3, 4}, + {2, 3, 4}, + {2, 3, 4}, + {2, 3, 4}, + {2, 3, 4} }; // Try block to detect exceptions raised by any of the calls inside it try { - // Turn off the auto-printing when failure occurs so that we can - // handle the errors appropriately - Exception::dontPrint(); - - // Create a new file using the default property lists. - H5File file(FILE_NAME, H5F_ACC_TRUNC); - - // Create the data space for the dataset. Note the use of pointer - // for the instance 'dataspace'. It can be deleted and used again - // later for another dataspace. An HDF5 identifier can be closed - // by the destructor or the method 'close()'. - DataSpace *dataspace = new DataSpace (2, dims, maxdims); - - // Modify dataset creation property to enable chunking - DSetCreatPropList prop; - prop.setChunk(2, chunk_dims); - - // Create the chunked dataset. Note the use of pointer. - DataSet *dataset = new DataSet(file.createDataSet( DATASETNAME, - PredType::STD_I32BE, *dataspace, prop) ); + // Turn off the auto-printing when failure occurs so that we can + // handle the errors appropriately + Exception::dontPrint(); + + // Create a new file using the default property lists. + H5File file(FILE_NAME, H5F_ACC_TRUNC); + + // Create the data space for the dataset. Note the use of pointer + // for the instance 'dataspace'. It can be deleted and used again + // later for another dataspace. An HDF5 identifier can be closed + // by the destructor or the method 'close()'. + DataSpace *dataspace = new DataSpace (2, dims, maxdims); + + // Modify dataset creation property to enable chunking + DSetCreatPropList prop; + prop.setChunk(2, chunk_dims); + + // Create the chunked dataset. Note the use of pointer. + DataSet *dataset = new DataSet(file.createDataSet( DATASETNAME, + PredType::STD_I32BE, *dataspace, prop) ); - // Write data to dataset. - dataset->write(data, PredType::NATIVE_INT); - - // Extend the dataset. Dataset becomes 10 x 3. - size[0] = dims[0] + dimsext[0]; - size[1] = dims[1]; - dataset->extend(size); - - // Select a hyperslab in extended portion of the dataset. - DataSpace *filespace = new DataSpace(dataset->getSpace ()); - offset[0] = 3; - offset[1] = 0; - filespace->selectHyperslab(H5S_SELECT_SET, dimsext, offset); - - // Define memory space. - DataSpace *memspace = new DataSpace(2, dimsext, NULL); - - // Write data to the extended portion of the dataset. - dataset->write(dataext, PredType::NATIVE_INT, *memspace, *filespace); - - // Close all objects and file. - prop.close(); - delete filespace; - delete memspace; - delete dataspace; - delete dataset; - file.close(); - - // --------------------------------------- - // Re-open the file and read the data back - // --------------------------------------- - - int rdata[10][3]; - int i,j, rank, rank_chunk; - hsize_t chunk_dimsr[2], dimsr[2]; - - // Open the file and dataset. - file.openFile(FILE_NAME, H5F_ACC_RDONLY); - dataset = new DataSet(file.openDataSet( DATASETNAME)); - - // Get the dataset's dataspace and creation property list. - filespace = new DataSpace(dataset->getSpace()); - prop = dataset->getCreatePlist(); - - // Get information to obtain memory dataspace. - rank = filespace->getSimpleExtentNdims(); - herr_t status_n = filespace->getSimpleExtentDims(dimsr); - - if (H5D_CHUNKED == prop.getLayout()) - rank_chunk = prop.getChunk(rank, chunk_dimsr); - cout << "rank chunk = " << rank_chunk << endl;; - - memspace = new DataSpace(rank, dimsr, NULL); - dataset->read(rdata, PredType::NATIVE_INT, *memspace, *filespace); + // Write data to dataset. + dataset->write(data, PredType::NATIVE_INT); + + // Extend the dataset. Dataset becomes 10 x 3. + size[0] = dims[0] + dimsext[0]; + size[1] = dims[1]; + dataset->extend(size); + + // Select a hyperslab in extended portion of the dataset. + DataSpace *filespace = new DataSpace(dataset->getSpace ()); + offset[0] = 3; + offset[1] = 0; + filespace->selectHyperslab(H5S_SELECT_SET, dimsext, offset); + + // Define memory space. + DataSpace *memspace = new DataSpace(2, dimsext, NULL); + + // Write data to the extended portion of the dataset. + dataset->write(dataext, PredType::NATIVE_INT, *memspace, *filespace); + + // Close all objects and file. + prop.close(); + delete filespace; + delete memspace; + delete dataspace; + delete dataset; + file.close(); + + // --------------------------------------- + // Re-open the file and read the data back + // --------------------------------------- + + int rdata[10][3]; + int i,j, rank, rank_chunk; + hsize_t chunk_dimsr[2], dimsr[2]; + + // Open the file and dataset. + file.openFile(FILE_NAME, H5F_ACC_RDONLY); + dataset = new DataSet(file.openDataSet( DATASETNAME)); + + // Get the dataset's dataspace and creation property list. + filespace = new DataSpace(dataset->getSpace()); + prop = dataset->getCreatePlist(); + + // Get information to obtain memory dataspace. + rank = filespace->getSimpleExtentNdims(); + herr_t status_n = filespace->getSimpleExtentDims(dimsr); + + if (H5D_CHUNKED == prop.getLayout()) + rank_chunk = prop.getChunk(rank, chunk_dimsr); + cout << "rank chunk = " << rank_chunk << endl;; + + memspace = new DataSpace(rank, dimsr, NULL); + dataset->read(rdata, PredType::NATIVE_INT, *memspace, *filespace); - cout << endl; - for (j = 0; j < dimsr[0]; j++) { - for (i = 0; i < dimsr[1]; i++) - cout << " " << rdata[j][i]; - cout << endl; - } - - // Close all objects and file. - prop.close(); - delete filespace; - delete memspace; - delete dataset; - file.close(); + cout << endl; + for (j = 0; j < dimsr[0]; j++) { + for (i = 0; i < dimsr[1]; i++) + cout << " " << rdata[j][i]; + cout << endl; + } + + // Close all objects and file. + prop.close(); + delete filespace; + delete memspace; + delete dataset; + file.close(); } // end of try block // catch failure caused by the H5File operations catch(FileIException error) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } // catch failure caused by the DataSet operations catch(DataSetIException error) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } // catch failure caused by the DataSpace operations catch(DataSpaceIException error) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } return 0; // successfully terminated diff --git a/c++/examples/h5tutr_rdwt.cpp b/c++/examples/h5tutr_rdwt.cpp index 4c9d49e..f17e6a5 100644 --- a/c++/examples/h5tutr_rdwt.cpp +++ b/c++/examples/h5tutr_rdwt.cpp @@ -1,8 +1,8 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * + * 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 COPYING file, which can be found at the root of the source code * @@ -21,10 +21,10 @@ #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME("h5tutr_dset.h5"); -const H5std_string DATASET_NAME("dset"); -const int DIM0 = 4; // dataset dimensions -const int DIM1 = 6; +const H5std_string FILE_NAME("h5tutr_dset.h5"); +const H5std_string DATASET_NAME("dset"); +const int DIM0 = 4; // dataset dimensions +const int DIM1 = 6; int main (void) { @@ -32,41 +32,41 @@ int main (void) // Data initialization. int i, j; - int data[DIM0][DIM1]; // buffer for data to write + int data[DIM0][DIM1]; // buffer for data to write for (j = 0; j < DIM0; j++) - for (i = 0; i < DIM1; i++) - data[j][i] = i * 6 + j + 1; + for (i = 0; i < DIM1; i++) + data[j][i] = i * 6 + j + 1; // Try block to detect exceptions raised by any of the calls inside it try { - // Turn off the auto-printing when failure occurs so that we can - // handle the errors appropriately - Exception::dontPrint(); + // Turn off the auto-printing when failure occurs so that we can + // handle the errors appropriately + Exception::dontPrint(); - // Open an existing file and dataset. - H5File file(FILE_NAME, H5F_ACC_RDWR); - DataSet dataset = file.openDataSet(DATASET_NAME); + // Open an existing file and dataset. + H5File file(FILE_NAME, H5F_ACC_RDWR); + DataSet dataset = file.openDataSet(DATASET_NAME); - // Write the data to the dataset using default memory space, file - // space, and transfer properties. - dataset.write(data, PredType::NATIVE_INT); + // Write the data to the dataset using default memory space, file + // space, and transfer properties. + dataset.write(data, PredType::NATIVE_INT); } // end of try block // catch failure caused by the H5File operations catch(FileIException error) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } // catch failure caused by the DataSet operations catch(DataSetIException error) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } return 0; // successfully terminated diff --git a/c++/examples/h5tutr_subset.cpp b/c++/examples/h5tutr_subset.cpp index 14a9ced..0747880 100644 --- a/c++/examples/h5tutr_subset.cpp +++ b/c++/examples/h5tutr_subset.cpp @@ -1,8 +1,8 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * + * 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 COPYING file, which can be found at the root of the source code * @@ -24,13 +24,13 @@ using std::endl; #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME("h5tutr_subset.h5"); -const H5std_string DATASET_NAME("IntArray"); +const H5std_string FILE_NAME("h5tutr_subset.h5"); +const H5std_string DATASET_NAME("IntArray"); const int RANK = 2; -const int DIM0_SUB = 3; // subset dimensions +const int DIM0_SUB = 3; // subset dimensions const int DIM1_SUB = 4; -const int DIM0 = 8; // size of dataset +const int DIM0 = 8; // size of dataset const int DIM1 = 10; int main (void) @@ -41,134 +41,134 @@ int main (void) // Try block to detect exceptions raised by any of the calls inside it try { - // Turn off the auto-printing when failure occurs so that we can - // handle the errors appropriately - Exception::dontPrint(); - - // --------------------------------------------------- - // Create a new file using the default property lists. - // Then create a dataset and write data to it. - // Close the file and dataset. - // --------------------------------------------------- + // Turn off the auto-printing when failure occurs so that we can + // handle the errors appropriately + Exception::dontPrint(); + + // --------------------------------------------------- + // Create a new file using the default property lists. + // Then create a dataset and write data to it. + // Close the file and dataset. + // --------------------------------------------------- - H5File file(FILE_NAME, H5F_ACC_TRUNC); + H5File file(FILE_NAME, H5F_ACC_TRUNC); - hsize_t dims[2]; - dims[0] = DIM0; - dims[1] = DIM1; - DataSpace dataspace = DataSpace (RANK, dims); + hsize_t dims[2]; + dims[0] = DIM0; + dims[1] = DIM1; + DataSpace dataspace = DataSpace (RANK, dims); - DataSet dataset(file.createDataSet( DATASET_NAME, - PredType::STD_I32BE, dataspace) ); + DataSet dataset(file.createDataSet( DATASET_NAME, + PredType::STD_I32BE, dataspace) ); - for (j = 0; j < DIM0; j++) { - for (i = 0; i < DIM1; i++) - if (i< (DIM1/2)) - data[j][i] = 1; - else - data[j][i] = 2; - } + for (j = 0; j < DIM0; j++) { + for (i = 0; i < DIM1; i++) + if (i< (DIM1/2)) + data[j][i] = 1; + else + data[j][i] = 2; + } - dataset.write(data, PredType::NATIVE_INT); + dataset.write(data, PredType::NATIVE_INT); - cout << endl << "Data Written to File:" << endl; - for (j = 0; j < DIM0; j++) { - for (i = 0; i < DIM1; i++) - cout << " " << data[j][i]; - cout << endl; - } + cout << endl << "Data Written to File:" << endl; + for (j = 0; j < DIM0; j++) { + for (i = 0; i < DIM1; i++) + cout << " " << data[j][i]; + cout << endl; + } - dataspace.close(); - dataset.close(); - file.close(); + dataspace.close(); + dataset.close(); + file.close(); - // --------------------------------------------------- - // Reopen the file and dataset and write a subset of - // values to the dataset. - // --------------------------------------------------- + // --------------------------------------------------- + // Reopen the file and dataset and write a subset of + // values to the dataset. + // --------------------------------------------------- - hsize_t offset[2], count[2], stride[2], block[2]; - hsize_t dimsm[2]; + hsize_t offset[2], count[2], stride[2], block[2]; + hsize_t dimsm[2]; - file.openFile(FILE_NAME, H5F_ACC_RDWR); - dataset = file.openDataSet(DATASET_NAME); + file.openFile(FILE_NAME, H5F_ACC_RDWR); + dataset = file.openDataSet(DATASET_NAME); - // Specify size and shape of subset to write. + // Specify size and shape of subset to write. - offset[0] = 1; - offset[1] = 2; + offset[0] = 1; + offset[1] = 2; - count[0] = DIM0_SUB; - count[1] = DIM1_SUB; + count[0] = DIM0_SUB; + count[1] = DIM1_SUB; - stride[0] = 1; - stride[1] = 1; + stride[0] = 1; + stride[1] = 1; - block[0] = 1; - block[1] = 1; + block[0] = 1; + block[1] = 1; - // Define Memory Dataspace. Get file dataspace and select - // a subset from the file dataspace. + // Define Memory Dataspace. Get file dataspace and select + // a subset from the file dataspace. - dimsm[0] = DIM0_SUB; - dimsm[1] = DIM1_SUB; + dimsm[0] = DIM0_SUB; + dimsm[1] = DIM1_SUB; - DataSpace memspace(RANK, dimsm, NULL); + DataSpace memspace(RANK, dimsm, NULL); - dataspace = dataset.getSpace(); - dataspace.selectHyperslab(H5S_SELECT_SET, count, offset, stride, block); + dataspace = dataset.getSpace(); + dataspace.selectHyperslab(H5S_SELECT_SET, count, offset, stride, block); - // Write a subset of data to the dataset, then read the - // entire dataset back from the file. + // Write a subset of data to the dataset, then read the + // entire dataset back from the file. - cout << endl << "Write subset to file specifying: " << endl; - cout << " offset=1x2 stride=1x1 count=3x4 block=1x1" << endl; - for (j = 0; j < DIM0_SUB; j++) { - for (i = 0; i < DIM1_SUB; i++) - sdata[j][i] = 5; - } - - dataset.write(sdata, PredType::NATIVE_INT, memspace, dataspace); - dataset.read(rdata, PredType::NATIVE_INT); + cout << endl << "Write subset to file specifying: " << endl; + cout << " offset=1x2 stride=1x1 count=3x4 block=1x1" << endl; + for (j = 0; j < DIM0_SUB; j++) { + for (i = 0; i < DIM1_SUB; i++) + sdata[j][i] = 5; + } + + dataset.write(sdata, PredType::NATIVE_INT, memspace, dataspace); + dataset.read(rdata, PredType::NATIVE_INT); - cout << endl << "Data in File after Subset is Written:" << endl; - for (i = 0; i < DIM0; i++) { - for (j = 0; j < DIM1; j++) - cout << " " << rdata[i][j]; - cout << endl; - } - cout << endl; - - // It is not necessary to close these objects because close() will - // be called when the object instances are going out of scope. - dataspace.close(); - memspace.close(); - dataset.close(); - file.close(); + cout << endl << "Data in File after Subset is Written:" << endl; + for (i = 0; i < DIM0; i++) { + for (j = 0; j < DIM1; j++) + cout << " " << rdata[i][j]; + cout << endl; + } + cout << endl; + + // It is not necessary to close these objects because close() will + // be called when the object instances are going out of scope. + dataspace.close(); + memspace.close(); + dataset.close(); + file.close(); } // end of try block // catch failure caused by the H5File operations catch(FileIException error) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } // catch failure caused by the DataSet operations catch(DataSetIException error) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } // catch failure caused by the DataSpace operations catch(DataSpaceIException error) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } return 0; // successfully terminated diff --git a/c++/examples/readdata.cpp b/c++/examples/readdata.cpp index 5a2f3bc..3df8191 100644 --- a/c++/examples/readdata.cpp +++ b/c++/examples/readdata.cpp @@ -31,9 +31,9 @@ using namespace H5; const H5std_string FILE_NAME( "SDS.h5" ); const H5std_string DATASET_NAME( "IntArray" ); -const int NX_SUB = 3; // hyperslab dimensions +const int NX_SUB = 3; // hyperslab dimensions const int NY_SUB = 4; -const int NX = 7; // output buffer dimensions +const int NX = 7; // output buffer dimensions const int NY = 7; const int NZ = 3; const int RANK_OUT = 3; @@ -49,8 +49,8 @@ int main (void) { for (i = 0; i < NY; i++) { - for (k = 0; k < NZ ; k++) - data_out[j][i][k] = 0; + for (k = 0; k < NZ ; k++) + data_out[j][i][k] = 0; } } @@ -81,19 +81,19 @@ int main (void) */ if( type_class == H5T_INTEGER ) { - cout << "Data set has INTEGER type" << endl; + cout << "Data set has INTEGER type" << endl; /* - * Get the integer datatype + * Get the integer datatype */ - IntType intype = dataset.getIntType(); + IntType intype = dataset.getIntType(); /* * Get order of datatype and print message if it's a little endian. */ - H5std_string order_string; + H5std_string order_string; H5T_order_t order = intype.getOrder( order_string ); - cout << order_string << endl; + cout << order_string << endl; /* * Get size of the data element stored in file and print it. @@ -119,15 +119,15 @@ int main (void) hsize_t dims_out[2]; int ndims = dataspace.getSimpleExtentDims( dims_out, NULL); cout << "rank " << rank << ", dimensions " << - (unsigned long)(dims_out[0]) << " x " << - (unsigned long)(dims_out[1]) << endl; + (unsigned long)(dims_out[0]) << " x " << + (unsigned long)(dims_out[1]) << endl; /* * Define hyperslab in the dataset; implicitly giving strike and * block NULL. */ - hsize_t offset[2]; // hyperslab offset in the file - hsize_t count[2]; // size of the hyperslab in the file + hsize_t offset[2]; // hyperslab offset in the file + hsize_t count[2]; // size of the hyperslab in the file offset[0] = 1; offset[1] = 2; count[0] = NX_SUB; @@ -146,8 +146,8 @@ int main (void) /* * Define memory hyperslab. */ - hsize_t offset_out[3]; // hyperslab offset in memory - hsize_t count_out[3]; // size of the hyperslab in memory + hsize_t offset_out[3]; // hyperslab offset in memory + hsize_t count_out[3]; // size of the hyperslab in memory offset_out[0] = 3; offset_out[1] = 0; offset_out[2] = 0; @@ -164,9 +164,9 @@ int main (void) for (j = 0; j < NX; j++) { - for (i = 0; i < NY; i++) - cout << data_out[j][i][0] << " "; - cout << endl; + for (i = 0; i < NY; i++) + cout << data_out[j][i][0] << " "; + cout << endl; } /* * 0 0 0 0 0 0 0 diff --git a/c++/examples/writedata.cpp b/c++/examples/writedata.cpp index f5c06cf..eada2ed 100644 --- a/c++/examples/writedata.cpp +++ b/c++/examples/writedata.cpp @@ -34,19 +34,19 @@ using namespace H5; const H5std_string FILE_NAME( "Select.h5" ); const H5std_string DATASET_NAME( "Matrix in file" ); -const int MSPACE1_RANK = 1; // Rank of the first dataset in memory +const int MSPACE1_RANK = 1; // Rank of the first dataset in memory const int MSPACE1_DIM = 50; // Dataset size in memory -const int MSPACE2_RANK = 1; // Rank of the second dataset in memory -const int MSPACE2_DIM = 4; // Dataset size in memory -const int FSPACE_RANK = 2; // Dataset rank as it is stored in the file -const int FSPACE_DIM1 = 8; // Dimension sizes of the dataset as it is -const int FSPACE_DIM2 = 12; // stored in the file -const int MSPACE_RANK = 2; // Rank of the first dataset in memory -const int MSPACE_DIM1 = 8; // We will read dataset back from the file -const int MSPACE_DIM2 = 9; // to the dataset in memory with these - // dataspace parameters -const int NPOINTS = 4; // Number of points that will be selected - // and overwritten +const int MSPACE2_RANK = 1; // Rank of the second dataset in memory +const int MSPACE2_DIM = 4; // Dataset size in memory +const int FSPACE_RANK = 2; // Dataset rank as it is stored in the file +const int FSPACE_DIM1 = 8; // Dimension sizes of the dataset as it is +const int FSPACE_DIM2 = 12; // stored in the file +const int MSPACE_RANK = 2; // Rank of the first dataset in memory +const int MSPACE_DIM1 = 8; // We will read dataset back from the file +const int MSPACE_DIM2 = 9; // to the dataset in memory with these + // dataspace parameters +const int NPOINTS = 4; // Number of points that will be selected + // and overwritten int main (void) { @@ -57,271 +57,271 @@ int main (void) */ try { - /* - * Turn off the auto-printing when failure occurs so that we can - * handle the errors appropriately - */ - Exception::dontPrint(); - - /* - * Create a file. - */ - H5File* file = new H5File( FILE_NAME, H5F_ACC_TRUNC ); - - /* - * Create property list for a dataset and set up fill values. - */ - int fillvalue = 0; /* Fill value for the dataset */ - DSetCreatPropList plist; - plist.setFillValue(PredType::NATIVE_INT, &fillvalue); - - /* - * Create dataspace for the dataset in the file. - */ - hsize_t fdim[] = {FSPACE_DIM1, FSPACE_DIM2}; // dim sizes of ds (on disk) - DataSpace fspace( FSPACE_RANK, fdim ); - - /* - * Create dataset and write it into the file. - */ - DataSet* dataset = new DataSet(file->createDataSet( - DATASET_NAME, PredType::NATIVE_INT, fspace, plist)); - - /* - * Select hyperslab for the dataset in the file, using 3x2 blocks, - * (4,3) stride and (2,4) count starting at the position (0,1). - */ - hsize_t start[2]; // Start of hyperslab - hsize_t stride[2]; // Stride of hyperslab - hsize_t count[2]; // Block count - hsize_t block[2]; // Block sizes - start[0] = 0; start[1] = 1; - stride[0] = 4; stride[1] = 3; - count[0] = 2; count[1] = 4; - block[0] = 3; block[1] = 2; - fspace.selectHyperslab( H5S_SELECT_SET, count, start, stride, block); - - /* - * Create dataspace for the first dataset. - */ - hsize_t dim1[] = {MSPACE1_DIM}; /* Dimension size of the first dataset - (in memory) */ - DataSpace mspace1( MSPACE1_RANK, dim1 ); - - /* - * Select hyperslab. - * We will use 48 elements of the vector buffer starting at the - * second element. Selected elements are 1 2 3 . . . 48 - */ - start[0] = 1; - stride[0] = 1; - count[0] = 48; - block[0] = 1; - mspace1.selectHyperslab( H5S_SELECT_SET, count, start, stride, block); - - /* - * Write selection from the vector buffer to the dataset in the file. - * - * File dataset should look like this: - * 0 1 2 0 3 4 0 5 6 0 7 8 - * 0 9 10 0 11 12 0 13 14 0 15 16 - * 0 17 18 0 19 20 0 21 22 0 23 24 - * 0 0 0 0 0 0 0 0 0 0 0 0 - * 0 25 26 0 27 28 0 29 30 0 31 32 - * 0 33 34 0 35 36 0 37 38 0 39 40 - * 0 41 42 0 43 44 0 45 46 0 47 48 - * 0 0 0 0 0 0 0 0 0 0 0 0 - */ - int vector[MSPACE1_DIM]; // vector buffer for dset - - /* - * Buffer initialization. - */ - vector[0] = vector[MSPACE1_DIM - 1] = -1; - for (i = 1; i < MSPACE1_DIM - 1; i++) - vector[i] = i; - - dataset->write( vector, PredType::NATIVE_INT, mspace1, fspace ); - - /* - * Reset the selection for the file dataspace fid. - */ - fspace.selectNone(); - - /* - * Create dataspace for the second dataset. - */ - hsize_t dim2[] = {MSPACE2_DIM}; /* Dimension size of the second dataset - (in memory */ - DataSpace mspace2( MSPACE2_RANK, dim2 ); - - /* - * Select sequence of NPOINTS points in the file dataspace. - */ - hsize_t coord[NPOINTS][FSPACE_RANK]; /* Array to store selected points - from the file dataspace */ - coord[0][0] = 0; coord[0][1] = 0; - coord[1][0] = 3; coord[1][1] = 3; - coord[2][0] = 3; coord[2][1] = 5; - coord[3][0] = 5; coord[3][1] = 6; - - fspace.selectElements( H5S_SELECT_SET, NPOINTS, (const hsize_t *)coord); - - /* - * Write new selection of points to the dataset. - */ - int values[] = {53, 59, 61, 67}; /* New values to be written */ - dataset->write( values, PredType::NATIVE_INT, mspace2, fspace ); - - /* - * File dataset should look like this: - * 53 1 2 0 3 4 0 5 6 0 7 8 - * 0 9 10 0 11 12 0 13 14 0 15 16 - * 0 17 18 0 19 20 0 21 22 0 23 24 - * 0 0 0 59 0 61 0 0 0 0 0 0 - * 0 25 26 0 27 28 0 29 30 0 31 32 - * 0 33 34 0 35 36 67 37 38 0 39 40 - * 0 41 42 0 43 44 0 45 46 0 47 48 - * 0 0 0 0 0 0 0 0 0 0 0 0 - * - */ - - /* - * Close the dataset and the file. - */ - delete dataset; - delete file; - - /* - * Open the file. - */ - file = new H5File( FILE_NAME, H5F_ACC_RDONLY ); - - /* - * Open the dataset. - */ - dataset = new DataSet( file->openDataSet( DATASET_NAME )); - - /* - * Get dataspace of the dataset. - */ - fspace = dataset->getSpace(); - - /* - * Select first hyperslab for the dataset in the file. The following - * elements are selected: - * 10 0 11 12 - * 18 0 19 20 - * 0 59 0 61 - * - */ - start[0] = 1; start[1] = 2; - block[0] = 1; block[1] = 1; - stride[0] = 1; stride[1] = 1; - count[0] = 3; count[1] = 4; - fspace.selectHyperslab(H5S_SELECT_SET, count, start, stride, block); - - /* - * Add second selected hyperslab to the selection. - * The following elements are selected: - * 19 20 0 21 22 - * 0 61 0 0 0 - * 27 28 0 29 30 - * 35 36 67 37 38 - * 43 44 0 45 46 - * 0 0 0 0 0 - * Note that two hyperslabs overlap. Common elements are: - * 19 20 - * 0 61 - */ - start[0] = 2; start[1] = 4; - block[0] = 1; block[1] = 1; - stride[0] = 1; stride[1] = 1; - count[0] = 6; count[1] = 5; - fspace.selectHyperslab(H5S_SELECT_OR, count, start, stride, block); - - /* - * Create memory dataspace. - */ - hsize_t mdim[] = {MSPACE_DIM1, MSPACE_DIM2}; /* Dimension sizes of the + /* + * Turn off the auto-printing when failure occurs so that we can + * handle the errors appropriately + */ + Exception::dontPrint(); + + /* + * Create a file. + */ + H5File* file = new H5File( FILE_NAME, H5F_ACC_TRUNC ); + + /* + * Create property list for a dataset and set up fill values. + */ + int fillvalue = 0; /* Fill value for the dataset */ + DSetCreatPropList plist; + plist.setFillValue(PredType::NATIVE_INT, &fillvalue); + + /* + * Create dataspace for the dataset in the file. + */ + hsize_t fdim[] = {FSPACE_DIM1, FSPACE_DIM2}; // dim sizes of ds (on disk) + DataSpace fspace( FSPACE_RANK, fdim ); + + /* + * Create dataset and write it into the file. + */ + DataSet* dataset = new DataSet(file->createDataSet( + DATASET_NAME, PredType::NATIVE_INT, fspace, plist)); + + /* + * Select hyperslab for the dataset in the file, using 3x2 blocks, + * (4,3) stride and (2,4) count starting at the position (0,1). + */ + hsize_t start[2]; // Start of hyperslab + hsize_t stride[2]; // Stride of hyperslab + hsize_t count[2]; // Block count + hsize_t block[2]; // Block sizes + start[0] = 0; start[1] = 1; + stride[0] = 4; stride[1] = 3; + count[0] = 2; count[1] = 4; + block[0] = 3; block[1] = 2; + fspace.selectHyperslab( H5S_SELECT_SET, count, start, stride, block); + + /* + * Create dataspace for the first dataset. + */ + hsize_t dim1[] = {MSPACE1_DIM}; /* Dimension size of the first dataset + (in memory) */ + DataSpace mspace1( MSPACE1_RANK, dim1 ); + + /* + * Select hyperslab. + * We will use 48 elements of the vector buffer starting at the + * second element. Selected elements are 1 2 3 . . . 48 + */ + start[0] = 1; + stride[0] = 1; + count[0] = 48; + block[0] = 1; + mspace1.selectHyperslab( H5S_SELECT_SET, count, start, stride, block); + + /* + * Write selection from the vector buffer to the dataset in the file. + * + * File dataset should look like this: + * 0 1 2 0 3 4 0 5 6 0 7 8 + * 0 9 10 0 11 12 0 13 14 0 15 16 + * 0 17 18 0 19 20 0 21 22 0 23 24 + * 0 0 0 0 0 0 0 0 0 0 0 0 + * 0 25 26 0 27 28 0 29 30 0 31 32 + * 0 33 34 0 35 36 0 37 38 0 39 40 + * 0 41 42 0 43 44 0 45 46 0 47 48 + * 0 0 0 0 0 0 0 0 0 0 0 0 + */ + int vector[MSPACE1_DIM]; // vector buffer for dset + + /* + * Buffer initialization. + */ + vector[0] = vector[MSPACE1_DIM - 1] = -1; + for (i = 1; i < MSPACE1_DIM - 1; i++) + vector[i] = i; + + dataset->write( vector, PredType::NATIVE_INT, mspace1, fspace ); + + /* + * Reset the selection for the file dataspace fid. + */ + fspace.selectNone(); + + /* + * Create dataspace for the second dataset. + */ + hsize_t dim2[] = {MSPACE2_DIM}; /* Dimension size of the second dataset + (in memory */ + DataSpace mspace2( MSPACE2_RANK, dim2 ); + + /* + * Select sequence of NPOINTS points in the file dataspace. + */ + hsize_t coord[NPOINTS][FSPACE_RANK]; /* Array to store selected points + from the file dataspace */ + coord[0][0] = 0; coord[0][1] = 0; + coord[1][0] = 3; coord[1][1] = 3; + coord[2][0] = 3; coord[2][1] = 5; + coord[3][0] = 5; coord[3][1] = 6; + + fspace.selectElements( H5S_SELECT_SET, NPOINTS, (const hsize_t *)coord); + + /* + * Write new selection of points to the dataset. + */ + int values[] = {53, 59, 61, 67}; /* New values to be written */ + dataset->write( values, PredType::NATIVE_INT, mspace2, fspace ); + + /* + * File dataset should look like this: + * 53 1 2 0 3 4 0 5 6 0 7 8 + * 0 9 10 0 11 12 0 13 14 0 15 16 + * 0 17 18 0 19 20 0 21 22 0 23 24 + * 0 0 0 59 0 61 0 0 0 0 0 0 + * 0 25 26 0 27 28 0 29 30 0 31 32 + * 0 33 34 0 35 36 67 37 38 0 39 40 + * 0 41 42 0 43 44 0 45 46 0 47 48 + * 0 0 0 0 0 0 0 0 0 0 0 0 + * + */ + + /* + * Close the dataset and the file. + */ + delete dataset; + delete file; + + /* + * Open the file. + */ + file = new H5File( FILE_NAME, H5F_ACC_RDONLY ); + + /* + * Open the dataset. + */ + dataset = new DataSet( file->openDataSet( DATASET_NAME )); + + /* + * Get dataspace of the dataset. + */ + fspace = dataset->getSpace(); + + /* + * Select first hyperslab for the dataset in the file. The following + * elements are selected: + * 10 0 11 12 + * 18 0 19 20 + * 0 59 0 61 + * + */ + start[0] = 1; start[1] = 2; + block[0] = 1; block[1] = 1; + stride[0] = 1; stride[1] = 1; + count[0] = 3; count[1] = 4; + fspace.selectHyperslab(H5S_SELECT_SET, count, start, stride, block); + + /* + * Add second selected hyperslab to the selection. + * The following elements are selected: + * 19 20 0 21 22 + * 0 61 0 0 0 + * 27 28 0 29 30 + * 35 36 67 37 38 + * 43 44 0 45 46 + * 0 0 0 0 0 + * Note that two hyperslabs overlap. Common elements are: + * 19 20 + * 0 61 + */ + start[0] = 2; start[1] = 4; + block[0] = 1; block[1] = 1; + stride[0] = 1; stride[1] = 1; + count[0] = 6; count[1] = 5; + fspace.selectHyperslab(H5S_SELECT_OR, count, start, stride, block); + + /* + * Create memory dataspace. + */ + hsize_t mdim[] = {MSPACE_DIM1, MSPACE_DIM2}; /* Dimension sizes of the dataset in memory when we read selection from the dataset on the disk */ - DataSpace mspace(MSPACE_RANK, mdim); - - /* - * Select two hyperslabs in memory. Hyperslabs has the same - * size and shape as the selected hyperslabs for the file dataspace. - */ - start[0] = 0; start[1] = 0; - block[0] = 1; block[1] = 1; - stride[0] = 1; stride[1] = 1; - count[0] = 3; count[1] = 4; - mspace.selectHyperslab(H5S_SELECT_SET, count, start, stride, block); - start[0] = 1; start[1] = 2; - block[0] = 1; block[1] = 1; - stride[0] = 1; stride[1] = 1; - count[0] = 6; count[1] = 5; - mspace.selectHyperslab(H5S_SELECT_OR, count, start, stride, block); - - /* - * Initialize data buffer. - */ - int matrix_out[MSPACE_DIM1][MSPACE_DIM2]; - for (i = 0; i < MSPACE_DIM1; i++) - for (j = 0; j < MSPACE_DIM2; j++) - matrix_out[i][j] = 0; - - /* - * Read data back to the buffer matrix. - */ - dataset->read(matrix_out, PredType::NATIVE_INT, mspace, fspace); - - /* - * Display the result. Memory dataset is: - * - * 10 0 11 12 0 0 0 0 0 - * 18 0 19 20 0 21 22 0 0 - * 0 59 0 61 0 0 0 0 0 - * 0 0 27 28 0 29 30 0 0 - * 0 0 35 36 67 37 38 0 0 - * 0 0 43 44 0 45 46 0 0 - * 0 0 0 0 0 0 0 0 0 - * 0 0 0 0 0 0 0 0 0 - */ - for (i=0; i < MSPACE_DIM1; i++) - { - for(j=0; j < MSPACE_DIM2; j++) - cout << matrix_out[i][j] << " "; - cout << endl; - } - - /* - * Close the dataset and the file. - */ - delete dataset; - delete file; + DataSpace mspace(MSPACE_RANK, mdim); + + /* + * Select two hyperslabs in memory. Hyperslabs has the same + * size and shape as the selected hyperslabs for the file dataspace. + */ + start[0] = 0; start[1] = 0; + block[0] = 1; block[1] = 1; + stride[0] = 1; stride[1] = 1; + count[0] = 3; count[1] = 4; + mspace.selectHyperslab(H5S_SELECT_SET, count, start, stride, block); + start[0] = 1; start[1] = 2; + block[0] = 1; block[1] = 1; + stride[0] = 1; stride[1] = 1; + count[0] = 6; count[1] = 5; + mspace.selectHyperslab(H5S_SELECT_OR, count, start, stride, block); + + /* + * Initialize data buffer. + */ + int matrix_out[MSPACE_DIM1][MSPACE_DIM2]; + for (i = 0; i < MSPACE_DIM1; i++) + for (j = 0; j < MSPACE_DIM2; j++) + matrix_out[i][j] = 0; + + /* + * Read data back to the buffer matrix. + */ + dataset->read(matrix_out, PredType::NATIVE_INT, mspace, fspace); + + /* + * Display the result. Memory dataset is: + * + * 10 0 11 12 0 0 0 0 0 + * 18 0 19 20 0 21 22 0 0 + * 0 59 0 61 0 0 0 0 0 + * 0 0 27 28 0 29 30 0 0 + * 0 0 35 36 67 37 38 0 0 + * 0 0 43 44 0 45 46 0 0 + * 0 0 0 0 0 0 0 0 0 + * 0 0 0 0 0 0 0 0 0 + */ + for (i=0; i < MSPACE_DIM1; i++) + { + for(j=0; j < MSPACE_DIM2; j++) + cout << matrix_out[i][j] << " "; + cout << endl; + } + + /* + * Close the dataset and the file. + */ + delete dataset; + delete file; } // end of try block // catch failure caused by the H5File operations catch( FileIException error ) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } // catch failure caused by the DataSet operations catch( DataSetIException error ) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } // catch failure caused by the DataSpace operations catch( DataSpaceIException error ) { - error.printErrorStack(); - return -1; + error.printErrorStack(); + return -1; } return 0; diff --git a/c++/src/H5FaccProp.cpp b/c++/src/H5FaccProp.cpp index 1657351..5a478e7 100644 --- a/c++/src/H5FaccProp.cpp +++ b/c++/src/H5FaccProp.cpp @@ -696,10 +696,16 @@ unsigned FileAccPropList::getGcReferences() const /// Valid values of \a libver_low are as follows: /// \li \c H5F_LIBVER_EARLIEST (Default) /// \li \c H5F_LIBVER_18 +/// \li \c H5F_LIBVER_110 +/// \li \c H5F_LIBVER_112 +/// \li \c H5F_LIBVER_114 /// \li \c H5F_LIBVER_LATEST /// /// Valid values of \a libver_high are as follows: /// \li \c H5F_LIBVER_18 +/// \li \c H5F_LIBVER_110 +/// \li \c H5F_LIBVER_112 +/// \li \c H5F_LIBVER_114 /// \li \c H5F_LIBVER_LATEST (Default) /// /// For more detail, please refer to the H5Pset_libver_bounds API in @@ -729,10 +735,16 @@ void FileAccPropList::setLibverBounds(H5F_libver_t libver_low, H5F_libver_t libv /// values: /// \li \c H5F_LIBVER_EARLIEST /// \li \c H5F_LIBVER_18 +/// \li \c H5F_LIBVER_110 +/// \li \c H5F_LIBVER_112 +/// \li \c H5F_LIBVER_114 /// \li \c H5F_LIBVER_LATEST /// /// and \a libver_high: /// \li \c H5F_LIBVER_18 +/// \li \c H5F_LIBVER_110 +/// \li \c H5F_LIBVER_112 +/// \li \c H5F_LIBVER_114 /// \li \c H5F_LIBVER_LATEST // Programmer Binh-Minh Ribler - March, 2015 //-------------------------------------------------------------------------- diff --git a/c++/src/cpp_doc_config b/c++/src/cpp_doc_config index 14ca90c..71db7f6 100644 --- a/c++/src/cpp_doc_config +++ b/c++/src/cpp_doc_config @@ -38,7 +38,7 @@ PROJECT_NAME = # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = "1.11.6" +PROJECT_NUMBER = "1.13.0" # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a |