summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElena Pourmal <epourmal@hdfgroup.org>2015-02-22 03:26:08 (GMT)
committerElena Pourmal <epourmal@hdfgroup.org>2015-02-22 03:26:08 (GMT)
commit7881deb15e681d6cee22b8c0f20257c762d115b7 (patch)
treec662fe36061b096a20c838797bda09706eea0154
parent88b7d8d34cd1c645c22197d440115c05435c816a (diff)
downloadhdf5-7881deb15e681d6cee22b8c0f20257c762d115b7.zip
hdf5-7881deb15e681d6cee22b8c0f20257c762d115b7.tar.gz
hdf5-7881deb15e681d6cee22b8c0f20257c762d115b7.tar.bz2
[svn-r26268] Added VDS example.
I ran bin/reconfigure on jam and it modified test/Makefile.in. May be Neil fixed Makefile.am, but didn't run reconfigure? Tested on jam.
-rw-r--r--MANIFEST1
-rw-r--r--examples/Makefile.am5
-rw-r--r--examples/Makefile.in5
-rw-r--r--examples/h5_vds.c244
-rw-r--r--examples/run-c-ex.sh.in4
-rw-r--r--test/Makefile.in2
6 files changed, 255 insertions, 6 deletions
diff --git a/MANIFEST b/MANIFEST
index a0737ef..b6a3168 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -150,6 +150,7 @@
./examples/h5_ref2reg.c
./examples/h5_shared_mesg.c
./examples/ph5example.c
+./examples/h5_vds.c
./examples/testh5cc.sh.in
./examples/README
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 5d0da93..419bb7f 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -37,7 +37,7 @@ 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
TEST_SCRIPT=testh5cc.sh
TEST_EXAMPLES_SCRIPT=$(INSTALL_SCRIPT_FILES)
@@ -48,7 +48,7 @@ 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
@@ -117,6 +117,7 @@ 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
if BUILD_SHARED_SZIP_CONDITIONAL
LD_LIBRARY_PATH=$(LL_PATH)
diff --git a/examples/Makefile.in b/examples/Makefile.in
index 71a9b4c..c4b8e3f 100644
--- a/examples/Makefile.in
+++ b/examples/Makefile.in
@@ -624,7 +624,7 @@ 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
TEST_SCRIPT = testh5cc.sh
TEST_EXAMPLES_SCRIPT = $(INSTALL_SCRIPT_FILES)
@@ -636,7 +636,7 @@ 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
# The external link examples demonstrate how to use paths; they need
@@ -1089,6 +1089,7 @@ 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
# How to create EXAMPLEDIR if it doesn't already exist
$(EXAMPLEDIR):
diff --git a/examples/h5_vds.c b/examples/h5_vds.c
new file mode 100644
index 0000000..ed30b5b
--- /dev/null
+++ b/examples/h5_vds.c
@@ -0,0 +1,244 @@
+/************************************************************
+
+ This example illustrates the concept of the virtual dataset.
+ The program creates three 1-dim source datasets and writes
+ data to them. Then it creates 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
+
+ ************************************************************/
+
+#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}, /* Datasets dimension */
+ dims[1] = {DIM0},
+ start[2], /* Hyperslab parameters */
+ stride[2],
+ count[2],
+ block[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);
+ }
+
+ file = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* Create VDS dataspace. */
+ space = H5Screate_simple (RANK2, vdsdims, NULL);
+ src_space = H5Screate_simple (RANK1, dims, NULL);
+
+ /* Create 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.
+ *
+ * Select the first, the second and the third rows and map each row to the data in the
+ * corresponding source datasets.
+ */
+ 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);
+ status = H5Sselect_none (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 file and virtual 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 ");
+ /* 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]);
+ printf(") - ");
+ printf("(");
+ for (k=0; k<RANK2-1; k++) printf("%d,", (int)buf[RANK2+k]);
+ printf("%d", (int)buf[RANK2+k]);
+ printf(")");
+ printf ("\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 the coordinates */
+ if(H5Sget_select_type(src_space) == H5S_SEL_ALL) {
+ printf("(0) - (%d)", DIM0-1);
+ printf ("\n");
+ }
+ H5Sclose(vspace);
+ H5Sclose(src_space);
+ free(filename);
+ free(dsetname);
+ free(buf);
+ }
+
+#ifdef LATER
+ /*
+ * 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");
+ }
+#endif
+ /*
+ * 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 9b2a2bb..9034f5c 100644
--- a/examples/run-c-ex.sh.in
+++ b/examples/run-c-ex.sh.in
@@ -125,7 +125,9 @@ 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 &&
+ rm h5_vds); then
EXIT_VALUE=${EXIT_SUCCESS}
else
EXIT_VALUE=${EXIT_FAILURE}
diff --git a/test/Makefile.in b/test/Makefile.in
index 3e4fd38..45db393 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -1105,7 +1105,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog accum.h5 cmpd_dset.h5 \
earray.h5 efc[0-5].h5 log_vfd_out.log new_multi_file_v16-r.h5 \
new_multi_file_v16-s.h5 split_get_file_image_test-m.h5 \
split_get_file_image_test-r.h5 file_image_core_test.h5.copy \
- unregister_filter_1.h5 unregister_filter_2.h5 vds_[1-4].h5
+ unregister_filter_1.h5 unregister_filter_2.h5 vds_1.h5
# Test script for error_test and err_compat
TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh \