Skip to content

Commit

Permalink
Merge pull request #980 from guj/1101
Browse files Browse the repository at this point in the history
Stream read is now consist with BP3.
  • Loading branch information
guj committed Nov 14, 2018
2 parents b441a32 + 9cd6b86 commit 7a33e0c
Show file tree
Hide file tree
Showing 7 changed files with 283 additions and 112 deletions.
4 changes: 4 additions & 0 deletions examples/hello/hdf5Writer/helloHDF5Writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ int main(int argc, char *argv[])
/** Application variable */
std::vector<float> myFloats = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
std::vector<int> myInts = {0, -1, -2, -3, -4, -5, -6, -7, -8, -9};
double myScalar = 1.234;
const std::size_t Nx = myFloats.size();

try
Expand All @@ -47,13 +48,16 @@ int main(int argc, char *argv[])
adios2::Variable<int> h5Ints = hdf5IO.DefineVariable<int>(
"h5Ints", {size * Nx}, {rank * Nx}, {Nx}, adios2::ConstantDims);

adios2::Variable<double> h5ScalarDouble =
hdf5IO.DefineVariable<double>("h5ScalarDouble");
/** Engine derived class, spawned to start IO operations */
adios2::Engine hdf5Writer =
hdf5IO.Open("myVector.h5", adios2::Mode::Write);

/** Write variable for buffering */
hdf5Writer.Put<float>(h5Floats, myFloats.data());
hdf5Writer.Put(h5Ints, myInts.data());
hdf5Writer.Put(h5ScalarDouble, &myScalar);

std::vector<int64_t> m_globalDims = {10, 20, 30, 40};
hdf5IO.DefineAttribute<std::string>(
Expand Down
8 changes: 5 additions & 3 deletions source/adios2/engine/hdf5/HDF5ReaderP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,12 @@ void HDF5ReaderP::Init()
m_H5File.ReadAttrToIO(m_IO);
if (!m_InStreamMode)
{
// m_H5File.ReadVariables(0, m_IO);
m_H5File.ReadAllVariables(m_IO);
}
else
{
// m_H5File.ReadVariables(0, m_IO);
m_H5File.ReadAllVariables(m_IO);
}
}
Expand Down Expand Up @@ -260,12 +262,12 @@ StepStatus HDF5ReaderP::BeginStep(StepMode mode, const float timeoutSeconds)

if (m_StreamAt >= ts)
{
m_IO.m_ReadStreaming = false;
return StepStatus::EndOfStream;
}

m_IO.RemoveAllVariables();
m_IO.RemoveAllAttributes();
m_H5File.ReadVariables(m_StreamAt, m_IO);
m_IO.m_ReadStreaming = true;
m_IO.m_EngineStep = m_StreamAt;

return StepStatus::OK;
}
Expand Down
2 changes: 2 additions & 0 deletions source/adios2/engine/hdf5/HDF5WriterP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ HDF5WriterP::HDF5WriterP(IO &io, const std::string &name, const Mode mode,
MPI_Comm mpiComm)
: Engine("HDF5Writer", io, name, mode, mpiComm), m_H5File(io.m_DebugMode)
{
m_IO.m_ReadStreaming = false;
m_EndMessage = ", in call to IO HDF5Writer Open " + m_Name + "\n";
Init();
}
Expand All @@ -32,6 +33,7 @@ HDF5WriterP::~HDF5WriterP() { DoClose(); }

StepStatus HDF5WriterP::BeginStep(StepMode mode, const float timeoutSeconds)
{
m_IO.m_ReadStreaming = false;
return StepStatus::OK;
}

Expand Down

0 comments on commit 7a33e0c

Please sign in to comment.