Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop merge examples #3851

Merged
merged 18 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ jobs:
- uses: actions/checkout@v4
- uses: codespell-project/actions-codespell@master
with:
skip: ./.github/workflows/codespell.yml,./bin/trace,./hl/tools/h5watch/h5watch.c,./tools/test/h5jam/tellub.c,./config/sanitizer/LICENSE,./config/sanitizer/sanitizers.cmake,./tools/test/h5repack/testfiles/*.dat,./test/API/driver,./configure,./bin/ltmain.sh,./bin/depcomp,./bin/config.guess,./bin/config.sub,./autom4te.cache,./m4/libtool.m4,./c++/src/*.html
skip: ./.github/workflows/codespell.yml,./bin/trace,./hl/tools/h5watch/h5watch.c,./tools/test/h5jam/tellub.c,./config/sanitizer/LICENSE,./config/sanitizer/sanitizers.cmake,./tools/test/h5repack/testfiles/*.dat,./test/API/driver,./configure,./bin/ltmain.sh,./bin/depcomp,./bin/config.guess,./bin/config.sub,./autom4te.cache,./m4/libtool.m4,./c++/src/*.html,./HDF5Examples/depcomp
ignore_words_list: ot,isnt,inout,nd,parms,parm,ba,offsetP,ser,ois,had,fiter,fo,clude,refere,minnum,offsetp,creat,ans:,eiter,lastr,ans,isn't,ifset,sur,trun,dne,tthe,hda,filname,te,htmp,ake,gord,numer,ro,oce,msdos
45 changes: 0 additions & 45 deletions CMakeInstallation.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -155,51 +155,6 @@ if (HDF5_PACK_EXAMPLES)
COMPONENT hdfdocuments
)

option (EXAMPLES_DOWNLOAD "Download to use released examples files" OFF)
if (EXAMPLES_DOWNLOAD)
option (EXAMPLES_USE_RELEASE_NAME "Use the released examples artifact name" OFF)
if (EXAMPLES_USE_RELEASE_NAME)
set (EXAMPLES_NAME ${EXAMPLES_TGZ_ORIGNAME})
else ()
set (EXAMPLES_NAME ${HDF5_EXAMPLES_COMPRESSED})
endif ()
if (NOT EXAMPLES_USE_LOCALCONTENT)
set (EXAMPLES_URL ${EXAMPLES_TGZ_ORIGPATH}/${EXAMPLES_NAME})
file (DOWNLOAD ${EXAMPLES_URL} ${HDF5_BINARY_DIR}/${HDF5_EXAMPLES_COMPRESSED} STATUS EX_DL)
message (STATUS "Examples file is ${EXAMPLES_URL} STATUS=${EX_DL}")
else ()
set (EXAMPLES_URL ${TGZPATH}/${EXAMPLES_NAME})
file (COPY_FILE ${EXAMPLES_URL} ${HDF5_BINARY_DIR}/${HDF5_EXAMPLES_COMPRESSED} RESULT EX_DL)
message (STATUS "Examples file is ${EXAMPLES_URL} RESULT=${EX_DL}")
endif ()
if (EXISTS "${HDF5_BINARY_DIR}/${HDF5_EXAMPLES_COMPRESSED}")
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar xzf ${HDF5_EXAMPLES_COMPRESSED}
WORKING_DIRECTORY ${HDF5_BINARY_DIR}
COMMAND_ECHO STDOUT
)
endif ()
else ()
if (EXISTS "${HDF5_EXAMPLES_COMPRESSED_DIR}/${HDF5_EXAMPLES_COMPRESSED}")
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar xzf ${HDF5_EXAMPLES_COMPRESSED_DIR}/${HDF5_EXAMPLES_COMPRESSED}
WORKING_DIRECTORY ${HDF5_BINARY_DIR}
COMMAND_ECHO STDOUT
)
endif ()
endif ()
get_filename_component (EX_LAST_EXT ${HDF5_EXAMPLES_COMPRESSED} LAST_EXT)
if (${EX_LAST_EXT} STREQUAL ".zip")
get_filename_component (EX_DIR_NAME ${HDF5_EXAMPLES_COMPRESSED} NAME_WLE)
else ()
get_filename_component (EX_DIR_NAME ${HDF5_EXAMPLES_COMPRESSED} NAME_WLE)
get_filename_component (EX_DIR_NAME ${EX_DIR_NAME} NAME_WLE)
endif ()
execute_process(
COMMAND ${CMAKE_COMMAND} -E rename ${EX_DIR_NAME} HDF5Examples
WORKING_DIRECTORY ${HDF5_BINARY_DIR}
COMMAND_ECHO STDOUT
)
install (
DIRECTORY ${HDF5_BINARY_DIR}/HDF5Examples
DESTINATION ${HDF5_INSTALL_DATA_DIR}
Expand Down
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1041,10 +1041,12 @@ endif ()
#-----------------------------------------------------------------------------
# Option to build examples
#-----------------------------------------------------------------------------
if (EXISTS "${HDF5_SOURCE_DIR}/examples" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/examples")
if (EXISTS "${HDF5_SOURCE_DIR}/HDF5Examples" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/HDF5Examples")
option (HDF5_BUILD_EXAMPLES "Build HDF5 Library Examples" ON)
if (HDF5_BUILD_EXAMPLES)
add_subdirectory (examples)
include (${HDF_RESOURCES_DIR}/HDF5ExampleCache.cmake)
set (HDF5_VERSION ${HDF5_PACKAGE_VERSION})
add_subdirectory (HDF5Examples)
endif ()
endif ()

Expand All @@ -1060,7 +1062,7 @@ if (EXISTS "${HDF5_SOURCE_DIR}/hl" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/hl")
endif ()

#-----------------------------------------------------------------------------
# Option to build Fortran bindings/tests/examples
# Option to build Fortran bindings/tests
# Make sure this appears before the CONFIGURE_FILE step
# so that fortran name mangling is detected before writing H5pubconf.h
#-----------------------------------------------------------------------------
Expand Down
14 changes: 1 addition & 13 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,11 @@
"PLUGIN_USE_LOCALCONTENT": "OFF"
}
},
{
"name": "ci-ExamplesVars",
"hidden": true,
"cacheVariables": {
"HDF5_EXAMPLES_COMPRESSED": {"type": "STRING", "value": "hdf5-examples-master.tar.gz"},
"HDF5_EXAMPLES_COMPRESSED_DIR": {"type": "PATH", "value": "${sourceParentDir}/temp"},
"EXAMPLES_TGZ_ORIGPATH": {"type": "STRING", "value": "https://github.com/HDFGroup/hdf5-examples/releases/download/snapshot"},
"EXAMPLES_TGZ_ORIGNAME": {"type": "STRING", "value": "hdf5-examples-2.0.4.tar.gz"}
}
},
{
"name": "ci-StdExamples",
"hidden": true,
"inherits": ["ci-base", "ci-ExamplesVars", "ci-base-tgz"],
"inherits": ["ci-base", "ci-base-tgz"],
"cacheVariables": {
"EXAMPLES_USE_RELEASE_NAME": "ON",
"EXAMPLES_USE_LOCALCONTENT": "OFF",
"HDF5_PACK_EXAMPLES": "ON",
"EXAMPLES_DOWNLOAD": "ON"
}
Expand Down
20 changes: 20 additions & 0 deletions HDF5Examples/C/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cmake_minimum_required (VERSION 3.12)
PROJECT (HDF5Examples_C)

#-----------------------------------------------------------------------------
# Build the C Examples
#-----------------------------------------------------------------------------
add_subdirectory (${PROJECT_SOURCE_DIR}/H5D)
add_subdirectory (${PROJECT_SOURCE_DIR}/H5G)
add_subdirectory (${PROJECT_SOURCE_DIR}/H5T)

if (${H5_LIBVER_DIR} GREATER 16)
# add_subdirectory (${PROJECT_SOURCE_DIR}/Perf)
if (USE_SHARED_LIBS AND HDF_BUILD_FILTERS AND HDF5_ENABLE_PLUGIN_SUPPORT)
add_subdirectory (${PROJECT_SOURCE_DIR}/H5FLT)
endif ()
endif ()

if (H5_HAVE_PARALLEL AND HDF5_ENABLE_PARALLEL)
add_subdirectory (${PROJECT_SOURCE_DIR}/H5PAR)
endif ()
132 changes: 132 additions & 0 deletions HDF5Examples/C/H5D/16/h5ex_d_alloc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/************************************************************

This example shows how to set the space allocation time
for a dataset. The program first creates two datasets,
one with the default allocation time (late) and one with
early allocation time, and displays whether each has been
allocated and their allocation size. Next, it writes data
to the datasets, and again displays whether each has been
allocated and their allocation size.

This file is intended for use with HDF5 Library version 1.6

************************************************************/

