summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/CMakeLists.txt24
-rw-r--r--examples/CMakeTests.cmake6
-rw-r--r--examples/Makefile.am12
-rw-r--r--examples/Makefile.in12
-rw-r--r--examples/h5_vds-eiger.c177
-rw-r--r--examples/h5_vds-exc.c215
-rw-r--r--examples/h5_vds-exclim.c222
-rw-r--r--examples/h5_vds-percival.c242
-rw-r--r--examples/h5_vds-simpleIO.c184
-rw-r--r--examples/h5_vds.c257
-rw-r--r--examples/run-c-ex.sh.in14
11 files changed, 1351 insertions, 14 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 1f33f04..f22e355 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -10,20 +10,20 @@ add_definitions (${HDF_EXTRA_C_FLAGS})
# Define Sources
#-----------------------------------------------------------------------------
set (examples
- h5_crtdat
- h5_rdwt
- h5_crtatt
- h5_crtgrp
- h5_crtgrpar
- h5_crtgrpd
- h5_cmprss
- h5_extend
- h5_subset
h5_write
h5_read
h5_extend_write
h5_chunk_read
h5_compound
+ h5_crtgrpar
+ h5_crtgrpd
+ h5_subset
+ h5_cmprss
+ h5_crtdat
+ h5_rdwt
+ h5_crtatt
+ h5_extend
+ h5_crtgrp
h5_group
h5_select
h5_attribute
@@ -34,6 +34,12 @@ set (examples
h5_extlink
h5_elink_unix2win
h5_shared_mesg
+ h5_vds
+ h5_vds-exc
+ h5_vds-exclim
+ h5_vds-eiger
+ h5_vds-simpleIO
+ h5_vds-percival
)
foreach (example ${examples})
diff --git a/examples/CMakeTests.cmake b/examples/CMakeTests.cmake
index 5a756c8..2d1a828 100644
--- a/examples/CMakeTests.cmake
+++ b/examples/CMakeTests.cmake
@@ -42,6 +42,12 @@
blue/prefix_target.h5
red/prefix_target.h5
u2w/u2w_target.h5
+ vds.h5
+ vds-excalibur.h5
+ vds-exclim.h5
+ vds-percival.h5
+ vds-simpleIO.h5
+ vds-eiger.h5
)
if (NOT "${last_test}" STREQUAL "")
set_tests_properties (EXAMPLES-clear-objects PROPERTIES DEPENDS ${last_test})
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 5d0da93..b67a788 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -37,7 +37,8 @@ EXAMPLE_PROG = h5_write h5_read h5_extend_write h5_chunk_read h5_compound \
h5_crtgrpd h5_subset h5_cmprss h5_rdwt h5_crtgrpar h5_extend \
h5_crtatt h5_crtgrp h5_crtdat \
h5_group h5_select h5_attribute h5_mount h5_reference h5_drivers \
- h5_ref2reg h5_extlink h5_elink_unix2win h5_shared_mesg
+ h5_ref2reg h5_extlink h5_elink_unix2win h5_shared_mesg h5_vds h5_vds-exc \
+ h5_vds-exclim h5_vds-eiger h5_vds-simpleIO h5_vds-percival
TEST_SCRIPT=testh5cc.sh
TEST_EXAMPLES_SCRIPT=$(INSTALL_SCRIPT_FILES)
@@ -48,7 +49,8 @@ INSTALL_FILES = h5_write.c h5_read.c h5_extend_write.c h5_chunk_read.c \
h5_extend.c h5_crtatt.c h5_crtgrp.c h5_crtdat.c \
h5_compound.c h5_group.c h5_select.c h5_attribute.c h5_mount.c \
h5_reference.c h5_drivers.c h5_extlink.c h5_elink_unix2win.c \
- h5_ref2reg.c h5_shared_mesg.c ph5example.c
+ h5_ref2reg.c h5_shared_mesg.c ph5example.c h5_vds.c h5_vds-exc.c \
+ h5_vds-exclim.c h5_vds-eiger.c h5_vds-simpleIO.c h5_vds-percival.c
@@ -117,6 +119,12 @@ h5_dtransform: $(srcdir)/h5_dtransform.c
h5_extlink: $(srcdir)/h5_extlink.c $(EXTLINK_DIRS)
h5_elink_unix2win: $(srcdir)/h5_elink_unix2win.c $(EXTLINK_DIRS)
h5_shared_mesg: $(srcdir)/h5_shared_mesg.c
+h5_vds: $(srcdir)/h5_vds.c
+h5_vds-exc: $(srcdir)/h5_vds-exc.c
+h5_vds-exclim: $(srcdir)/h5_vds-exclim.c
+h5_vds-eiger: $(srcdir)/h5_vds-eiger.c
+h5_vds-simpleIO: $(srcdir)/h5_vds-simpleIO.c
+h5_vds-percival: $(srcdir)/h5_vds-percival.c
if BUILD_SHARED_SZIP_CONDITIONAL
LD_LIBRARY_PATH=$(LL_PATH)
diff --git a/examples/Makefile.in b/examples/Makefile.in
index 5d76be3..9a57439 100644
--- a/examples/Makefile.in
+++ b/examples/Makefile.in
@@ -615,7 +615,8 @@ EXAMPLE_PROG = h5_write h5_read h5_extend_write h5_chunk_read h5_compound \
h5_crtgrpd h5_subset h5_cmprss h5_rdwt h5_crtgrpar h5_extend \
h5_crtatt h5_crtgrp h5_crtdat \
h5_group h5_select h5_attribute h5_mount h5_reference h5_drivers \
- h5_ref2reg h5_extlink h5_elink_unix2win h5_shared_mesg
+ h5_ref2reg h5_extlink h5_elink_unix2win h5_shared_mesg h5_vds h5_vds-exc \
+ h5_vds-exclim h5_vds-eiger h5_vds-simpleIO h5_vds-percival
TEST_SCRIPT = testh5cc.sh
TEST_EXAMPLES_SCRIPT = $(INSTALL_SCRIPT_FILES)
@@ -627,7 +628,8 @@ INSTALL_FILES = h5_write.c h5_read.c h5_extend_write.c h5_chunk_read.c \
h5_extend.c h5_crtatt.c h5_crtgrp.c h5_crtdat.c \
h5_compound.c h5_group.c h5_select.c h5_attribute.c h5_mount.c \
h5_reference.c h5_drivers.c h5_extlink.c h5_elink_unix2win.c \
- h5_ref2reg.c h5_shared_mesg.c ph5example.c
+ h5_ref2reg.c h5_shared_mesg.c ph5example.c h5_vds.c h5_vds-exc.c \
+ h5_vds-exclim.c h5_vds-eiger.c h5_vds-simpleIO.c h5_vds-percival.c
# The external link examples demonstrate how to use paths; they need
@@ -1080,6 +1082,12 @@ h5_dtransform: $(srcdir)/h5_dtransform.c
h5_extlink: $(srcdir)/h5_extlink.c $(EXTLINK_DIRS)
h5_elink_unix2win: $(srcdir)/h5_elink_unix2win.c $(EXTLINK_DIRS)
h5_shared_mesg: $(srcdir)/h5_shared_mesg.c
+h5_vds: $(srcdir)/h5_vds.c
+h5_vds-exc: $(srcdir)/h5_vds-exc.c
+h5_vds-exclim: $(srcdir)/h5_vds-exclim.c
+h5_vds-eiger: $(srcdir)/h5_vds-eiger.c
+h5_vds-simpleIO: $(srcdir)/h5_vds-simpleIO.c
+h5_vds-percival: $(srcdir)/h5_vds-percival.c
# How to create EXAMPLEDIR if it doesn't already exist
$(EXAMPLEDIR):
diff --git a/examples/h5_vds-eiger.c b/examples/h5_vds-eiger.c
new file mode 100644
index 0000000..93b39b2
--- /dev/null
+++ b/examples/h5_vds-eiger.c
@@ -0,0 +1,177 @@
+/************************************************************
+
+ This example illustrates the concept of the virtual dataset.
+ Eiger use case. Every 5 frames 10x10 are in the source
+ dataset "/A" in file with the name f-<#>.h5
+ This file is intended for use with HDF5 Library version 1.10
+
+ ************************************************************/
+/* EIP Add link to the picture */
+
+#include "hdf5.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+#define FILE "vds-eiger.h5"
+#define DATASET "VDS-Eiger"
+#define VDSDIM0 5
+#define VDSDIM1 10
+#define VDSDIM2 10
+#define DIM0 5
+#define DIM1 10
+#define DIM2 10
+#define RANK 3
+
+int
+main (void)
+{
+ hid_t file, src_space, vspace,
+ dset; /* Handles */
+ hid_t dcpl;
+ herr_t status;
+ hsize_t vdsdims[3] = {VDSDIM0, VDSDIM1, VDSDIM2},
+ vdsdims_max[3] = {H5S_UNLIMITED, VDSDIM1, VDSDIM1},
+ dims[3] = {DIM0, DIM1, DIM2},
+ start[3], /* Hyperslab parameters */
+ stride[3],
+ count[3],
+ block[3];
+ hsize_t start_out[3], /* Hyperslab parameter out */
+ stride_out[3],
+ count_out[3],
+ block_out[3];
+ int i;
+ H5D_layout_t layout; /* Storage layout */
+ size_t num_map; /* Number of mappings */
+ ssize_t len; /* Length of the string; also a return value */
+ char *filename;
+ char *dsetname;
+
+
+ file = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* Create VDS dataspace. */
+ vspace = H5Screate_simple (RANK, vdsdims, vdsdims_max);
+
+ /* Create dataspaces for the source dataset. */
+ src_space = H5Screate_simple (RANK, dims, NULL);
+
+ /* Create VDS creation property */
+ dcpl = H5Pcreate (H5P_DATASET_CREATE);
+
+ /* Initialize hyperslab values */
+
+ start[0] = 0;
+ start[1] = 0;
+ start[2] = 0;
+ stride[0] = DIM0;
+ stride[1] = 1;
+ stride[2] = 1;
+ count[0] = H5S_UNLIMITED;
+ count[1] = 1;
+ count[2] = 1;
+ block[0] = DIM0;
+ block[1] = DIM1;
+ block[2] = DIM2;
+
+ /*
+ * Build the mappings
+ *
+ */
+ status = H5Sselect_hyperslab (vspace, H5S_SELECT_SET, start, stride, count, block);
+ status = H5Pset_virtual (dcpl, vspace, "f-%0b.h5", "/A", src_space);
+
+
+
+ /* Create a virtual dataset */
+ dset = H5Dcreate (file, DATASET, H5T_NATIVE_INT, vspace, H5P_DEFAULT,
+ dcpl, H5P_DEFAULT);
+ status = H5Sclose (vspace);
+ status = H5Sclose (src_space);
+ status = H5Dclose (dset);
+ status = H5Fclose (file);
+
+
+ /*
+ * Now we begin the read section of this example.
+ */
+
+ /*
+ * Open file and dataset using the default properties.
+ */
+ file = H5Fopen (FILE, H5F_ACC_RDONLY, H5P_DEFAULT);
+ dset = H5Dopen (file, DATASET, H5P_DEFAULT);
+
+ /*
+ * Get creation property list and mapping properties.
+ */
+ dcpl = H5Dget_create_plist (dset);
+
+ /*
+ * Get storage layout.
+ */
+ layout = H5Pget_layout (dcpl);
+
+ if (H5D_VIRTUAL == layout)
+ printf(" Dataset has a virtual layout \n");
+ else
+ printf(" Wrong layout found \n");
+
+ /*
+ * Find number of mappings.
+ */
+ status = H5Pget_virtual_count (dcpl, &num_map);
+ printf(" Number of mappings is %d\n", num_map);
+
+ /*
+ * Get mapping parameters for each mapping.
+ */
+ for (i = 0; i < (int)num_map; i++) {
+ printf(" Mapping %d \n", i);
+ printf(" Selection in the virtual dataset \n");
+ /* Get selection in the virttual dataset */
+ vspace = H5Pget_virtual_vspace (dcpl, (size_t)i);
+ if (H5Sget_select_type(vspace) == H5S_SEL_HYPERSLABS) {
+ if (H5Sis_regular_hyperslab(vspace)) {
+ status = H5Sget_regular_hyperslab (vspace, start_out, stride_out, count_out, block_out);
+ printf(" start = [%llu, %llu, %llu] \n", (unsigned long long)start_out[0], (unsigned long long)start_out[1], (unsigned long long)start_out[2]);
+ printf(" stride = [%llu, %llu, %llu] \n", (unsigned long long)stride_out[0], (unsigned long long)stride_out[1], (unsigned long long)stride_out[2]);
+ printf(" count = [%llu, %llu, %llu] \n", (unsigned long long)count_out[0], (unsigned long long)count_out[1], (unsigned long long)count_out[2]);
+ printf(" block = [%llu, %llu, %llu] \n", (unsigned long long)block_out[0], (unsigned long long)block_out[1], (unsigned long long)block_out[2]);
+ }
+ }
+ /* Get source file name */
+ len = H5Pget_virtual_filename (dcpl, (size_t)i, NULL, 0);
+ filename = (char *)malloc((size_t)len*sizeof(char)+1);
+ H5Pget_virtual_filename (dcpl, (size_t)i, filename, len+1);
+ printf(" Source filename %s\n", filename);
+
+ /* Get source dataset name */
+ len = H5Pget_virtual_dsetname (dcpl, (size_t)i, NULL, 0);
+ dsetname = (char *)malloc((size_t)len*sizeof(char)+1);
+ H5Pget_virtual_dsetname (dcpl, (size_t)i, dsetname, len+1);
+ printf(" Source dataset name %s\n", dsetname);
+
+ /* Get selection in the source dataset */
+ printf(" Selection in the source dataset ");
+ src_space = H5Pget_virtual_srcspace (dcpl, (size_t)i);
+ if(H5Sget_select_type(src_space) == H5S_SEL_ALL) {
+ printf("H5S_ALL \n");
+ }
+/* EIP read data back */
+ H5Sclose(vspace);
+ H5Sclose(src_space);
+ free(filename);
+ free(dsetname);
+ }
+
+ /*
+ * Close and release resources.
+ */
+ status = H5Pclose (dcpl);
+ status = H5Dclose (dset);
+ status = H5Fclose (file);
+
+ return 0;
+}
+
diff --git a/examples/h5_vds-exc.c b/examples/h5_vds-exc.c
new file mode 100644
index 0000000..509b3e1
--- /dev/null
+++ b/examples/h5_vds-exc.c
@@ -0,0 +1,215 @@
+/************************************************************
+
+ This example illustrates the concept of the virtual dataset.
+ Excalibur use case with k=2 and m=3.
+ This file is intended for use with HDF5 Library version 1.10
+
+ ************************************************************/
+/* EIP Add link to the picture */
+
+#include "hdf5.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+#define FILE "vds-exc.h5"
+#define DATASET "VDS-Excalibur"
+#define VDSDIM0 0
+#define VDSDIM1 15
+#define VDSDIM2 6
+#define KDIM0 0
+#define KDIM1 2
+#define KDIM2 6
+#define NDIM0 0
+#define NDIM1 3
+#define NDIM2 6
+#define RANK 3
+
+const char *SRC_FILE[] = {
+ "a.h5",
+ "b.h5",
+ "c.h5",
+ "d.h5",
+ "e.h5",
+ "f.h5"
+};
+
+const char *SRC_DATASET[] = {
+ "A",
+ "B",
+ "C",
+ "D",
+ "E",
+ "F"
+};
+
+int
+main (void)
+{
+ hid_t file, space, ksrc_space, nsrc_space, vspace,
+ src_space,
+ dset; /* Handles */
+ hid_t dcpl;
+ herr_t status;
+ hsize_t vdsdims[3] = {VDSDIM0, VDSDIM1, VDSDIM2},
+ vdsdims_max[3] = {H5S_UNLIMITED,VDSDIM1, VDSDIM2},
+ kdims[3] = {KDIM0, KDIM1, KDIM2},
+ kdims_max[3] = {H5S_UNLIMITED, KDIM1, KDIM2},
+ ndims[3] = {NDIM0, NDIM1, NDIM2},
+ ndims_max[3] = {H5S_UNLIMITED, NDIM1, NDIM2},
+ start[3], /* Hyperslab parameters */
+ stride[3],
+ count[3],
+ block[3];
+ hsize_t start_out[3],
+ stride_out[3],
+ count_out[3],
+ block_out[3];
+ int k = 2;
+ int n = 3;
+ int i;
+ H5D_layout_t layout; /* Storage layout */
+ size_t num_map; /* Number of mappings */
+ ssize_t len; /* Length of the string; also a return value */
+ char *filename;
+ char *dsetname;
+
+
+ file = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* Create VDS dataspace. */
+ space = H5Screate_simple (RANK, vdsdims, vdsdims_max);
+ /* Create dataspaces for A, C, and E datasets. */
+ ksrc_space = H5Screate_simple (RANK, kdims, kdims_max);
+ /* Create dataspaces for B, D, and F datasets. */
+ nsrc_space = H5Screate_simple (RANK, ndims, ndims_max);
+
+ /* Create VDS creation property */
+ dcpl = H5Pcreate (H5P_DATASET_CREATE);
+
+ /* Initialize hyperslab values */
+
+ start[0] = 0;
+ start[1] = 0;
+ start[2] = 0;
+ count[0] = H5S_UNLIMITED;
+ count[1] = 1;
+ count[2] = 1;
+ block[0] = 1;
+ block[1] = k;
+ block[2] = VDSDIM2;
+
+ /*
+ * Build the mappings for A, C and E source datasets.
+ *
+ */
+ for (i = 0; i < 3; i++) {
+ start[1] = (hsize_t)((k+n)*i);
+ status = H5Sselect_hyperslab (space, H5S_SELECT_SET, start, NULL, count, block);
+ status = H5Pset_virtual (dcpl, space, SRC_FILE[2*i], SRC_DATASET[2*i], ksrc_space);
+ }
+
+ /* Reinitialize block[1] */
+ block[1] = n;
+ /*
+ * Build the mappings for B, D and F source datasets.
+ *
+ */
+ for (i = 0; i < 3; i++) {
+ start[1] = (hsize_t)(k+(k+n)*i);
+ status = H5Sselect_hyperslab (space, H5S_SELECT_SET, start, NULL, count, block);
+ status = H5Pset_virtual (dcpl, space, SRC_FILE[2*i+1], SRC_DATASET[2*i+1], nsrc_space);
+ }
+
+ /* Create a virtual dataset */
+ dset = H5Dcreate (file, DATASET, H5T_NATIVE_INT, space, H5P_DEFAULT,
+ dcpl, H5P_DEFAULT);
+ status = H5Sclose (space);
+ status = H5Sclose (nsrc_space);
+ status = H5Sclose (ksrc_space);
+ status = H5Dclose (dset);
+ status = H5Fclose (file);
+
+
+ /*
+ * Now we begin the read section of this example.
+ */
+
+ /*
+ * Open file and dataset using the default properties.
+ */
+ file = H5Fopen (FILE, H5F_ACC_RDONLY, H5P_DEFAULT);
+ dset = H5Dopen (file, DATASET, H5P_DEFAULT);
+
+ /*
+ * Get creation property list and mapping properties.
+ */
+ dcpl = H5Dget_create_plist (dset);
+
+ /*
+ * Get storage layout.
+ */
+ layout = H5Pget_layout (dcpl);
+
+ if (H5D_VIRTUAL == layout)
+ printf(" Dataset has a virtual layout \n");
+ else
+ printf("Wrong layout found \n");
+
+ /*
+ * Find number of mappings.
+ */
+ status = H5Pget_virtual_count (dcpl, &num_map);
+ printf(" Number of mappings is %d\n", num_map);
+
+ /*
+ * Get mapping parameters for each mapping.
+ */
+ for (i = 0; i < (int)num_map; i++) {
+ printf(" Mapping %d \n", i);
+ printf(" Selection in the virtual dataset \n");
+ /* Get selection in the virttual dataset */
+ vspace = H5Pget_virtual_vspace (dcpl, (size_t)i);
+ if (H5Sget_select_type(vspace) == H5S_SEL_HYPERSLABS) {
+ if (H5Sis_regular_hyperslab(vspace)) {
+ status = H5Sget_regular_hyperslab (vspace, start_out, stride_out, count_out, block_out);
+ printf(" start = [%llu, %llu, %llu] \n", (unsigned long long)start_out[0], (unsigned long long)start_out[1], (unsigned long long)start_out[2]);
+ printf(" stride = [%llu, %llu, %llu] \n", (unsigned long long)stride_out[0], (unsigned long long)stride_out[1], (unsigned long long)stride_out[2]);
+ printf(" count = [%llu, %llu, %llu] \n", (unsigned long long)count_out[0], (unsigned long long)count_out[1], (unsigned long long)count_out[2]);
+ printf(" block = [%llu, %llu, %llu] \n", (unsigned long long)block_out[0], (unsigned long long)block_out[1], (unsigned long long)block_out[2]);
+ }
+ }
+ /* Get source file name */
+ len = H5Pget_virtual_filename (dcpl, (size_t)i, NULL, 0);
+ filename = (char *)malloc((size_t)len*sizeof(char)+1);
+ H5Pget_virtual_filename (dcpl, (size_t)i, filename, len+1);
+ printf(" Source filename %s\n", filename);
+
+ /* Get source dataset name */
+ len = H5Pget_virtual_dsetname (dcpl, (size_t)i, NULL, 0);
+ dsetname = (char *)malloc((size_t)len*sizeof(char)+1);
+ H5Pget_virtual_dsetname (dcpl, (size_t)i, dsetname, len+1);
+ printf(" Source dataset name %s\n", dsetname);
+
+ /* Get selection in the source dataset */
+ printf(" Selection in the source dataset ");
+ src_space = H5Pget_virtual_srcspace (dcpl, (size_t)i);
+ if(H5Sget_select_type(src_space) == H5S_SEL_ALL) {
+ printf("H5S_ALL \n");
+ }
+ H5Sclose(vspace);
+ H5Sclose(src_space);
+ free(filename);
+ free(dsetname);
+ }
+/* EIP read data back */
+
+ /*
+ * Close and release resources.
+ */
+ status = H5Pclose (dcpl);
+ status = H5Dclose (dset);
+ status = H5Fclose (file);
+
+ return 0;
+}
+
diff --git a/examples/h5_vds-exclim.c b/examples/h5_vds-exclim.c
new file mode 100644
index 0000000..af39c55
--- /dev/null
+++ b/examples/h5_vds-exclim.c
@@ -0,0 +1,222 @@
+/************************************************************
+
+ This example illustrates the concept of the virtual dataset.
+ Excalibur use case with k=2 and m=3 and only 3 planes in
+ Z-direction (i.e., not unlimited).
+ This file is intended for use with HDF5 Library version 1.10
+
+ ************************************************************/
+/* EIP Add link to the picture */
+
+#include "hdf5.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+#define FILE "vds-exclim.h5"
+#define DATASET "VDS-Excaliburlim"
+#define VDSDIM0 3
+#define VDSDIM1 15
+#define VDSDIM2 6
+#define KDIM0 3
+#define KDIM1 2
+#define KDIM2 6
+#define NDIM0 3
+#define NDIM1 3
+#define NDIM2 6
+#define RANK 3
+
+const char *SRC_FILE[] = {
+ "a.h5",
+ "b.h5",
+ "c.h5",
+ "d.h5",
+ "e.h5",
+ "f.h5"
+};
+
+const char *SRC_DATASET[] = {
+ "A",
+ "B",
+ "C",
+ "D",
+ "E",
+ "F"
+};
+
+int
+main (void)
+{
+ hid_t file, space, ksrc_space, nsrc_space, vspace,
+ src_space,
+ dset; /* Handles */
+ hid_t dcpl;
+ herr_t status;
+ hsize_t vdsdims[3] = {VDSDIM0, VDSDIM1, VDSDIM2},
+ kdims[3] = {KDIM0, KDIM1, KDIM2},
+ ndims[3] = {NDIM0, NDIM1, NDIM2},
+ start[3], /* Hyperslab parameters */
+ stride[3],
+ count[3],
+ block[3];
+ hsize_t start_out[3],
+ stride_out[3],
+ count_out[3],
+ block_out[3];
+ int k = 2;
+ int n = 3;
+ int i;
+ H5D_layout_t layout; /* Storage layout */
+ size_t num_map; /* Number of mappings */
+ ssize_t len; /* Length of the string; also a return value */
+ char *filename;
+ char *dsetname;
+
+
+ file = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* Create VDS dataspace. */
+ space = H5Screate_simple (RANK, vdsdims, NULL);
+ /* Create dataspaces for A, C, and E datasets. */
+ ksrc_space = H5Screate_simple (RANK, kdims, NULL);
+ /* Create dataspaces for B, D, and F datasets. */
+ nsrc_space = H5Screate_simple (RANK, ndims, NULL);
+
+ /* Create VDS creation property */
+ dcpl = H5Pcreate (H5P_DATASET_CREATE);
+
+ /* Initialize hyperslab values */
+
+ start[0] = 0;
+ start[1] = 0;
+ start[2] = 0;
+ count[0] = VDSDIM0;
+ count[1] = 1;
+ count[2] = 1;
+ block[0] = 1;
+ block[1] = k;
+ block[2] = VDSDIM2;
+
+ /*
+ * Build the mappings for A, C and E source datasets.
+ *
+ */
+ status = H5Sselect_hyperslab (ksrc_space, H5S_SELECT_SET, start, NULL, count, block);
+ for (i = 0; i < 3; i++) {
+ start[1] = (hsize_t)((k+n)*i);
+ status = H5Sselect_hyperslab (space, H5S_SELECT_SET, start, NULL, count, block);
+ status = H5Pset_virtual (dcpl, space, SRC_FILE[2*i], SRC_DATASET[2*i], ksrc_space);
+ }
+
+ /* Reinitialize start[0] and block[1] */
+ start[0] = 0;
+ block[1] = n;
+ /*
+ * Build the mappings for B, D and F source datasets.
+ *
+ */
+ status = H5Sselect_hyperslab (nsrc_space, H5S_SELECT_SET, start, NULL, count, block);
+ for (i = 0; i < 3; i++) {
+ start[1] = (hsize_t)(k+(k+n)*i);
+ status = H5Sselect_hyperslab (space, H5S_SELECT_SET, start, NULL, count, block);
+ status = H5Pset_virtual (dcpl, space, SRC_FILE[2*i+1], SRC_DATASET[2*i+1], nsrc_space);
+ }
+
+ /* Create a virtual dataset */
+ dset = H5Dcreate (file, DATASET, H5T_NATIVE_INT, space, H5P_DEFAULT,
+ dcpl, H5P_DEFAULT);
+ status = H5Sclose (space);
+ status = H5Sclose (nsrc_space);
+ status = H5Sclose (ksrc_space);
+ status = H5Dclose (dset);
+ status = H5Fclose (file);
+
+
+ /*
+ * Now we begin the read section of this example.
+ */
+
+ /*
+ * Open file and dataset using the default properties.
+ */
+ file = H5Fopen (FILE, H5F_ACC_RDONLY, H5P_DEFAULT);
+ dset = H5Dopen (file, DATASET, H5P_DEFAULT);
+
+ /*
+ * Get creation property list and mapping properties.
+ */
+ dcpl = H5Dget_create_plist (dset);
+
+ /*
+ * Get storage layout.
+ */
+ layout = H5Pget_layout (dcpl);
+
+ if (H5D_VIRTUAL == layout)
+ printf(" Dataset has a virtual layout \n");
+ else
+ printf("Wrong layout found \n");
+
+ /*
+ * Find number of mappings.
+ */
+ status = H5Pget_virtual_count (dcpl, &num_map);
+ printf(" Number of mappings is %d\n", num_map);
+
+ /*
+ * Get mapping parameters for each mapping.
+ */
+ for (i = 0; i < (int)num_map; i++) {
+ printf(" Mapping %d \n", i);
+ printf(" Selection in the virtual dataset \n");
+ /* Get selection in the virttual dataset */
+ vspace = H5Pget_virtual_vspace (dcpl, (size_t)i);
+ if (H5Sget_select_type(vspace) == H5S_SEL_HYPERSLABS) {
+ if (H5Sis_regular_hyperslab(vspace)) {
+ status = H5Sget_regular_hyperslab (vspace, start_out, stride_out, count_out, block_out);
+ printf(" start = [%llu, %llu, %llu] \n", (unsigned long long)start_out[0], (unsigned long long)start_out[1], (unsigned long long)start_out[2]);
+ printf(" stride = [%llu, %llu, %llu] \n", (unsigned long long)stride_out[0], (unsigned long long)stride_out[1], (unsigned long long)stride_out[2]);
+ printf(" count = [%llu, %llu, %llu] \n", (unsigned long long)count_out[0], (unsigned long long)count_out[1], (unsigned long long)count_out[2]);
+ printf(" block = [%llu, %llu, %llu] \n", (unsigned long long)block_out[0], (unsigned long long)block_out[1], (unsigned long long)block_out[2]);
+ }
+ }
+ /* Get source file name */
+ len = H5Pget_virtual_filename (dcpl, (size_t)i, NULL, 0);
+ filename = (char *)malloc((size_t)len*sizeof(char)+1);
+ H5Pget_virtual_filename (dcpl, (size_t)i, filename, len+1);
+ printf(" Source filename %s\n", filename);
+
+ /* Get source dataset name */
+ len = H5Pget_virtual_dsetname (dcpl, (size_t)i, NULL, 0);
+ dsetname = (char *)malloc((size_t)len*sizeof(char)+1);
+ H5Pget_virtual_dsetname (dcpl, (size_t)i, dsetname, len+1);
+ printf(" Source dataset name %s\n", dsetname);
+
+ /* Get selection in the source dataset */
+ printf(" Selection in the source dataset \n");
+ src_space = H5Pget_virtual_srcspace (dcpl, (size_t)i);
+ if(H5Sget_select_type(src_space) == H5S_SEL_HYPERSLABS) {
+ if (H5Sis_regular_hyperslab(vspace)) {
+ status = H5Sget_regular_hyperslab (vspace, start_out, stride_out, count_out, block_out);
+ printf(" start = [%d, %d, %d] \n", (int)start_out[0], (int)start_out[1], (int)start_out[2]);
+ printf(" stride = [%d, %d, %d] \n", (int)stride_out[0], (int)stride_out[1], (int)stride_out[2]);
+ printf(" count = [%d, %d, %d] \n", (int)count_out[0], (int)count_out[1], (int)count_out[2]);
+ printf(" block = [%d, %d, %d] \n", (int)block_out[0], (int)block_out[1], (int)block_out[2]);
+ }
+ }
+ H5Sclose(vspace);
+ H5Sclose(src_space);
+ free(filename);
+ free(dsetname);
+ }
+/* EIP read data back */
+
+ /*
+ * Close and release resources.
+ */
+ status = H5Pclose (dcpl);
+ status = H5Dclose (dset);
+ status = H5Fclose (file);
+
+ return 0;
+}
+
diff --git a/examples/h5_vds-percival.c b/examples/h5_vds-percival.c
new file mode 100644
index 0000000..ba9e13f
--- /dev/null
+++ b/examples/h5_vds-percival.c
@@ -0,0 +1,242 @@
+/************************************************************
+
+ This example illustrates the concept of the virtual dataset.
+ Percival use case. Every fifth 10x10 plane in VDS is stored in
+ the corresponding 3D unlimited dataset.
+ EIP: For now we will use finite dimension.
+ There are 4 source datasets total.
+ This file is intended for use with HDF5 Library version 1.10
+
+ ************************************************************/
+/* EIP Add link to the picture */
+
+#include "hdf5.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+#define FILE "vds-percival.h5"
+#define DATASET "VDS-Percival"
+/* later
+#define VDSDIM0 H5S_UNLIMITED
+*/
+#define VDSDIM0 40
+#define VDSDIM1 10
+#define VDSDIM2 10
+/* later
+#define DIM0 H5S_UNLIMITED
+*/
+#define DIM0 10
+#define DIM1 10
+#define DIM2 10
+#define RANK 3
+#define PLANE_STRIDE 4
+
+const char *SRC_FILE[] = {
+ "a.h5",
+ "b.h5",
+ "c.h5",
+ "d.h5"
+};
+
+const char *SRC_DATASET[] = {
+ "A",
+ "B",
+ "C",
+ "D"
+};
+
+int
+main (void)
+{
+ hid_t file, src_space, vspace,
+ dset; /* Handles */
+ hid_t dcpl;
+ herr_t status;
+ hsize_t vdsdims[3] = {VDSDIM0, VDSDIM1, VDSDIM2},
+ vdsdims_max[3] = {VDSDIM0, VDSDIM1, VDSDIM2},
+ dims[3] = {DIM0, DIM1, DIM2},
+ dims_max[3] = {DIM0, DIM1, DIM2},
+ start[3], /* Hyperslab start parameter for VDS */
+ stride[3],
+ count[3],
+ src_count[3],
+ block[3];
+ hsize_t start_out[3], /* Hyperslab parameter out */
+ stride_out[3],
+ count_out[3],
+ block_out[3];
+ int i, j;
+ H5D_layout_t layout; /* Storage layout */
+ size_t num_map; /* Number of mappings */
+ ssize_t len; /* Length of the string; also a return value */
+ char *filename;
+ char *dsetname;
+ int wdata[DIM0*DIM1*DIM2];
+
+ /*
+ * Create source files and datasets. This step is optional.
+ */
+ for (i=0; i < PLANE_STRIDE; i++) {
+ /*
+ * Initialize data for i-th source dataset.
+ */
+ for (j = 0; j < DIM0*DIM1*DIM2; j++) wdata[j] = i+1;
+
+ /*
+ * Create the source files and datasets. Write data to each dataset and
+ * close all resources.
+ */
+
+ file = H5Fcreate (SRC_FILE[i], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ src_space = H5Screate_simple (RANK, dims, NULL);
+ dset = H5Dcreate (file, SRC_DATASET[i], H5T_NATIVE_INT, src_space, H5P_DEFAULT,
+ H5P_DEFAULT, H5P_DEFAULT);
+ status = H5Dwrite (dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
+ wdata);
+ status = H5Sclose (src_space);
+ status = H5Dclose (dset);
+ status = H5Fclose (file);
+ }
+
+ file = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* Create VDS dataspace. */
+ vspace = H5Screate_simple (RANK, vdsdims, vdsdims_max);
+
+ /* Create dataspaces for the source dataset. */
+ src_space = H5Screate_simple (RANK, dims, dims_max);
+
+ /* Create VDS creation property */
+ dcpl = H5Pcreate (H5P_DATASET_CREATE);
+
+ /* Initialize hyperslab values */
+
+ start[0] = 0;
+ start[1] = 0;
+ start[2] = 0;
+ stride[0] = PLANE_STRIDE; /* we will select every fifth plane in VDS */
+ stride[1] = 1;
+ stride[2] = 1;
+/* later
+ count[0] = H5S_UNLIMITED;
+*/
+ count[0] = VDSDIM0/4;
+ count[1] = 1;
+ count[2] = 1;
+/* later
+ src_count[0] = H5S_UNLIMITED;
+*/
+ src_count[0] = DIM0;
+ src_count[1] = 1;
+ src_count[2] = 1;
+ block[0] = 1;
+ block[1] = DIM1;
+ block[2] = DIM2;
+
+ /*
+ * Build the mappings
+ *
+ */
+ status = H5Sselect_hyperslab (src_space, H5S_SELECT_SET, start, NULL, src_count, block);
+ for (i=0; i < PLANE_STRIDE; i++) {
+ status = H5Sselect_hyperslab (vspace, H5S_SELECT_SET, start, stride, count, block);
+ status = H5Pset_virtual (dcpl, vspace, SRC_FILE[i], SRC_DATASET[i], src_space);
+ start[0]++;
+ }
+
+ H5Sselect_none(vspace);
+
+ /* Create a virtual dataset */
+ dset = H5Dcreate (file, DATASET, H5T_NATIVE_INT, vspace, H5P_DEFAULT,
+ dcpl, H5P_DEFAULT);
+ status = H5Sclose (vspace);
+ status = H5Sclose (src_space);
+ status = H5Dclose (dset);
+ status = H5Fclose (file);
+
+ /*
+ * Now we begin the read section of this example.
+ */
+
+ /*
+ * Open file and dataset using the default properties.
+ */
+ file = H5Fopen (FILE, H5F_ACC_RDONLY, H5P_DEFAULT);
+ dset = H5Dopen (file, DATASET, H5P_DEFAULT);
+
+ /*
+ * Get creation property list and mapping properties.
+ */
+ dcpl = H5Dget_create_plist (dset);
+
+ /*
+ * Get storage layout.
+ */
+ layout = H5Pget_layout (dcpl);
+
+ if (H5D_VIRTUAL == layout)
+ printf(" Dataset has a virtual layout \n");
+ else
+ printf(" Wrong layout found \n");
+
+ /*
+ * Find number of mappings.
+ */
+ status = H5Pget_virtual_count (dcpl, &num_map);
+ printf(" Number of mappings is %d\n", num_map);
+
+ /*
+ * Get mapping parameters for each mapping.
+ */
+ for (i = 0; i < (int)num_map; i++) {
+ printf(" Mapping %d \n", i);
+ printf(" Selection in the virtual dataset \n");
+ /* Get selection in the virttual dataset */
+ vspace = H5Pget_virtual_vspace (dcpl, (size_t)i);
+ if (H5Sget_select_type(vspace) == H5S_SEL_HYPERSLABS) {
+ if (H5Sis_regular_hyperslab(vspace)) {
+ status = H5Sget_regular_hyperslab (vspace, start_out, stride_out, count_out, block_out);
+ printf(" start = [%llu, %llu, %llu] \n", (unsigned long long)start_out[0], (unsigned long long)start_out[1], (unsigned long long)start_out[2]);
+ printf(" stride = [%llu, %llu, %llu] \n", (unsigned long long)stride_out[0], (unsigned long long)stride_out[1], (unsigned long long)stride_out[2]);
+ printf(" count = [%llu, %llu, %llu] \n", (unsigned long long)count_out[0], (unsigned long long)count_out[1], (unsigned long long)count_out[2]);
+ printf(" block = [%llu, %llu, %llu] \n", (unsigned long long)block_out[0], (unsigned long long)block_out[1], (unsigned long long)block_out[2]);
+ }
+ }
+ /* Get source file name */
+ len = H5Pget_virtual_filename (dcpl, (size_t)i, NULL, 0);
+ filename = (char *)malloc((size_t)len*sizeof(char)+1);
+ H5Pget_virtual_filename (dcpl, (size_t)i, filename, len+1);
+ printf(" Source filename %s\n", filename);
+
+ /* Get source dataset name */
+ len = H5Pget_virtual_dsetname (dcpl, (size_t)i, NULL, 0);
+ dsetname = (char *)malloc((size_t)len*sizeof(char)+1);
+ H5Pget_virtual_dsetname (dcpl, (size_t)i, dsetname, len+1);
+ printf(" Source dataset name %s\n", dsetname);
+
+ /* Get selection in the source dataset */
+ printf(" Selection in the source dataset \n");
+ src_space = H5Pget_virtual_srcspace (dcpl, (size_t)i);
+ if (H5Sget_select_type(src_space) == H5S_SEL_HYPERSLABS) {
+ if (H5Sis_regular_hyperslab(src_space)) {
+ status = H5Sget_regular_hyperslab (src_space, start_out, stride_out, count_out, block_out);
+ printf(" start = [%llu, %llu, %llu] \n", (unsigned long long)start_out[0], (unsigned long long)start_out[1], (unsigned long long)start_out[2]);
+ printf(" stride = [%llu, %llu, %llu] \n", (unsigned long long)stride_out[0], (unsigned long long)stride_out[1], (unsigned long long)stride_out[2]);
+ printf(" count = [%llu, %llu, %llu] \n", (unsigned long long)count_out[0], (unsigned long long)count_out[1], (unsigned long long)count_out[2]);
+ printf(" block = [%llu, %llu, %llu] \n", (unsigned long long)block_out[0], (unsigned long long)block_out[1], (unsigned long long)block_out[2]);
+ }
+ }
+ H5Sclose(vspace);
+ H5Sclose(src_space);
+ free(filename);
+ free(dsetname);
+ }
+ /*
+ * Close and release resources.
+ */
+ status = H5Pclose (dcpl);
+ status = H5Dclose (dset);
+ status = H5Fclose (file);
+ return 0;
+}
+
diff --git a/examples/h5_vds-simpleIO.c b/examples/h5_vds-simpleIO.c
new file mode 100644
index 0000000..e4b0018
--- /dev/null
+++ b/examples/h5_vds-simpleIO.c
@@ -0,0 +1,184 @@
+/************************************************************
+
+ This example illustrates the concept of virtual dataset I/O
+ The program creates 2-dim source dataset and writes
+ data to it. Then it creates 2-dim virtual dataset that has
+ the same dimesnion sizes and maps the all elements of the
+ virtual dataset to all elements of the source dataset.
+ Then VDS is read back.
+
+ This file is intended for use with HDF5 Library version 1.10
+
+ ************************************************************/
+/* EIP Add link to the picture */
+
+#include "hdf5.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+#define FILE "vds-simpleIO.h5"
+#define DATASET "VDS"
+#define DIM1 6
+#define DIM0 4
+#define RANK 2
+
+#define SRC_FILE "a.h5"
+#define SRC_DATASET "/A"
+
+
+int
+main (void)
+{
+ hid_t file, space, src_space, vspace, dset; /* Handles */
+ hid_t dcpl;
+ herr_t status;
+ hsize_t vdsdims[2] = {DIM0, DIM1}, /* Virtual dataset dimension */
+ dims[2] = {DIM0, DIM1}; /* Source dataset dimensions */
+ int wdata[DIM0][DIM1], /* Write buffer for source dataset */
+ rdata[DIM0][DIM1], /* Read buffer for virtual dataset */
+ i, j;
+ H5D_layout_t layout; /* Storage layout */
+ size_t num_map; /* Number of mappings */
+ ssize_t len; /* Length of the string; also a return value */
+ char *filename;
+ char *dsetname;
+ /*
+ * Initialize data.
+ */
+ for (i = 0; i < DIM0; i++)
+ for (j = 0; j < DIM1; j++) wdata[i][j] = i+1;
+
+ /*
+ * Create the source file and the dataset. Write data to the source dataset
+ * and close all resources.
+ */
+
+ file = H5Fcreate (SRC_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ space = H5Screate_simple (RANK, dims, NULL);
+ dset = H5Dcreate (file, SRC_DATASET, H5T_NATIVE_INT, space, H5P_DEFAULT,
+ H5P_DEFAULT, H5P_DEFAULT);
+ status = H5Dwrite (dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
+ wdata[0]);
+ status = H5Sclose (space);
+ status = H5Dclose (dset);
+ status = H5Fclose (file);
+
+ /* Create file in which virtual dataset will be stored. */
+ file = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* Create VDS dataspace. */
+ vspace = H5Screate_simple (RANK, vdsdims, NULL);
+
+ /* Set VDS creation property. */
+ dcpl = H5Pcreate (H5P_DATASET_CREATE);
+
+ /*
+ * Build the mappings.
+ * Selections in the source datasets are H5S_ALL.
+ * In the virtual dataset we select the first, the second and the third rows
+ * and map each row to the data in the corresponding source dataset.
+ */
+ src_space = H5Screate_simple (RANK, dims, NULL);
+ status = H5Pset_virtual (dcpl, vspace, SRC_FILE, SRC_DATASET, src_space);
+
+ /* Create a virtual dataset. */
+ dset = H5Dcreate (file, DATASET, H5T_NATIVE_INT, vspace, H5P_DEFAULT,
+ dcpl, H5P_DEFAULT);
+ status = H5Sclose (vspace);
+ status = H5Sclose (src_space);
+ status = H5Dclose (dset);
+ status = H5Fclose (file);
+
+ /*
+ * Now we begin the read section of this example.
+ */
+
+ /*
+ * Open the file and virtual dataset.
+ */
+ file = H5Fopen (FILE, H5F_ACC_RDONLY, H5P_DEFAULT);
+ dset = H5Dopen (file, DATASET, H5P_DEFAULT);
+ /*
+ * Get creation property list and mapping properties.
+ */
+ dcpl = H5Dget_create_plist (dset);
+
+ /*
+ * Get storage layout.
+ */
+ layout = H5Pget_layout (dcpl);
+ if (H5D_VIRTUAL == layout)
+ printf(" Dataset has a virtual layout \n");
+ else
+ printf(" Wrong layout found \n");
+
+ /*
+ * Find the number of mappings.
+ */
+ status = H5Pget_virtual_count (dcpl, &num_map);
+ printf(" Number of mappings is %d\n", num_map);
+
+ /*
+ * Get mapping parameters for each mapping.
+ */
+ for (i = 0; i < (int)num_map; i++) {
+ printf(" Mapping %d \n", i);
+ printf(" Selection in the virtual dataset ");
+ /* Get selection in the virttual dataset */
+ vspace = H5Pget_virtual_vspace (dcpl, (size_t)i);
+
+ /* Make sure it is ALL selection and then print selection. */
+ if(H5Sget_select_type(vspace) == H5S_SEL_ALL) {
+ printf("Selection is H5S_ALL \n");
+ }
+ /* Get source file name. */
+ len = H5Pget_virtual_filename (dcpl, (size_t)i, NULL, 0);
+ filename = (char *)malloc((size_t)len*sizeof(char)+1);
+ H5Pget_virtual_filename (dcpl, (size_t)i, filename, len+1);
+ printf(" Source filename %s\n", filename);
+
+ /* Get source dataset name. */
+ len = H5Pget_virtual_dsetname (dcpl, (size_t)i, NULL, 0);
+ dsetname = (char *)malloc((size_t)len*sizeof(char)+1);
+ H5Pget_virtual_dsetname (dcpl, (size_t)i, dsetname, len+1);
+ printf(" Source dataset name %s\n", dsetname);
+
+ /* Get selection in the source dataset. */
+ printf(" Selection in the source dataset ");
+ src_space = H5Pget_virtual_srcspace (dcpl, (size_t)i);
+
+ /* Make sure it is ALL selection and then print selection. */
+ if(H5Sget_select_type(src_space) == H5S_SEL_ALL) {
+ printf("Selection is H5S_ALL \n");
+ }
+ H5Sclose(vspace);
+ H5Sclose(src_space);
+ free(filename);
+ free(dsetname);
+ }
+ /*
+ * Read the data using the default properties.
+ */
+ status = H5Dread (dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
+ rdata[0]);
+
+ /*
+ * Output the data to the screen.
+ */
+ printf (" VDS Data:\n");
+ for (i=0; i<DIM0; i++) {
+ printf (" [");
+ for (j=0; j<DIM1; j++)
+ printf (" %3d", rdata[i][j]);
+ printf ("]\n");
+ }
+ /*
+ * Close and release resources.
+ */
+ status = H5Pclose (dcpl);
+ status = H5Dclose (dset);
+ status = H5Fclose (file);
+
+ return 0;
+}
+
diff --git a/examples/h5_vds.c b/examples/h5_vds.c
new file mode 100644
index 0000000..7e128db
--- /dev/null
+++ b/examples/h5_vds.c
@@ -0,0 +1,257 @@
+/************************************************************
+
+ This example illustrates the concept of virtual dataset.
+ The program creates three 1-dim source datasets and writes
+ data to them. Then it creates a 2-dim virtual dataset and
+ maps the first three rows of the virtual dataset to the data
+ in the source datasets. Elements of a row are mapped to all
+ elements of the corresponding source dataset.
+ The fourth row is not mapped and will be filled with the fill
+ values when virtual dataset is read back.
+
+ The program closes all datasets, and then reopens the virtual
+ dataset, and finds and prints its creation properties.
+ Then it reads the values.
+
+ This file is intended for use with HDF5 Library version 1.10
+
+ ************************************************************/
+/* EIP Add link to the picture */
+
+#include "hdf5.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+#define FILE "vds.h5"
+#define DATASET "VDS"
+#define VDSDIM1 6
+#define VDSDIM0 4
+#define DIM0 6
+#define RANK1 1
+#define RANK2 2
+
+const char *SRC_FILE[] = {
+ "a.h5",
+ "b.h5",
+ "c.h5"
+};
+
+const char *SRC_DATASET[] = {
+ "A",
+ "B",
+ "C"
+};
+
+int
+main (void)
+{
+ hid_t file, space, src_space, vspace, dset; /* Handles */
+ hid_t dcpl;
+ herr_t status;
+ hsize_t vdsdims[2] = {VDSDIM0, VDSDIM1}, /* Virtual datasets dimension */
+ dims[1] = {DIM0}, /* Source datasets dimensions */
+ start[2], /* Hyperslab parameters */
+ stride[2],
+ count[2],
+ block[2];
+ hsize_t start_out[2],
+ stride_out[2],
+ count_out[2],
+ block_out[2];
+ int wdata[DIM0], /* Write buffer for source dataset */
+ rdata[VDSDIM0][VDSDIM1], /* Read buffer for virtual dataset */
+ i, j, k, l;
+ int fill_value = -1; /* Fill value for VDS */
+ H5D_layout_t layout; /* Storage layout */
+ size_t num_map; /* Number of mappings */
+ ssize_t len; /* Length of the string; also a return value */
+ char *filename;
+ char *dsetname;
+ hsize_t nblocks;
+ hsize_t *buf; /* Buffer to hold hyperslab coordinates */
+
+ /*
+ * Create source files and datasets. This step is optional.
+ */
+ for (i=0; i < 3; i++) {
+ /*
+ * Initialize data for i-th source dataset.
+ */
+ for (j = 0; j < DIM0; j++) wdata[j] = i+1;
+
+ /*
+ * Create the source files and datasets. Write data to each dataset and
+ * close all resources.
+ */
+
+ file = H5Fcreate (SRC_FILE[i], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ space = H5Screate_simple (RANK1, dims, NULL);
+ dset = H5Dcreate (file, SRC_DATASET[i], H5T_NATIVE_INT, space, H5P_DEFAULT,
+ H5P_DEFAULT, H5P_DEFAULT);
+ status = H5Dwrite (dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
+ wdata);
+ status = H5Sclose (space);
+ status = H5Dclose (dset);
+ status = H5Fclose (file);
+ }
+
+ /* Create file in which virtual dataset will be stored. */
+ file = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* Create VDS dataspace. */
+ space = H5Screate_simple (RANK2, vdsdims, NULL);
+
+ /* Set VDS creation property. */
+ dcpl = H5Pcreate (H5P_DATASET_CREATE);
+ status = H5Pset_fill_value (dcpl, H5T_NATIVE_INT, &fill_value);
+
+ /* Initialize hyperslab values. */
+ start[0] = 0;
+ start[1] = 0;
+ count[0] = 1;
+ count[1] = 1;
+ block[0] = 1;
+ block[1] = VDSDIM1;
+
+ /*
+ * Build the mappings.
+ * Selections in the source datasets are H5S_ALL.
+ * In the virtual dataset we select the first, the second and the third rows
+ * and map each row to the data in the corresponding source dataset.
+ */
+ src_space = H5Screate_simple (RANK1, dims, NULL);
+ for (i = 0; i < 3; i++) {
+ start[0] = (hsize_t)i;
+ /* Select i-th row in the virtual dataset; selection in the source datasets is the same. */
+ status = H5Sselect_hyperslab (space, H5S_SELECT_SET, start, NULL, count, block);
+ status = H5Pset_virtual (dcpl, space, SRC_FILE[i], SRC_DATASET[i], src_space);
+ }
+
+ /* Create a virtual dataset. */
+ dset = H5Dcreate (file, DATASET, H5T_NATIVE_INT, space, H5P_DEFAULT,
+ dcpl, H5P_DEFAULT);
+ status = H5Sclose (space);
+ status = H5Sclose (src_space);
+ status = H5Dclose (dset);
+ status = H5Fclose (file);
+
+ /*
+ * Now we begin the read section of this example.
+ */
+
+ /*
+ * Open the file and virtual dataset.
+ */
+ file = H5Fopen (FILE, H5F_ACC_RDONLY, H5P_DEFAULT);
+ dset = H5Dopen (file, DATASET, H5P_DEFAULT);
+
+ /*
+ * Get creation property list and mapping properties.
+ */
+ dcpl = H5Dget_create_plist (dset);
+
+ /*
+ * Get storage layout.
+ */
+ layout = H5Pget_layout (dcpl);
+ if (H5D_VIRTUAL == layout)
+ printf(" Dataset has a virtual layout \n");
+ else
+ printf(" Wrong layout found \n");
+
+ /*
+ * Find the number of mappings.
+ */
+ status = H5Pget_virtual_count (dcpl, &num_map);
+ printf(" Number of mappings is %d\n", num_map);
+
+ /*
+ * Get mapping parameters for each mapping.
+ */
+ for (i = 0; i < (int)num_map; i++) {
+ printf(" Mapping %d \n", i);
+ printf(" Selection in the virtual dataset ");
+ /* Get selection in the virttual dataset */
+ vspace = H5Pget_virtual_vspace (dcpl, (size_t)i);
+
+ /* Make sure that this is a hyperslab selection and then print information. */
+ if (H5Sget_select_type(vspace) == H5S_SEL_HYPERSLABS) {
+ nblocks = H5Sget_select_hyper_nblocks (vspace);
+ buf = (hsize_t *)malloc(sizeof(hsize_t)*2*RANK2*nblocks);
+ status = H5Sget_select_hyper_blocklist (vspace, (hsize_t)0, nblocks, buf);
+ for (l=0; l<nblocks; l++) {
+ printf("(");
+ for (k=0; k<RANK2-1; k++)
+ printf("%d,", (int)buf[k]);
+ printf("%d ) - (", (int)buf[k]);
+ for (k=0; k<RANK2-1; k++)
+ printf("%d,", (int)buf[RANK2+k]);
+ printf("%d)\n", (int)buf[RANK2+k]);
+ }
+ /* We also can use new APIs to get start, stride, count and block */
+ if (H5Sis_regular_hyperslab(vspace)) {
+ status = H5Sget_regular_hyperslab (vspace, start_out, stride_out, count_out, block_out);
+ printf(" start = [%llu, %llu] \n", (unsigned long long)start_out[0], (unsigned long long)start_out[1]);
+ printf(" stride = [%llu, %llu] \n", (unsigned long long)stride_out[0], (unsigned long long)stride_out[1]);
+ printf(" count = [%llu, %llu] \n", (unsigned long long)count_out[0], (unsigned long long)count_out[1]);
+ printf(" block = [%llu, %llu] \n", (unsigned long long)block_out[0], (unsigned long long)block_out[1]);
+ }
+ }
+ /* Get source file name. */
+ len = H5Pget_virtual_filename (dcpl, (size_t)i, NULL, 0);
+ filename = (char *)malloc((size_t)len*sizeof(char)+1);
+ H5Pget_virtual_filename (dcpl, (size_t)i, filename, len+1);
+ printf(" Source filename %s\n", filename);
+
+ /* Get source dataset name. */
+ len = H5Pget_virtual_dsetname (dcpl, (size_t)i, NULL, 0);
+ dsetname = (char *)malloc((size_t)len*sizeof(char)+1);
+ H5Pget_virtual_dsetname (dcpl, (size_t)i, dsetname, len+1);
+ printf(" Source dataset name %s\n", dsetname);
+
+ /* Get selection in the source dataset. */
+ printf(" Selection in the source dataset ");
+ src_space = H5Pget_virtual_srcspace (dcpl, (size_t)i);
+
+ /* Make sure it is ALL selection and then print the coordinates. */
+ if(H5Sget_select_type(src_space) == H5S_SEL_ALL) {
+ printf("(0) - (%d) \n", DIM0-1);
+ }
+ H5Sclose(vspace);
+ H5Sclose(src_space);
+ free(filename);
+ free(dsetname);
+ free(buf);
+ }
+ /* EIP Initialize read buffer with -2 since fille values for VDS are not implemented yet */
+ for (i=0; i<VDSDIM0; i++) {
+ for (j=0; j<VDSDIM1; j++)
+ rdata[i][j] = -2;
+ }
+
+ /*
+ * Read the data using the default properties.
+ */
+ status = H5Dread (dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
+ rdata[0]);
+
+ /*
+ * Output the data to the screen.
+ */
+ printf (" VDS Data:\n");
+ for (i=0; i<VDSDIM0; i++) {
+ printf (" [");
+ for (j=0; j<VDSDIM1; j++)
+ printf (" %3d", rdata[i][j]);
+ printf ("]\n");
+ }
+ /*
+ * Close and release resources.
+ */
+ status = H5Pclose (dcpl);
+ status = H5Dclose (dset);
+ status = H5Fclose (file);
+
+ return 0;
+}
+
diff --git a/examples/run-c-ex.sh.in b/examples/run-c-ex.sh.in
index 6b5d0f7..fe19bc8 100644
--- a/examples/run-c-ex.sh.in
+++ b/examples/run-c-ex.sh.in
@@ -125,7 +125,19 @@ then
RunTest h5_elink_unix2win &&\
rm h5_elink_unix2win &&\
RunTest h5_shared_mesg &&\
- rm h5_shared_mesg); then
+ rm h5_shared_mesg &&\
+ RunTest h5_vds-eiger &&\
+ rm h5_vds-eiger &&\
+ RunTest h5_vds-exclim &&\
+ rm h5_vds-exclim &&\
+ RunTest h5_vds-exc &&\
+ rm h5_vds-exc &&\
+ RunTest h5_vds-simpleIO &&\
+ rm h5_vds-simpleIO &&\
+ RunTest h5_vds-percival &&\
+ rm h5_vds-percival &&\
+ RunTest h5_vds &&\
+ rm h5_vds); then
EXIT_VALUE=${EXIT_SUCCESS}
else
EXIT_VALUE=${EXIT_FAILURE}