[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
This commit is contained in:
Binh-Minh Ribler 2013-09-23 21:12:40 -05:00
parent ab239810e1
commit 91df66782e
9 changed files with 83 additions and 42 deletions

View File

@ -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

View File

@ -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 $@

View File

@ -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 )
{

View File

@ -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

View File

@ -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);

View File

@ -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
}

View File

@ -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();
// ---------------------------------------------------

View File

@ -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

View File

@ -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.