Skip to content
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 63 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,72 @@ if(Idefix_HDF5)
PUBLIC src/output/xdmf.cpp
PUBLIC src/output/xdmf.hpp
)
find_package(HDF5 REQUIRED)
target_link_libraries(idefix "${HDF5_LIBRARIES}")
# Prefer imported targets (matches older working behavior), then fall back.
find_package(HDF5 QUIET COMPONENTS C)
if(NOT HDF5_FOUND)
find_package(HDF5 REQUIRED MODULE COMPONENTS C)
endif()

set(_idefix_hdf5_link_items "${HDF5_LIBRARIES}")
if(TARGET hdf5::hdf5)
set(_idefix_hdf5_link_items hdf5::hdf5)
elseif(TARGET HDF5::HDF5)
set(_idefix_hdf5_link_items HDF5::HDF5)
endif()

target_link_libraries(idefix ${_idefix_hdf5_link_items})
message(STATUS "Found HDF5 include directories: ${HDF5_INCLUDE_DIRS}")
target_include_directories(idefix PUBLIC "${HDF5_INCLUDE_DIRS}")
if(Idefix_MPI)
if(NOT HDF5_IS_PARALLEL)
include(CheckCSourceCompiles)

# Some CMake/HDF5 combinations do not reliably set HDF5_IS_PARALLEL
# (e.g. when HDF5 is found via its CMake config package rather than the
# FindHDF5 module). Combine metadata checks with a compile+link probe for
# the MPI-IO symbols to reliably detect parallel HDF5.
set(_idefix_hdf5_is_parallel FALSE)
if(HDF5_IS_PARALLEL OR HDF5_C_IS_PARALLEL)
set(_idefix_hdf5_is_parallel TRUE)
endif()

if(NOT _idefix_hdf5_is_parallel AND DEFINED HDF5_C_COMPILER_EXECUTABLE)
execute_process(
COMMAND "${HDF5_C_COMPILER_EXECUTABLE}" -showconfig
OUTPUT_VARIABLE _idefix_hdf5_showconfig
ERROR_QUIET
)
if(_idefix_hdf5_showconfig MATCHES "Parallel HDF5:[ \t]*yes")
set(_idefix_hdf5_is_parallel TRUE)
endif()
endif()

set(_idefix_saved_required_includes "${CMAKE_REQUIRED_INCLUDES}")
set(_idefix_saved_required_libraries "${CMAKE_REQUIRED_LIBRARIES}")

set(CMAKE_REQUIRED_INCLUDES ${HDF5_INCLUDE_DIRS} ${MPI_C_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${_idefix_hdf5_link_items} MPI::MPI_C)
check_c_source_compiles(
"#include <mpi.h>
#include <hdf5.h>
int main(void) {
hid_t plist = H5Pcreate(H5P_FILE_ACCESS);
H5Pset_fapl_mpio(plist, MPI_COMM_WORLD, MPI_INFO_NULL);
H5Pclose(plist);
return 0;
}"
IDEFIX_HDF5_HAS_MPI_IO
)

set(CMAKE_REQUIRED_INCLUDES "${_idefix_saved_required_includes}")
set(CMAKE_REQUIRED_LIBRARIES "${_idefix_saved_required_libraries}")
unset(_idefix_saved_required_includes)
unset(_idefix_saved_required_libraries)

if(IDEFIX_HDF5_HAS_MPI_IO)
set(_idefix_hdf5_is_parallel TRUE)
endif()

if(NOT _idefix_hdf5_is_parallel)
message(FATAL_ERROR "Parallel HDF5 required for Idefix_MPI but the found HDF5 library does not support it")
endif()
endif()
Expand Down
4 changes: 2 additions & 2 deletions src/fluid/boundary/axis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ void Axis::ExchangeMPI(int side) {
idfx::pushRegion("Axis::ExchangeMPI");
#ifdef WITH_MPI
// Load the buffers with data
int ibeg,iend,jbeg,jend,kbeg,kend,offset;
int ny;
[[maybe_unused]] int ibeg,iend,jbeg,jend,kbeg,kend,offset;
[[maybe_unused]] int ny;
Buffer bufferSend = this->bufferSend;
IdefixArray1D<int> map = this->mapVars;
IdefixArray4D<real> Vc = this->Vc;
Expand Down
2 changes: 1 addition & 1 deletion src/fluid/showConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void Fluid<Phys>::ShowConfig() {
<< ": Ohmic resistivity ENABLED with user-defined resistivity function."
<< std::endl;
if(!ohmicDiffusivityFunc) {
IDEFIX_ERROR("No user-defined Ihmic resistivity function has been enrolled.");
IDEFIX_ERROR("No user-defined Ohmic resistivity function has been enrolled.");
}
} else {
IDEFIX_ERROR("Unknown Ohmic resistivity mode");
Expand Down
2 changes: 1 addition & 1 deletion src/output/xdmf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ int Xdmf::Write() {
#if DIMENSIONS == 1
[[maybe_unused]] int tot_dim = 1;
#elif DIMENSIONS == 2
int tot_dim = 2;
[[maybe_unused]] int tot_dim = 2;
#elif DIMENSIONS == 3
[[maybe_unused]] int tot_dim = 3;
#endif
Expand Down