From 00995444997665d25803b2c957b58ffabdaba1b0 Mon Sep 17 00:00:00 2001
From: Chuck Atkins <chuck.atkins@kitware.com>
Date: Mon, 17 Apr 2017 11:07:07 -0400
Subject: [PATCH] Allow HDF5 to be build in serial or parallel mode

---
 source/ADIOS.cpp                   | 6 ++----
 source/CMakeLists.txt              | 6 ++++--
 source/engine/hdf5/HDF5WriterP.cpp | 5 ++++-
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/source/ADIOS.cpp b/source/ADIOS.cpp
index 30aac797c..ac6eb5626 100644
--- a/source/ADIOS.cpp
+++ b/source/ADIOS.cpp
@@ -36,12 +36,10 @@
 #include "engine/adios1/ADIOS1Writer.h"
 #endif
 
-#ifdef ADIOS_HAVE_PHDF5 // external dependencies
-#ifdef ADIOS_HAVE_MPI
+#ifdef ADIOS_HAVE_HDF5 // external dependencies
 #include "engine/hdf5/HDF5ReaderP.h"
 #include "engine/hdf5/HDF5WriterP.h"
 #endif
-#endif
 namespace adios
 {
 
@@ -194,7 +192,7 @@ std::shared_ptr<Engine> ADIOS::Open(const std::string &name,
     }
     else if (type == "HDF5Writer") // -junmin
     {
-#if defined(ADIOS_HAVE_PHDF5) && defined(ADIOS_HAVE_MPI)
+#ifdef ADIOS_HAVE_HDF5
         return std::make_shared<HDF5Writer>(*this, name, accessMode, mpiComm,
                                             method);
 #else
diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index fb4e97252..c3ec1b7e1 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -90,8 +90,10 @@ endif()
 
 if(ADIOS_USE_HDF5)
   find_package(HDF5 REQUIRED)
-  if(ADIOS_USE_MPI AND NOT HDF5_IS_PARALLEL)
-    message(FATAL_ERROR "A sequential version of HDF5 was detected but the parallel version of ADIOS requires a parallel HDF5.")
+  if(ADIOS_USE_MPI AND (NOT HDF5_IS_PARALLEL))
+    message(FATAL_ERROR "A sequential version of HDF5 was detected but the parallel version of ADIOS is being built, which requires a parallel HDF5.")
+  elseif((NOT ADIOS_USE_MPI) AND HDF5_IS_PARALLEL)
+    message(FATAL_ERROR "A parallel version of HDF5 was detected but the sequential version of ADIOS is being built, which requires a sequential HDF5.")
   endif()
 
   target_include_directories(adios2 PRIVATE ${HDF5_INCLUDE_DIRS})
diff --git a/source/engine/hdf5/HDF5WriterP.cpp b/source/engine/hdf5/HDF5WriterP.cpp
index 05656e2ba..b75a447b4 100644
--- a/source/engine/hdf5/HDF5WriterP.cpp
+++ b/source/engine/hdf5/HDF5WriterP.cpp
@@ -78,7 +78,9 @@ void HDF5Writer::Init()
 
     _plist_id = H5Pcreate(H5P_FILE_ACCESS);
 
+#ifdef ADIOS_HAVE_MPI
     H5Pset_fapl_mpio(_plist_id, m_MPIComm, MPI_INFO_NULL);
+#endif
 
     /*
      * Create a new file collectively and release property list identifier.
@@ -340,8 +342,9 @@ void HDF5Writer::UseHDFWrite(Variable<T> &variable, const T *values,
     //  Create property list for collective dataset write.
 
     _plist_id = H5Pcreate(H5P_DATASET_XFER);
+#ifdef ADIOS_HAVE_MPI
     H5Pset_dxpl_mpio(_plist_id, H5FD_MPIO_COLLECTIVE);
-
+#endif
     herr_t status;
 
     status =
-- 
GitLab