summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/CMakeLists.txt18
-rw-r--r--examples/h5_attribute.c5
-rw-r--r--examples/h5_cmprss.c2
-rw-r--r--examples/h5_dtransform.c40
-rw-r--r--examples/h5_extlink.c5
-rw-r--r--examples/h5_group.c10
-rw-r--r--examples/h5_ref_compat.c4
-rw-r--r--examples/h5_ref_extern.c4
-rw-r--r--examples/h5_vds.c11
-rw-r--r--examples/testh5cc.sh.in6
10 files changed, 63 insertions, 42 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 527b11f..9ab870f 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -44,7 +44,7 @@ set (examples
foreach (example ${examples})
add_executable (${example} ${HDF5_EXAMPLES_SOURCE_DIR}/${example}.c)
- target_include_directories (${example} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (${example} PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_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})
@@ -53,11 +53,18 @@ foreach (example ${examples})
target_link_libraries (${example} PRIVATE ${HDF5_LIBSH_TARGET})
endif ()
set_target_properties (${example} PROPERTIES FOLDER examples)
+
+ #-----------------------------------------------------------------------------
+ # Add Target to clang-format
+ #-----------------------------------------------------------------------------
+ if (HDF5_ENABLE_FORMATTERS)
+ clang_format (HDF5_EXAMPLES_${example}_FORMAT ${example})
+ endif ()
endforeach ()
if (H5_HAVE_PARALLEL)
add_executable (ph5example ${HDF5_EXAMPLES_SOURCE_DIR}/ph5example.c)
- target_include_directories (ph5example PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (ph5example PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_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})
@@ -66,6 +73,13 @@ if (H5_HAVE_PARALLEL)
target_link_libraries (ph5example PRIVATE ${HDF5_LIBSH_TARGET} ${MPI_C_LIBRARIES})
endif ()
set_target_properties (ph5example PROPERTIES FOLDER examples)
+
+ #-----------------------------------------------------------------------------
+ # Add Target to clang-format
+ #-----------------------------------------------------------------------------
+ if (HDF5_ENABLE_FORMATTERS)
+ clang_format (HDF5_EXAMPLES_ph5example_FORMAT ph5example)
+ endif ()
endif ()
if (BUILD_TESTING AND HDF5_TEST_EXAMPLES)
diff --git a/examples/h5_attribute.c b/examples/h5_attribute.c
index 5d90d91..97be7f5 100644
--- a/examples/h5_attribute.c
+++ b/examples/h5_attribute.c
@@ -184,6 +184,8 @@ main(void)
printf("The value of the attribute \"Integer attribute\" is %d \n", point_out);
ret = H5Aclose(attr);
+ //! [H5Oget_info3_snip]
+
/*
* Find string attribute by iterating through all attributes
*/
@@ -203,6 +205,7 @@ main(void)
ret = H5Tclose(atype);
}
+ //! [H5Oget_info3_snip]
/*
* Get attribute info using iteration function.
*/
@@ -232,7 +235,7 @@ attr_info(hid_t loc_id, const char *name, const H5A_info_t *ainfo, void *opdata)
float * float_array; /* Pointer to the array attribute. */
/* avoid warnings */
- opdata = opdata;
+ (void)opdata;
/*
* Open the attribute using its name.
diff --git a/examples/h5_cmprss.c b/examples/h5_cmprss.c
index 59a59f5..d8848e2 100644
--- a/examples/h5_cmprss.c
+++ b/examples/h5_cmprss.c
@@ -99,7 +99,7 @@ main()
for (i = 0; i < numfilt; i++) {
nelmts = 0;
- filter_type = H5Pget_filter2(plist_id, 0, &flags, &nelmts, NULL, 0, NULL, &filter_info);
+ filter_type = H5Pget_filter2(plist_id, i, &flags, &nelmts, NULL, 0, NULL, &filter_info);
printf("Filter Type: ");
switch (filter_type) {
case H5Z_FILTER_DEFLATE:
diff --git a/examples/h5_dtransform.c b/examples/h5_dtransform.c
index 289c102..a364ec1 100644
--- a/examples/h5_dtransform.c
+++ b/examples/h5_dtransform.c
@@ -36,30 +36,22 @@
#define ROWS 12
#define COLS 18
-const float windchillF[ROWS][COLS] = {{36.0, 31.0, 25.0, 19.0, 13.0, 7.0, 1.0, -5.0, -11.0, -16.0, -22.0,
- -28.0, -34.0, -40.0, -46.0, -52.0, -57.0, -63.0},
- {34.0, 27.0, 21.0, 15.0, 9.0, 3.0, -4.0, -10.0, -16.0, -22.0, -28.0,
- -35.0, -41.0, -47.0, -53.0, -59.0, -66.0, -72.0},
- {32.0, 25.0, 19.0, 13.0, 6.0, 0.0, -7.0, -13.0, -19.0, -26.0, -32.0,
- -39.0, -45.0, -51.0, -58.0, -64.0, -71.0, -77.0},
- {30.0, 24.0, 17.0, 11.0, 4.0, -2.0, -9.0, -15.0, -22.0, -29.0, -35.0,
- -42.0, -48.0, -55.0, -61.0, -68.0, -74.0, -81.0},
- {29.0, 23.0, 16.0, 9.0, 3.0, -4.0, -11.0, -17.0, -24.0, -31.0, -37.0,
- -44.0, -51.0, -58.0, -64.0, -71.0, -78.0, -84.0},
- {28.0, 22.0, 15.0, 8.0, 1.0, -5.0, -12.0, -19.0, -26.0, -33.0, -39.0,
- -46.0, -53.0, -60.0, -67.0, -73.0, -80.0, -87.0},
- {28.0, 21.0, 14.0, 7.0, 0.0, -7.0, -14.0, -21.0, -27.0, -34.0, -41.0,
- -48.0, -55.0, -62.0, -69.0, -76.0, -82.0, -89.0},
- {27.0, 20.0, 13.0, 6.0, -1.0, -8.0, -15.0, -22.0, -29.0, -36.0, -43.0,
- -50.0, -57.0, -64.0, -71.0, -78.0, -84.0, -91.0},
- {26.0, 19.0, 12.0, 5.0, -2.0, -9.0, -16.0, -23.0, -30.0, -37.0, -44.0,
- -51.0, -58.0, -65.0, -72.0, -79.0, -86.0, -93.0},
- {26.0, 19.0, 12.0, 4.0, -3.0, -10.0, -17.0, -24.0, -31.0, -38.0, -45.0,
- -52.0, -60.0, -67.0, -74.0, -81.0, -88.0, -95.0},
- {25.0, 18.0, 11.0, 4.0, -3.0, -11.0, -18.0, -25.0, -32.0, -39.0, -46.0,
- -54.0, -61.0, -68.0, -75.0, -82.0, -89.0, -97.0},
- {25.0, 17.0, 10.0, 3.0, -4.0, -11.0, -19.0, -26.0, -33.0, -40.0, -48.0,
- -55.0, -62.0, -69.0, -76.0, -84.0, -91.0, -98.0}};
+/* clang-format off */
+const float windchillF[ROWS][COLS] =
+ { {36.0, 31.0, 25.0, 19.0, 13.0, 7.0, 1.0, -5.0, -11.0, -16.0, -22.0, -28.0, -34.0, -40.0, -46.0, -52.0, -57.0, -63.0},
+ {34.0, 27.0, 21.0, 15.0, 9.0, 3.0, -4.0, -10.0, -16.0, -22.0, -28.0, -35.0, -41.0, -47.0, -53.0, -59.0, -66.0, -72.0},
+ {32.0, 25.0, 19.0, 13.0, 6.0, 0.0, -7.0, -13.0, -19.0, -26.0, -32.0, -39.0, -45.0, -51.0, -58.0, -64.0, -71.0, -77.0},
+ {30.0, 24.0, 17.0, 11.0, 4.0, -2.0, -9.0, -15.0, -22.0, -29.0, -35.0, -42.0, -48.0, -55.0, -61.0, -68.0, -74.0, -81.0},
+ {29.0, 23.0, 16.0, 9.0, 3.0, -4.0, -11.0, -17.0, -24.0, -31.0, -37.0, -44.0, -51.0, -58.0, -64.0, -71.0, -78.0, -84.0},
+ {28.0, 22.0, 15.0, 8.0, 1.0, -5.0, -12.0, -19.0, -26.0, -33.0, -39.0, -46.0, -53.0, -60.0, -67.0, -73.0, -80.0, -87.0},
+ {28.0, 21.0, 14.0, 7.0, 0.0, -7.0, -14.0, -21.0, -27.0, -34.0, -41.0, -48.0, -55.0, -62.0, -69.0, -76.0, -82.0, -89.0},
+ {27.0, 20.0, 13.0, 6.0, -1.0, -8.0, -15.0, -22.0, -29.0, -36.0, -43.0, -50.0, -57.0, -64.0, -71.0, -78.0, -84.0, -91.0},
+ {26.0, 19.0, 12.0, 5.0, -2.0, -9.0, -16.0, -23.0, -30.0, -37.0, -44.0, -51.0, -58.0, -65.0, -72.0, -79.0, -86.0, -93.0},
+ {26.0, 19.0, 12.0, 4.0, -3.0, -10.0, -17.0, -24.0, -31.0, -38.0, -45.0, -52.0, -60.0, -67.0, -74.0, -81.0, -88.0, -95.0},
+ {25.0, 18.0, 11.0, 4.0, -3.0, -11.0, -18.0, -25.0, -32.0, -39.0, -46.0, -54.0, -61.0, -68.0, -75.0, -82.0, -89.0, -97.0},
+ {25.0, 17.0, 10.0, 3.0, -4.0, -11.0, -19.0, -26.0, -33.0, -40.0, -48.0, -55.0, -62.0, -69.0, -76.0, -84.0, -91.0, -98.0}
+ };
+/* clang-format on */
#define PRINT(array) \
{ \
diff --git a/examples/h5_extlink.c b/examples/h5_extlink.c
index 44ff2da..f9d4046 100644
--- a/examples/h5_extlink.c
+++ b/examples/h5_extlink.c
@@ -414,10 +414,15 @@ UD_hard_create(const char *link_name, hid_t loc_group, const void *udata, size_t
token = *((H5O_token_t *)udata);
+ //! [H5Open_by_token_snip]
+
/* Open the object this link points to so that we can increment
* 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_token(loc_group, token);
+
+ //! [H5Open_by_token_snip]
+
if (target_obj < 0) {
ret_value = -1;
goto done;
diff --git a/examples/h5_group.c b/examples/h5_group.c
index 4b489f0..40acafe 100644
--- a/examples/h5_group.c
+++ b/examples/h5_group.c
@@ -171,9 +171,9 @@ static herr_t
file_info(hid_t loc_id, const char *name, const H5L_info2_t *linfo, void *opdata)
{
/* avoid compiler warnings */
- loc_id = loc_id;
- opdata = opdata;
- linfo = linfo;
+ (void)loc_id;
+ (void)opdata;
+ (void)linfo;
/*
* Display group name. The name is passed to the function by
@@ -198,8 +198,8 @@ group_info(hid_t loc_id, const char *name, const H5L_info2_t *linfo, void *opdat
int rank_chunk;
/* avoid warnings */
- opdata = opdata;
- linfo = linfo;
+ (void)opdata;
+ (void)linfo;
/*
* Open the datasets using their names.
diff --git a/examples/h5_ref_compat.c b/examples/h5_ref_compat.c
index 82ef525..cce755b 100644
--- a/examples/h5_ref_compat.c
+++ b/examples/h5_ref_compat.c
@@ -76,9 +76,9 @@ main(void)
/* 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);
+ H5Rget_obj_type3(&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);
+ dset1 = H5Ropen_object(&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]);
diff --git a/examples/h5_ref_extern.c b/examples/h5_ref_extern.c
index a46f676..691d235 100644
--- a/examples/h5_ref_extern.c
+++ b/examples/h5_ref_extern.c
@@ -78,9 +78,9 @@ main(void)
/* 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);
+ H5Rget_obj_type3(&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);
+ dset1 = H5Ropen_object(&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]);
diff --git a/examples/h5_vds.c b/examples/h5_vds.c
index 6bef06f..e036204 100644
--- a/examples/h5_vds.c
+++ b/examples/h5_vds.c
@@ -60,7 +60,7 @@ main(void)
hsize_t start_out[2], stride_out[2], count_out[2], block_out[2];
int wdata[DIM0], /* Write buffer for source dataset */
rdata[VDSDIM0][VDSDIM1], /* Read buffer for virtual dataset */
- i, j, k, l;
+ i, j, k, l, block_inc;
int fill_value = -1; /* Fill value for VDS */
H5D_layout_t layout; /* Storage layout */
size_t num_map; /* Number of mappings */
@@ -178,13 +178,14 @@ main(void)
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++) {
+ block_inc = 2 * RANK2 * l;
printf("(");
for (k = 0; k < RANK2 - 1; k++)
- printf("%d,", (int)buf[k]);
- printf("%d ) - (", (int)buf[k]);
+ printf("%d,", (int)buf[block_inc + k]);
+ printf("%d) - (", (int)buf[block_inc + k]);
for (k = 0; k < RANK2 - 1; k++)
- printf("%d,", (int)buf[RANK2 + k]);
- printf("%d)\n", (int)buf[RANK2 + k]);
+ printf("%d,", (int)buf[block_inc + RANK2 + k]);
+ printf("%d)\n", (int)buf[block_inc + RANK2 + k]);
}
/* We also can use new APIs to get start, stride, count and block */
if (H5Sis_regular_hyperslab(vspace)) {
diff --git a/examples/testh5cc.sh.in b/examples/testh5cc.sh.in
index 0c122c7..ba80f2d 100644
--- a/examples/testh5cc.sh.in
+++ b/examples/testh5cc.sh.in
@@ -91,6 +91,8 @@ temp_FILES="a.out $applib"
cat > $appmain <<EOF
#include "hdf5.h"
#define H5FILE_NAME "tmp.h5"
+extern void sub1(void);
+extern void sub2(void);
int
main (void)
{
@@ -115,6 +117,8 @@ EOF
# generate prog1
cat > $prog1 <<EOF
+#include <stdio.h>
+void
sub1(void)
{
printf("in sub1\n");
@@ -123,6 +127,8 @@ EOF
# generate prog2
cat > $prog2 <<EOF
+#include <stdio.h>
+void
sub2(void)
{
printf("in sub2\n");