summaryrefslogtreecommitdiffstats
path: root/c++/examples
diff options
context:
space:
mode:
authorLarry Knox <lrknox@hdfgroup.org>2017-07-06 19:16:57 (GMT)
committerLarry Knox <lrknox@hdfgroup.org>2017-07-06 19:16:57 (GMT)
commit23a702e7bad93fc4f14eab07678c75d276e2d0ad (patch)
treeafb57ddaeca17021342fa09b8999c15569630e71 /c++/examples
parent03dbcb75918b2cbf39800d9edf5665d3471a1fee (diff)
parentc15238a38fdb3692466bc1218de4c5aeb420fdcc (diff)
downloadhdf5-23a702e7bad93fc4f14eab07678c75d276e2d0ad.zip
hdf5-23a702e7bad93fc4f14eab07678c75d276e2d0ad.tar.gz
hdf5-23a702e7bad93fc4f14eab07678c75d276e2d0ad.tar.bz2
Merge pull request #593 in HDFFV/hdf5 from hdf5_1_8_19 to 1.8/masterhdf5-1_8_19
* commit 'c15238a38fdb3692466bc1218de4c5aeb420fdcc': (153 commits) Commit changes to release version strings in README.txt and RELEASE.txt from release. Put back link targets for dynamically loaded libraries in Makefile.ams that avoid linking with libhdf5 dependencies. Some configurations failed unnecessarily to find and link with lz and lsz when these targets were removed. Update URL for obtaining source inINSTALL file. Disable building of libdynlib* dynamically loaded plugin test libraries on CYGWIN. Added known problem entry to RELEASE.txt. Set version for 1.8.19 release. Barbara updated contents of README.txt file. Moved libdynlib* plugin test libraries to noist_LT_LIBRARIES with added flag '-rpath /nowhere' to stop them being installed while keeping them from linking with libhdf5, etc. Incremented version to 1.8.19-pre1 and ran bin/release to create tar and zip files for testing. HDF5 1.8.19-pre1 released. Add RELEASE.txt entry for H5Dget_chunk_size. Remove test entries Ran bin/reconfigure after so number change. Update hl lib .so numbers: new function was added. Update RELEASE.txt: move H5DOread_chunks entry to new features, clarify entry for HDFFV-10051. Updated notes for test fixes and added bug fix for h5diff help text. Update h5vers and release scripts for 1.8.19 branch, set version to 1.8.19-pre1. Make script name consistent across product versions Update version to 1.8.19-pre1. Propagate .so number changes to Makefile.ins with bin/reconfigure. Add toolset option Update so version numbers according to the interface compatibility report. Update supported Platforms section. Remove empty sub-sections of New Features and Bugs Fixed sections. Add entries for HDFFV-10051 and HDFFV-9934 to RELEASE.txt. Correct spelling ...
Diffstat (limited to 'c++/examples')
-rw-r--r--c++/examples/CMakeLists.txt12
-rw-r--r--c++/examples/CMakeTests.cmake60
-rw-r--r--c++/examples/Makefile.am10
-rw-r--r--c++/examples/Makefile.in13
-rw-r--r--c++/examples/chunks.cpp348
-rw-r--r--c++/examples/compound.cpp26
-rw-r--r--c++/examples/create.cpp22
-rw-r--r--c++/examples/extend_ds.cpp34
-rw-r--r--c++/examples/h5group.cpp298
-rw-r--r--c++/examples/h5tutr_cmprss.cpp206
-rw-r--r--c++/examples/h5tutr_crtatt.cpp68
-rw-r--r--c++/examples/h5tutr_crtdat.cpp64
-rw-r--r--c++/examples/h5tutr_crtgrp.cpp44
-rw-r--r--c++/examples/h5tutr_crtgrpar.cpp64
-rw-r--r--c++/examples/h5tutr_crtgrpd.cpp146
-rw-r--r--c++/examples/h5tutr_extend.cpp228
-rw-r--r--c++/examples/h5tutr_rdwt.cpp58
-rw-r--r--c++/examples/h5tutr_subset.cpp202
-rw-r--r--c++/examples/readdata.cpp46
-rw-r--r--c++/examples/run-c++-ex.sh.in10
-rw-r--r--c++/examples/testh5c++.sh.in10
-rw-r--r--c++/examples/writedata.cpp528
22 files changed, 1247 insertions, 1250 deletions
diff --git a/c++/examples/CMakeLists.txt b/c++/examples/CMakeLists.txt
index cfcdd8d..e5b0b4a 100644
--- a/c++/examples/CMakeLists.txt
+++ b/c++/examples/CMakeLists.txt
@@ -1,11 +1,11 @@
-cmake_minimum_required (VERSION 3.1.0)
+cmake_minimum_required (VERSION 3.2.2)
+PROJECT (HDF5_CPP_EXAMPLES)
+
# --------------------------------------------------------------------
# Notes: When creating examples they should be prefixed
# with "cpp_ex_". This allows for easier filtering of the examples.
# --------------------------------------------------------------------
-PROJECT (HDF5_CPP_EXAMPLES)
-
#-----------------------------------------------------------------------------
# Define examples
#-----------------------------------------------------------------------------
@@ -38,7 +38,7 @@ foreach (example ${examples})
TARGET_C_PROPERTIES (cpp_ex_${example} STATIC " " " ")
target_link_libraries (cpp_ex_${example} ${HDF5_CPP_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (cpp_ex_${example} PROPERTIES FOLDER examples/cpp)
-endforeach (example ${examples})
+endforeach ()
foreach (example ${tutr_examples})
add_executable (cpp_ex_${example} ${HDF5_CPP_EXAMPLES_SOURCE_DIR}/${example}.cpp)
@@ -46,8 +46,8 @@ foreach (example ${tutr_examples})
TARGET_C_PROPERTIES (cpp_ex_${example} STATIC " " " ")
target_link_libraries (cpp_ex_${example} ${HDF5_CPP_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (cpp_ex_${example} PROPERTIES FOLDER examples/cpp)
-endforeach (example ${tutr_examples})
+endforeach ()
if (BUILD_TESTING)
include (CMakeTests.cmake)
-endif (BUILD_TESTING)
+endif ()
diff --git a/c++/examples/CMakeTests.cmake b/c++/examples/CMakeTests.cmake
index 4db8c68..8043863 100644
--- a/c++/examples/CMakeTests.cmake
+++ b/c++/examples/CMakeTests.cmake
@@ -1,3 +1,14 @@
+#
+# Copyright by The HDF Group.
+# 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
+# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# If you do not have access to either file, you may request a copy from
+# help@hdfgroup.org.
+
##############################################################################
##############################################################################
@@ -8,7 +19,7 @@
add_test (
NAME CPP_ex-clear-objects
COMMAND ${CMAKE_COMMAND}
- -E remove
+ -E remove
Group.h5
SDS.h5
SDScompound.h5
@@ -17,16 +28,29 @@
)
if (NOT "${last_test}" STREQUAL "")
set_tests_properties (CPP_ex-clear-objects PROPERTIES DEPENDS ${last_test})
- endif (NOT "${last_test}" STREQUAL "")
+ endif ()
set (last_test "CPP_ex-clear-objects")
foreach (example ${examples})
- add_test (NAME CPP_ex_${example} COMMAND $<TARGET_FILE:cpp_ex_${example}>)
+ if (HDF5_ENABLE_USING_MEMCHECKER)
+ add_test (NAME CPP_ex_${example} COMMAND $<TARGET_FILE:cpp_ex_${example}>)
+ else ()
+ add_test (NAME CPP_ex_${example} COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:cpp_ex_${example}>"
+ -D "TEST_ARGS:STRING="
+ -D "TEST_EXPECT=0"
+ -D "TEST_SKIP_COMPARE=TRUE"
+ -D "TEST_OUTPUT=cpp_ex_${example}.txt"
+ #-D "TEST_REFERENCE=cpp_ex_${example}.out"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
+ -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
+ )
+ endif ()
if (NOT "${last_test}" STREQUAL "")
set_tests_properties (CPP_ex_${example} PROPERTIES DEPENDS ${last_test})
- endif (NOT "${last_test}" STREQUAL "")
+ endif ()
set (last_test "CPP_ex_${example}")
- endforeach (example ${examples})
+ endforeach ()
#the following dependicies are handled by the order of the files
# SET_TESTS_PROPERTIES(CPP_ex_readdata PROPERTIES DEPENDS CPP_ex_create)
# SET_TESTS_PROPERTIES(CPP_ex_chunks PROPERTIES DEPENDS CPP_ex_extend_ds)
@@ -34,7 +58,7 @@
add_test (
NAME CPP_ex_tutr-clear-objects
COMMAND ${CMAKE_COMMAND}
- -E remove
+ -E remove
h5tutr_cmprss.h5
h5tutr_dset.h5
h5tutr_extend.h5
@@ -44,18 +68,30 @@
)
if (NOT "${last_test}" STREQUAL "")
set_tests_properties (CPP_ex_tutr-clear-objects PROPERTIES DEPENDS ${last_test})
- endif (NOT "${last_test}" STREQUAL "")
+ endif ()
set (last_test "CPP_ex_tutr-clear-objects")
-
+
foreach (example ${tutr_examples})
- add_test (NAME CPP_ex_${example} COMMAND $<TARGET_FILE:cpp_ex_${example}>)
+ if (HDF5_ENABLE_USING_MEMCHECKER)
+ add_test (NAME CPP_ex_${example} COMMAND $<TARGET_FILE:cpp_ex_${example}>)
+ else ()
+ add_test (NAME CPP_ex_${example} COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:cpp_ex_${example}>"
+ -D "TEST_ARGS:STRING="
+ -D "TEST_EXPECT=0"
+ -D "TEST_SKIP_COMPARE=TRUE"
+ -D "TEST_OUTPUT=cpp_ex_${example}.txt"
+ #-D "TEST_REFERENCE=cpp_ex_${example}.out"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
+ -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
+ )
+ endif ()
if (NOT "${last_test}" STREQUAL "")
set_tests_properties (CPP_ex_${example} PROPERTIES DEPENDS ${last_test})
- endif (NOT "${last_test}" STREQUAL "")
+ endif ()
set (last_test "CPP_ex_${example}")
- endforeach (example ${tutr_examples})
+ endforeach ()
#the following dependicies are handled by the order of the files
# SET_TESTS_PROPERTIES(CPP_ex_h5tutr_crtatt PROPERTIES DEPENDS CPP_ex_h5tutr_crtdat)
# SET_TESTS_PROPERTIES(CPP_ex_h5tutr_rdwt PROPERTIES DEPENDS CPP_ex_h5tutr_crtdat)
# SET_TESTS_PROPERTIES(CPP_ex_h5tutr_crtgrpd PROPERTIES DEPENDS CPP_ex_h5tutr_crtgrpar)
- \ No newline at end of file
diff --git a/c++/examples/Makefile.am b/c++/examples/Makefile.am
index 2408217..51ab8e3 100644
--- a/c++/examples/Makefile.am
+++ b/c++/examples/Makefile.am
@@ -5,12 +5,10 @@
#
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
-# the files COPYING and Copyright.html. COPYING can be found at the root
-# of the source code distribution tree; Copyright.html can be found at the
-# root level of an installed copy of the electronic HDF5 document set and
-# is linked from the top-level documents page. It can also be found at
-# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have
-# access to either file, you may request a copy from help@hdfgroup.org.
+# the COPYING file, which can be found at the root of the source code
+# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# If you do not have access to either file, you may request a copy from
+# help@hdfgroup.org.
##
## Makefile.am
## Run automake to generate a Makefile.in from this file.
diff --git a/c++/examples/Makefile.in b/c++/examples/Makefile.in
index d13f818..863765f 100644
--- a/c++/examples/Makefile.in
+++ b/c++/examples/Makefile.in
@@ -21,12 +21,10 @@
#
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
-# the files COPYING and Copyright.html. COPYING can be found at the root
-# of the source code distribution tree; Copyright.html can be found at the
-# root level of an installed copy of the electronic HDF5 document set and
-# is linked from the top-level documents page. It can also be found at
-# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have
-# access to either file, you may request a copy from help@hdfgroup.org.
+# the COPYING file, which can be found at the root of the source code
+# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# If you do not have access to either file, you may request a copy from
+# help@hdfgroup.org.
#
# HDF5 Library Examples Makefile(.in)
#
@@ -495,6 +493,7 @@ THREADSAFE = @THREADSAFE@
TIME = @TIME@
TR = @TR@
TRACE_API = @TRACE_API@
+UNAME_CYGWIN = @UNAME_CYGWIN@
UNAME_INFO = @UNAME_INFO@
USE_FILTER_DEFLATE = @USE_FILTER_DEFLATE@
USE_FILTER_SZIP = @USE_FILTER_SZIP@
@@ -648,7 +647,7 @@ EXTRA_PROG = $(EXAMPLE_PROG) $(EXAMPLE_PROG_PARA)
MOSTLYCLEANFILES = *.raw *.meta *.o
CLEANFILES = $(EXAMPLE_PROG) $(EXAMPLE_PROG_PARA)
-# Automake needs to be taught how to build lib, progs, and tests targets.
+# Automake needs to be taught how to build lib, dyn, progs, and tests targets.
# These will be filled in automatically for the most part (e.g.,
# lib_LIBRARIES are built for lib target), but EXTRA_LIB, EXTRA_PROG, and
# EXTRA_TEST variables are supplied to allow the user to force targets to
diff --git a/c++/examples/chunks.cpp b/c++/examples/chunks.cpp
index 286934a..ba2c089 100644
--- a/c++/examples/chunks.cpp
+++ b/c++/examples/chunks.cpp
@@ -5,12 +5,10 @@
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
- * the files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
@@ -47,194 +45,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.printError();
- return -1;
+ error.printError();
+ return -1;
}
// catch failure caused by the DataSet operations
catch( DataSetIException error )
{
- error.printError();
- return -1;
+ error.printError();
+ return -1;
}
// catch failure caused by the DataSpace operations
catch( DataSpaceIException error )
{
- error.printError();
- return -1;
+ error.printError();
+ return -1;
}
return 0;
}
diff --git a/c++/examples/compound.cpp b/c++/examples/compound.cpp
index dfc5d81..284ce16 100644
--- a/c++/examples/compound.cpp
+++ b/c++/examples/compound.cpp
@@ -5,12 +5,10 @@
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
- * the files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
@@ -51,15 +49,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
@@ -145,12 +143,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;
/*
@@ -171,7 +169,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 b4cc768..2993a0c 100644
--- a/c++/examples/create.cpp
+++ b/c++/examples/create.cpp
@@ -5,12 +5,10 @@
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
- * the files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
@@ -30,11 +28,11 @@
using namespace H5;
#endif
-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)
{
@@ -46,7 +44,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 2723263..dbedfc9 100644
--- a/c++/examples/extend_ds.cpp
+++ b/c++/examples/extend_ds.cpp
@@ -5,12 +5,10 @@
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
- * the files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
@@ -113,8 +111,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 );
/*
@@ -187,16 +185,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 a5137bc..6e1764f 100644
--- a/c++/examples/h5group.cpp
+++ b/c++/examples/h5group.cpp
@@ -5,12 +5,10 @@
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
- * the files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
@@ -43,7 +41,7 @@
#endif
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,
@@ -58,169 +56,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.printError();
- return -1;
+ error.printError();
+ return -1;
}
// catch failure caused by the DataSet operations
catch( DataSetIException error )
{
- error.printError();
- return -1;
+ error.printError();
+ return -1;
}
// catch failure caused by the DataSpace operations
catch( DataSpaceIException error )
{
- error.printError();
- return -1;
+ error.printError();
+ return -1;
}
// catch failure caused by the Attribute operations
catch( AttributeIException error )
{
- error.printError();
- return -1;
+ error.printError();
+ return -1;
}
return 0;
}
diff --git a/c++/examples/h5tutr_cmprss.cpp b/c++/examples/h5tutr_cmprss.cpp
index e9c87f1..32f67ad 100644
--- a/c++/examples/h5tutr_cmprss.cpp
+++ b/c++/examples/h5tutr_cmprss.cpp
@@ -1,16 +1,14 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
@@ -31,130 +29,130 @@
#endif // H5_NO_STD
#endif
-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.printError();
- return -1;
+ error.printError();
+ return -1;
}
// catch failure caused by the DataSet operations
catch(DataSetIException error)
{
- error.printError();
- return -1;
+ error.printError();
+ return -1;
}
// catch failure caused by the DataSpace operations
catch(DataSpaceIException error)
{
- error.printError();
- return -1;
+ error.printError();
+ return -1;
}
return 0; // successfully terminated
diff --git a/c++/examples/h5tutr_crtatt.cpp b/c++/examples/h5tutr_crtatt.cpp
index df8ca5a..bdc2fc5 100644
--- a/c++/examples/h5tutr_crtatt.cpp
+++ b/c++/examples/h5tutr_crtatt.cpp
@@ -1,16 +1,14 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
@@ -27,11 +25,11 @@
using namespace H5;
#endif
-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)
{
@@ -42,52 +40,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.printError();
- return -1;
+ error.printError();
+ return -1;
}
// catch failure caused by the H5File operations
catch( AttributeIException error )
{
- error.printError();
- return -1;
+ error.printError();
+ return -1;
}
// catch failure caused by the H5File operations
catch( FileIException error )
{
- error.printError();
- return -1;
+ error.printError();
+ return -1;
}
// catch failure caused by the DataSet operations
catch( DataSetIException error )
{
- error.printError();
- return -1;
+ error.printError();
+ return -1;
}
return 0; // successfully terminated
diff --git a/c++/examples/h5tutr_crtdat.cpp b/c++/examples/h5tutr_crtdat.cpp
index c767f72..9fed595 100644
--- a/c++/examples/h5tutr_crtdat.cpp
+++ b/c++/examples/h5tutr_crtdat.cpp
@@ -1,16 +1,14 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
@@ -27,54 +25,54 @@
using namespace H5;
#endif
-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.printError();
- return -1;
+ error.printError();
+ return -1;
}
// catch failure caused by the DataSet operations
catch(DataSetIException error)
{
- error.printError();
- return -1;
+ error.printError();
+ return -1;
}
// catch failure caused by the DataSpace operations
catch(DataSpaceIException error)
{
- error.printError();
- return -1;
+ error.printError();
+ return -1;
}
return 0; // successfully terminated
diff --git a/c++/examples/h5tutr_crtgrp.cpp b/c++/examples/h5tutr_crtgrp.cpp
index 3db4e72..cee306c 100644
--- a/c++/examples/h5tutr_crtgrp.cpp
+++ b/c++/examples/h5tutr_crtgrp.cpp
@@ -1,16 +1,14 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
@@ -38,31 +36,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.printError();
- return -1;
+ error.printError();
+ return -1;
}
// catch failure caused by the Group operations
catch(GroupIException error)
{
- error.printError();
- return -1;
+ error.printError();
+ return -1;
}
return 0;
diff --git a/c++/examples/h5tutr_crtgrpar.cpp b/c++/examples/h5tutr_crtgrpar.cpp
index f6e031f..d120833 100644
--- a/c++/examples/h5tutr_crtgrpar.cpp
+++ b/c++/examples/h5tutr_crtgrpar.cpp
@@ -1,16 +1,14 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
@@ -40,50 +38,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.printError();
- return -1;
+ error.printError();
+ return -1;
}
// catch failure caused by the Group operations
catch(GroupIException error)
{
- error.printError();
- return -1;
+ error.printError();
+ return -1;
}
return 0;
diff --git a/c++/examples/h5tutr_crtgrpd.cpp b/c++/examples/h5tutr_crtgrpd.cpp
index f0bde52..12c6848 100644
--- a/c++/examples/h5tutr_crtgrpd.cpp
+++ b/c++/examples/h5tutr_crtgrpd.cpp
@@ -1,16 +1,14 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
@@ -34,11 +32,11 @@
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)
{
@@ -48,93 +46,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.printError();
- return -1;
+ error.printError();
+ return -1;
}
// catch failure caused by the DataSet operations
catch(DataSetIException error)
{
- error.printError();
- return -1;
+ error.printError();
+ return -1;
}
// catch failure caused by the DataSpace operations
catch(DataSpaceIException error)
{
- error.printError();
- return -1;
+ error.printError();
+ return -1;
}
// catch failure caused by the Group operations
catch(GroupIException error)
{
- error.printError();
- return -1;
+ error.printError();
+ return -1;
}
return 0;
diff --git a/c++/examples/h5tutr_extend.cpp b/c++/examples/h5tutr_extend.cpp
index 432ca5e..92576f1 100644
--- a/c++/examples/h5tutr_extend.cpp
+++ b/c++/examples/h5tutr_extend.cpp
@@ -1,16 +1,14 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
@@ -31,17 +29,17 @@
#endif // H5_NO_STD
#endif
-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
@@ -49,127 +47,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.printError();
- return -1;
+ error.printError();
+ return -1;
}
// catch failure caused by the DataSet operations
catch(DataSetIException error)
{
- error.printError();
- return -1;
+ error.printError();
+ return -1;
}
// catch failure caused by the DataSpace operations
catch(DataSpaceIException error)
{
- error.printError();
- return -1;
+ error.printError();
+ return -1;
}
return 0; // successfully terminated
diff --git a/c++/examples/h5tutr_rdwt.cpp b/c++/examples/h5tutr_rdwt.cpp
index 68c28ca..076822f 100644
--- a/c++/examples/h5tutr_rdwt.cpp
+++ b/c++/examples/h5tutr_rdwt.cpp
@@ -1,16 +1,14 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
@@ -27,10 +25,10 @@
using namespace H5;
#endif
-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)
{
@@ -38,41 +36,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.printError();
- return -1;
+ error.printError();
+ return -1;
}
// catch failure caused by the DataSet operations
catch(DataSetIException error)
{
- error.printError();
- return -1;
+ error.printError();
+ return -1;
}
return 0; // successfully terminated
diff --git a/c++/examples/h5tutr_subset.cpp b/c++/examples/h5tutr_subset.cpp
index ad52747..13720b9 100644
--- a/c++/examples/h5tutr_subset.cpp
+++ b/c++/examples/h5tutr_subset.cpp
@@ -1,16 +1,14 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
@@ -31,13 +29,13 @@
#endif // H5_NO_STD
#endif
-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)
@@ -48,134 +46,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.printError();
- return -1;
+ error.printError();
+ return -1;
}
// catch failure caused by the DataSet operations
catch(DataSetIException error)
{
- error.printError();
- return -1;
+ error.printError();
+ return -1;
}
// catch failure caused by the DataSpace operations
catch(DataSpaceIException error)
{
- error.printError();
- return -1;
+ error.printError();
+ return -1;
}
return 0; // successfully terminated
diff --git a/c++/examples/readdata.cpp b/c++/examples/readdata.cpp
index b615a40..3826090 100644
--- a/c++/examples/readdata.cpp
+++ b/c++/examples/readdata.cpp
@@ -5,12 +5,10 @@
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
- * the files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
//
@@ -41,9 +39,9 @@
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;
@@ -59,8 +57,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;
}
}
@@ -91,19 +89,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.
@@ -129,15 +127,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;
@@ -156,8 +154,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;
@@ -174,9 +172,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/run-c++-ex.sh.in b/c++/examples/run-c++-ex.sh.in
index 77ac36a..315010e 100644
--- a/c++/examples/run-c++-ex.sh.in
+++ b/c++/examples/run-c++-ex.sh.in
@@ -5,12 +5,10 @@
#
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
-# the files COPYING and Copyright.html. COPYING can be found at the root
-# of the source code distribution tree; Copyright.html can be found at the
-# root level of an installed copy of the electronic HDF5 document set and
-# is linked from the top-level documents page. It can also be found at
-# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have
-# access to either file, you may request a copy from help@hdfgroup.org.
+# the COPYING file, which can be found at the root of the source code
+# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# If you do not have access to either file, you may request a copy from
+# help@hdfgroup.org.
#
# This file: run-c++-ex.sh
diff --git a/c++/examples/testh5c++.sh.in b/c++/examples/testh5c++.sh.in
index ca4fc56..c82ccc3 100644
--- a/c++/examples/testh5c++.sh.in
+++ b/c++/examples/testh5c++.sh.in
@@ -6,12 +6,10 @@
#
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
-# the files COPYING and Copyright.html. COPYING can be found at the root
-# of the source code distribution tree; Copyright.html can be found at the
-# root level of an installed copy of the electronic HDF5 document set and
-# is linked from the top-level documents page. It can also be found at
-# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have
-# access to either file, you may request a copy from help@hdfgroup.org.
+# the COPYING file, which can be found at the root of the source code
+# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# If you do not have access to either file, you may request a copy from
+# help@hdfgroup.org.
#
# Tests for the h5c++ compiler tool
# Created: Albert Cheng, 2007/3/14
diff --git a/c++/examples/writedata.cpp b/c++/examples/writedata.cpp
index 496c5d1..f8a1cea 100644
--- a/c++/examples/writedata.cpp
+++ b/c++/examples/writedata.cpp
@@ -5,12 +5,10 @@
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
- * the files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
@@ -44,19 +42,19 @@
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)
{
@@ -67,271 +65,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.printError();
- return -1;
+ error.printError();
+ return -1;
}
// catch failure caused by the DataSet operations
catch( DataSetIException error )
{
- error.printError();
- return -1;
+ error.printError();
+ return -1;
}
// catch failure caused by the DataSpace operations
catch( DataSpaceIException error )
{
- error.printError();
- return -1;
+ error.printError();
+ return -1;
}
return 0;