Skip to content

Commit

Permalink
Add basic C++ HighFive HDF infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl authored and speth committed Jan 12, 2023
1 parent 957dd24 commit a5327f3
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
7 changes: 7 additions & 0 deletions SConstruct
Expand Up @@ -1497,6 +1497,9 @@ else: # env['system_sundials'] == 'n'
env['sundials_version'] = '5.3'
env['has_sundials_lapack'] = int(env['use_lapack'])

env["has_highfive"] = conf.CheckLibWithHeader(
"hdf5", "highfive/H5File.hpp", language="C++", autoadd=False)

def set_fortran(pattern, value):
# Set compiler / flags for all Fortran versions to be the same
for version in ("FORTRAN", "F77", "F90", "F95", "F03", "F08"):
Expand Down Expand Up @@ -2029,6 +2032,7 @@ cdefine('CT_USE_SYSTEM_FMT', 'system_fmt')
cdefine('CT_USE_SYSTEM_YAMLCPP', 'system_yamlcpp')
cdefine('CT_USE_DEMANGLE', 'has_demangle')
cdefine('CT_HAS_PYTHON', 'python_package', 'full')
cdefine("CT_USE_HIGHFIVE_HDF", "has_highfive")

config_h_build = env.Command('build/src/config.h.build',
'include/cantera/base/config.h.in',
Expand Down Expand Up @@ -2112,6 +2116,9 @@ else:
env["external_libs"] = []
env["external_libs"].extend(env["sundials_libs"])

if env["has_highfive"]:
env["external_libs"].append("hdf5")

if env["system_fmt"]:
env["external_libs"].append("fmt")

Expand Down
7 changes: 5 additions & 2 deletions include/cantera/base/config.h.in
Expand Up @@ -62,8 +62,11 @@ typedef int ftnlen; // Fortran hidden string length type

//-------------- Optional Cantera Capabilities ----------------------

// Enable Sundials to use an external BLAS/LAPACK library if it was
// built to use this option
// Enable Sundials to use an external BLAS/LAPACK library if it was
// built to use this option
{CT_SUNDIALS_USE_LAPACK!s}

// Enable export/import of HDF data via C++ HighFive
{CT_USE_HIGHFIVE_HDF!s}

#endif
3 changes: 3 additions & 0 deletions include/cantera/base/global.h
Expand Up @@ -105,6 +105,9 @@ std::string gitCommit();
//! preprocessor macro is defined.
bool debugModeEnabled();

//! Returns true if Cantera was compiled with C++ HighFive HDF support.
bool usesHighFive();

/*!
* @defgroup logs Diagnostic Output
*
Expand Down
9 changes: 9 additions & 0 deletions src/base/global.cpp
Expand Up @@ -170,6 +170,15 @@ bool debugModeEnabled()
#endif
}

bool usesHighFive()
{
#if CT_USE_HIGHFIVE_HDF
return true;
#else
return false;
#endif
}

std::vector<FactoryBase*> FactoryBase::s_vFactoryRegistry;

std::string demangle(const std::type_info& type)
Expand Down
8 changes: 8 additions & 0 deletions src/oneD/Sim1D.cpp
Expand Up @@ -159,6 +159,14 @@ void Sim1D::restore(const std::string& fname, const std::string& id,
if (extension == "xml") {
throw CanteraError("Sim1D::restore",
"Restoring from XML is no longer supported.");
} else if (extension == "h5" || extension == "hdf") {
#if CT_USE_HIGHFIVE_HDF
throw CanteraError("Sim1D::restore",
"Not yet implemented.");
#else
throw CanteraError("Sim1D::restore",
"Restoring from HDF requires HighFive installation.");
#endif
}
AnyMap root = AnyMap::fromYamlFile(fname);
if (!root.hasKey(id)) {
Expand Down

0 comments on commit a5327f3

Please sign in to comment.