diff --git a/examples/hello/hdf5Writer/helloHDF5Writer.cpp b/examples/hello/hdf5Writer/helloHDF5Writer.cpp index 65e8fe86d9db032f70b289aa068d44c945c360e8..39e9c0759fdf465bb3fd412afbc99f8ff19571e4 100644 --- a/examples/hello/hdf5Writer/helloHDF5Writer.cpp +++ b/examples/hello/hdf5Writer/helloHDF5Writer.cpp @@ -68,8 +68,11 @@ int main(int argc, char *argv[]) intCountDim1 = intDim1 - rank * (intDim1 / size); } - std::cout<<" rank="<<rank<<" of "<<size<<", dim1 count: "<<intCountDim1<<", offset: "<<intOffsetDim1<<std::endl; - std::cout<<" intOffsetDim2="<<intOffsetDim2<<" "<<intDim2<<std::endl; + std::cout << " rank=" << rank << " of " << size + << ", dim1 count: " << intCountDim1 + << ", offset: " << intOffsetDim1 << std::endl; + std::cout << " intOffsetDim2=" << intOffsetDim2 << " " << intDim2 + << std::endl; try { // Define variable and local size @@ -103,66 +106,72 @@ int main(int argc, char *argv[]) throw std::ios_base::failure( "ERROR: failed to create HDF5 I/O engine at Open\n"); - int ts = 0; - int totalts = 3; - while (true) { - if (rank == 0) { - std::cout<<" total timesteps: "<<totalts<<" curr: "<<ts<<" th"<<std::endl; - } - HDF5Writer->Write(ioMyDoubles, myDoubles.data() + - doubleVOffset); // Base class Engine - // own the Write<T> - // that will call - // overloaded Write - // from Derived - HDF5Writer->Write(ioMyInts, - myInts.data() + (intOffsetDim1 * intDim2 )); - - HDF5Writer->Write(ioMyCFloats, myCFloats.data() + complexOffset); - HDF5Writer->Write(ioMyCDoubles, myCDoubles.data() + complexOffset); - HDF5Writer->Write(ioMyCLongDoubles, - myCLongDoubles.data() + complexOffset); - ts++; - if (ts >= totalts) { - break; - } - HDF5Writer->Advance(); - } - HDF5Writer->Close(); - - // now read out: - /* - HDF5Settings.SetEngine("HDF5Reader"); - std::cout<<"... Testing a copy of test.h5, [test1.h5] , b/c engine does not decrease name count !! "<<std::endl; - auto HDF5Reader = adios.Open("test1.h5", "r", HDF5Settings); - - //int findts = HDF5Reader->getNumTimeSteps(); - //HDF5Reader->InquireVariableDouble("wrongMyDoubles", true); - HDF5Reader->InquireVariableDouble(ioMyDoubles.m_Name, true); - */ - -#ifndef NEVER - adios::HDF5Common myReader; - myReader.H5_Init("test.h5", MPI_COMM_WORLD, false); - double values[15]; - ts = 0; - - while (ts < totalts) { - //myReader.ReadMe(ioMyDoubles, values, H5T_NATIVE_DOUBLE); - myReader.H5_Advance(totalts); - ts++; - } + int ts = 0; + int totalts = 3; + while (true) + { + if (rank == 0) + { + std::cout << " total timesteps: " << totalts << " curr: " << ts + << " th" << std::endl; + } + HDF5Writer->Write(ioMyDoubles, + myDoubles.data() + + doubleVOffset); // Base class Engine + // own the Write<T> + // that will call + // overloaded Write + // from Derived + HDF5Writer->Write(ioMyInts, + myInts.data() + (intOffsetDim1 * intDim2)); + + HDF5Writer->Write(ioMyCFloats, myCFloats.data() + complexOffset); + HDF5Writer->Write(ioMyCDoubles, myCDoubles.data() + complexOffset); + HDF5Writer->Write(ioMyCLongDoubles, + myCLongDoubles.data() + complexOffset); + ts++; + if (ts >= totalts) + { + break; + } + HDF5Writer->Advance(); + } + HDF5Writer->Close(); + +// now read out: +/* +HDF5Settings.SetEngine("HDF5Reader"); +std::cout<<"... Testing a copy of test.h5, [test1.h5] , b/c engine does not +decrease name count !! "<<std::endl; +auto HDF5Reader = adios.Open("test1.h5", "r", HDF5Settings); + +//int findts = HDF5Reader->getNumTimeSteps(); +//HDF5Reader->InquireVariableDouble("wrongMyDoubles", true); +HDF5Reader->InquireVariableDouble(ioMyDoubles.m_Name, true); +*/ + +#ifndef NEVER + adios::HDF5Common myReader; + myReader.H5_Init("test.h5", MPI_COMM_WORLD, false); + double values[15]; + ts = 0; + + while (ts < totalts) + { + // myReader.ReadMe(ioMyDoubles, values, H5T_NATIVE_DOUBLE); + myReader.H5_Advance(totalts); + ts++; + } #else - /* - adios::HDF5Reader myReader(adios, "test.h5", "r", MPI_COMM_WORLD, HDF5Settings); - double values[15]; +/* +adios::HDF5Reader myReader(adios, "test.h5", "r", MPI_COMM_WORLD, HDF5Settings); +double values[15]; - myReader.ReadMe(ioMyDoubles, values, H5T_NATIVE_DOUBLE); - myReader.Close(); - */ +myReader.ReadMe(ioMyDoubles, values, H5T_NATIVE_DOUBLE); +myReader.Close(); +*/ #endif - } catch (std::invalid_argument &e) { diff --git a/source/adios2/engine/hdf5/HDF5Common.cpp b/source/adios2/engine/hdf5/HDF5Common.cpp index d931686294386adfe9231a5dac0f0ad63820d14e..b78f421de6468ccb705fe9f8cb11c21736252375 100644 --- a/source/adios2/engine/hdf5/HDF5Common.cpp +++ b/source/adios2/engine/hdf5/HDF5Common.cpp @@ -198,13 +198,10 @@ void HDF5Common::CheckWriteGroup() H5P_DEFAULT); } - - template <class T> void HDF5Common::ReadMe(Variable<T> &variable, T *data_array, hid_t h5type) { - hid_t datasetID = - H5Dopen(m_Group_id, variable.m_Name.c_str(), H5P_DEFAULT); + hid_t datasetID = H5Dopen(m_Group_id, variable.m_Name.c_str(), H5P_DEFAULT); #ifdef NEVER if (_mpi_rank == 0) diff --git a/source/adios2/engine/hdf5/HDF5Common.h b/source/adios2/engine/hdf5/HDF5Common.h index 876c76fe2e22e92d9e0fdf4c3fef84bd0c41eb05..bee0b456cc662a00e0509eefce18205a25d9eba4 100644 --- a/source/adios2/engine/hdf5/HDF5Common.h +++ b/source/adios2/engine/hdf5/HDF5Common.h @@ -39,9 +39,9 @@ public: void WriteTimeSteps(); template <class T> - void ReadMe(Variable<T> &variable, T *data_array, hid_t h5type); - - //void ReadFromHDF5(const char* name, void* data_array); + void ReadMe(Variable<T> &variable, T *data_array, hid_t h5type); + + // void ReadFromHDF5(const char* name, void* data_array); hid_t m_Plist_id, m_File_id; hid_t m_Group_id; @@ -55,7 +55,7 @@ public: void CheckWriteGroup(); private: - //void H5_AdvanceWrite(); + // void H5_AdvanceWrite(); bool m_WriteMode; int m_Total_timestep; }; diff --git a/source/adios2/engine/hdf5/HDF5ReaderP.cpp b/source/adios2/engine/hdf5/HDF5ReaderP.cpp index 8e7a01952a4869bc0eee2ce005e93e5374d417e1..ee97670ae52a9066c7f74d8d5eaadda3f17b26fe 100644 --- a/source/adios2/engine/hdf5/HDF5ReaderP.cpp +++ b/source/adios2/engine/hdf5/HDF5ReaderP.cpp @@ -236,7 +236,6 @@ HDF5Reader::InquireVariableCompound(const std::string &variableName, return NULL; } - template <class T> void HDF5Reader::UseHDFRead(const std::string &variableName, T *values, hid_t h5type) diff --git a/testing/adios2/engine/hdf5/TestHDF5WriteRead.cpp b/testing/adios2/engine/hdf5/TestHDF5WriteRead.cpp index b3e4f51a7db0d25c2b41a7143b92f662a830f79d..5c50f805c8fce0da9a990d16eb42943d4d42503d 100644 --- a/testing/adios2/engine/hdf5/TestHDF5WriteRead.cpp +++ b/testing/adios2/engine/hdf5/TestHDF5WriteRead.cpp @@ -9,7 +9,6 @@ #include <stdexcept> #include <adios2.h> -#include "adios2/engine/hdf5/HDF5ReaderP.h" #include <hdf5.h> #include <gtest/gtest.h>