#include "hdf5.h"
#include <stdio.h>
#include <stdlib.h>

#define FILE "h5ex_d_alloc.h5"
#define DATASET1 "DS1"
#define DATASET2 "DS2"
#define DIM0 4
#define DIM1 7
#define FILLVAL 99

int
main(void)
{
hid_t file, space, dset1, dset2, dcpl;
/* Handles */
herr_t status;
H5D_space_status_t space_status;
hsize_t dims[2] = {DIM0, DIM1}, storage_size;
int wdata[DIM0][DIM1], /* Write buffer */
i, j;

/*
* Initialize data.
*/
for (i = 0; i < DIM0; i++)
for (j = 0; j < DIM1; j++)
wdata[i][j] = i * j - j;

/*
* Create a new file using the default properties.
*/
file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);

/*
* Create dataspace. Setting maximum size to NULL sets the maximum
* size to be the current size.
*/
space = H5Screate_simple(2, dims, NULL);

/*
* Create the dataset creation property list, and set the chunk
* size.
*/
dcpl = H5Pcreate(H5P_DATASET_CREATE);

/*
* Set the allocation time to "early". This way we can be sure
* that reading from the dataset immediately after creation will
* return the fill value.
*/
status = H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY);

printf("Creating datasets...\n");
printf("%s has allocation time H5D_ALLOC_TIME_LATE\n", DATASET1);
printf("%s has allocation time H5D_ALLOC_TIME_EARLY\n\n", DATASET2);

