From 833ff6fbb4dcc548ede3209485eab49f059f5310 Mon Sep 17 00:00:00 2001 From: guj <jgu@lbl.gov> Date: Fri, 12 May 2017 14:07:50 -0700 Subject: [PATCH] new heatTransfer IO with adios2/hdf5 --- examples/heatTransfer/write/IO_ph5_adios2.cpp | 18 ++++++------- source/adios2/engine/hdf5/HDF5WriterP.cpp | 27 ++++++++++--------- source/adios2/engine/hdf5/HDF5WriterP.h | 2 +- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/examples/heatTransfer/write/IO_ph5_adios2.cpp b/examples/heatTransfer/write/IO_ph5_adios2.cpp index a4b37c5dc..abed29d13 100644 --- a/examples/heatTransfer/write/IO_ph5_adios2.cpp +++ b/examples/heatTransfer/write/IO_ph5_adios2.cpp @@ -24,7 +24,7 @@ IO::IO(const Settings &s, MPI_Comm comm) { rank_saved = s.rank; m_outputfilename = s.outputfile + ".h5"; - //adios::ADIOS adios(comm, adios::Verbose::INFO, false); + // adios::ADIOS adios(comm, adios::Verbose::INFO, false); ad = new adios::ADIOS(comm, adios::Verbose::INFO, false); // Define method for engine creation @@ -36,7 +36,7 @@ IO::IO(const Settings &s, MPI_Comm comm) // if not defined by user, we can change the default settings // BPFileWriter is the default engine h5writerSettings.SetEngine("HDF5Writer"); - // Allow an extra thread for data processing + // Allow an extra thread for data processing const std::string aggregatorsParam("Aggregators=" + std::to_string((s.nproc + 1) / 2)); @@ -56,7 +56,7 @@ IO::IO(const Settings &s, MPI_Comm comm) // starting offset of the local array in the global space {s.offsx, s.offsy}, // local size, could be defined later using SetSelection() - {s.ndx, s.ndy})); + {s.ndx, s.ndy})); // add transform to variable // adios::Transform tr = adios::transform::BZIP2( ); @@ -72,7 +72,7 @@ IO::IO(const Settings &s, MPI_Comm comm) IO::~IO() { h5writer->Close(); - //delete ad; + // delete ad; } void IO::write(int step, const HeatTransfer &ht, const Settings &s, @@ -86,8 +86,8 @@ void IO::write(int step, const HeatTransfer &ht, const Settings &s, // Make a selection to describe the local dimensions of the variable we // write and its offsets in the global spaces. This could have been done in // adios.DefineVariable() - //adios::SelectionBoundingBox sel({s.offsx, s.offsy}, {s.ndx, s.ndy}); - //varT->SetSelection(sel); + // adios::SelectionBoundingBox sel({s.offsx, s.offsy}, {s.ndx, s.ndy}); + // varT->SetSelection(sel); /* Select the area that we want to write from the data pointer we pass to the @@ -100,12 +100,12 @@ void IO::write(int step, const HeatTransfer &ht, const Settings &s, above. Default memspace is always the full selection. */ - //adios::SelectionBoundingBox memspace = + // adios::SelectionBoundingBox memspace = // adios::SelectionBoundingBox({1, 1}, {s.ndx, s.ndy}); - //varT->SetMemorySelection(memspace); + // varT->SetMemorySelection(memspace); h5writer->Write<double>(*varT, ht.data_noghost().data()); - //h5writer->Write(*varT, ht.data_noghost().data()); + // h5writer->Write(*varT, ht.data_noghost().data()); h5writer->Write<unsigned int>(*varGndx, s.gndx); h5writer->Write<unsigned int>("gndy", s.gndy); diff --git a/source/adios2/engine/hdf5/HDF5WriterP.cpp b/source/adios2/engine/hdf5/HDF5WriterP.cpp index 6969c4a40..acd523fec 100644 --- a/source/adios2/engine/hdf5/HDF5WriterP.cpp +++ b/source/adios2/engine/hdf5/HDF5WriterP.cpp @@ -23,7 +23,7 @@ HDF5Writer::HDF5Writer(ADIOS &adios, const std::string name, : Engine(adios, "HDF5Writer", name, accessMode, mpiComm, method, /*debugMode, cores,*/ " HDF5Writer constructor (or call to ADIOS Open).\n") - //m_Buffer(m_DebugMode) +// m_Buffer(m_DebugMode) { Init(); } @@ -256,17 +256,20 @@ void HDF5Writer::UseHDFWrite(Variable<T> &variable, const T *values, int dimSize = std::max(variable.m_Shape.size(), variable.m_Count.size()); - if (dimSize == 0) { - // scalar - hid_t filespaceID = H5Screate(H5S_SCALAR); - hid_t dsetID = H5Dcreate(m_H5File.m_GroupId, variable.m_Name.c_str(), h5Type, filespaceID, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - herr_t status = H5Dwrite(dsetID, h5Type, H5S_ALL, H5S_ALL, H5P_DEFAULT, values); - - H5Sclose (filespaceID); - H5Dclose (dsetID); - - return; + if (dimSize == 0) + { + // scalar + hid_t filespaceID = H5Screate(H5S_SCALAR); + hid_t dsetID = + H5Dcreate(m_H5File.m_GroupId, variable.m_Name.c_str(), h5Type, + filespaceID, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + herr_t status = + H5Dwrite(dsetID, h5Type, H5S_ALL, H5S_ALL, H5P_DEFAULT, values); + + H5Sclose(filespaceID); + H5Dclose(dsetID); + + return; } std::vector<hsize_t> dimsf, count, offset; diff --git a/source/adios2/engine/hdf5/HDF5WriterP.h b/source/adios2/engine/hdf5/HDF5WriterP.h index d4c4d217e..3ab1b970e 100644 --- a/source/adios2/engine/hdf5/HDF5WriterP.h +++ b/source/adios2/engine/hdf5/HDF5WriterP.h @@ -91,7 +91,7 @@ public: private: ///< heap capsule, contains data and metadata buffers - //capsule::STLVector m_Buffer; + // capsule::STLVector m_Buffer; void Init(); -- GitLab