Skip to content

Make hdf5 printers and build system more robust to hdf5 version differences#583

Open
anderkve wants to merge 2 commits intomasterfrom
hdf5_stability_improvements
Open

Make hdf5 printers and build system more robust to hdf5 version differences#583
anderkve wants to merge 2 commits intomasterfrom
hdf5_stability_improvements

Conversation

@anderkve
Copy link
Copy Markdown
Collaborator

This PR adds some modifications to Printers/ and to our CMake system, to make the GAMBIT build more robust to issues related to the API changes between different versions of the HDF5 library.

Note that we should probably wait for PR #582 to be merged first and pull that small change into this PR before merging this one.

Summary of changes:

Changes to CMake system (cmake/optional.cmake):

  • Set HDF5_PREFER_PARALLEL FALSE before find_package so a parallel HDF5 install can't be silently preferred. GAMBIT's printers are serial. (MPI coordination is done on the GAMBIT side, not by the parallell HDF5 library.)
  • Switched include_directories(...) to include_directories(SYSTEM ...).
  • Dropped the global -DH5_USE_110_API. (When not scoped, this would affect all our build targets, not just the GAMBIT code in Printers.)
  • Added a check_c_source_compiles test (GAMBIT_HDF5_USABLE) that compiles + links a small program against the discovered HDF5; if it fails, the printers get ditched with a clear
    hint to use -DHDF5_ROOT=.... This should ensure that we catch the cases where different hdf5 libraries are mixed early in the configure process, rather that giving some cryptic compile/link error deep into the GAMBIT build.
  • Added a -DHDF5_ROOT=... hint to the not-found message.

Changes to Printers/ (so we no longer need -DH5_USE_110_API):

  • Printers/include/gambit/Printers/printers/hdf5printer/hdf5tools.hpp: added a small set of macros that maps GAMBIT_H5L_INFO_T, GAMBIT_H5O_INFO_T, GAMBIT_H5OGET_INFO_BY_NAME(...)
    and GAMBIT_H5LITERATE to the version-specific symbols (H5Literate2/H5Oget_info_by_name3/H5O_info2_t/H5L_info2_t on 1.12+, the unversioned forms on 1.10).
  • Printers/src/printers/hdf5printer/hdf5tools.cpp: group_ls no longer uses the deprecated H5Gget_objinfo/H5G_stat_t (now uses GAMBIT_H5OGET_INFO_BY_NAME + H5O_TYPE_DATASET);
    lsGroup uses GAMBIT_H5LITERATE; isDataSet uses the macros.
  • Printers/src/printers/hdf5printer/hdf5_combine_tools.cpp: op_func/op_func_aux updated to use the macros

@anderkve anderkve requested a review from carlmfe April 28, 2026 13:29
@anderkve anderkve added Core Core group task build Printers labels Apr 28, 2026
@anderkve
Copy link
Copy Markdown
Collaborator Author

This is a follow-up to what we discussed in the Core meeting today, @pstoecker, @ChrisJChang and @carlmfe. I added @carlmfe as reviewer, but if anyone else gets to it first, feel free to grab it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant