From 43ef310d3b23bb3c9b32a25e2f1b83c245644a6c Mon Sep 17 00:00:00 2001 From: Norbert Podhorszki <pnorbert@ornl.gov> Date: Mon, 8 May 2017 18:07:41 -0400 Subject: [PATCH] Fix hello examples with new DefineVariable() syntax, for BP, timeBP and ADIOS1. Missing HDF5 and DataMan --- .../hello/adios1Writer/helloADIOS1Writer.cpp | 16 ++++++++-------- .../adios1Writer/helloADIOS1Writer_nompi.cpp | 8 +++++++- examples/hello/bpWriter/helloBPWriter.cpp | 16 ++++++++-------- examples/hello/bpWriter/helloBPWriter_nompi.cpp | 6 ++++++ examples/hello/timeBP/timeBPWriter.cpp | 17 +++++++++-------- examples/hello/timeBP/timeBPWriter_nompi.cpp | 8 ++++---- 6 files changed, 42 insertions(+), 29 deletions(-) diff --git a/examples/hello/adios1Writer/helloADIOS1Writer.cpp b/examples/hello/adios1Writer/helloADIOS1Writer.cpp index 068a7b151..7403775df 100644 --- a/examples/hello/adios1Writer/helloADIOS1Writer.cpp +++ b/examples/hello/adios1Writer/helloADIOS1Writer.cpp @@ -52,13 +52,13 @@ int main(int argc, char *argv[]) { // Define variable and local size adios::Variable<double> &ioMyDoubles = adios.DefineVariable<double>( - "myDoubles", {1, Nx}, {nproc, Nx}, {rank, 0}); - adios::Variable<float> &ioMyMatrix = adios.DefineVariable<float>( - "myMatrix", {rows, columns}, {nproc * rows, columns}, - {rank * rows, 0}); - adios::Variable<float> &ioMyMatrix2 = adios.DefineVariable<float>( - "myMatrix2", {rows, columns}, {rows, nproc * columns}, - {0, rank * columns}); + "myDoubles", {nproc, Nx}, {rank, 0}, {1, Nx}); + adios::Variable<float> &ioMyMatrix = + adios.DefineVariable<float>("myMatrix", {nproc * rows, columns}, + {rank * rows, 0}, {rows, columns}); + adios::Variable<float> &ioMyMatrix2 = + adios.DefineVariable<float>("myMatrix2", {rows, nproc * columns}, + {0, rank * columns}, {rows, columns}); // Define method for engine creation, it is basically straight-forward // parameters @@ -73,7 +73,7 @@ int main(int argc, char *argv[]) // Create engine smart pointer due to polymorphism, // Open returns a smart pointer to Engine containing the Derived class // Writer - auto bpWriter = adios.Open("myDoubles.bp", "w", bpWriterSettings); + auto bpWriter = adios.Open("hello_adios1.bp", "w", bpWriterSettings); if (bpWriter == nullptr) throw std::ios_base::failure( diff --git a/examples/hello/adios1Writer/helloADIOS1Writer_nompi.cpp b/examples/hello/adios1Writer/helloADIOS1Writer_nompi.cpp index f5d1f9b72..89487cf28 100644 --- a/examples/hello/adios1Writer/helloADIOS1Writer_nompi.cpp +++ b/examples/hello/adios1Writer/helloADIOS1Writer_nompi.cpp @@ -52,12 +52,18 @@ int main(int argc, char *argv[]) // Open returns a smart pointer to Engine containing the Derived class // Writer auto bpFileWriter = - adios.Open("myDoubles_nompi.bp", "w", bpWriterSettings); + adios.Open("hello_adios1_nompi.bp", "w", bpWriterSettings); if (bpFileWriter == nullptr) throw std::ios_base::failure( "ERROR: couldn't create bpWriter at Open\n"); + ioMyDoubles.SetSelection({0}, {Nx}); + adios::SelectionBoundingBox box({0, 0}, {rows, columns}); + ioMyMatrix.SetSelection(box); + ioMyMatrix2.SetSelection(box); + ioMyMatrix3.SetSelection(box); + bpFileWriter->Write<double>( ioMyDoubles, myDoubles.data()); // Base class Engine own the Write<T> diff --git a/examples/hello/bpWriter/helloBPWriter.cpp b/examples/hello/bpWriter/helloBPWriter.cpp index bd0b62e1d..0de89cdd9 100644 --- a/examples/hello/bpWriter/helloBPWriter.cpp +++ b/examples/hello/bpWriter/helloBPWriter.cpp @@ -18,9 +18,9 @@ int main(int argc, char *argv[]) { MPI_Init(&argc, &argv); - int rank, size; + int rank, nproc; MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); + MPI_Comm_size(MPI_COMM_WORLD, &nproc); const bool adiosDebug = true; adios::ADIOS adios(MPI_COMM_WORLD, adios::Verbose::INFO, adiosDebug); @@ -49,14 +49,14 @@ int main(int argc, char *argv[]) try { // Define variable and local size - adios::Variable<double> &ioMyDoubles = - adios.DefineLocalArray<double>("myDoubles", true, {Nx}); - + adios::Variable<double> &ioMyDoubles = adios.DefineVariable<double>( + "myDoubles", {nproc, Nx}, {rank, 0}, {1, Nx}); adios::Variable<float> &ioMyMatrix = - adios.DefineLocalArray<float>("myMatrix", true, {rows, columns}); - + adios.DefineVariable<float>("myMatrix", {nproc * rows, columns}, + {rank * rows, 0}, {rows, columns}); adios::Variable<float> &ioMyMatrix2 = - adios.DefineLocalArray<float>("myMatrix2", false, {rows, columns}); + adios.DefineVariable<float>("myMatrix2", {rows, nproc * columns}, + {0, rank * columns}, {rows, columns}); // Define method for engine creation, it is basically straight-forward // parameters diff --git a/examples/hello/bpWriter/helloBPWriter_nompi.cpp b/examples/hello/bpWriter/helloBPWriter_nompi.cpp index 51f36d8ae..9acc0b5a2 100644 --- a/examples/hello/bpWriter/helloBPWriter_nompi.cpp +++ b/examples/hello/bpWriter/helloBPWriter_nompi.cpp @@ -62,6 +62,12 @@ int main(int /*argc*/, char ** /*argv*/) "ERROR: couldn't create bpWriter at Open\n"); } + ioMyDoubles.SetSelection({0}, {Nx}); + adios::SelectionBoundingBox box({0, 0}, {rows, columns}); + ioMyMatrix.SetSelection(box); + ioMyMatrix2.SetSelection(box); + ioMyMatrix3.SetSelection(box); + bpFileWriter->Write<double>( ioMyDoubles, myDoubles.data()); // Base class Engine own the Write<T> diff --git a/examples/hello/timeBP/timeBPWriter.cpp b/examples/hello/timeBP/timeBPWriter.cpp index 23cbe7484..ea3e8e6f6 100644 --- a/examples/hello/timeBP/timeBPWriter.cpp +++ b/examples/hello/timeBP/timeBPWriter.cpp @@ -18,8 +18,9 @@ int main(int argc, char *argv[]) { MPI_Init(&argc, &argv); - int rank; + int rank, nproc; MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &nproc); const bool adiosDebug = true; adios::ADIOS adios(MPI_COMM_WORLD, adios::Verbose::ERROR, adiosDebug); @@ -47,14 +48,14 @@ int main(int argc, char *argv[]) try { // Define variable and local size - adios::Variable<double> &ioMyDoubles = - adios.DefineVariable<double>("myDoubles", {}, {}, {Nx}); - - adios::Variable<float> &ioMyMatrix = adios.DefineVariable<float>( - "myMatrix", {adios::JoinedDim, columns}, {}, {rows, columns}); - + adios::Variable<double> &ioMyDoubles = adios.DefineVariable<double>( + "myDoubles", {nproc, Nx}, {rank, 0}, {1, Nx}); + adios::Variable<float> &ioMyMatrix = + adios.DefineVariable<float>("myMatrix", {nproc * rows, columns}, + {rank * rows, 0}, {rows, columns}); adios::Variable<float> &ioMyMatrix2 = - adios.DefineVariable<float>("myMatrix2", {}, {}, {rows, columns}); + adios.DefineVariable<float>("myMatrix2", {rows, nproc * columns}, + {0, rank * columns}, {rows, columns}); // Define method for engine creation, it is basically straight-forward // parameters diff --git a/examples/hello/timeBP/timeBPWriter_nompi.cpp b/examples/hello/timeBP/timeBPWriter_nompi.cpp index 3b27b9bdb..69d3ec71c 100644 --- a/examples/hello/timeBP/timeBPWriter_nompi.cpp +++ b/examples/hello/timeBP/timeBPWriter_nompi.cpp @@ -40,11 +40,11 @@ int main(int /*argc*/, char ** /*argv*/) { // Define variable and local size adios::Variable<double> &ioMyDoubles = - adios.DefineVariable<double>("myDoubles", {}, {}, {Nx}); + adios.DefineVariable<double>("myDoubles", {Nx}, {0}, {Nx}); adios::Variable<float> &ioMyMatrix = adios.DefineVariable<float>( - "myMatrix", {adios::JoinedDim, columns}, {}, {rows, columns}); - adios::Variable<float> &ioMyMatrix2 = - adios.DefineVariable<float>("myMatrix2", {}, {}, {rows, columns}); + "myMatrix", {rows, columns}, {0, 0}, {rows, columns}); + adios::Variable<float> &ioMyMatrix2 = adios.DefineVariable<float>( + "myMatrix2", {rows, columns}, {0, 0}, {rows, columns}); // Define method for engine creation, it is basically straight-forward // parameters -- GitLab