summaryrefslogtreecommitdiffstats
path: root/doxygen/dox/cookbook
diff options
context:
space:
mode:
Diffstat (limited to 'doxygen/dox/cookbook')
-rw-r--r--doxygen/dox/cookbook/Accessibility.c48
-rw-r--r--doxygen/dox/cookbook/Accessibility.dox39
-rw-r--r--doxygen/dox/cookbook/Attributes.c61
-rw-r--r--doxygen/dox/cookbook/Attributes.dox38
-rw-r--r--doxygen/dox/cookbook/Files.c87
-rw-r--r--doxygen/dox/cookbook/Files.dox71
-rw-r--r--doxygen/dox/cookbook/Performance.dox21
7 files changed, 365 insertions, 0 deletions
diff --git a/doxygen/dox/cookbook/Accessibility.c b/doxygen/dox/cookbook/Accessibility.c
new file mode 100644
index 0000000..f4cc905
--- /dev/null
+++ b/doxygen/dox/cookbook/Accessibility.c
@@ -0,0 +1,48 @@
+/* -*- c-file-style: "stroustrup" -*- */
+
+#include "hdf5.h"
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(void)
+{
+ int ret_val = EXIT_SUCCESS;
+
+ //! <!-- [set_libver_bounds] -->
+ {
+ __label__ fail_fapl, fail_file;
+ hid_t fapl, file, aspace, attr;
+
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
+ ret_val = EXIT_FAILURE;
+ goto fail_fapl;
+ }
+#if H5_VERSION_GE(1, 10, 0)
+ if (H5Pset_libver_bounds(fapl, H5F_LIBVER_V18, H5F_LIBVER_V18) < 0) {
+#elif H5_VERSION_GE(1, 8, 0)
+ if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) {
+#else
+#error Only HDF5 1.8.x and later supported.
+#endif
+ ret_val = EXIT_FAILURE;
+ goto fail_file;
+ }
+ if ((file = H5Fcreate("set_libver_bounds.h5", H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) {
+ ret_val = EXIT_FAILURE;
+ goto fail_file;
+ }
+
+ H5Fclose(file);
+fail_file:
+ H5Pclose(fapl);
+fail_fapl:;
+ }
+ //! <!-- [set_libver_bounds] -->
+
+ assert(ret_val == EXIT_SUCCESS);
+
+ return ret_val;
+}
diff --git a/doxygen/dox/cookbook/Accessibility.dox b/doxygen/dox/cookbook/Accessibility.dox
new file mode 100644
index 0000000..f100283
--- /dev/null
+++ b/doxygen/dox/cookbook/Accessibility.dox
@@ -0,0 +1,39 @@
+/** \page Accessibility
+
+\section Accessibility
+
+\subsection CB_MaintainCompat Maintaining Compatibility with other HDF5 Library Versions
+
+\par Problem
+You want to ensure that the HDF5 files you produce or modify are accessible by all
+releavnt tools and applications
+
+\par Solution
+For HDF5 items (objects, attributes, etc.) that you would like to
+create in new or existing HDF5 files, ascertain the supported range of HDF5
+library versions as lower and upper bounds. When creating new or opening
+existing HDF5 files, use a file access property list and configure the supported
+range via the H5Pset_libver_bounds() function.\n
+In the example below, we restrict HDF5 item creation to the HDF5 1.8.x family of
+library versions.
+\snippet{lineno} Accessibility.c set_libver_bounds
+
+\par Discussion
+See RFC \ref_rfc20160105 for a detailed and comprehensive account of HDF5
+versioning (library, file format spec., etc.) and the H5Pset_libver_bounds()
+function.\n
+The default range #H5F_LIBVER_EARLIEST (low) - #H5F_LIBVER_LATEST (high) offers the
+widest compatibility range, but may not be suitable for certain (feature-)use
+cases.\n
+The HDF5 library comes with a \Emph{forward-} and \Emph{backward-compatibility}
+guarantee: This means that the latest version of the library can always read
+HDF5 files created by a version realesed earlier (backward compatibility).
+It also means that a given release of the library can read the contents of
+HDF5 files created with later versions of the library as long as the files
+do not contain features introduced in later versions (forward compatibility).
+
+\par See Also
+See the recipe \ref CB_LargeAttributes for an example where we use HDF5
+compatibility settings to enable the creation of large HDF5 attributes.
+
+*/ \ No newline at end of file
diff --git a/doxygen/dox/cookbook/Attributes.c b/doxygen/dox/cookbook/Attributes.c
new file mode 100644
index 0000000..f4e894f
--- /dev/null
+++ b/doxygen/dox/cookbook/Attributes.c
@@ -0,0 +1,61 @@
+/* -*- c-file-style: "stroustrup" -*- */
+
+#include "hdf5.h"
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(void)
+{
+ int ret_val = EXIT_SUCCESS;
+
+ //! <!-- [large_attribute] -->
+ {
+ __label__ fail_attr, fail_aspace, fail_fapl, fail_file;
+ hid_t fapl, file, aspace, attr;
+
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
+ ret_val = EXIT_FAILURE;
+ goto fail_fapl;
+ }
+#if H5_VERSION_GE(1, 10, 0)
+ if (H5Pset_libver_bounds(fapl, H5F_LIBVER_V18, H5F_LIBVER_LATEST) < 0) {
+#elif H5_VERSION_GE(1, 8, 0)
+ if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) {
+#else
+#error Only HDF5 1.8.x and later supported.
+#endif
+ ret_val = EXIT_FAILURE;
+ goto fail_file;
+ }
+ if ((file = H5Fcreate("large_attribute.h5", H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) {
+ ret_val = EXIT_FAILURE;
+ goto fail_file;
+ }
+
+ if ((aspace = H5Screate_simple(1, (hsize_t[]){1024 * 1024}, NULL)) < 0) {
+ ret_val = EXIT_FAILURE;
+ goto fail_aspace;
+ }
+ if ((attr = H5Acreate(file, "4MiB", H5T_IEEE_F32LE, aspace, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
+ ret_val = EXIT_FAILURE;
+ goto fail_attr;
+ }
+
+ H5Aclose(attr);
+fail_attr:
+ H5Sclose(aspace);
+fail_aspace:
+ H5Fclose(file);
+fail_file:
+ H5Pclose(fapl);
+fail_fapl:;
+ }
+ //! <!-- [large_attribute] -->
+
+ assert(ret_val == EXIT_SUCCESS);
+
+ return ret_val;
+}
diff --git a/doxygen/dox/cookbook/Attributes.dox b/doxygen/dox/cookbook/Attributes.dox
new file mode 100644
index 0000000..68fd159
--- /dev/null
+++ b/doxygen/dox/cookbook/Attributes.dox
@@ -0,0 +1,38 @@
+/** \page Attributes
+
+\section Attributes
+
+\subsection CB_LargeAttributes Creating "Large" HDF5 Attributes
+
+\par Problem
+You would like to use HDF5 attributes the size of whose values
+exceeds a few dozen kilobytes
+
+\par Solution
+A file format change in the HDF5 1.8.x family of library releases made it
+possible to have attributes larger than about 64 KiB. Ensure that the lower
+library version bound for new HDF5 item creation is at least 1.8.x, and create
+larger attributes as usual.\n
+In the example below, we create an attribute whose value occupies 4 MiB.
+
+\note This feature is only supported in HDF5 1.8.x+
+
+\snippet{lineno} Attributes.c large_attribute
+
+\par Discussion
+Large attributes are supported only in HDF5 versions 1.8.x and higher.
+This has implications for the accessibility of your HDF5 files and
+is your call.\n
+Since there are no size limitations for large attributes, it might
+seem tempting to mistake them for dataset stand-ins. This is not the
+case, for at least two reasons:
+1. Attributes decorate HDF5 objects, have their own local namespace,
+ and can't be link targets.
+2. Attribute I/O treats the attribute value as atomic, i.e., there
+ is no support for partial I/O. A large attribute will always be
+ read or written in its entirety.
+
+\par See Also
+See \ref CB_MaintainCompat for HDF5 compatibility implications.
+
+ */ \ No newline at end of file
diff --git a/doxygen/dox/cookbook/Files.c b/doxygen/dox/cookbook/Files.c
new file mode 100644
index 0000000..b824933
--- /dev/null
+++ b/doxygen/dox/cookbook/Files.c
@@ -0,0 +1,87 @@
+/* -*- c-file-style: "stroustrup" -*- */
+
+#include "hdf5.h"
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(void)
+{
+ int ret_val = EXIT_SUCCESS;
+
+ //! <!-- [free_space] -->
+ {
+ __label__ fail_fcpl, fail_fapl, fail_file;
+ hid_t fcpl, fapl, file;
+
+ if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) {
+ ret_val = EXIT_FAILURE;
+ goto fail_fcpl;
+ }
+#if H5_VERSION_GE(1, 10, 1)
+ if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, 1, 4096) < 0) {
+#else
+#error HDF5 1.10.1+ required
+#endif
+ ret_val = EXIT_FAILURE;
+ goto fail_fapl;
+ }
+
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
+ ret_val = EXIT_FAILURE;
+ goto fail_fapl;
+ }
+#if H5_VERSION_GE(1, 10, 1)
+ if (H5Pset_libver_bounds(fapl, H5F_LIBVER_V110, H5F_LIBVER_LATEST) < 0) {
+#else
+#error HDF5 1.10.x+ required
+#endif
+ ret_val = EXIT_FAILURE;
+ goto fail_file;
+ }
+
+ if ((file = H5Fcreate("free_space.h5", H5F_ACC_TRUNC, fcpl, fapl)) < 0) {
+ ret_val = EXIT_FAILURE;
+ goto fail_file;
+ }
+ H5Fclose(file);
+
+fail_file:
+ H5Pclose(fapl);
+fail_fapl:
+ H5Pclose(fcpl);
+fail_fcpl:;
+ }
+ //! <!-- [free_space] -->
+
+ //! <!-- [user_block] -->
+ {
+ __label__ fail_fcpl, fail_file;
+ hid_t fcpl, file;
+
+ if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) {
+ ret_val = EXIT_FAILURE;
+ goto fail_fcpl;
+ }
+ if (H5Pset_userblock(fcpl, 8192 * 1024) < 0) {
+ ret_val = EXIT_FAILURE;
+ goto fail_file;
+ }
+ if ((file = H5Fcreate("userblock.h5", H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) {
+ ret_val = EXIT_FAILURE;
+ goto fail_file;
+ }
+ H5Fclose(file);
+
+fail_file:
+ H5Pclose(fcpl);
+fail_fcpl:;
+ }
+ //! <!-- [user_block] -->
+
+ assert(ret_val == EXIT_SUCCESS);
+
+ return ret_val;
+}
diff --git a/doxygen/dox/cookbook/Files.dox b/doxygen/dox/cookbook/Files.dox
new file mode 100644
index 0000000..169d638
--- /dev/null
+++ b/doxygen/dox/cookbook/Files.dox
@@ -0,0 +1,71 @@
+/** \page Files
+
+\section Files
+
+\subsection CB_FreeSpace Tracking Free Space in HDF5 Files
+
+\par Problem
+You sometimes delete objects in HDF5 files and don't have new content to use the
+free space, but would like to reuse it in the future.
+
+\par Solution
+At file creation time, set the file space management strategy and persistence of
+free space tracking information via H5Pset_file_space_strategy().
+
+\note This feature is only supported in HDF5 1.10.1+.
+
+\snippet{lineno} Files.c free_space
+
+\par Discussion
+Free space tracking is supported only in HDF5 versions 1.10.x and higher.
+This has implications for the accessibility of your HDF5 files and
+should be considered carefully. If compatibility with previous versions of
+HDF5 must be maintained, space reclamation via \Code{h5repack} might be an option.\n
+The file space strategy #H5F_FSPACE_STRATEGY_FSM_AGGR is not the only option
+that supports free-space tracking. #H5F_FSPACE_STRATEGY_PAGE is another option,
+which adds paged allocation and is used most effectively with page buffering.\n
+For an in-depth account of HDF5 file space management, paged-allocation, and
+page buffering, see the following documents:
+\li \ref_rfc20121024
+\li \ref_rfc20120523
+\li \ref_rfc20150709
+
+\par See Also
+See \ref CB_MaintainCompat for HDF5 compatibility implications.
+
+
+\subsection CB_RemoveUnusedSpace Removing Unused Space from HDF5 Files
+
+\par Problem
+Based on estimates or \Code{h5stat} output you know that a large portion
+of an HDF5 file consists of free or unaccounted space, and you would like
+to remove it.
+
+
+\subsection CB_UserBlock Creating an HDF5 File User Block
+
+\par Problem
+You would like to include certain ancillary, non-HDF5 content in an
+HDF5 file such that it can be accessed without the HDF5 library.
+
+\par Solution
+Use a file creation property list in which the user block size is set via
+H5Pset_userblock(). In the example below, we create an 8 MiB user block.
+\snippet{lineno} Files.c user_block
+
+\par Discussion
+The user block begins at offset 0 and must be at least 512 bytes and a power
+of 2. The HDF5 library ignores any content between the beginning of the
+file and the end of the user block.\n
+You can add or strip a user block to/from an existing HDF5 file with the
+\Code{h5jam}/\Code{h5unjam} tool, respectively.
+\warning
+If you try to embed content into the user block for use by other applications,
+pay close attention to how they handle space beyond the last used byte in the
+user block or the user block in general. In the worst case, applications might
+try to truncate the rest of the file and destroy the HDF5 portion of the file.
+
+\par See Also
+References to related recipes
+
+ */ \ No newline at end of file
diff --git a/doxygen/dox/cookbook/Performance.dox b/doxygen/dox/cookbook/Performance.dox
new file mode 100644
index 0000000..7ac3a18
--- /dev/null
+++ b/doxygen/dox/cookbook/Performance.dox
@@ -0,0 +1,21 @@
+/** \page Performance
+
+\section Performance
+
+\subsection CB_MDCPerf Assessing HDF5 Metadata Cache Performance
+
+\par Problem
+You are trying to diagnose and improve the I/O performance of an application
+and would like to understand if a simple metadata cache adjustment might
+yield substantial performance gains
+
+\par Solution
+The to-the-point solution, i.e., the solution w/o any background or explanation
+
+\par Discussion
+A discussion of the fine points and variants of the solution
+
+\par See Also
+References to related recipes
+
+ */ \ No newline at end of file