From af90818ee123f4073ca5981e36f39152ea4d1d95 Mon Sep 17 00:00:00 2001
From: William F Godoy <wfg@pc0098504.ornl.gov>
Date: Tue, 11 Apr 2017 08:43:25 -0400
Subject: [PATCH] Fixed bugs in DataMan integration

Tested
---
 .../datamanReader/helloDataManReader.cpp      |  5 +-
 .../helloDataManReader_nompi.cpp              |  5 +-
 include/engine/dataman/DataManReader.h        | 38 ++++++-------
 include/engine/dataman/DataManWriter.h        | 15 ++---
 source/engine/dataman/DataManReader.cpp       | 55 ++++++++++---------
 source/engine/dataman/DataManWriter.cpp       |  7 ++-
 6 files changed, 65 insertions(+), 60 deletions(-)

diff --git a/examples/hello/datamanReader/helloDataManReader.cpp b/examples/hello/datamanReader/helloDataManReader.cpp
index 6c1c87897..b3c8aa0cb 100644
--- a/examples/hello/datamanReader/helloDataManReader.cpp
+++ b/examples/hello/datamanReader/helloDataManReader.cpp
@@ -46,7 +46,7 @@ int main(int argc, char *argv[])
         // Define method for engine creation, it is basically straight-forward
         // parameters
         adios::Method &datamanSettings = adios.DeclareMethod("WAN");
