diff options
-rw-r--r-- | MANIFEST | 2 | ||||
-rw-r--r-- | examples/CMakeLists.txt | 2 | ||||
-rw-r--r-- | examples/Makefile.am | 8 | ||||
-rw-r--r-- | examples/Makefile.in | 8 | ||||
-rw-r--r-- | examples/h5_vds-eiger.c | 175 | ||||
-rw-r--r-- | examples/h5_vds-exc.c | 43 | ||||
-rw-r--r-- | examples/h5_vds-exclim.c | 220 | ||||
-rw-r--r-- | examples/run-c-ex.sh.in | 4 |
8 files changed, 437 insertions, 25 deletions
@@ -154,6 +154,8 @@ ./examples/ph5example.c ./examples/h5_vds.c ./examples/h5_vds-exc.c +./examples/h5_vds-exclim.c +./examples/h5_vds-eiger.c ./examples/testh5cc.sh.in ./examples/README diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index bc97b75..cfb0e11 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -34,6 +34,8 @@ set (examples h5_extlink h5_elink_unix2win h5_shared_mesg + h5_vds-eiger + h5_vds-exclim h5_vds-exc h5_vds ) diff --git a/examples/Makefile.am b/examples/Makefile.am index 5ceb81c..667fb3a 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_vds h5_vds-exc + h5_ref2reg h5_extlink h5_elink_unix2win h5_shared_mesg h5_vds h5_vds-exc \ + h5_vds-exclim h5_vds-eiger 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_vds.c h5_vds-exc.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 @@ -119,6 +121,8 @@ 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 if BUILD_SHARED_SZIP_CONDITIONAL LD_LIBRARY_PATH=$(LL_PATH) diff --git a/examples/Makefile.in b/examples/Makefile.in index 183d684..45a9691 100644 --- a/examples/Makefile.in +++ b/examples/Makefile.in @@ -625,7 +625,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_vds h5_vds-exc + h5_ref2reg h5_extlink h5_elink_unix2win h5_shared_mesg h5_vds h5_vds-exc \ + h5_vds-exclim h5_vds-eiger TEST_SCRIPT = testh5cc.sh TEST_EXAMPLES_SCRIPT = $(INSTALL_SCRIPT_FILES) @@ -637,7 +638,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_vds.c h5_vds-exc.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 # The external link examples demonstrate how to use paths; they need @@ -1092,6 +1094,8 @@ 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 # 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..d35fc85 --- /dev/null +++ b/examples/h5_vds-eiger.c @@ -0,0 +1,175 @@ +/************************************************************ + + 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 + + ************************************************************/ + +#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 = [%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]); + } + } + /* 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); + } + + /* + * 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 index 124d22b..ceafe68 100644 --- a/examples/h5_vds-exc.c +++ b/examples/h5_vds-exc.c @@ -10,14 +10,17 @@ #include <stdio.h> #include <stdlib.h> -#define FILE "vds-excalibur.h5" -#define DATASET "VDS-excalibur" -#define VDSDIM1 6 -#define VDSDIM0 15 -#define KDIM0 2 -#define KDIM1 6 -#define NDIM0 3 -#define NDIM1 6 +#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[] = { @@ -46,12 +49,12 @@ main (void) dset; /* Handles */ hid_t dcpl; herr_t status; - hsize_t vdsdims[3] = {0,VDSDIM0, VDSDIM1}, - vdsdims_max[3] = {H5S_UNLIMITED,VDSDIM0, VDSDIM1}, - kdims[3] = {0, KDIM0, KDIM1}, - kdims_max[3] = {H5S_UNLIMITED, KDIM0, KDIM1}, - ndims[3] = {0, NDIM0, NDIM1}, - ndims_max[3] = {H5S_UNLIMITED, NDIM0, NDIM1}, + 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], @@ -68,8 +71,6 @@ main (void) 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 */ file = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -94,14 +95,14 @@ main (void) count[2] = 1; block[0] = 1; block[1] = k; - block[2] = VDSDIM1; + block[2] = VDSDIM2; /* * Build the mappings for A, C and E source datasets. * */ for (i = 0; i < 3; i++) { - start[0] = (hsize_t)((k+n)*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); } @@ -113,7 +114,7 @@ main (void) * */ for (i = 0; i < 3; i++) { - start[0] = (hsize_t)(k+(k+n)*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); } @@ -157,13 +158,13 @@ main (void) * Find number of mappings. */ status = H5Pget_virtual_count (dcpl, &num_map); - printf("Number of mappings is %d\n", 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(" 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); diff --git a/examples/h5_vds-exclim.c b/examples/h5_vds-exclim.c new file mode 100644 index 0000000..0d88442 --- /dev/null +++ b/examples/h5_vds-exclim.c @@ -0,0 +1,220 @@ +/************************************************************ + + 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 + + ************************************************************/ + +#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 = [%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]); + } + } + /* 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); + } + + /* + * 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 c4c87b2..b41d89d 100644 --- a/examples/run-c-ex.sh.in +++ b/examples/run-c-ex.sh.in @@ -126,6 +126,10 @@ then rm h5_elink_unix2win &&\ RunTest h5_shared_mesg &&\ 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 &&\ |