diff --git a/src/IO/HDF5/HDF5IOHandler.cpp b/src/IO/HDF5/HDF5IOHandler.cpp index 516041a830..8671a0e92d 100644 --- a/src/IO/HDF5/HDF5IOHandler.cpp +++ b/src/IO/HDF5/HDF5IOHandler.cpp @@ -2938,9 +2938,13 @@ HDF5IOHandlerImpl::getFile(Writable *writable) return std::make_optional(std::move(res)); } +#define OPENPMD_HAVE_HDF5_INDEPENDENT_STORES openPMD_HAVE_MPI + std::future HDF5IOHandlerImpl::flush(internal::ParsedFlushParams ¶ms) { +#if OPENPMD_HAVE_HDF5_INDEPENDENT_STORES std::optional old_value; +#endif if (params.backendConfig.json().contains("hdf5")) { auto hdf5_config = params.backendConfig["hdf5"]; @@ -2948,6 +2952,7 @@ std::future HDF5IOHandlerImpl::flush(internal::ParsedFlushParams ¶ms) if (hdf5_config.json().contains("independent_stores")) { auto independent_stores_json = hdf5_config["independent_stores"]; +#if OPENPMD_HAVE_HDF5_INDEPENDENT_STORES if (!independent_stores_json.json().is_boolean()) { throw error::BackendConfigSchema( @@ -2970,6 +2975,12 @@ std::future HDF5IOHandlerImpl::flush(internal::ParsedFlushParams ¶ms) status >= 0, "[HDF5] Internal error: Failed to set the local data " "transfer mode before flushing."); +#else + std::cerr << "[Warning] HDF5 backend option " + "`hdf5.independent_stores` was specified, but " + "HDF5 has no MPI support. Will ignore." + << std::endl; +#endif } if (auto shadow = hdf5_config.invertShadow(); shadow.size() > 0) @@ -2993,6 +3004,7 @@ std::future HDF5IOHandlerImpl::flush(internal::ParsedFlushParams ¶ms) } auto res = AbstractIOHandlerImpl::flush(); +#if OPENPMD_HAVE_HDF5_INDEPENDENT_STORES if (old_value.has_value()) { herr_t status = H5Pset_dxpl_mpio(m_datasetTransferProperty, *old_value); @@ -3001,6 +3013,7 @@ std::future HDF5IOHandlerImpl::flush(internal::ParsedFlushParams ¶ms) "[HDF5] Internal error: Failed to reset the global data " "transfer mode after flushing."); } +#endif return res; } diff --git a/test/ParallelIOTest.cpp b/test/ParallelIOTest.cpp index 9d9b4f2f4c..4f1bf25adf 100644 --- a/test/ParallelIOTest.cpp +++ b/test/ParallelIOTest.cpp @@ -1152,7 +1152,7 @@ TEST_CASE("hipace_like_write", "[parallel]") } #endif -#if openPMD_HAVE_ADIOS2 && openPMD_HAS_ADIOS_2_9 +#if openPMD_HAVE_ADIOS2 && openPMD_HAS_ADIOS_2_9 && openPMD_HAVE_MPI TEST_CASE("independent_write_with_collective_flush", "[parallel]") { Series write(