-        if (!datamanSettings.isUserDefined())
+        if (!datamanSettings.IsUserDefined())
         {
             // if not defined by user, we can change the default settings
             datamanSettings.SetEngine("DataManReader");
@@ -64,8 +64,7 @@ int main(int argc, char *argv[])
         // polymorphism,
         // Open returns a smart pointer to Engine containing the Derived class
         // DataManReader
-        auto datamanReader = adios.Open("myDoubles.bp", "r", datamanSettings,
-                                        adios::IOMode::INDEPENDENT);
+        auto datamanReader = adios.Open("myDoubles.bp", "r", datamanSettings);
 
         if (datamanReader == nullptr)
             throw std::ios_base::failure(
diff --git a/examples/hello/datamanReader/helloDataManReader_nompi.cpp b/examples/hello/datamanReader/helloDataManReader_nompi.cpp
index db7a717be..7e8c982bd 100644
--- a/examples/hello/datamanReader/helloDataManReader_nompi.cpp
+++ b/examples/hello/datamanReader/helloDataManReader_nompi.cpp
@@ -39,7 +39,7 @@ int main(int argc, char *argv[])
         // Define method for engine creation, it is basically straight-forward
         // parameters
         adios::Method &datamanSettings = adios.DeclareMethod("WAN");
-        if (!datamanSettings.isUserDefined())
+        if (!datamanSettings.IsUserDefined())
         {
             // if not defined by user, we can change the default settings
             datamanSettings.SetEngine("DataManReader");
@@ -59,8 +59,7 @@ int main(int argc, char *argv[])
         // polymorphism,
         // Open returns a smart pointer to Engine containing the Derived class
         // DataManReader
-        auto datamanReader = adios.Open("myDoubles.bp", "r", datamanSettings,
-                                        adios::IOMode::INDEPENDENT);
+        auto datamanReader = adios.Open("myDoubles.bp", "r", datamanSettings);
 
         if (datamanReader == nullptr)
             throw std::ios_base::failure(
diff --git a/include/engine/dataman/DataManReader.h b/include/engine/dataman/DataManReader.h
index 6ed82a598..f82e649bf 100644
--- a/include/engine/dataman/DataManReader.h
+++ b/include/engine/dataman/DataManReader.h
@@ -38,7 +38,7 @@ public:
      * @param debugMode
      * @param nthreads
      */
-    DataManReader(ADIOS &adios, const std::string name,
+    DataManReader(ADIOS &adios, const std::string &name,
                   const std::string accessMode, MPI_Comm mpiComm,
                   const Method &method);
 
@@ -53,40 +53,40 @@ public:
                                         std::string, Dims)>
                          callback);
 
-    Variable<void> *InquireVariable(const std::string name,
+    Variable<void> *InquireVariable(const std::string &name,
                                     const bool readIn = true);
-    Variable<char> *InquireVariableChar(const std::string name,
+    Variable<char> *InquireVariableChar(const std::string &name,
                                         const bool readIn = true);
-    Variable<unsigned char> *InquireVariableUChar(const std::string name,
+    Variable<unsigned char> *InquireVariableUChar(const std::string &name,
                                                   const bool readIn = true);
-    Variable<short> *InquireVariableShort(const std::string name,
+    Variable<short> *InquireVariableShort(const std::string &name,
                                           const bool readIn = true);
-    Variable<unsigned short> *InquireVariableUShort(const std::string name,
+    Variable<unsigned short> *InquireVariableUShort(const std::string &name,
                                                     const bool readIn = true);
-    Variable<int> *InquireVariableInt(const std::string name,
+    Variable<int> *InquireVariableInt(const std::string &name,
                                       const bool readIn = true);
-    Variable<unsigned int> *InquireVariableUInt(const std::string name,
+    Variable<unsigned int> *InquireVariableUInt(const std::string &name,
                                                 const bool readIn = true);
-    Variable<long int> *InquireVariableLInt(const std::string name,
+    Variable<long int> *InquireVariableLInt(const std::string &name,
                                             const bool readIn = true);
-    Variable<unsigned long int> *InquireVariableULInt(const std::string name,
+    Variable<unsigned long int> *InquireVariableULInt(const std::string &name,
                                                       const bool readIn = true);
-    Variable<long long int> *InquireVariableLLInt(const std::string name,
+    Variable<long long int> *InquireVariableLLInt(const std::string &name,
                                                   const bool readIn = true);
     Variable<unsigned long long int> *
-    InquireVariableULLInt(const std::string name, const bool readIn = true);
-    Variable<float> *InquireVariableFloat(const std::string name,
+    InquireVariableULLInt(const std::string &name, const bool readIn = true);
+    Variable<float> *InquireVariableFloat(const std::string &name,
                                           const bool readIn = true);
-    Variable<double> *InquireVariableDouble(const std::string name,
+    Variable<double> *InquireVariableDouble(const std::string &name,
                                             const bool readIn = true);
-    Variable<long double> *InquireVariableLDouble(const std::string name,
+    Variable<long double> *InquireVariableLDouble(const std::string &name,
                                                   const bool readIn = true);
     Variable<std::complex<float>> *
-    InquireVariableCFloat(const std::string name, const bool readIn = true);
+    InquireVariableCFloat(const std::string &name, const bool readIn = true);
     Variable<std::complex<double>> *
-    InquireVariableCDouble(const std::string name, const bool readIn = true);
+    InquireVariableCDouble(const std::string &name, const bool readIn = true);
     Variable<std::complex<long double>> *
-    InquireVariableCLDouble(const std::string name, const bool readIn = true);
+    InquireVariableCLDouble(const std::string &name, const bool readIn = true);
 
     /**
      * Not implemented
@@ -94,7 +94,7 @@ public:
      * @param readIn
      * @return
      */
-    VariableCompound *InquireVariableCompound(const std::string name,
+    VariableCompound *InquireVariableCompound(const std::string &name,
                                               const bool readIn = true);
 
     void Close(const int transportIndex = -1);
diff --git a/include/engine/dataman/DataManWriter.h b/include/engine/dataman/DataManWriter.h
index ec2392cf7..6116de429 100644
--- a/include/engine/dataman/DataManWriter.h
+++ b/include/engine/dataman/DataManWriter.h
@@ -142,13 +142,13 @@ private:
         jmsg["doid"] = m_Name;
         jmsg["var"] = variable.m_Name;
         jmsg["dtype"] = GetType<T>();
-        jmsg["putshape"] = variable.m_Dimensions;
+        jmsg["putshape"] = variable.m_LocalDimensions;
         if (variable.m_GlobalDimensions.size() == 0)
-            variable.m_GlobalDimensions = variable.m_Dimensions;
+            variable.m_GlobalDimensions = variable.m_LocalDimensions;
         jmsg["varshape"] = variable.m_GlobalDimensions;
-        if (variable.m_GlobalOffsets.size() == 0)
-            variable.m_GlobalOffsets.assign(variable.m_Dimensions.size(), 0);
-        jmsg["offset"] = variable.m_GlobalOffsets;
+        if (variable.m_Offsets.size() == 0)
+            variable.m_Offsets.assign(variable.m_LocalDimensions.size(), 0);
+        jmsg["offset"] = variable.m_Offsets;
         jmsg["timestep"] = 0;
         m_Man.put(values, jmsg);
 
@@ -156,10 +156,11 @@ private:
         {
             MPI_Barrier(m_MPIComm);
             std::cout << "I am hooked to the DataMan library\n";
-            std::cout << "putshape " << variable.m_Dimensions.size() << endl;
+            std::cout << "putshape " << variable.m_LocalDimensions.size()
+                      << endl;
             std::cout << "varshape " << variable.m_GlobalDimensions.size()
                       << endl;
-            std::cout << "offset " << variable.m_GlobalOffsets.size() << endl;
+            std::cout << "offset " << variable.m_Offsets.size() << endl;
             for (int i = 0; i < m_SizeMPI; ++i)
             {
                 if (i == m_RankMPI)
diff --git a/source/engine/dataman/DataManReader.cpp b/source/engine/dataman/DataManReader.cpp
index f90c446d8..4b383491c 100644
--- a/source/engine/dataman/DataManReader.cpp
+++ b/source/engine/dataman/DataManReader.cpp
@@ -11,6 +11,7 @@
 #include "engine/dataman/DataManReader.h"
 
 #include "core/Support.h"
+#include "external/json.hpp"
 #include "functions/adiosFunctions.h" //CSVToVector
 
 // supported transports
@@ -24,12 +25,12 @@
 namespace adios
 {
 
-DataManReader::DataManReader(ADIOS &adios, const std::string name,
+DataManReader::DataManReader(ADIOS &adios, const std::string &name,
                              const std::string accessMode, MPI_Comm mpiComm,
                              const Method &method)
 : Engine(adios, "DataManReader", name, accessMode, mpiComm, method,
-         " DataManReader constructor (or call to ADIOS Open).\n")
-// m_Buffer(accessMode, m_RankMPI, m_DebugMode)
+         " DataManReader constructor (or call to ADIOS Open).\n"),
+  m_Buffer(accessMode, m_RankMPI, m_DebugMode)
 {
     Init();
 }
@@ -46,111 +47,114 @@ void DataManReader::SetCallBack(
 }
 
 Variable<void> *
-DataManReader::InquireVariable(const std::string name,
+DataManReader::InquireVariable(const std::string &name,
                                const bool readIn) // not yet implemented
 {
     return nullptr;
 }
 
-Variable<char> *DataManReader::InquireVariableChar(const std::string name,
+Variable<char> *DataManReader::InquireVariableChar(const std::string &name,
                                                    const bool readIn)
 {
     return InquireVariableCommon<char>(name, readIn);
 }
 
 Variable<unsigned char> *
-DataManReader::InquireVariableUChar(const std::string name, const bool readIn)
+DataManReader::InquireVariableUChar(const std::string &name, const bool readIn)
 {
     return InquireVariableCommon<unsigned char>(name, readIn);
 }
 
-Variable<short> *DataManReader::InquireVariableShort(const std::string name,
+Variable<short> *DataManReader::InquireVariableShort(const std::string &name,
                                                      const bool readIn)
 {
     return InquireVariableCommon<short>(name, readIn);
 }
 
 Variable<unsigned short> *
-DataManReader::InquireVariableUShort(const std::string name, const bool readIn)
+DataManReader::InquireVariableUShort(const std::string &name, const bool readIn)
 {
     return InquireVariableCommon<unsigned short>(name, readIn);
 }
 
-Variable<int> *DataManReader::InquireVariableInt(const std::string name,
+Variable<int> *DataManReader::InquireVariableInt(const std::string &name,
                                                  const bool readIn)
 {
     return InquireVariableCommon<int>(name, readIn);
 }
 
 Variable<unsigned int> *
-DataManReader::InquireVariableUInt(const std::string name, const bool readIn)
+DataManReader::InquireVariableUInt(const std::string &name, const bool readIn)
 {
     return InquireVariableCommon<unsigned int>(name, readIn);
 }
 
-Variable<long int> *DataManReader::InquireVariableLInt(const std::string name,
+Variable<long int> *DataManReader::InquireVariableLInt(const std::string &name,
                                                        const bool readIn)
 {
     return InquireVariableCommon<long int>(name, readIn);
 }
 
 Variable<unsigned long int> *
-DataManReader::InquireVariableULInt(const std::string name, const bool readIn)
+DataManReader::InquireVariableULInt(const std::string &name, const bool readIn)
 {
     return InquireVariableCommon<unsigned long int>(name, readIn);
 }
 
 Variable<long long int> *
-DataManReader::InquireVariableLLInt(const std::string name, const bool readIn)
+DataManReader::InquireVariableLLInt(const std::string &name, const bool readIn)
 {
     return InquireVariableCommon<long long int>(name, readIn);
 }
 
 Variable<unsigned long long int> *
-DataManReader::InquireVariableULLInt(const std::string name, const bool readIn)
+DataManReader::InquireVariableULLInt(const std::string &name, const bool readIn)
 {
     return InquireVariableCommon<unsigned long long int>(name, readIn);
 }
 
-Variable<float> *DataManReader::InquireVariableFloat(const std::string name,
+Variable<float> *DataManReader::InquireVariableFloat(const std::string &name,
                                                      const bool readIn)
 {
     return InquireVariableCommon<float>(name, readIn);
 }
 
-Variable<double> *DataManReader::InquireVariableDouble(const std::string name,
+Variable<double> *DataManReader::InquireVariableDouble(const std::string &name,
                                                        const bool readIn)
 {
     return InquireVariableCommon<double>(name, readIn);
 }
 
 Variable<long double> *
-DataManReader::InquireVariableLDouble(const std::string name, const bool readIn)
+DataManReader::InquireVariableLDouble(const std::string &name,
+                                      const bool readIn)
 {
     return InquireVariableCommon<long double>(name, readIn);
 }
 
 Variable<std::complex<float>> *
-DataManReader::InquireVariableCFloat(const std::string name, const bool readIn)
+DataManReader::InquireVariableCFloat(const std::string &name, const bool readIn)
 {
     return InquireVariableCommon<std::complex<float>>(name, readIn);
 }
 
 Variable<std::complex<double>> *
-DataManReader::InquireVariableCDouble(const std::string name, const bool readIn)
+DataManReader::InquireVariableCDouble(const std::string &name,
+                                      const bool readIn)
 {
     return InquireVariableCommon<std::complex<double>>(name, readIn);
 }
 
 Variable<std::complex<long double>> *
-DataManReader::InquireVariableCLDouble(const std::string name,
+DataManReader::InquireVariableCLDouble(const std::string &name,
                                        const bool readIn)
 {
     return InquireVariableCommon<std::complex<long double>>(name, readIn);
 }
 
-VariableCompound *DataManReader::InquireVariableCompound(const std::string name,
-                                                         const bool readIn)
+VariableCompound *
+DataManReader::InquireVariableCompound(const std::string &name,
+                                       const bool readIn)
 {
     return nullptr;
 }
@@ -260,9 +264,10 @@ void DataManReader::InitTransports() // maybe move this?
             const std::vector<int> priorities =
                 CSVToVectorInt(GetMdtmParameter("priorities", parameters));
 
-            m_Transports.push_back(std::make_shared<transport::MdtmMan>(
-                localIP, remoteIP, m_AccessMode, prefix, numberOfPipes,
-                tolerances, priorities, m_MPIComm, m_DebugMode));
+            //            m_Transports.push_back(std::make_shared<transport::MdtmMan>(
+            //                localIP, remoteIP, m_AccessMode, prefix,
+            //                numberOfPipes,
+            //                tolerances, priorities, m_MPIComm, m_DebugMode));
         }
         else if (itTransport->second == "Zmq")
         {
diff --git a/source/engine/dataman/DataManWriter.cpp b/source/engine/dataman/DataManWriter.cpp
index de1cf8455..3810d3f0b 100644
--- a/source/engine/dataman/DataManWriter.cpp
+++ b/source/engine/dataman/DataManWriter.cpp
@@ -353,9 +353,10 @@ void DataManWriter::InitTransports() // maybe move this?
             const std::vector<int> priorities =
                 CSVToVectorInt(GetMdtmParameter("priorities", parameters));
 
-            m_Transports.push_back(std::make_shared<transport::MdtmMan>(
-                localIP, remoteIP, m_AccessMode, prefix, numberOfPipes,
-                tolerances, priorities, m_MPIComm, m_DebugMode));
+            //            m_Transports.push_back(std::make_shared<transport::MdtmMan>(
+            //                localIP, remoteIP, m_AccessMode, prefix,
+            //                numberOfPipes,
+            //                tolerances, priorities, m_MPIComm, m_DebugMode));
         }
         else if (itTransport->second == "Zmq")
         {
-- 
GitLab