Skip to content

Commit

Permalink
CMake: add HDF5 support (#1048)
Browse files Browse the repository at this point in the history
  • Loading branch information
mic84 authored Jun 24, 2020
1 parent df3e65b commit 32d2e44
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Docs/sphinx_documentation/source/BuildingAMReX.rst
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,8 @@ below.
+------------------------------+-------------------------------------------------+-------------+-----------------+
| ENABLE_HYPRE | Enable HYPRE interfaces | NO | YES, NO |
+------------------------------+-------------------------------------------------+-------------+-----------------+
| ENABLE_HDF5 | Enable HDF5-based I/O | NO | YES, NO |
+------------------------------+-------------------------------------------------+-------------+-----------------+
| ENABLE_PLOTFILE_TOOLS | Build and install plotfile postprocessing tools| NO | YES, NO |
+------------------------------+-------------------------------------------------+-------------+-----------------+
| ENABLE_TUTORIALS | Build tutorials | NO | YES, NO |
Expand Down
2 changes: 2 additions & 0 deletions Tools/CMake/AMReX_Config.H.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
#cmakedefine AMREX_GPUS_PER_SOCKET @AMREX_GPUS_PER_SOCKET@
#cmakedefine AMREX_GPUS_PER_NODE @AMREX_GPUS_PER_NODE@
#cmakedefine AMREX_PARTICLES
#cmakedefine AMREX_USE_HDF5
#cmakedefine AMREX_USE_HDF5_ASYNC
#ifdef __cplusplus
#ifndef @COMPILER_ID_MACRO@
static_assert(false,"libamrex was built with @CMAKE_CXX_COMPILER_ID@");
Expand Down
13 changes: 13 additions & 0 deletions Tools/CMake/AMReX_Config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,19 @@ function (configure_amrex)
endif()
endif()

#
# Setup HDF5 -- for now we do not create an imported target
#
if (ENABLE_HDF5)
set(HDF5_PREFER_PARALLEL TRUE)
find_package(HDF5 1.10.4 REQUIRED COMPONENTS CXX)
if (NOT HDF5_IS_PARALLEL)
message(FATAL_ERROR "\nHDF5 library does not support parallel I/O")
endif ()
target_include_directories(amrex PUBLIC ${HDF5_CXX_INCLUDE_DIRS})
target_compile_definitions(amrex PUBLIC ${HDF5_CXX_DEFINES})
target_link_libraries(amrex PUBLIC ${HDF5_CXX_LIBRARIES})
endif ()

#
# Setup third-party profilers
Expand Down
6 changes: 6 additions & 0 deletions Tools/CMake/AMReX_Defines.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,10 @@ function ( set_amrex_defines )
NO_LEGACY IF GPUS_PER_NODE)
endif ()

#
# HDF5
#
add_amrex_define(AMREX_USE_HDF5 NO_LEGACY IF ENABLE_HDF5)
add_amrex_define(AMREX_USE_HDF5_ASYNC NO_LEGACY IF ENABLE_HDF5_ASYNC)

endfunction ()
13 changes: 13 additions & 0 deletions Tools/CMake/AMReX_Options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,19 @@ cmake_dependent_option(ENABLE_PETSC "Enable PETSc interfaces" OFF
"ENABLE_FORTRAN;ENABLE_LINEAR_SOLVERS" OFF )
print_option(ENABLE_PETSC)

# HDF5
option(ENABLE_HDF5 "Enable HDF5-based I/O" OFF)
print_option(ENABLE_HDF5)

cmake_dependent_option(ENABLE_HDF5_ASYNC "Enable asynchronous writes in the HDF5-based IO" OFF
"ENABLE_HDF5" OFF )
print_option(ENABLE_HDF5_ASYNC)

if (ENABLE_HDF5_ASYNC)
message(FATAL_ERROR "\nENABLE_HDF5_ASYNC not yet supported\n")
endif ()


#
# Miscellanoues options =====================================================
#
Expand Down

0 comments on commit 32d2e44

Please sign in to comment.