/*
* Create the dataset using the dataset creation property list.
*/
dset1 = H5Dcreate(file, DATASET1, H5T_STD_I32LE, space, H5P_DEFAULT);
dset2 = H5Dcreate(file, DATASET2, H5T_STD_I32LE, space, dcpl);

/*
* Retrieve and print space status and storage size for dset1.
*/
status = H5Dget_space_status(dset1, &space_status);
storage_size = H5Dget_storage_size(dset1);
printf("Space for %s has%sbeen allocated.\n", DATASET1,
space_status == H5D_SPACE_STATUS_ALLOCATED ? " " : " not ");
printf("Storage size for %s is: %ld bytes.\n", DATASET1, (long)storage_size);

/*
* Retrieve and print space status and storage size for dset2.
*/
status = H5Dget_space_status(dset2, &space_status);
storage_size = H5Dget_storage_size(dset2);
printf("Space for %s has%sbeen allocated.\n", DATASET2,
space_status == H5D_SPACE_STATUS_ALLOCATED ? " " : " not ");
printf("Storage size for %s is: %ld bytes.\n", DATASET2, (long)storage_size);

printf("\nWriting data...\n\n");

/*
* Write the data to the datasets.
*/
status = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata[0]);
status = H5Dwrite(dset2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata[0]);

/*
* Retrieve and print space status and storage size for dset1.
*/
status = H5Dget_space_status(dset1, &space_status);
storage_size = H5Dget_storage_size(dset1);
printf("Space for %s has%sbeen allocated.\n", DATASET1,
space_status == H5D_SPACE_STATUS_ALLOCATED ? " " : " not ");
printf("Storage size for %s is: %ld bytes.\n", DATASET1, (long)storage_size);

/*
* Retrieve and print space status and storage size for dset2.
*/
status = H5Dget_space_status(dset2, &space_status);
storage_size = H5Dget_storage_size(dset2);
printf("Space for %s has%sbeen allocated.\n", DATASET2,
space_status == H5D_SPACE_STATUS_ALLOCATED ? " " : " not ");
printf("Storage size for %s is: %ld bytes.\n", DATASET2, (long)storage_size);

/*
* Close and release resources.
*/
status = H5Pclose(dcpl);
status = H5Dclose(dset1);
status = H5Dclose(dset2);
status = H5Sclose(space);
status = H5Fclose(file);

return 0;
}
Loading