Merge remote-tracking branch 'origin/develop' into monotonic_timer

This commit is contained in:
Quincey Koziol
2020-06-26 18:57:38 -05:00
1843 changed files with 351405 additions and 183730 deletions

View File

@@ -1,4 +1,4 @@
Attribute Examples:
Attribute Examples:
H5Acreate2 example: Show how to create an attribute for a dataset and a group
----------------
@@ -19,7 +19,7 @@ H5Acreate2 example: Show how to create an attribute for a dataset and a group
rank=2;
dimsf[0] = H5S_UNLIMITED;
dimsf[1] = H5S_UNLIMITED;
dataspace = H5Screate_simple(rank, dimsf, NULL);
dataspace = H5Screate_simple(rank, dimsf, NULL);
/* Create a dataset */
dataset = H5Dcreate2(file, "Dataset1", H5T_UINT8, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
@@ -122,7 +122,7 @@ H5Alink Example: Shows how to share an attribute between two datasets.
/* Get the OID of the attribute */
attr=H5Aopen(dataset1, "Foo", H5P_DEFAULT);
/*
/*
* Create an attribute in the second dataset to the attribute in dataset1,
* changing the name of the attribute information in dataset2.
*/

View File

@@ -1,10 +1,5 @@
cmake_minimum_required (VERSION 3.2.2)
PROJECT (HDF5_EXAMPLES)
#-----------------------------------------------------------------------------
# Apply Definitions to compiler in this directory and below
#-----------------------------------------------------------------------------
add_definitions (${HDF_EXTRA_C_FLAGS})
cmake_minimum_required (VERSION 3.12)
project (HDF5_EXAMPLES C)
#-----------------------------------------------------------------------------
# Define Sources
@@ -28,9 +23,11 @@ set (examples
h5_select
h5_attribute
h5_mount
h5_reference
h5_ref_extern
h5_ref_compat
h5_reference_deprec
h5_drivers
h5_ref2reg
h5_ref2reg_deprec
h5_extlink
h5_elink_unix2win
h5_shared_mesg
@@ -46,34 +43,30 @@ set (examples
foreach (example ${examples})
add_executable (${example} ${HDF5_EXAMPLES_SOURCE_DIR}/${example}.c)
TARGET_NAMING (${example} STATIC)
TARGET_C_PROPERTIES (${example} STATIC " " " ")
target_link_libraries (${example} ${HDF5_LIB_TARGET})
set_target_properties (${example} PROPERTIES FOLDER examples)
if (BUILD_SHARED_LIBS)
add_executable (${example}-shared ${HDF5_EXAMPLES_SOURCE_DIR}/${example}.c)
TARGET_NAMING (${example}-shared SHARED)
TARGET_C_PROPERTIES (${example}-shared SHARED " " " ")
target_link_libraries (${example}-shared ${HDF5_LIBSH_TARGET})
set_target_properties (${example}-shared PROPERTIES FOLDER examples)
target_include_directories (${example} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
if (NOT BUILD_SHARED_LIBS)
TARGET_C_PROPERTIES (${example} STATIC)
target_link_libraries (${example} PRIVATE ${HDF5_LIB_TARGET})
else ()
TARGET_C_PROPERTIES (${example} SHARED)
target_link_libraries (${example} PRIVATE ${HDF5_LIBSH_TARGET})
endif ()
set_target_properties (${example} PROPERTIES FOLDER examples)
endforeach ()
if (H5_HAVE_PARALLEL)
add_executable (ph5example ${HDF5_EXAMPLES_SOURCE_DIR}/ph5example.c)
TARGET_NAMING (ph5example STATIC)
TARGET_C_PROPERTIES (ph5example STATIC " " " ")
target_link_libraries (ph5example ${HDF5_LIB_TARGET})
set_target_properties (ph5example PROPERTIES FOLDER examples)
if (BUILD_SHARED_LIBS)
add_executable (ph5example-shared ${HDF5_EXAMPLES_SOURCE_DIR}/ph5example.c)
TARGET_NAMING (ph5example-shared SHARED)
TARGET_C_PROPERTIES (ph5example-shared SHARED " " " ")
target_link_libraries (ph5example-shared ${HDF5_LIBSH_TARGET})
set_target_properties (ph5example-shared PROPERTIES FOLDER examples)
target_include_directories (ph5example PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
if (NOT BUILD_SHARED_LIBS)
TARGET_C_PROPERTIES (ph5example STATIC)
target_link_libraries (ph5example PRIVATE ${HDF5_LIB_TARGET} ${MPI_C_LIBRARIES})
else ()
TARGET_C_PROPERTIES (ph5example SHARED)
target_link_libraries (ph5example PRIVATE ${HDF5_LIBSH_TARGET} ${MPI_C_LIBRARIES})
endif ()
set_target_properties (ph5example PROPERTIES FOLDER examples)
endif ()
if (BUILD_TESTING)
if (BUILD_TESTING AND HDF5_TEST_EXAMPLES)
include (CMakeTests.cmake)
endif ()

View File

@@ -15,72 +15,69 @@
### T E S T I N G ###
##############################################################################
##############################################################################
file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/red ${PROJECT_BINARY_DIR}/blue ${PROJECT_BINARY_DIR}/u2w)
if (BUILD_SHARED_LIBS)
file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/H5EX-shared")
file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/H5EX-shared/red ${PROJECT_BINARY_DIR}/H5EX-shared/blue ${PROJECT_BINARY_DIR}/H5EX-shared/u2w)
endif ()
file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/red ${PROJECT_BINARY_DIR}/blue ${PROJECT_BINARY_DIR}/u2w)
set (test_ex_CLEANFILES
Attributes.h5
btrees_file.h5
cmprss.h5
default_file.h5
dset.h5
extend.h5
extlink_prefix_source.h5
extlink_source.h5
extlink_target.h5
group.h5
groups.h5
hard_link.h5
mount1.h5
mount2.h5
one_index_file.h5
only_dspaces_and_attrs_file.h5
only_huge_mesgs_file.h5
REF_REG.h5
refere.h5
SDS.h5
SDScompound.h5
SDSextendible.h5
Select.h5
separate_indexes_file.h5
small_lists_file.h5
soft_link.h5
subset.h5
unix2win.h5
blue/prefix_target.h5
red/prefix_target.h5
u2w/u2w_target.h5
vds.h5
vds-exc.h5
vds-excalibur.h5
vds-exclim.h5
vds-percival.h5
vds-percival-unlim.h5
vds-percival-unlim-maxmin.h5
a.h5
b.h5
c.h5
d.h5
vds-simpleIO.h5
vds-eiger.h5
)
if (HDF5_TEST_SERIAL)
# Remove any output file left over from previous test run
add_test (
NAME EXAMPLES-clear-objects
COMMAND ${CMAKE_COMMAND}
-E remove
Attributes.h5
btrees_file.h5
cmprss.h5
default_file.h5
dset.h5
extend.h5
extlink_prefix_source.h5
extlink_source.h5
extlink_target.h5
group.h5
groups.h5
hard_link.h5
mount1.h5
mount2.h5
one_index_file.h5
only_dspaces_and_attrs_file.h5
only_huge_mesgs_file.h5
REF_REG.h5
refere.h5
SDS.h5
SDScompound.h5
SDSextendible.h5
Select.h5
separate_indexes_file.h5
small_lists_file.h5
soft_link.h5
subset.h5
unix2win.h5
blue/prefix_target.h5
red/prefix_target.h5
u2w/u2w_target.h5
vds.h5
vds-exc.h5
vds-excalibur.h5
vds-exclim.h5
vds-percival.h5
vds-percival-unlim.h5
vds-percival-unlim-maxmin.h5
a.h5
b.h5
c.h5
d.h5
vds-simpleIO.h5
vds-eiger.h5
COMMAND ${CMAKE_COMMAND} -E remove ${test_ex_CLEANFILES}
)
if (NOT "${last_test}" STREQUAL "")
set_tests_properties (EXAMPLES-clear-objects PROPERTIES DEPENDS ${last_test})
endif ()
set (last_test "EXAMPLES-clear-objects")
set_tests_properties (EXAMPLES-clear-objects PROPERTIES FIXTURES_SETUP clear_EXAMPLES)
foreach (example ${examples})
if (HDF5_ENABLE_USING_MEMCHECKER)
add_test (NAME EXAMPLES-${example} COMMAND $<TARGET_FILE:${example}>)
add_test (NAME EXAMPLES-${example} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:${example}>)
else ()
add_test (NAME EXAMPLES-${example} COMMAND "${CMAKE_COMMAND}"
-D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
-D "TEST_PROGRAM=$<TARGET_FILE:${example}>"
-D "TEST_ARGS:STRING="
-D "TEST_EXPECT=0"
@@ -91,132 +88,32 @@
-P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
)
endif ()
if (NOT "${last_test}" STREQUAL "")
set_tests_properties (EXAMPLES-${example} PROPERTIES FIXTURES_REQUIRED clear_EXAMPLES)
if (last_test)
set_tests_properties (EXAMPLES-${example} PROPERTIES DEPENDS ${last_test})
endif ()
set (last_test "EXAMPLES-${example}")
endforeach ()
if (BUILD_SHARED_LIBS)
# Remove any output file left over from previous test run
add_test (
NAME EXAMPLES-shared-clear-objects
COMMAND ${CMAKE_COMMAND}
-E remove
Attributes.h5
btrees_file.h5
cmprss.h5
default_file.h5
dset.h5
extend.h5
extlink_prefix_source.h5
extlink_source.h5
extlink_target.h5
group.h5
groups.h5
hard_link.h5
mount1.h5
mount2.h5
one_index_file.h5
only_dspaces_and_attrs_file.h5
only_huge_mesgs_file.h5
REF_REG.h5
refere.h5
SDS.h5
SDScompound.h5
SDSextendible.h5
Select.h5
separate_indexes_file.h5
small_lists_file.h5
soft_link.h5
subset.h5
unix2win.h5
vds.h5
vds-exc.h5
vds-excalibur.h5
vds-exclim.h5
vds-percival.h5
vds-percival-unlim.h5
vds-percival-unlim-maxmin.h5
a.h5
b.h5
c.h5
d.h5
vds-simpleIO.h5
vds-eiger.h5
blue/prefix_target.h5
red/prefix_target.h5
u2w/u2w_target.h5
WORKING_DIRECTORY
${PROJECT_BINARY_DIR}/H5EX-shared
)
if (NOT "${last_test}" STREQUAL "")
set_tests_properties (EXAMPLES-shared-clear-objects PROPERTIES DEPENDS ${last_test})
endif ()
set (last_test "EXAMPLES-shared-clear-objects")
foreach (example ${examples})
if (HDF5_ENABLE_USING_MEMCHECKER)
add_test (NAME EXAMPLES-shared-${example} COMMAND $<TARGET_FILE:${example}-shared>)
else ()
add_test (NAME EXAMPLES-shared-${example} COMMAND "${CMAKE_COMMAND}"
-D "TEST_PROGRAM=$<TARGET_FILE:${example}>"
-D "TEST_ARGS:STRING="
-D "TEST_EXPECT=0"
-D "TEST_SKIP_COMPARE=TRUE"
-D "TEST_OUTPUT=${example}.txt"
#-D "TEST_REFERENCE=${example}.out"
-D "TEST_FOLDER=${PROJECT_BINARY_DIR}/H5EX-shared"
-P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
)
endif ()
set_tests_properties (EXAMPLES-shared-${example} PROPERTIES WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/H5EX-shared)
if (NOT "${last_test}" STREQUAL "")
set_tests_properties (EXAMPLES-shared-${example} PROPERTIES DEPENDS ${last_test})
endif ()
set (last_test "EXAMPLES-shared-${example}")
endforeach ()
endif ()
endif ()
### Windows pops up a modal permission dialog on this test
if (H5_HAVE_PARALLEL AND NOT WIN32)
if (HDF5_ENABLE_USING_MEMCHECKER)
add_test (NAME EXAMPLES-ph5example COMMAND $<TARGET_FILE:ph5example>)
else ()
add_test (NAME EXAMPLES-ph5example COMMAND "${CMAKE_COMMAND}"
-D "TEST_PROGRAM=$<TARGET_FILE:ph5example>"
-D "TEST_ARGS:STRING="
-D "TEST_EXPECT=0"
-D "TEST_SKIP_COMPARE=TRUE"
-D "TEST_OUTPUT=ph5example.txt"
#-D "TEST_REFERENCE=ph5example.out"
-D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
-P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
)
endif ()
if (NOT "${last_test}" STREQUAL "")
set_tests_properties (EXAMPLES-ph5example PROPERTIES DEPENDS ${last_test})
endif ()
set (last_test "EXAMPLES-ph5example")
if (BUILD_SHARED_LIBS)
if (HDF5_ENABLE_USING_MEMCHECKER)
add_test (NAME EXAMPLES-shared-ph5example COMMAND $<TARGET_FILE:ph5example-shared>)
else ()
add_test (NAME EXAMPLES-shared-ph5example COMMAND "${CMAKE_COMMAND}"
-D "TEST_PROGRAM=$<TARGET_FILE:ph5example-shared>"
-D "TEST_ARGS:STRING="
-D "TEST_EXPECT=0"
-D "TEST_SKIP_COMPARE=TRUE"
-D "TEST_OUTPUT=ph5example-shared.txt"
#-D "TEST_REFERENCE=ph5example-shared.out"
-D "TEST_FOLDER=${PROJECT_BINARY_DIR}/H5EX-shared"
-P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
)
endif ()
set_tests_properties (EXAMPLES-shared-ph5example PROPERTIES WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/H5EX-shared)
if (NOT "${last_test}" STREQUAL "")
set_tests_properties (EXAMPLES-shared-ph5example PROPERTIES DEPENDS ${last_test})
endif ()
set (last_test "EXAMPLES-shared-ph5example")
endif ()
if (H5_HAVE_PARALLEL AND HDF5_TEST_PARALLEL AND NOT WIN32)
if (HDF5_ENABLE_USING_MEMCHECKER)
add_test (NAME MPI_TEST_EXAMPLES-ph5example COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $<TARGET_FILE:ph5example> ${MPIEXEC_POSTFLAGS})
else ()
add_test (NAME MPI_TEST_EXAMPLES-ph5example COMMAND "${CMAKE_COMMAND}"
-D "TEST_PROGRAM=${MPIEXEC_EXECUTABLE};${MPIEXEC_NUMPROC_FLAG};${MPIEXEC_MAX_NUMPROCS};${MPIEXEC_PREFLAGS};$<TARGET_FILE:ph5example>;${MPIEXEC_POSTFLAGS}"
-D "TEST_ARGS:STRING="
-D "TEST_EXPECT=0"
-D "TEST_OUTPUT=ph5example.out"
-D "TEST_REFERENCE:STRING=PHDF5 tests finished with no errors"
-D "TEST_FILTER:STRING=PHDF5 tests finished with no errors"
-D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
-P "${HDF_RESOURCES_EXT_DIR}/grepTest.cmake"
)
endif ()
if (last_test)
set_tests_properties (MPI_TEST_EXAMPLES-ph5example PROPERTIES DEPENDS ${last_test})
endif ()
set (last_test "MPI_TEST_EXAMPLES-ph5example")
endif ()

View File

@@ -32,25 +32,27 @@ INSTALL_TOP_FILES = README
# it would try to compile them instead of using the h5cc script.
# Use the boilerplate in config/examples.am instead.
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_debug_trace \
h5_vds h5_vds-exc h5_vds-exclim h5_vds-eiger h5_vds-simpleIO \
h5_vds-percival h5_vds-percival-unlim h5_vds-percival-unlim-maxmin
TEST_SCRIPT=testh5cc.sh
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_drivers \
h5_reference_deprec h5_ref_extern h5_ref_compat h5_ref2reg h5_ref2reg_deprec \
h5_extlink h5_elink_unix2win h5_shared_mesg h5_debug_trace \
h5_vds h5_vds-exc h5_vds-exclim h5_vds-eiger h5_vds-simpleIO \
h5_vds-percival h5_vds-percival-unlim h5_vds-percival-unlim-maxmin
TEST_SCRIPT=testh5cc.sh
TEST_EXAMPLES_SCRIPT=$(INSTALL_SCRIPT_FILES)
# Install files
# List all file that should be installed in examples directory
INSTALL_FILES = h5_write.c h5_read.c h5_extend_write.c h5_chunk_read.c \
h5_crtgrpd.c h5_subset.c h5_cmprss.c h5_rdwt.c h5_crtgrpar.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 h5_debug_trace.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 h5_vds-percival-unlim.c h5_vds-percival-unlim-maxmin.c
INSTALL_FILES = h5_write.c h5_read.c h5_extend_write.c h5_chunk_read.c h5_compound.c \
h5_crtgrpd.c h5_subset.c h5_cmprss.c h5_rdwt.c h5_crtgrpar.c h5_extend.c \
h5_crtatt.c h5_crtgrp.c h5_crtdat.c \
h5_group.c h5_select.c h5_attribute.c h5_mount.c h5_drivers.c \
h5_reference_deprec.c h5_ref_extern.c h5_ref_compat.c h5_ref2reg.c h5_ref2reg_deprec.c \
h5_extlink.c h5_elink_unix2win.c h5_shared_mesg.c h5_debug_trace.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 h5_vds-percival-unlim.c h5_vds-percival-unlim-maxmin.c
@@ -84,8 +86,8 @@ CHECK_CLEANFILES+=$(EXTLINK_DIRS)
# Example directory
# Note: no '/' after DESTDIR. Explanation in commence.am
EXAMPLEDIR=${DESTDIR}$(exec_prefix)/share/hdf5_examples/c
EXAMPLETOPDIR=${DESTDIR}$(exec_prefix)/share/hdf5_examples
EXAMPLEDIR=${DESTDIR}$(examplesdir)/c
EXAMPLETOPDIR=${DESTDIR}$(examplesdir)
# List dependencies for each program. Normally, automake would take
# care of this for us, but if we tell automake about the programs it
@@ -111,8 +113,10 @@ h5_read: $(srcdir)/h5_read.c
h5_select: $(srcdir)/h5_select.c
h5_attribute: $(srcdir)/h5_attribute.c
h5_mount: $(srcdir)/h5_mount.c
h5_reference: $(srcdir)/h5_reference.c
h5_ref2reg: $(srcdir)/h5_ref2reg.c
h5_ref_compat: $(srcdir)/h5_ref_compat.c
h5_ref_extern: $(srcdir)/h5_ref_extern.c
h5_reference_deprec: $(srcdir)/h5_reference_deprec.c
h5_ref2reg_deprec: $(srcdir)/h5_ref2reg_deprec.c
h5_drivers: $(srcdir)/h5_drivers.c
ph5example: $(srcdir)/ph5example.c
h5_dtransform: $(srcdir)/h5_dtransform.c

View File

@@ -60,7 +60,7 @@ main (void)
float matrix[ADIM1][ADIM2]; /* Attribute data */
herr_t ret; /* Return value */
H5O_info_t oinfo; /* Object info */
H5O_info2_t oinfo; /* Object info */
unsigned i, j; /* Counters */
char string_out[80]; /* Buffer to read string attribute back */
int point_out; /* Buffer to read scalar attribute back */
@@ -189,7 +189,7 @@ main (void)
/*
* Find string attribute by iterating through all attributes
*/
ret = H5Oget_info(dataset, &oinfo);
ret = H5Oget_info3(dataset, &oinfo, H5O_INFO_NUM_ATTRS);
for(i = 0; i < (unsigned)oinfo.num_attrs; i++) {
attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)i, H5P_DEFAULT, H5P_DEFAULT);
atype = H5Aget_type(attr);

View File

@@ -11,10 +11,10 @@
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
/*
* This example illustrates how to create a compressed dataset.
* It is used in the HDF5 Tutorial.
*/
*/
#include "hdf5.h"
@@ -22,11 +22,11 @@
#define RANK 2
#define DIM0 100
#define DIM1 20
int main () {
hid_t file_id, dataset_id, dataspace_id; /* identifiers */
hid_t plist_id;
hid_t plist_id;
size_t nelmts;
unsigned flags, filter_info;
@@ -35,13 +35,12 @@ int main () {
herr_t status;
hsize_t dims[2];
hsize_t cdims[2];
int idx;
int i,j, numfilt;
int buf[DIM0][DIM1];
int rbuf [DIM0][DIM1];
/* Uncomment these variables to use SZIP compression
/* Uncomment these variables to use SZIP compression
unsigned szip_options_mask;
unsigned szip_pixels_per_block;
*/
@@ -63,21 +62,21 @@ int main () {
status = H5Pset_chunk (plist_id, 2, cdims);
/* Set ZLIB / DEFLATE Compression using compression level 6.
* To use SZIP Compression comment out these lines.
*/
status = H5Pset_deflate (plist_id, 6);
* To use SZIP Compression comment out these lines.
*/
status = H5Pset_deflate (plist_id, 6);
/* Uncomment these lines to set SZIP Compression
/* Uncomment these lines to set SZIP Compression
szip_options_mask = H5_SZIP_NN_OPTION_MASK;
szip_pixels_per_block = 16;
status = H5Pset_szip (plist_id, szip_options_mask, szip_pixels_per_block);
*/
dataset_id = H5Dcreate2 (file_id, "Compressed_Data", H5T_STD_I32BE,
dataspace_id, H5P_DEFAULT, plist_id, H5P_DEFAULT);
for (i = 0; i< DIM0; i++)
for (j=0; j<DIM1; j++)
dataset_id = H5Dcreate2 (file_id, "Compressed_Data", H5T_STD_I32BE,
dataspace_id, H5P_DEFAULT, plist_id, H5P_DEFAULT);
for (i = 0; i< DIM0; i++)
for (j=0; j<DIM1; j++)
buf[i][j] = i+j;
status = H5Dwrite (dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
@@ -93,10 +92,10 @@ int main () {
/* Retrieve filter information. */
plist_id = H5Dget_create_plist (dataset_id);
numfilt = H5Pget_nfilters (plist_id);
printf ("Number of filters associated with dataset: %i\n", numfilt);
for (i=0; i<numfilt; i++) {
nelmts = 0;
filter_type = H5Pget_filter2 (plist_id, 0, &flags, &nelmts, NULL, 0, NULL,
@@ -114,9 +113,9 @@ int main () {
}
}
status = H5Dread (dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
H5P_DEFAULT, rbuf);
status = H5Dread (dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
H5P_DEFAULT, rbuf);
status = H5Dclose (dataset_id);
status = H5Pclose (plist_id);
status = H5Fclose (file_id);

View File

@@ -41,7 +41,7 @@ int main() {
dataspace_id = H5Screate_simple(1, &dims, NULL);
/* Create a dataset attribute. */
attribute_id = H5Acreate2 (dataset_id, "Units", H5T_STD_I32BE, dataspace_id,
attribute_id = H5Acreate2 (dataset_id, "Units", H5T_STD_I32BE, dataspace_id,
H5P_DEFAULT, H5P_DEFAULT);
/* Write the attribute data. */

View File

@@ -12,7 +12,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* This example illustrates how to create a dataset that is a 4 x 6
* This example illustrates how to create a dataset that is a 4 x 6
* array. It is used in the HDF5 Tutorial.
*/
@@ -29,18 +29,18 @@ int main() {
file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
/* Create the data space for the dataset. */
dims[0] = 4;
dims[1] = 6;
dims[0] = 4;
dims[1] = 6;
dataspace_id = H5Screate_simple(2, dims, NULL);
/* Create the dataset. */
dataset_id = H5Dcreate2(file_id, "/dset", H5T_STD_I32BE, dataspace_id,
dataset_id = H5Dcreate2(file_id, "/dset", H5T_STD_I32BE, dataspace_id,
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/* End access to the dataset and release resources used by it. */
status = H5Dclose(dataset_id);
/* Terminate access to the data space. */
/* Terminate access to the data space. */
status = H5Sclose(dataspace_id);
/* Close the file. */

View File

@@ -12,7 +12,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* This example illustrates how to create and close a group.
* This example illustrates how to create and close a group.
* It is used in the HDF5 Tutorial.
*/

View File

@@ -12,7 +12,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* This example illustrates the creation of groups using absolute and
* This example illustrates the creation of groups using absolute and
* relative names. It is used in the HDF5 Tutorial.
*/

View File

@@ -67,7 +67,7 @@ int main() {
dataspace_id = H5Screate_simple(2, dims, NULL);
/* Create the second dataset in group "Group_A". */
dataset_id = H5Dcreate2(group_id, "dset2", H5T_STD_I32BE, dataspace_id,
dataset_id = H5Dcreate2(group_id, "dset2", H5T_STD_I32BE, dataspace_id,
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/* Write the second dataset. */

View File

@@ -38,7 +38,7 @@
* understand Unix paths.
*/
static hid_t elink_unix2win_trav(const char *link_name, hid_t cur_group,
const void *udata, size_t udata_size, hid_t lapl_id)
const void *udata, size_t udata_size, hid_t lapl_id, hid_t dxpl_id)
{
hid_t fid;
const char *file_name;

View File

@@ -12,9 +12,9 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* This example how to work with extendible datasets. The dataset
* This example how to work with extendible datasets. The dataset
* must be chunked in order to be extendible.
*
*
* It is used in the HDF5 Tutorial.
*/
@@ -29,28 +29,28 @@ int
main (void)
{
hid_t file; /* handles */
hid_t dataspace, dataset;
hid_t dataspace, dataset;
hid_t filespace, memspace;
hid_t prop;
hid_t prop;
hsize_t dims[2] = {3, 3}; /* dataset dimensions at creation time */
hsize_t dims[2] = {3, 3}; /* dataset dimensions at creation time */
hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
herr_t status;
herr_t status;
hsize_t chunk_dims[2] = {2, 5};
int data[3][3] = { {1, 1, 1}, /* data to write */
{1, 1, 1},
{1, 1, 1} };
{1, 1, 1} };
/* Variables used in extending and writing to the extended portion of dataset */
hsize_t size[2];
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},
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} };
/* Variables used in reading data back */
@@ -58,11 +58,11 @@ main (void)
hsize_t dimsr[2];
hsize_t i, j;
int rdata[10][3];
herr_t status_n;
herr_t status_n;
int rank, rank_chunk;
/* Create the data space with unlimited dimensions. */
dataspace = H5Screate_simple (RANK, dims, maxdims);
dataspace = H5Screate_simple (RANK, dims, maxdims);
/* Create a new file. If file exists its contents will be overwritten. */
file = H5Fcreate (FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
@@ -71,7 +71,7 @@ main (void)
prop = H5Pcreate (H5P_DATASET_CREATE);
status = H5Pset_chunk (prop, RANK, chunk_dims);
/* Create a new dataset within the file using chunk
/* Create a new dataset within the file using chunk
creation properties. */
dataset = H5Dcreate2 (file, DATASETNAME, H5T_NATIVE_INT, dataspace,
H5P_DEFAULT, prop, H5P_DEFAULT);
@@ -90,10 +90,10 @@ main (void)
offset[0] = 3;
offset[1] = 0;
status = H5Sselect_hyperslab (filespace, H5S_SELECT_SET, offset, NULL,
dimsext, NULL);
dimsext, NULL);
/* Define memory space */
memspace = H5Screate_simple (RANK, dimsext, NULL);
memspace = H5Screate_simple (RANK, dimsext, NULL);
/* Write the data to the extended portion of dataset */
status = H5Dwrite (dataset, H5T_NATIVE_INT, memspace, filespace,
@@ -120,7 +120,7 @@ main (void)
prop = H5Dget_create_plist (dataset);
if (H5D_CHUNKED == H5Pget_layout (prop))
if (H5D_CHUNKED == H5Pget_layout (prop))
rank_chunk = H5Pget_chunk (prop, rank, chunk_dimsr);
memspace = H5Screate_simple (rank, dimsr, NULL);

View File

@@ -163,9 +163,9 @@ main (void)
/*
* Resulting dataset
*
* 1 1 1 3 3
* 1 1 1 3 3
* 1 1 1 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

View File

@@ -208,7 +208,7 @@ static void extlink_prefix_example(void)
* that a path was supplied in the udata.
*/
static hid_t UD_soft_traverse(const char *link_name, hid_t cur_group,
const void *udata, size_t udata_size, hid_t lapl_id);
const void *udata, size_t udata_size, hid_t lapl_id, hid_t dxpl_id);
static void soft_link_example(void)
{
@@ -277,7 +277,7 @@ static void soft_link_example(void)
*/
static hid_t UD_soft_traverse(const char *link_name, hid_t cur_group,
const void *udata, size_t udata_size, hid_t lapl_id)
const void *udata, size_t udata_size, hid_t lapl_id, hid_t dxpl_id)
{
const char *target = (const char *) udata;
hid_t ret_value;
@@ -310,13 +310,13 @@ static herr_t UD_hard_create(const char *link_name, hid_t loc_group,
static herr_t UD_hard_delete(const char *link_name, hid_t loc_group,
const void *udata, size_t udata_size);
static hid_t UD_hard_traverse(const char *link_name, hid_t cur_group,
const void *udata, size_t udata_size, hid_t lapl_id);
const void *udata, size_t udata_size, hid_t lapl_id, hid_t dxpl_id);
static void hard_link_example(void)
{
hid_t file_id;
hid_t group_id;
H5L_info_t li;
H5L_info2_t li;
/* Define the link class that we'll use to register "user-defined hard
* links" using the callbacks we defined above.
* A link class can have NULL for any callback except its traverse
@@ -361,13 +361,13 @@ static void hard_link_example(void)
* the target group's address. We do this by calling H5Lget_info
* on a hard link to the object.
*/
H5Lget_info(file_id, TARGET_GROUP, &li, H5P_DEFAULT);
H5Lget_info2(file_id, TARGET_GROUP, &li, H5P_DEFAULT);
/* Now create a user-defined link. We give it the group's address
* as its udata.
*/
H5Lcreate_ud(file_id, UD_HARD_LINK_NAME, (H5L_type_t)UD_HARD_CLASS, &(li.u.address),
sizeof(li.u.address), H5P_DEFAULT, H5P_DEFAULT);
H5Lcreate_ud(file_id, UD_HARD_LINK_NAME, (H5L_type_t)UD_HARD_CLASS, &(li.u.token),
sizeof(H5O_token_t), H5P_DEFAULT, H5P_DEFAULT);
/* The UD hard link has now incremented the group's reference count
* like a normal hard link would. This means that we can unlink the
@@ -404,23 +404,23 @@ static void hard_link_example(void)
static herr_t UD_hard_create(const char *link_name, hid_t loc_group,
const void *udata, size_t udata_size, hid_t lcpl_id)
{
haddr_t addr;
hid_t target_obj = -1;
H5O_token_t token;
hid_t target_obj = H5I_INVALID_HID;
herr_t ret_value = 0;
/* Make sure that the address passed in looks valid */
if(udata_size != sizeof(haddr_t))
if(udata_size != sizeof(H5O_token_t))
{
ret_value = -1;
goto done;
}
addr = *((const haddr_t *) udata);
token = *((H5O_token_t *) udata);
/* Open the object this link points to so that we can increment
* its reference count. This also ensures that the address passed
* its reference count. This also ensures that the token passed
* in points to a real object (although this check is not perfect!) */
target_obj= H5Oopen_by_addr(loc_group, addr);
target_obj = H5Oopen_by_token(loc_group, token);
if(target_obj < 0)
{
ret_value = -1;
@@ -448,23 +448,23 @@ done:
static herr_t UD_hard_delete(const char *link_name, hid_t loc_group,
const void *udata, size_t udata_size)
{
haddr_t addr;
hid_t target_obj = -1;
H5O_token_t token;
hid_t target_obj = H5I_INVALID_HID;
herr_t ret_value = 0;
/* Sanity check; we have already verified the udata's size in the creation
* callback.
*/
if(udata_size != sizeof(haddr_t))
if(udata_size != sizeof(H5O_token_t))
{
ret_value = -1;
goto done;
}
addr = *((const haddr_t *) udata);
token = *((H5O_token_t *) udata);
/* Open the object this link points to */
target_obj= H5Oopen_by_addr(loc_group, addr);
target_obj = H5Oopen_by_token(loc_group, token);
if(target_obj < 0)
{
ret_value = -1;
@@ -490,23 +490,23 @@ done:
* return its ID.
*/
static hid_t UD_hard_traverse(const char *link_name, hid_t cur_group,
const void *udata, size_t udata_size, hid_t lapl_id)
const void *udata, size_t udata_size, hid_t lapl_id, hid_t dxpl_id)
{
haddr_t addr;
hid_t ret_value = -1;
H5O_token_t token;
hid_t ret_value = H5I_INVALID_HID;
/* Sanity check; we have already verified the udata's size in the creation
* callback.
*/
if(udata_size != sizeof(haddr_t))
return -1;
if(udata_size != sizeof(H5O_token_t))
return H5I_INVALID_HID;
addr = *((const haddr_t *) udata);
token = *((H5O_token_t *) udata);
/* Open the object by address. If H5Oopen_by_addr fails, ret_value will
/* Open the object by token. If H5Oopen_by_token fails, ret_value will
* be negative to indicate that the traversal function failed.
*/
ret_value = H5Oopen_by_addr(cur_group, addr);
ret_value = H5Oopen_by_token(cur_group, token);
return ret_value;
}
@@ -527,7 +527,7 @@ static hid_t UD_hard_traverse(const char *link_name, hid_t cur_group,
* These links have no udata, so they don't need a query function.
*/
static hid_t UD_plist_traverse(const char *link_name, hid_t cur_group,
const void *udata, size_t udata_size, hid_t lapl_id);
const void *udata, size_t udata_size, hid_t lapl_id, hid_t dxpl_id);
static void plist_link_example(void)
{
@@ -618,10 +618,10 @@ static void plist_link_example(void)
* Open a path passed in through the property list.
*/
static hid_t UD_plist_traverse(const char *link_name, hid_t cur_group,
const void *udata, size_t udata_size, hid_t lapl_id)
const void *udata, size_t udata_size, hid_t lapl_id, hid_t dxpl_id)
{
char * path;
hid_t ret_value = -1;
hid_t ret_value = H5I_INVALID_HID;
/* If the link property isn't set or can't be found, traversal fails. */
if(H5Pexist(lapl_id, PLIST_LINK_PROP) < 0)
@@ -638,7 +638,7 @@ static hid_t UD_plist_traverse(const char *link_name, hid_t cur_group,
return ret_value;
error:
return -1;
return H5I_INVALID_HID;
}

View File

@@ -26,9 +26,9 @@
#define H5FILE_NAME "group.h5"
#define RANK 2
static herr_t file_info(hid_t loc_id, const char *name, const H5L_info_t *linfo,
static herr_t file_info(hid_t loc_id, const char *name, const H5L_info2_t *linfo,
void *opdata); /* Link iteration operator function */
static herr_t group_info(hid_t loc_id, const char *name, const H5L_info_t *linfo,
static herr_t group_info(hid_t loc_id, const char *name, const H5L_info2_t *linfo,
void *opdata); /* Link iteration operator function */
int
main(void)
@@ -135,7 +135,7 @@ main(void)
/*
* Use iterator to see the names of the objects in the root group.
*/
idx_f = H5Literate(file, H5_INDEX_NAME, H5_ITER_INC, NULL, file_info, NULL);
idx_f = H5Literate2(file, H5_INDEX_NAME, H5_ITER_INC, NULL, file_info, NULL);
/*
* Unlink name "Data" and use iterator to see the names
@@ -146,13 +146,13 @@ main(void)
else
printf("\"Data\" is unlinked \n");
idx_f = H5Literate(file, H5_INDEX_NAME, H5_ITER_INC, NULL, file_info, NULL);
idx_f = H5Literate2(file, H5_INDEX_NAME, H5_ITER_INC, NULL, file_info, NULL);
/*
* Use iterator to see the names of the objects in the group
* /Data_new.
*/
idx_g = H5Literate_by_name(grp, "/Data_new", H5_INDEX_NAME, H5_ITER_INC, NULL, group_info, NULL, H5P_DEFAULT);
idx_g = H5Literate_by_name2(grp, "/Data_new", H5_INDEX_NAME, H5_ITER_INC, NULL, group_info, NULL, H5P_DEFAULT);
/*
* Close the file.
@@ -168,7 +168,7 @@ main(void)
* Operator function.
*/
static herr_t
file_info(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *opdata)
file_info(hid_t loc_id, const char *name, const H5L_info2_t *linfo, void *opdata)
{
/* avoid compiler warnings */
loc_id = loc_id;
@@ -189,7 +189,7 @@ file_info(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *opdata)
* Operator function.
*/
static herr_t
group_info(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *opdata)
group_info(hid_t loc_id, const char *name, const H5L_info2_t *linfo, void *opdata)
{
hid_t did; /* dataset identifier */
hid_t tid; /* datatype identifier */

View File

@@ -11,7 +11,7 @@
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
/*
* This example illustrates how to write and read data in an existing
* dataset. It is used in the HDF5 Tutorial.
*/
@@ -37,10 +37,10 @@ int main() {
dataset_id = H5Dopen2(file_id, "/dset", H5P_DEFAULT);
/* Write the dataset. */
status = H5Dwrite(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
status = H5Dwrite(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
dset_data);
status = H5Dread(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
status = H5Dread(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
dset_data);
/* Close the dataset. */

90
examples/h5_ref_compat.c Normal file
View File

@@ -0,0 +1,90 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* The example below illustrates the use of the new API with a file that was
* written using the old-style reference API, showing how one can take
* advantage of the automatic type conversion from old reference type to new
* reference type.
*/
#include <stdlib.h>
#include "hdf5.h"
#include <assert.h>
#define H5FILE_NAME "refer_deprec.h5"
#define NDIMS 1 /* Number of dimensions */
#define BUF_SIZE 4 /* Size of example buffer */
#define NREFS 1 /* Number of references */
int
main(void) {
hid_t file1, dset1, space1;
hsize_t dset1_dims[NDIMS] = { BUF_SIZE };
int dset_buf[BUF_SIZE];
hid_t dset2, space2;
hsize_t dset2_dims[NDIMS] = { NREFS };
hobj_ref_t ref_buf[NREFS] = { 0 };
H5R_ref_t new_ref_buf[NREFS] = { 0 };
H5O_type_t obj_type;
int i;
for (i = 0; i < BUF_SIZE; i++)
dset_buf[i] = i;
/* Create file with one dataset and close it */
file1 = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
space1 = H5Screate_simple(NDIMS, dset1_dims, NULL);
dset1 = H5Dcreate2(file1, "dataset1", H5T_NATIVE_INT, space1, H5P_DEFAULT,
H5P_DEFAULT, H5P_DEFAULT);
H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_buf);
H5Dclose(dset1);
H5Sclose(space1);
/**
* Create reference to dataset1 with deprecated API
* (reminder: there is no destroy call for those references)
*/
H5Rcreate(&ref_buf[0], file1, "dataset1", H5R_OBJECT, H5I_INVALID_HID);
/* Store reference in separate dataset using deprecated reference type */
space2 = H5Screate_simple(NDIMS, dset2_dims, NULL);
dset2 = H5Dcreate2(file1, "references", H5T_STD_REF_OBJ, space2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
H5Dwrite(dset2, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_buf);
H5Dclose(dset2);
H5Sclose(space2);
H5Fclose(file1);
/* Read reference from file using new reference type */
file1 = H5Fopen(H5FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT);
dset2 = H5Dopen2(file1, "references", H5P_DEFAULT);
H5Dread(dset2, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, new_ref_buf);
H5Dclose(dset2);
/* Access reference and read dataset data through new API */
assert(H5Rget_type((const H5R_ref_t *)&new_ref_buf[0]) == H5R_OBJECT2);
H5Rget_obj_type3((const H5R_ref_t *)&new_ref_buf[0], H5P_DEFAULT, &obj_type);
assert(obj_type == H5O_TYPE_DATASET);
dset1 = H5Ropen_object((const H5R_ref_t *)&new_ref_buf[0], H5P_DEFAULT, H5P_DEFAULT);
H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_buf);
H5Dclose(dset1);
H5Rdestroy(&new_ref_buf[0]);
for (i = 0; i < BUF_SIZE; i++)
assert(dset_buf[i] == i);
return 0;
}

94
examples/h5_ref_extern.c Normal file
View File

@@ -0,0 +1,94 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* The example below illustrates the use of the new API with files that are
* opened read-only. Created references to the objects in that file are
* stored into a separate file, and accessed from that file, without the user
* explicitly opening the original file that was referenced.
*/
#include <stdlib.h>
#include "hdf5.h"
#include <assert.h>
#define H5FILE_NAME1 "refer_extern1.h5"
#define H5FILE_NAME2 "refer_extern2.h5"
#define NDIMS 1 /* Number of dimensions */
#define BUF_SIZE 4 /* Size of example buffer */
#define NREFS 1 /* Number of references */
int
main(void) {
hid_t file1, dset1, space1;
hsize_t dset1_dims[NDIMS] = { BUF_SIZE };
int dset_buf[BUF_SIZE];
hid_t file2, dset2, space2;
hsize_t dset2_dims[NDIMS] = { NREFS };
H5R_ref_t ref_buf[NREFS] = { 0 };
H5O_type_t obj_type;
int i;
for (i = 0; i < BUF_SIZE; i++)
dset_buf[i] = i;
/* Create file with one dataset and close it */
file1 = H5Fcreate(H5FILE_NAME1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
space1 = H5Screate_simple(NDIMS, dset1_dims, NULL);
dset1 = H5Dcreate2(file1, "dataset1", H5T_NATIVE_INT, space1, H5P_DEFAULT,
H5P_DEFAULT, H5P_DEFAULT);
H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_buf);
H5Dclose(dset1);
H5Sclose(space1);
H5Fclose(file1);
/* Create reference to dataset1 in "refer_extern1.h5" */
file1 = H5Fopen(H5FILE_NAME1, H5F_ACC_RDONLY, H5P_DEFAULT);
H5Rcreate_object(file1, "dataset1", H5P_DEFAULT, &ref_buf[0]);
H5Fclose(file1);
/* Store reference in dataset in separate file "refer_extern2.h5" */
file2 = H5Fcreate(H5FILE_NAME2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
space2 = H5Screate_simple(NDIMS, dset2_dims, NULL);
dset2 = H5Dcreate2(file2, "references", H5T_STD_REF, space2, H5P_DEFAULT,
H5P_DEFAULT, H5P_DEFAULT);
H5Dwrite(dset2, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_buf);
H5Dclose(dset2);
H5Sclose(space2);
H5Fclose(file2);
H5Rdestroy(&ref_buf[0]);
/* Read reference back from "refer_extern2.h5" */
file2 = H5Fopen(H5FILE_NAME2, H5F_ACC_RDONLY, H5P_DEFAULT);
dset2 = H5Dopen2(file2, "references", H5P_DEFAULT);
H5Dread(dset2, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_buf);
H5Dclose(dset2);
H5Fclose(file2);
/* Access reference and read dataset data without opening original file */
assert(H5Rget_type((const H5R_ref_t *)&ref_buf[0]) == H5R_OBJECT2);
H5Rget_obj_type3((const H5R_ref_t *)&ref_buf[0], H5P_DEFAULT, &obj_type);
assert(obj_type == H5O_TYPE_DATASET);
dset1 = H5Ropen_object((const H5R_ref_t *)&ref_buf[0], H5P_DEFAULT, H5P_DEFAULT);
H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_buf);
H5Dclose(dset1);
H5Rdestroy(&ref_buf[0]);
for (i = 0; i < BUF_SIZE; i++)
assert(dset_buf[i] == i);
return 0;
}

View File

@@ -11,44 +11,44 @@
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* This example illustrates how to read/write a subset of data (a slab)
/*
* This example illustrates how to read/write a subset of data (a slab)
* from/to a dataset in an HDF5 file. It is used in the HDF5 Tutorial.
*/
#include "hdf5.h"
#define FILE "subset.h5"
#define DATASETNAME "IntArray"
#define DATASETNAME "IntArray"
#define RANK 2
#define DIM0_SUB 3 /* subset dimensions */
#define DIM1_SUB 4
#define DIM0_SUB 3 /* subset dimensions */
#define DIM1_SUB 4
#define DIM0 8 /* size of dataset */
#define DIM1 10
#define DIM0 8 /* size of dataset */
#define DIM1 10
int
main (void)
{
hsize_t dims[2], dimsm[2];
hsize_t dims[2], dimsm[2];
int data[DIM0][DIM1]; /* data to write */
int sdata[DIM0_SUB][DIM1_SUB]; /* subset to write */
int rdata[DIM0][DIM1]; /* buffer for read */
hid_t file_id, dataset_id; /* handles */
hid_t dataspace_id, memspace_id;
herr_t status;
hid_t file_id, dataset_id; /* handles */
hid_t dataspace_id, memspace_id;
herr_t status;
hsize_t count[2]; /* size of subset in the file */
hsize_t offset[2]; /* subset offset in the file */
hsize_t stride[2];
hsize_t block[2];
int i, j;
/*****************************************************************
* Create a new file with default creation and access properties.*
* Then create a dataset and write data to it and close the file *
@@ -59,7 +59,7 @@ main (void)
dims[0] = DIM0;
dims[1] = DIM1;
dataspace_id = H5Screate_simple (RANK, dims, NULL);
dataspace_id = H5Screate_simple (RANK, dims, NULL);
dataset_id = H5Dcreate2 (file_id, DATASETNAME, H5T_STD_I32BE, dataspace_id,
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
@@ -71,7 +71,7 @@ main (void)
data[j][i] = 1;
else
data[j][i] = 2;
}
}
status = H5Dwrite (dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
H5P_DEFAULT, data);
@@ -89,7 +89,7 @@ main (void)
/*****************************************************
* Reopen the file and dataset and write a subset of *
* values to the dataset.
* values to the dataset.
*****************************************************/
file_id = H5Fopen (FILE, H5F_ACC_RDWR, H5P_DEFAULT);
@@ -100,7 +100,7 @@ main (void)
offset[0] = 1;
offset[1] = 2;
count[0] = DIM0_SUB;
count[0] = DIM0_SUB;
count[1] = DIM1_SUB;
stride[0] = 1;
@@ -109,18 +109,18 @@ main (void)
block[0] = 1;
block[1] = 1;
/* Create memory space with size of subset. Get file dataspace
/* Create memory space with size of subset. Get file dataspace
and select subset from file dataspace. */
dimsm[0] = DIM0_SUB;
dimsm[1] = DIM1_SUB;
memspace_id = H5Screate_simple (RANK, dimsm, NULL);
memspace_id = H5Screate_simple (RANK, dimsm, NULL);
dataspace_id = H5Dget_space (dataset_id);
status = H5Sselect_hyperslab (dataspace_id, H5S_SELECT_SET, offset,
stride, count, block);
/* Write a subset of data to the dataset, then read the
/* Write a subset of data to the dataset, then read the
entire dataset back from the file. */
printf ("\nWrite subset to file specifying:\n");
@@ -128,11 +128,11 @@ main (void)
for (j = 0; j < DIM0_SUB; j++) {
for (i = 0; i < DIM1_SUB; i++)
sdata[j][i] = 5;
}
}
status = H5Dwrite (dataset_id, H5T_NATIVE_INT, memspace_id,
dataspace_id, H5P_DEFAULT, sdata);
status = H5Dread (dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
H5P_DEFAULT, rdata);
@@ -147,5 +147,5 @@ main (void)
status = H5Sclose (dataspace_id);
status = H5Dclose (dataset_id);
status = H5Fclose (file_id);
}

View File

@@ -12,7 +12,7 @@
/************************************************************
This example illustrates the concept of the virtual dataset.
Eiger use case. Every 5 frames 10x10 are in the source
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
@@ -25,13 +25,13 @@
#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
#define VDSDIM0 5
#define VDSDIM1 10
#define VDSDIM2 10
#define DIM0 5
#define DIM1 10
#define DIM2 10
#define RANK 3
int
main (void)
@@ -69,7 +69,7 @@ main (void)
/* Create VDS creation property */
dcpl = H5Pcreate (H5P_DATASET_CREATE);
/* Initialize hyperslab values */
start[0] = 0;
@@ -85,13 +85,13 @@ main (void)
block[1] = DIM1;
block[2] = DIM2;
/*
* Build the mappings
/*
* Build the mappings
*
*/
status = H5Sselect_hyperslab (vspace, H5S_SELECT_SET, start, stride, count, block);
status = H5Pset_virtual (dcpl, vspace, "f-%b.h5", "/A", src_space);
/* Create a virtual dataset */
@@ -100,8 +100,8 @@ main (void)
status = H5Sclose (vspace);
status = H5Sclose (src_space);
status = H5Dclose (dset);
status = H5Fclose (file);
status = H5Fclose (file);
/*
* Now we begin the read section of this example.
@@ -123,7 +123,7 @@ main (void)
*/
layout = H5Pget_layout (dcpl);
if (H5D_VIRTUAL == layout)
if (H5D_VIRTUAL == layout)
printf(" Dataset has a virtual layout \n");
else
printf(" Wrong layout found \n");
@@ -134,15 +134,15 @@ main (void)
status = H5Pget_virtual_count (dcpl, &num_map);
printf(" Number of mappings is %d\n", (int)num_map);
/*
/*
* Get mapping parameters for each mapping.
*/
for (i = 0; i < (int)num_map; i++) {
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 (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]);

View File

@@ -24,16 +24,16 @@
#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
#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",
@@ -96,7 +96,7 @@ main (void)
/* Create VDS creation property */
dcpl = H5Pcreate (H5P_DATASET_CREATE);
/* Initialize hyperslab values */
start[0] = 0;
@@ -109,7 +109,7 @@ main (void)
block[1] = k;
block[2] = VDSDIM2;
/*
/*
* Build the mappings for A, C and E source datasets.
* Unlimited hyperslab selection is the same in the source datasets.
* Unlimited hyperslab selections in the virtual dataset have different offsets.
@@ -124,7 +124,7 @@ main (void)
/* Reinitialize start[1] and block[1] to build the second set of mappings. */
start[1] = 0;
block[1] = n;
/*
/*
* Build the mappings for B, D and F source datasets.
* Unlimited hyperslab selection is the same in the source datasets.
* Unlimited hyperslab selections in the virtual dataset have different offsets.
@@ -143,8 +143,8 @@ main (void)
status = H5Sclose (nsrc_space);
status = H5Sclose (ksrc_space);
status = H5Dclose (dset);
status = H5Fclose (file);
status = H5Fclose (file);
/*
* Now we begin the read section of this example.
@@ -166,7 +166,7 @@ main (void)
*/
layout = H5Pget_layout (dcpl);
if (H5D_VIRTUAL == layout)
if (H5D_VIRTUAL == layout)
printf(" Dataset has a virtual layout \n");
else
printf("Wrong layout found \n");
@@ -177,15 +177,15 @@ main (void)
status = H5Pget_virtual_count (dcpl, &num_map);
printf(" Number of mappings is %lu\n", (unsigned long)num_map);
/*
/*
* Get mapping parameters for each mapping.
*/
for (i = 0; i < (int)num_map; i++) {
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 (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]);
@@ -209,7 +209,7 @@ main (void)
/* 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 (H5Sget_select_type(src_space) == H5S_SEL_HYPERSLABS) {
if (H5Sis_regular_hyperslab(vspace)) {
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]);

View File

@@ -25,16 +25,16 @@
#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
#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",
@@ -94,7 +94,7 @@ main (void)
/* Create VDS creation property */
dcpl = H5Pcreate (H5P_DATASET_CREATE);
/* Initialize hyperslab values */
start[0] = 0;
@@ -107,7 +107,7 @@ main (void)
block[1] = k;
block[2] = VDSDIM2;
/*
/*
* Build the mappings for A, C and E source datasets.
*
*/
@@ -121,7 +121,7 @@ main (void)
/* Reinitialize start[0] and block[1] */
start[0] = 0;
block[1] = n;
/*
/*
* Build the mappings for B, D and F source datasets.
*
*/
@@ -139,8 +139,8 @@ main (void)
status = H5Sclose (nsrc_space);
status = H5Sclose (ksrc_space);
status = H5Dclose (dset);
status = H5Fclose (file);
status = H5Fclose (file);
/*
* Now we begin the read section of this example.
@@ -162,7 +162,7 @@ main (void)
*/
layout = H5Pget_layout (dcpl);
if (H5D_VIRTUAL == layout)
if (H5D_VIRTUAL == layout)
printf(" Dataset has a virtual layout \n");
else
printf("Wrong layout found \n");
@@ -173,15 +173,15 @@ main (void)
status = H5Pget_virtual_count (dcpl, &num_map);
printf(" Number of mappings is %lu\n", (unsigned long)num_map);
/*
/*
* Get mapping parameters for each mapping.
*/
for (i = 0; i < (int)num_map; i++) {
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 (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]);

View File

@@ -12,8 +12,8 @@
/************************************************************
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.
Percival use case. Every fifth 10x10 plane in VDS is stored in
the corresponding 3D unlimited dataset.
There are 4 source datasets total.
Each of the source datasets is extended to different sizes.
VDS access property can be used to get max and min extent.
@@ -28,15 +28,15 @@
#define VFILE "vds-percival-unlim-maxmin.h5"
#define DATASET "VDS-Percival-unlim-maxmin"
#define VDSDIM0 H5S_UNLIMITED
#define VDSDIM1 10
#define VDSDIM2 10
#define VDSDIM0 H5S_UNLIMITED
#define VDSDIM1 10
#define VDSDIM2 10
#define DIM0 H5S_UNLIMITED
#define DIM0 H5S_UNLIMITED
#define DIM0_1 4 /* Initial size of the source datasets */
#define DIM1 10
#define DIM2 10
#define RANK 3
#define DIM1 10
#define DIM2 10
#define RANK 3
#define PLANE_STRIDE 4
const char *SRC_FILE[] = {
@@ -61,7 +61,7 @@ main (void)
hid_t dcpl, dapl;
herr_t status;
hsize_t vdsdims[3] = {4*DIM0_1, VDSDIM1, VDSDIM2},
vdsdims_max[3] = {VDSDIM0, VDSDIM1, VDSDIM2},
vdsdims_max[3] = {VDSDIM0, VDSDIM1, VDSDIM2},
dims[3] = {DIM0_1, DIM1, DIM2},
memdims[3] = {DIM0_1, DIM1, DIM2},
extdims[3] = {0, DIM1, DIM2}, /* Dimensions of the extended source datasets */
@@ -96,7 +96,7 @@ main (void)
for (j = 0; j < DIM0_1*DIM1*DIM2; j++) wdata[j] = i+1;
/*
* Create the source files and datasets. Write data to each dataset and
* Create the source files and datasets. Write data to each dataset and
* close all resources.
*/
@@ -112,7 +112,7 @@ main (void)
status = H5Pclose (dcpl);
status = H5Dclose (dset);
status = H5Fclose (file);
}
}
vfile = H5Fcreate (VFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
@@ -124,7 +124,7 @@ main (void)
/* Create VDS creation property */
dcpl = H5Pcreate (H5P_DATASET_CREATE);
/* Initialize hyperslab values */
start[0] = 0;
@@ -143,18 +143,18 @@ main (void)
block[1] = DIM1;
block[2] = DIM2;
/*
* Build the mappings
/*
* 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]++;
}
start[0]++;
}
H5Sselect_none(vspace);
H5Sselect_none(vspace);
/* Create a virtual dataset */
vdset = H5Dcreate2 (vfile, DATASET, H5T_NATIVE_INT, vspace, H5P_DEFAULT,
@@ -174,14 +174,14 @@ main (void)
for (j = 0; j < (i+1)*DIM1*DIM2; j++) wdata[j] = 10*(i+1);
/*
* Open the source files and datasets. Appen data to each dataset and
* Open the source files and datasets. Appen data to each dataset and
* close all resources.
*/
file = H5Fopen (SRC_FILE[i], H5F_ACC_RDWR, H5P_DEFAULT);
dset = H5Dopen2 (file, SRC_DATASET[i], H5P_DEFAULT);
extdims[0] = DIM0_1+i+1;
status = H5Dset_extent (dset, extdims);
status = H5Dset_extent (dset, extdims);
src_space = H5Dget_space (dset);
start[0] = DIM0_1;
start[1] = 0;
@@ -194,7 +194,7 @@ main (void)
block[2] = DIM2;
memdims[0] = i+1;
mem_space = H5Screate_simple(RANK, memdims, NULL);
mem_space = H5Screate_simple(RANK, memdims, NULL);
status = H5Sselect_hyperslab (src_space, H5S_SELECT_SET, start, NULL, count, block);
status = H5Dwrite (dset, H5T_NATIVE_INT, mem_space, src_space, H5P_DEFAULT,
wdata);
@@ -204,8 +204,8 @@ main (void)
}
status = H5Dclose (vdset);
status = H5Fclose (vfile);
status = H5Fclose (vfile);
/*
* Now we begin the read section of this example.
*/
@@ -214,8 +214,8 @@ main (void)
* Open file and dataset using the default properties.
*/
vfile = H5Fopen (VFILE, H5F_ACC_RDONLY, H5P_DEFAULT);
/*
/*
* Open VDS using different access properties to use max or
* min extents depending on the sizes of the underlying datasets
*/
@@ -252,7 +252,7 @@ main (void)
*/
layout = H5Pget_layout (dcpl);
if (H5D_VIRTUAL == layout)
if (H5D_VIRTUAL == layout)
printf(" Dataset has a virtual layout \n");
else
printf(" Wrong layout found \n");
@@ -263,15 +263,15 @@ main (void)
status = H5Pget_virtual_count (dcpl, &num_map);
printf(" Number of mappings is %lu\n", (unsigned long)num_map);
/*
/*
* Get mapping parameters for each mapping.
*/
for (i = 0; i < (int)num_map; i++) {
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 (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]);

View File

@@ -12,8 +12,8 @@
/************************************************************
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.
Percival use case. Every fifth 10x10 plane in VDS is stored in
the corresponding 3D unlimited dataset.
There are 4 source datasets total.
This file is intended for use with HDF5 Library version 1.10
@@ -26,15 +26,15 @@
#define VFILE "vds-percival-unlim.h5"
#define DATASET "VDS-Percival-unlim"
#define VDSDIM0 H5S_UNLIMITED
#define VDSDIM1 10
#define VDSDIM2 10
#define VDSDIM0 H5S_UNLIMITED
#define VDSDIM1 10
#define VDSDIM2 10
#define DIM0 H5S_UNLIMITED
#define DIM0 H5S_UNLIMITED
#define DIM0_1 10 /* Initial size of the datasets */
#define DIM1 10
#define DIM2 10
#define RANK 3
#define DIM1 10
#define DIM2 10
#define RANK 3
#define PLANE_STRIDE 4
const char *SRC_FILE[] = {
@@ -59,7 +59,7 @@ main (void)
hid_t dcpl;
herr_t status;
hsize_t vdsdims[3] = {4*DIM0_1, VDSDIM1, VDSDIM2},
vdsdims_max[3] = {VDSDIM0, VDSDIM1, VDSDIM2},
vdsdims_max[3] = {VDSDIM0, VDSDIM1, VDSDIM2},
dims[3] = {DIM0_1, DIM1, DIM2},
extdims[3] = {2*DIM0_1, DIM1, DIM2},
chunk_dims[3] = {DIM0_1, DIM1, DIM2},
@@ -95,7 +95,7 @@ main (void)
for (j = 0; j < DIM0_1*DIM1*DIM2; j++) wdata[j] = i+1;
/*
* Create the source files and datasets. Write data to each dataset and
* Create the source files and datasets. Write data to each dataset and
* close all resources.
*/
@@ -111,7 +111,7 @@ main (void)
status = H5Pclose (dcpl);
status = H5Dclose (dset);
status = H5Fclose (file);
}
}
vfile = H5Fcreate (VFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
@@ -123,7 +123,7 @@ main (void)
/* Create VDS creation property */
dcpl = H5Pcreate (H5P_DATASET_CREATE);
/* Initialize hyperslab values */
start[0] = 0;
@@ -142,18 +142,18 @@ main (void)
block[1] = DIM1;
block[2] = DIM2;
/*
* Build the mappings
/*
* 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]++;
}
start[0]++;
}
H5Sselect_none(vspace);
H5Sselect_none(vspace);
/* Create a virtual dataset */
vdset = H5Dcreate2 (vfile, DATASET, H5T_NATIVE_INT, vspace, H5P_DEFAULT,
@@ -179,13 +179,13 @@ main (void)
for (j = 0; j < DIM0_1*DIM1*DIM2; j++) wdata[j] = 10*(i+1);
/*
* Create the source files and datasets. Write data to each dataset and
* Create the source files and datasets. Write data to each dataset and
* close all resources.
*/
file = H5Fopen (SRC_FILE[i], H5F_ACC_RDWR, H5P_DEFAULT);
dset = H5Dopen2 (file, SRC_DATASET[i], H5P_DEFAULT);
status = H5Dset_extent (dset, extdims);
status = H5Dset_extent (dset, extdims);
src_space = H5Dget_space (dset);
start[0] = DIM0_1;
start[1] = 0;
@@ -197,7 +197,7 @@ main (void)
block[1] = DIM1;
block[2] = DIM2;
mem_space = H5Screate_simple(RANK, dims, NULL);
mem_space = H5Screate_simple(RANK, dims, NULL);
status = H5Sselect_hyperslab (src_space, H5S_SELECT_SET, start, NULL, count, block);
status = H5Dwrite (dset, H5T_NATIVE_INT, mem_space, src_space, H5P_DEFAULT,
wdata);
@@ -207,8 +207,8 @@ main (void)
}
status = H5Dclose (vdset);
status = H5Fclose (vfile);
status = H5Fclose (vfile);
/*
* Now we begin the read section of this example.
*/
@@ -229,7 +229,7 @@ main (void)
*/
layout = H5Pget_layout (dcpl);
if (H5D_VIRTUAL == layout)
if (H5D_VIRTUAL == layout)
printf(" Dataset has a virtual layout \n");
else
printf(" Wrong layout found \n");
@@ -240,15 +240,15 @@ main (void)
status = H5Pget_virtual_count (dcpl, &num_map);
printf(" Number of mappings is %lu\n", (unsigned long)num_map);
/*
/*
* Get mapping parameters for each mapping.
*/
for (i = 0; i < (int)num_map; i++) {
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 (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]);
@@ -300,7 +300,7 @@ main (void)
/* Read all VDS data */
/* EIP We should be able to do it by using H5S_ALL instead of making selection
* or using H5Sselect_all from vspace.
* or using H5Sselect_all from vspace.
*/
start[0] = 0;
start[1] = 0;
@@ -315,12 +315,12 @@ main (void)
status = H5Sselect_hyperslab (vspace, H5S_SELECT_SET, start, NULL, count, block);
mem_space = H5Screate_simple(RANK, vdsdims_out, NULL);
status = H5Dread (vdset, H5T_NATIVE_INT, mem_space, vspace, H5P_DEFAULT,
rdata);
rdata);
printf (" All data: \n");
for (i=0; i < (int)vdsdims_out[0]; i++) {
for (j=0; j < (int)vdsdims_out[1]; j++) {
printf ("(%d, %d, 0)", i, j);
for (k=0; k < (int)vdsdims_out[2]; k++)
for (k=0; k < (int)vdsdims_out[2]; k++)
printf (" %d ", rdata[i][j][k]);
printf ("\n");
}
@@ -338,16 +338,16 @@ main (void)
block[0] = 1;
block[1] = vdsdims_out[1];
block[2] = vdsdims_out[2];
dims[0] = 2*DIM0_1;
dims[0] = 2*DIM0_1;
status = H5Sselect_hyperslab (vspace, H5S_SELECT_SET, start, stride, count, block);
mem_space = H5Screate_simple(RANK, dims, NULL);
status = H5Dread (vdset, H5T_NATIVE_INT, mem_space, vspace, H5P_DEFAULT,
a_rdata);
a_rdata);
printf (" All data: \n");
for (i=0; i < 2*DIM0_1; i++) {
for (j=0; j < (int)vdsdims_out[1]; j++) {
printf ("(%d, %d, 0)", i, j);
for (k=0; k < (int)vdsdims_out[2]; k++)
for (k=0; k < (int)vdsdims_out[2]; k++)
printf (" %d ", a_rdata[i][j][k]);
printf ("\n");
}

View File

@@ -12,8 +12,8 @@
/************************************************************
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.
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
@@ -28,18 +28,18 @@
#define FILE "vds-percival.h5"
#define DATASET "VDS-Percival"
/* later
#define VDSDIM0 H5S_UNLIMITED
#define VDSDIM0 H5S_UNLIMITED
*/
#define VDSDIM0 40
#define VDSDIM1 10
#define VDSDIM2 10
#define VDSDIM1 10
#define VDSDIM2 10
/* later
#define DIM0 H5S_UNLIMITED
#define DIM0 H5S_UNLIMITED
*/
#define DIM0 10
#define DIM1 10
#define DIM2 10
#define RANK 3
#define DIM0 10
#define DIM1 10
#define DIM2 10
#define RANK 3
#define PLANE_STRIDE 4
const char *SRC_FILE[] = {
@@ -64,7 +64,7 @@ main (void)
hid_t dcpl;
herr_t status;
hsize_t vdsdims[3] = {VDSDIM0, VDSDIM1, VDSDIM2},
vdsdims_max[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 */
@@ -94,7 +94,7 @@ main (void)
for (j = 0; j < DIM0*DIM1*DIM2; j++) wdata[j] = i+1;
/*
* Create the source files and datasets. Write data to each dataset and
* Create the source files and datasets. Write data to each dataset and
* close all resources.
*/
@@ -107,7 +107,7 @@ main (void)
status = H5Sclose (src_space);
status = H5Dclose (dset);
status = H5Fclose (file);
}
}
file = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
@@ -119,7 +119,7 @@ main (void)
/* Create VDS creation property */
dcpl = H5Pcreate (H5P_DATASET_CREATE);
/* Initialize hyperslab values */
start[0] = 0;
@@ -144,18 +144,18 @@ main (void)
block[1] = DIM1;
block[2] = DIM2;
/*
* Build the mappings
/*
* 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]++;
}
start[0]++;
}
H5Sselect_none(vspace);
H5Sselect_none(vspace);
/* Create a virtual dataset */
dset = H5Dcreate2 (file, DATASET, H5T_NATIVE_INT, vspace, H5P_DEFAULT,
@@ -163,8 +163,8 @@ main (void)
status = H5Sclose (vspace);
status = H5Sclose (src_space);
status = H5Dclose (dset);
status = H5Fclose (file);
status = H5Fclose (file);
/*
* Now we begin the read section of this example.
*/
@@ -185,7 +185,7 @@ main (void)
*/
layout = H5Pget_layout (dcpl);
if (H5D_VIRTUAL == layout)
if (H5D_VIRTUAL == layout)
printf(" Dataset has a virtual layout \n");
else
printf(" Wrong layout found \n");
@@ -196,15 +196,15 @@ main (void)
status = H5Pget_virtual_count (dcpl, &num_map);
printf(" Number of mappings is %lu\n", (unsigned long)num_map);
/*
/*
* Get mapping parameters for each mapping.
*/
for (i = 0; i < (int)num_map; i++) {
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 (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]);

View File

@@ -14,7 +14,7 @@
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 dimension sizes and maps the all elements of the
the same dimension sizes and maps the all elements of the
virtual dataset to all elements of the source dataset.
Then VDS is read back.
@@ -30,7 +30,7 @@
#define FILE "vds-simpleIO.h5"
#define DATASET "VDS"
#define DIM1 6
#define DIM0 4
#define DIM0 4
#define RANK 2
#define SRC_FILE "a.h5"
@@ -40,27 +40,27 @@
int
main (void)
{
hid_t file, space, src_space, vspace, dset; /* Handles */
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;
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 *filename;
char *dsetname;
/*
* Initialize data.
*/
for (i = 0; i < DIM0; i++)
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
* Create the source file and the dataset. Write data to the source dataset
* and close all resources.
*/
@@ -82,12 +82,12 @@ main (void)
/* 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.
* 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);
@@ -98,8 +98,8 @@ main (void)
status = H5Sclose (vspace);
status = H5Sclose (src_space);
status = H5Dclose (dset);
status = H5Fclose (file);
status = H5Fclose (file);
/*
* Now we begin the read section of this example.
*/
@@ -118,7 +118,7 @@ main (void)
* Get storage layout.
*/
layout = H5Pget_layout (dcpl);
if (H5D_VIRTUAL == layout)
if (H5D_VIRTUAL == layout)
printf(" Dataset has a virtual layout \n");
else
printf(" Wrong layout found \n");
@@ -129,10 +129,10 @@ main (void)
status = H5Pget_virtual_count (dcpl, &num_map);
printf(" Number of mappings is %lu\n", (unsigned long)num_map);
/*
/*
* Get mapping parameters for each mapping.
*/
for (i = 0; i < (int)num_map; i++) {
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 */

View File

@@ -16,15 +16,15 @@
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
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 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.
Then it reads the values.
This file is intended for use with HDF5 Library version 1.10
@@ -37,9 +37,9 @@
#define FILE "vds.h5"
#define DATASET "VDS"
#define VDSDIM1 6
#define VDSDIM0 4
#define DIM0 6
#define VDSDIM1 6
#define VDSDIM0 4
#define DIM0 6
#define RANK1 1
#define RANK2 2
@@ -58,7 +58,7 @@ const char *SRC_DATASET[] = {
int
main (void)
{
hid_t file, space, src_space, vspace, dset; /* Handles */
hid_t file, space, src_space, vspace, dset; /* Handles */
hid_t dcpl;
herr_t status;
hsize_t vdsdims[2] = {VDSDIM0, VDSDIM1}, /* Virtual datasets dimension */
@@ -73,12 +73,12 @@ main (void)
block_out[2];
int wdata[DIM0], /* Write buffer for source dataset */
rdata[VDSDIM0][VDSDIM1], /* Read buffer for virtual dataset */
i, j, k, l;
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 *filename;
char *dsetname;
hsize_t nblocks;
hsize_t *buf; /* Buffer to hold hyperslab coordinates */
@@ -91,9 +91,9 @@ main (void)
* 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
* Create the source files and datasets. Write data to each dataset and
* close all resources.
*/
@@ -117,7 +117,7 @@ main (void)
/* 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;
@@ -126,11 +126,11 @@ main (void)
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.
* 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++) {
@@ -146,8 +146,8 @@ main (void)
status = H5Sclose (space);
status = H5Sclose (src_space);
status = H5Dclose (dset);
status = H5Fclose (file);
status = H5Fclose (file);
/*
* Now we begin the read section of this example.
*/
@@ -167,7 +167,7 @@ main (void)
* Get storage layout.
*/
layout = H5Pget_layout (dcpl);
if (H5D_VIRTUAL == layout)
if (H5D_VIRTUAL == layout)
printf(" Dataset has a virtual layout \n");
else
printf(" Wrong layout found \n");
@@ -178,26 +178,26 @@ main (void)
status = H5Pget_virtual_count (dcpl, &num_map);
printf(" Number of mappings is %lu\n", (unsigned long)num_map);
/*
/*
* Get mapping parameters for each mapping.
*/
for (i = 0; i < (int)num_map; i++) {
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) {
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++)
for (k=0; k<RANK2-1; k++)
printf("%d,", (int)buf[k]);
printf("%d ) - (", (int)buf[k]);
for (k=0; k<RANK2-1; k++)
for (k=0; k<RANK2-1; k++)
printf("%d,", (int)buf[RANK2+k]);
printf("%d)\n", (int)buf[RANK2+k]);
}

View File

@@ -18,7 +18,7 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# This script will compile and run the c examples from source files installed #
# in .../share/hdf5_examples/c using h5cc or h5pc. The order for running #
# in @examplesdir@/c using h5cc or h5pc. The order for running #
# programs with RunTest in the MAIN section below is taken from the Makefile. #
# The order is important since some of the test programs use data files created #
# by earlier test programs. Any future additions should be placed accordingly. #
@@ -28,10 +28,33 @@
# Initializations
EXIT_SUCCESS=0
EXIT_FAILURE=1
#
# Try to derive the path to the installation $prefix established
# by ./configure relative to the examples directory established by
# ./configure. If successful, set `prefix_relto_examplesdir` to the
# relative path. Otherwise, set `prefix_relto_examplesdir` to the
# absolute installation $prefix.
#
# This script uses the value of `prefix` in the user's environment, if
# it is set, below. The content of $() is evaluated in a sub-shell, so
# if `prefix` is set in the user's environment, the shell statements in
# $() won't clobbered it.
#
prefix_relto_examplesdir=$(
prefix=@prefix@
examplesdir=@examplesdir@
if [ ${examplesdir##${prefix}/} != ${examplesdir} ]; then
echo $(echo ${examplesdir##${prefix}/} | \
sed 's,[^/][^/]*,..,g')
else
echo $prefix
fi
)
# Where the tool is installed.
# default is relative path to installed location of the tools
prefix="${prefix:-@prefix@}"
# default is relative path to installed location of the tools
prefix="${prefix:-../${prefix_relto_examplesdir}}"
PARALLEL=@PARALLEL@ # Am I in parallel mode?
AR="@AR@"
RANLIB="@RANLIB@"
@@ -112,12 +135,16 @@ then
rm h5_attribute &&\
RunTest h5_mount &&\
rm h5_mount &&\
RunTest h5_reference &&\
rm h5_reference &&\
RunTest h5_reference_deprec &&\
rm h5_reference_deprec &&\
RunTest h5_ref_extern &&\
rm h5_ref_extern &&\
RunTest h5_ref_compat &&\
rm h5_ref_compat &&\
RunTest h5_drivers &&\
rm h5_drivers &&\
RunTest h5_ref2reg &&\
rm h5_ref2reg &&\
RunTest h5_ref2reg_deprec &&\
rm h5_ref2reg_deprec &&\
RunTest h5_extlink &&\
rm h5_extlink &&\
RunTest h5_elink_unix2win &&\
@@ -157,5 +184,5 @@ rm *.h5
rm -rf red blue u2w
echo
exit $EXIT_VALUE
exit $EXIT_VALUE

View File

@@ -48,6 +48,10 @@ verbose=${HDF5_VERBOSE:-1} # 0: none; 1: default; 2: chatty; 3: everything
test $verbose -gt 2 && set -x
H5_NO_DEPRECATED_SYMBOLS=`grep '#define H5_NO_DEPRECATED_SYMBOLS ' ../src/H5pubconf.h`
H5_USE_16_API_DEFAULT=`grep '#define H5_USE_16_API_DEFAULT ' ../src/H5pubconf.h`
H5_USE_18_API_DEFAULT=`grep '#define H5_USE_18_API_DEFAULT ' ../src/H5pubconf.h`
H5_USE_110_API_DEFAULT=`grep '#define H5_USE_110_API_DEFAULT ' ../src/H5pubconf.h`
H5_USE_112_API_DEFAULT=`grep '#define H5_USE_112_API_DEFAULT ' ../src/H5pubconf.h`
H5_USE_114_API_DEFAULT=`grep '#define H5_USE_114_API_DEFAULT ' ../src/H5pubconf.h`
# setup my machine information.
myos=`uname -s`
@@ -61,6 +65,10 @@ v16main=${H5TOOL}_v16main.$suffix
v16main_o=${H5TOOL}_v16main.o
v18main=${H5TOOL}_v18main.$suffix
v18main_o=${H5TOOL}_v18main.o
v110main=${H5TOOL}_v110main.$suffix
v110main_o=${H5TOOL}_v110main.o
v112main=${H5TOOL}_v112main.$suffix
v112main_o=${H5TOOL}_v112main.o
appmain=${H5TOOL}_appmain.$suffix
appmain_o=${H5TOOL}_appmain.o
prog1=${H5TOOL}_prog1.$suffix
@@ -74,7 +82,7 @@ applib=libapp${H5TOOL}.a
# Don't use the wildcard form of *.h5 as it will wipe out even *.h5 generated
# by otehr test programs. This will cause a racing condition error when
# parallel make (e.g., gmake -j 4) is used.
temp_SRC="$hdf5main $v16main $v18main $appmain $prog1 $prog2"
temp_SRC="$hdf5main $v16main $v18main $v110main $v112main $appmain $prog1 $prog2"
temp_OBJ=`echo $temp_SRC | sed -e "s/\.${suffix}/.o/g"`
temp_FILES="a.out $applib"
@@ -100,9 +108,9 @@ main (void)
printf("HDF5 C Sample program ran successfully. File %s generated.\n", H5FILE_NAME);
remove(H5FILE_NAME);
return 0;
}
}
EOF
# generate prog1
@@ -143,7 +151,7 @@ main (void)
remove(H5FILE_NAME);
return 0;
}
}
EOF
# Generate HDF5 v1.6 Main Program:
@@ -196,6 +204,82 @@ main (void)
}
EOF
# Generate HDF5 v1.10 Main Program:
# This makes unique V1.10 API calls.
cat > $v110main <<EOF
/* This is a V1.10 API calls example Program. */
#include "hdf5.h"
#define H5FILE_NAME "tmp.h5"
int
main (void)
{
hid_t file, group, group2, dset, dset2; /* file and group handles */
file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
group = H5Gcreate(file, "/Group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
group2 = H5Gcreate2(file, "/Group1.8", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
dset = H5Dopen(group, "Dataset", H5P_DEFAULT);
dset2 = H5Dopen2(group2, "Dataset2", H5P_DEFAULT);
H5Dclose(dset);
H5Dclose(dset2);
H5Gclose(group2);
H5Gclose(group);
H5Fclose(file);
printf("HDF5 C program created with V1.10 API ran successfully. "
"File %s generated.\n", H5FILE_NAME);
remove(H5FILE_NAME);
return 0;
}
EOF
# Generate HDF5 v1.12 Main Program:
# This makes unique V1.12 API calls.
cat > $v112main <<EOF
/* This is a V1.12 API calls example Program. */
#include "hdf5.h"
#define H5FILE_NAME "tmp.h5"
#define SPACE1_RANK 3
int
main (void)
{
hid_t sid; /* Dataspace ID */
hid_t fapl = -1; /* File access property list ID */
int rank; /* Logical rank of dataspace */
hsize_t dims[] = {3, 3, 15};
size_t sbuf_size=0;
herr_t ret; /* Generic return value */
hsize_t start[] = {0, 0, 0};
hsize_t stride[] = {2, 5, 3};
hsize_t count[] = {2, 2, 2};
hsize_t block[] = {1, 3, 1};
/* Create the file access property list */
fapl = H5Pcreate(H5P_FILE_ACCESS);
/* Set low/high bounds in the fapl */
ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_EARLIEST,
H5F_LIBVER_LATEST);
/* Create the dataspace */
sid = H5Screate_simple(SPACE1_RANK, dims, NULL);
/* Set the hyperslab selection */
ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block);
/* Encode simple dataspace in a buffer with the fapl setting */
ret = H5Sencode(sid, NULL, &sbuf_size, fapl);
/* Encode simple dataspace in a buffer with the fapl setting */
ret = H5Sencode2(sid, NULL, &sbuf_size, fapl);
printf("HDF5 C program created with V1.12 API ran successfully. ");
/* "File %s generated.\n", H5FILE_NAME);
remove(H5FILE_NAME); */
return 0;
}
EOF
# Parse option
# None
@@ -304,17 +388,30 @@ TOOLTEST -E $appmain $prog1 $prog2
# Group5: Version compatibility tests.
echo "***"Version compatibility tests.
# Test these two cases now. More later.
# 20200610 Updated for versions 1.10 - 1.14.
# If H5_NO_DEPRECATED_SYMBOLS;
# then only v18main works.
# then versions v18main, v110main, and v112main work.
# -DH5_USE_<N>_API_DEFAULT flags cannot be used with H5_NO_DEPRECATED_SYMBOLS;
# else if H5_USE_16_API_DEFAULT;
# then v16main works and -DH5_NO_DEPRECATED_SYMBOLS v18main also works.
# else v18main works and -DH5_USE_16_API_DEFAULT v16main also works.
# then v16main works.
# else v18main works and -DH5_USE_16_API_DEFAULT v16main also works.
# as new versions with versioned functions are added, they will work with and
# should be added to H5_NO_DEPRECATED_SYMBOLS and to the else section, with and
# without the -DH5_USE_<N>_API_DEFAULT flag. A new H5_USE_<N>_API_DEFAULT section
# should also be added.
#
if [ -n "$H5_USE_16_API_DEFAULT" ]; then
echo "H5_USE_16_API_DEFAULT is defined."
elif [ -n "$H5_USE_18_API_DEFAULT" ]; then
echo "H5_USE_18_API_DEFAULT is defined."
elif [ -n "$H5_USE_110_API_DEFAULT" ]; then
echo "H5_USE_110_API_DEFAULT is defined."
elif [ -n "$H5_USE_112_API_DEFAULT" ]; then
echo "H5_USE_112_API_DEFAULT is defined."
elif [ -n "$H5_USE_114_API_DEFAULT" ]; then
echo "H5_USE_114_API_DEFAULT is defined."
else
echo "H5_USE_16_API_DEFAULT is not defined."
echo "No H5 API_DEFAULT is defined."
fi
if [ -n "$H5_NO_DEPRECATED_SYMBOLS" ]; then
echo "H5_NO_DEPRECATED_SYMBOLS is defined."
@@ -324,12 +421,36 @@ fi
if [ -n "$H5_NO_DEPRECATED_SYMBOLS" ]; then
echo "Skipping $v16main test"
TOOLTEST $v18main
TOOLTEST $v18main
TOOLTEST $v110main
TOOLTEST $v112main
elif [ -n "$H5_USE_16_API_DEFAULT" ]; then
echo "Testing HDF5 with 16_API_DEFAULT"
TOOLTEST $v16main
TOOLTEST -DH5_NO_DEPRECATED_SYMBOLS $v18main
else
elif [ -n "$H5_USE_18_API_DEFAULT" ]; then
echo "Testing HDF5 with 18_API_DEFAULT"
TOOLTEST -DH5_USE_16_API_DEFAULT $v16main
TOOLTEST $v18main
elif [ -n "$H5_USE_110_API_DEFAULT" ]; then
echo "Testing HDF5 with 110_API_DEFAULT"
TOOLTEST -DH5_USE_16_API_DEFAULT $v16main
TOOLTEST -DH5_USE_18_API_DEFAULT $v18main
TOOLTEST $v110main
elif [ -n "$H5_USE_112_API_DEFAULT" ]; then
echo "Testing HDF5 with 112_API_DEFAULT"
TOOLTEST -DH5_USE_16_API_DEFAULT $v16main
TOOLTEST -DH5_USE_18_API_DEFAULT $v18main
TOOLTEST -DH5_USE_110_API_DEFAULT $v110main
TOOLTEST $v112main
else
echo "Testing HDF5 with 114_API_DEFAULT"
TOOLTEST -DH5_USE_16_API_DEFAULT $v16main
TOOLTEST -DH5_USE_18_API_DEFAULT $v18main
TOOLTEST -DH5_USE_110_API_DEFAULT $v110main
TOOLTEST -DH5_USE_112_API_DEFAULT $v112main
TOOLTEST $v18main
TOOLTEST $v110main
TOOLTEST $v112main
fi
##############################################################################