From e227979a0867fc81200f75bfe21e8fa58c196a19 Mon Sep 17 00:00:00 2001 From: Junmin Gu Date: Wed, 16 Sep 2020 20:59:15 -0700 Subject: [PATCH 1/2] check whether file is a hdf5 file before read --- source/adios2/engine/hdf5/HDF5ReaderP.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/adios2/engine/hdf5/HDF5ReaderP.cpp b/source/adios2/engine/hdf5/HDF5ReaderP.cpp index 65f796d1f6..ee44f0ae98 100644 --- a/source/adios2/engine/hdf5/HDF5ReaderP.cpp +++ b/source/adios2/engine/hdf5/HDF5ReaderP.cpp @@ -12,7 +12,7 @@ #include "HDF5ReaderP.tcc" #include "adios2/helper/adiosFunctions.h" //CSVToVector - +#include "adios2/helper/adiosFunctions.h" //IsHDF5 #include namespace adios2 @@ -27,6 +27,10 @@ HDF5ReaderP::HDF5ReaderP(IO &io, const std::string &name, const Mode openMode, : Engine("HDF5Reader", io, name, openMode, std::move(comm)) { m_EndMessage = ", in call to IO HDF5Reader Open " + m_Name + "\n"; + if (!helper::IsHDF5File(name, m_Comm, {})) + throw std::invalid_argument("!ADIOS2 Error: Invalid HDF5 file found" + + m_EndMessage); + Init(); } From 5ce226f2468a74e16b3155bac9546355e98bdf67 Mon Sep 17 00:00:00 2001 From: Junmin Gu Date: Wed, 16 Sep 2020 21:03:17 -0700 Subject: [PATCH 2/2] do not enforce .h5 as file extension --- source/adios2/engine/hdf5/HDF5WriterP.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/source/adios2/engine/hdf5/HDF5WriterP.cpp b/source/adios2/engine/hdf5/HDF5WriterP.cpp index f7cc30495c..c503edc75d 100644 --- a/source/adios2/engine/hdf5/HDF5WriterP.cpp +++ b/source/adios2/engine/hdf5/HDF5WriterP.cpp @@ -60,9 +60,18 @@ void HDF5WriterP::Init() ", in call to ADIOS Open or HDF5Writer constructor\n"); } -#ifdef NEVER - m_H5File.Init(m_Name, m_Comm, true); -#else + m_H5File.ParseParameters(m_IO); + + if (m_OpenMode == Mode::Append) + { + m_H5File.Append(m_Name, m_Comm); + m_H5File.ReadAttrToIO(m_IO); + m_H5File.ReadAllVariables(m_IO); + } + else + m_H5File.Init(m_Name, m_Comm, true); + + /* // enforce .h5 ending std::string suffix = ".h5"; std::string wrongSuffix = ".bp"; @@ -93,7 +102,7 @@ void HDF5WriterP::Init() m_H5File.ReadAttrToIO(m_IO); m_H5File.ReadAllVariables(m_IO); } -#endif + */ } #define declare_type(T) \