diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2013-09-24 02:12:40 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2013-09-24 02:12:40 (GMT) |
commit | 91df66782ea03416f4dae1a8171ede49fb016725 (patch) | |
tree | c8486e06ed06240e9f548d360903d6337151a8c6 /c++ | |
parent | ab239810e1ae81f390a91dfbb3e5d68934efee55 (diff) | |
download | hdf5-91df66782ea03416f4dae1a8171ede49fb016725.zip hdf5-91df66782ea03416f4dae1a8171ede49fb016725.tar.gz hdf5-91df66782ea03416f4dae1a8171ede49fb016725.tar.bz2 |
[svn-r24195] Description:
- Improved format/comments in tutorial examples
- Added them to Makefile.* and run-c++-ex.sh.in
Platforms tested:
Linux/32 2.6 (jam)
Linux/64 2.6 (koala)/PGI compilers
Diffstat (limited to 'c++')
-rw-r--r-- | c++/examples/Makefile.am | 20 | ||||
-rw-r--r-- | c++/examples/Makefile.in | 21 | ||||
-rw-r--r-- | c++/examples/h5tutr_crtatt.cpp | 9 | ||||
-rw-r--r-- | c++/examples/h5tutr_crtdat.cpp | 9 | ||||
-rw-r--r-- | c++/examples/h5tutr_extend.cpp | 24 | ||||
-rw-r--r-- | c++/examples/h5tutr_rdwt.cpp | 5 | ||||
-rw-r--r-- | c++/examples/h5tutr_subset.cpp | 2 | ||||
-rw-r--r-- | c++/examples/run-c++-ex.sh.in | 31 | ||||
-rw-r--r-- | c++/src/H5Exception.cpp | 4 |
9 files changed, 83 insertions, 42 deletions
diff --git a/c++/examples/Makefile.am b/c++/examples/Makefile.am index cd9a9f6..f479776 100644 --- a/c++/examples/Makefile.am +++ b/c++/examples/Makefile.am @@ -23,12 +23,18 @@ include $(top_srcdir)/config/commence.am # These are the programs that 'make all' or 'make prog' will build and # which 'make check' will run. List them in the order they should be run. -EXAMPLE_PROG=create readdata writedata compound extend_ds chunks h5group +EXAMPLE_PROG=create readdata writedata compound extend_ds chunks h5group \ + h5tutr_cmprss h5tutr_crtatt h5tutr_crtdat h5tutr_crtgrpar \ + h5tutr_crtgrp h5tutr_crtgrpd h5tutr_extend h5tutr_rdwt \ + h5tutr_subset TEST_SCRIPT=testh5c++.sh # These are the example files to be installed INSTALL_FILES=create.cpp readdata.cpp writedata.cpp compound.cpp \ - extend_ds.cpp chunks.cpp h5group.cpp + extend_ds.cpp chunks.cpp h5group.cpp \ + h5tutr_cmprss.cpp h5tutr_crtatt.cpp h5tutr_crtdat.cpp \ + h5tutr_crtgrpar.cpp h5tutr_crtgrp.cpp h5tutr_crtgrpd.cpp \ + h5tutr_extend.cpp h5tutr_rdwt.cpp h5tutr_subset.cpp INSTALL_SCRIPT_FILES = run-c++-ex.sh # Some of the examples depend on files created by running other examples @@ -58,5 +64,15 @@ extend_ds: $(srcdir)/extend_ds.cpp chunks: $(srcdir)/chunks.cpp h5group: $(srcdir)/h5group.cpp +h5tutr_cmprss: $(srcdir)/h5tutr_cmprss.cpp +h5tutr_crtatt: $(srcdir)/h5tutr_crtatt.cpp +h5tutr_crtdat: $(srcdir)/h5tutr_crtdat.cpp +h5tutr_crtgrpar: $(srcdir)/h5tutr_crtgrpar.cpp +h5tutr_crtgrp: $(srcdir)/h5tutr_crtgrp.cpp +h5tutr_crtgrpd: $(srcdir)/h5tutr_crtgrpd.cpp +h5tutr_extend: $(srcdir)/h5tutr_extend.cpp +h5tutr_rdwt: $(srcdir)/h5tutr_rdwt.cpp +h5tutr_subset: $(srcdir)/h5tutr_subset.cpp + include $(top_srcdir)/config/examples.am include $(top_srcdir)/config/conclude.am diff --git a/c++/examples/Makefile.in b/c++/examples/Makefile.in index 78b1e58..f392787 100644 --- a/c++/examples/Makefile.in +++ b/c++/examples/Makefile.in @@ -392,12 +392,19 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog *.h5 # These are the programs that 'make all' or 'make prog' will build and # which 'make check' will run. List them in the order they should be run. -EXAMPLE_PROG = create readdata writedata compound extend_ds chunks h5group +EXAMPLE_PROG = create readdata writedata compound extend_ds chunks h5group \ + h5tutr_cmprss h5tutr_crtatt h5tutr_crtdat h5tutr_crtgrpar \ + h5tutr_crtgrp h5tutr_crtgrpd h5tutr_extend h5tutr_rdwt \ + h5tutr_subset + TEST_SCRIPT = testh5c++.sh # These are the example files to be installed INSTALL_FILES = create.cpp readdata.cpp writedata.cpp compound.cpp \ - extend_ds.cpp chunks.cpp h5group.cpp + extend_ds.cpp chunks.cpp h5group.cpp \ + h5tutr_cmprss.cpp h5tutr_crtatt.cpp h5tutr_crtdat.cpp \ + h5tutr_crtgrpar.cpp h5tutr_crtgrp.cpp h5tutr_crtgrpd.cpp \ + h5tutr_extend.cpp h5tutr_rdwt.cpp h5tutr_subset.cpp INSTALL_SCRIPT_FILES = run-c++-ex.sh @@ -669,6 +676,16 @@ extend_ds: $(srcdir)/extend_ds.cpp chunks: $(srcdir)/chunks.cpp h5group: $(srcdir)/h5group.cpp +h5tutr_cmprss: $(srcdir)/h5tutr_cmprss.cpp +h5tutr_crtatt: $(srcdir)/h5tutr_crtatt.cpp +h5tutr_crtdat: $(srcdir)/h5tutr_crtdat.cpp +h5tutr_crtgrpar: $(srcdir)/h5tutr_crtgrpar.cpp +h5tutr_crtgrp: $(srcdir)/h5tutr_crtgrp.cpp +h5tutr_crtgrpd: $(srcdir)/h5tutr_crtgrpd.cpp +h5tutr_extend: $(srcdir)/h5tutr_extend.cpp +h5tutr_rdwt: $(srcdir)/h5tutr_rdwt.cpp +h5tutr_subset: $(srcdir)/h5tutr_subset.cpp + # How to create EXAMPLEDIR if it doesn't already exist $(EXAMPLEDIR): -$(top_srcdir)/bin/mkdirs $@ diff --git a/c++/examples/h5tutr_crtatt.cpp b/c++/examples/h5tutr_crtatt.cpp index 3d5b558..651dc69 100644 --- a/c++/examples/h5tutr_crtatt.cpp +++ b/c++/examples/h5tutr_crtatt.cpp @@ -42,33 +42,26 @@ 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(); // 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 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); } // end of try block - // catch failure caused by the H5File operations catch( DataSpaceIException error ) { @@ -76,7 +69,6 @@ int main (void) return -1; } - // catch failure caused by the H5File operations catch( AttributeIException error ) { @@ -84,7 +76,6 @@ int main (void) return -1; } - // catch failure caused by the H5File operations catch( FileIException error ) { diff --git a/c++/examples/h5tutr_crtdat.cpp b/c++/examples/h5tutr_crtdat.cpp index 592cc0c..d7f887e 100644 --- a/c++/examples/h5tutr_crtdat.cpp +++ b/c++/examples/h5tutr_crtdat.cpp @@ -35,32 +35,23 @@ 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(); // 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); - // Define the datatype to be used - //IntType datatype(PredType::STD_I32BE); - // Create the dataset. - DataSet dataset = file.createDataSet(DATASET_NAME, PredType::STD_I32BE, dataspace); } // end of try block diff --git a/c++/examples/h5tutr_extend.cpp b/c++/examples/h5tutr_extend.cpp index 6437fb8..c3a18d7 100644 --- a/c++/examples/h5tutr_extend.cpp +++ b/c++/examples/h5tutr_extend.cpp @@ -36,21 +36,19 @@ const H5std_string DATASETNAME("ExtendibleArray"); int main (void) { - - 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}; - + 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} }; // Variables used in extending and writing to the extended portion of dataset - hsize_t size[2]; - hsize_t offset[2]; - hsize_t dimsext[2] = {7, 3}; // extend dimensions - int dataext[7][3] = { {2, 3, 4}, + hsize_t size[2]; + 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}, @@ -118,13 +116,15 @@ int main (void) 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)); - - filespace = new DataSpace(dataset->getSpace()); + // 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); diff --git a/c++/examples/h5tutr_rdwt.cpp b/c++/examples/h5tutr_rdwt.cpp index a0c1996..e6e45b7 100644 --- a/c++/examples/h5tutr_rdwt.cpp +++ b/c++/examples/h5tutr_rdwt.cpp @@ -47,20 +47,16 @@ 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(); // 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 ); } // end of try block @@ -81,4 +77,3 @@ int main (void) return 0; // successfully terminated } - diff --git a/c++/examples/h5tutr_subset.cpp b/c++/examples/h5tutr_subset.cpp index 76e63fd..77174ab 100644 --- a/c++/examples/h5tutr_subset.cpp +++ b/c++/examples/h5tutr_subset.cpp @@ -48,10 +48,8 @@ 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(); // --------------------------------------------------- diff --git a/c++/examples/run-c++-ex.sh.in b/c++/examples/run-c++-ex.sh.in index 6b33577..77ac36a 100644 --- a/c++/examples/run-c++-ex.sh.in +++ b/c++/examples/run-c++-ex.sh.in @@ -64,6 +64,10 @@ RunTest() # Run tests if [ $? -eq 0 ] then + echo "*************************************************" + echo "** Run C++ API Examples **" + echo "** **" + echo "*************************************************" if (RunTest create &&\ rm create &&\ RunTest readdata &&\ @@ -82,6 +86,33 @@ then else EXIT_VALUE=${EXIT_FAILURE} fi + echo + echo "***************************************************" + echo "** Run Tutorial Examples **" + echo "** **" + echo "***************************************************" + if (RunTest h5tutr_crtdat &&\ + rm h5tutr_crtdat &&\ + RunTest h5tutr_rdwt &&\ + rm h5tutr_rdwt &&\ + RunTest h5tutr_crtatt &&\ + rm h5tutr_crtatt &&\ + RunTest h5tutr_crtgrp &&\ + rm h5tutr_crtgrp &&\ + RunTest h5tutr_crtgrpar &&\ + rm h5tutr_crtgrpar &&\ + RunTest h5tutr_crtgrpd &&\ + rm h5tutr_crtgrpd &&\ + RunTest h5tutr_extend &&\ + rm h5tutr_extend &&\ + RunTest h5tutr_subset &&\ + rm h5tutr_subset &&\ + RunTest h5tutr_cmprss &&\ + rm h5tutr_cmprss ); then + EXIT_VALUE=${EXIT_SUCCESS} + else + EXIT_VALUE=${EXIT_FAILURE} + fi fi # Cleanup diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp index 8513372..ac1f506 100644 --- a/c++/src/H5Exception.cpp +++ b/c++/src/H5Exception.cpp @@ -330,7 +330,9 @@ FileIException::FileIException():Exception(){} ///\param func_name - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -FileIException::FileIException(const H5std_string& func_name, const H5std_string& message) : Exception(func_name, message) {} +FileIException::FileIException(const H5std_string& func_name, const H5std_string& message) : Exception(func_name, message) { + fprintf(stderr, "FileIException::FileIException is thrown, <%s> <%s>\n", func_name.c_str(), message.c_str()); + } //-------------------------------------------------------------------------- // Function: FileIException destructor ///\brief Noop destructor. |