From 12cf4d2e53b4e95be89855f09597e4fe54e6fa7c Mon Sep 17 00:00:00 2001
From: wfg <wfg@pc0098504.ornl.gov>
Date: Thu, 20 Oct 2016 17:39:01 -0400
Subject: [PATCH] Working on Makefile with external dependencies in transport
 and transform classes (e.g. NetCDF4, PHDF5, BZIP2, etc.) Added debug mode
 member variable in ADIOS, CGroup classes for additional checking, expect
 slower code.

---
 Makefile                            |  58 ++++++++++++---
 examples/hello/helloADIOS.cpp       |   1 -
 examples/hello/helloADIOS_nompi.cpp |   1 -
 include/core/CGroup.h               |  11 +--
 include/functions/ADIOSFunctions.h  |  19 ++++-
 include/public/ADIOS.h              |  12 ++--
 include/transport/CNetCDF4.h        |   1 +
 include/transport/CPHDF5.h          |   1 +
 src/core/CGroup.cpp                 |  29 +++++---
 src/functions/ADIOSFunctions.cpp    | 106 ++++++++++++++++++++++++----
 src/public/ADIOS.cpp                |  51 ++++---------
 src/transport/CPOSIX.cpp            |  12 ++--
 12 files changed, 208 insertions(+), 94 deletions(-)

diff --git a/Makefile b/Makefile
index b7daf05bb..db567164f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,11 @@
 # Makefile for testing purposes, will build libadios.a 
 # Created on: Oct 4, 2016
 #     Author: wfg
-
      
+#SYSTEM DIRECTORIES, USER MUST MODIFY THESE VALUES
 SYS_BIN:=/usr/bin
-UTIL_LIB:=/usr/local/lib
+SYS_LIB:=/usr/lib/x86_64-linux-gnu
+LOCAL_LIB:=/usr/local/lib
 
 #COMPILERS
 CC:=$(SYS_BIN)/g++
@@ -14,25 +15,60 @@ AR:=$(SYS_BIN)/ar
 #FLAGS
 CFLAGS:=-c -Wall -O0 -g -Wpedantic -std=c++11
 
-
-#ADIOS FLAGS
+#ALL FILES
 HFiles:=$(shell find ./include -type f -name "*.h")
 CPPFiles:=$(shell find ./src -type f -name "*.cpp")
 
+#EXTERNAL LIBRARY PATHS
+
+LIBS := -L$(SYS_LIB) -L$(LOCAL_LIB)
 
-#EXTERNAL DEPENDENCIES
-LIBS := -L$(UTIL_LIB)
+#TRANSPORT WITH EXTERNAL DEPENDENCIES
+TRANSPORT_INC:=./include/transport
+TRANSPORT_SRC:=./src/transport
 
 ifeq ($(HAVE_NETCDF),yes)
-    CFLAGS += -DHAVE_NETCDF
-    LIBS += -netcdf
+    LIBS += -lnetcdf
+else
+    HFiles:=$(filter-out $(TRANSPORT_INC)/CNetCDF4.h,$(HFiles))
+    CPPFiles:=$(filter-out $(TRANSPORT_SRC)/CNetCDF4.cpp,$(CPPFiles))     
+endif
+
+ifeq ($(HAVE_PHDF5),yes)
+    LIBS += -lhdf5
 else
-    HFiles:=$(filter-out ./include/transport/CNetCDF4.h,$(HFiles))
-    CPPFiles:=$(filter-out ./src/transport/CNetCDF4.cpp,$(CPPFiles))     
+    HFiles:=$(filter-out $(TRANSPORT_INC)/CPHDF5.h,$(HFiles))
+    CPPFiles:=$(filter-out $(TRANSPORT_SRC)/CPHDF5.cpp,$(CPPFiles))     
 endif
 
 
-#MPI_CPPFiles=$(shell find ./src/mpi -type f -name "*.cpp")
+#TRANSFORM WITH EXTERNAL DEPENDENCIES
+TRANSFORM_INC:=./include/transform
+TRANSFORM_SRC:=./src/transform
+
+ifeq ($(HAVE_BZIP2),yes)
+    LIBS += -lbz2
+else
+    HFiles:=$(filter-out $(TRANSFORM_INC)/CSZIP.h,$(HFiles))
+    CPPFiles:=$(filter-out $(TRANSFORM_SRC)/CSZIP.cpp,$(CPPFiles))     
+endif
+
+ifeq ($(HAVE_SZIP),yes)
+    LIBS += -lsz
+else
+    HFiles:=$(filter-out $(TRANSFORM_INC)/CSZIP.h,$(HFiles))
+    CPPFiles:=$(filter-out $(TRANSFORM_SRC)/CSZIP.cpp,$(CPPFiles))     
+endif
+
+ifeq ($(HAVE_ZLIB),yes)
+    LIBS += -lz
+else
+    HFiles:=$(filter-out $(TRANSFORM_INC)/CZLIB.h,$(HFiles))
+    CPPFiles:=$(filter-out $(TRANSFORM_SRC)/CZLIB.cpp,$(CPPFiles))     
+endif
+
+
+
 
 OBJFiles:=$(patsubst %.cpp, ./bin/%.o, $(notdir $(CPPFiles)) )
 
diff --git a/examples/hello/helloADIOS.cpp b/examples/hello/helloADIOS.cpp
index 25b557217..ccda96dda 100644
--- a/examples/hello/helloADIOS.cpp
+++ b/examples/hello/helloADIOS.cpp
@@ -26,7 +26,6 @@ int main( int argc, char* argv [] )
     {
         //testing with CPOSIXMPI
         adios::ADIOS adiosFile( "writer.xml", MPI_COMM_WORLD );
-        adiosFile.Init( );
 
         //Get Monitor info
         std::ofstream logStream( "info_" + std::to_string(rank) + ".log" );
diff --git a/examples/hello/helloADIOS_nompi.cpp b/examples/hello/helloADIOS_nompi.cpp
index 2897b0f98..2f73b3302 100644
--- a/examples/hello/helloADIOS_nompi.cpp
+++ b/examples/hello/helloADIOS_nompi.cpp
@@ -17,7 +17,6 @@ int main( int argc, char* argv [] )
     try
     {
         adios::ADIOS adiosFile( "writer2Groups.xml" ); //testing with CPOSIXNoMPI
-        adiosFile.Init( );
         adiosFile.MonitorGroups( std::cout );
         std::cout << "Finished initializing ADIOS\n";
     }
diff --git a/include/core/CGroup.h b/include/core/CGroup.h
index f544a838e..f9bb78445 100644
--- a/include/core/CGroup.h
+++ b/include/core/CGroup.h
@@ -23,7 +23,6 @@
 #endif
 
 
-
 #include "core/CVariable.h"
 #include "core/SAttribute.h"
 #include "core/CTransport.h"
@@ -44,12 +43,13 @@ public:
      * @brief Constructor for XML config file
      * @param xmlGroup contains <adios-group....</adios-group> single group definition from XML config file
      * @param groupName returns the groupName from <adios-group name=" "
+     * @param debugMode
      */
-    CGroup( const std::string& xmlGroup, std::string& groupName );
+    CGroup( const std::string& xmlGroup, std::string& groupName, const bool debugMode = false );
 
-    CGroup( ); ///Non-XML empty constructor
+    CGroup( const bool debugMode = false ); ///Non-XML empty constructor
 
-    ~CGroup( ); ///< Using STL containers
+    ~CGroup( ); ///< Using STL containers, no deallocation
 
     /**
      * Opens group and passes fileName and accessMode to m_Transport
@@ -128,13 +128,14 @@ private:
      * </pre>
      */
     std::map< std::string, std::shared_ptr<CVariable> > m_Variables;
-    std::vector< SAttribute > m_Attributes; ///< Contains all group attributes from SAttribute.h
+    std::vector< SAttribute > m_Attributes; ///< Contains all group attributes from SAttribute.h, should be moved to a map
 
     std::vector< std::string > m_GlobalDimensions; ///< from global-bounds in XML File, data in global space
     std::vector< std::string > m_GlobalOffsets; ///< from global-bounds in XML File, data in global space
 
     std::shared_ptr< CTransport > m_Transport; ///< transport method defined in XML File, using shared pointer as SGroup can be uninitialized
     std::string m_ActiveTransport;
+    const bool m_DebugMode = false; ///< if true will do more checks, exceptions, warnings, expect slower code
 
     bool m_IsOpen = false; ///< checks if group was opened for operations;
     std::string m_FileName; ///< associated fileName is the Group is opened.
diff --git a/include/functions/ADIOSFunctions.h b/include/functions/ADIOSFunctions.h
index 88fe93c09..4180b56ef 100644
--- a/include/functions/ADIOSFunctions.h
+++ b/include/functions/ADIOSFunctions.h
@@ -68,6 +68,7 @@ void GetPairs( const std::string tag, std::vector< std::pair<const std::string,
  * @param fileContent file Content in a single string
  * @param tag field0="value0" field1="value1" in a single string
  * @param pairs pairs[0].first=field0 pairs[0].second=value0 pairs[1].first=field1 pairs[1].second=value1
+ * @param debugMode if true will do more checks, exceptions, warnings, expect slower code
  */
 void GetPairsFromTag( const std::string& fileContent, const std::string tag,
                       std::vector< std::pair<const std::string, const std::string> >& pairs );
@@ -75,12 +76,24 @@ void GetPairsFromTag( const std::string& fileContent, const std::string tag,
 /**
  * Set members m_Groups and m_HostLanguage from XML file content, called within Init functions
  * @param fileContent file Content in a single string
+ * @param mpiComm MPI Communicator passed from application passed to Transport method if required
  * @param hostLanguage return the host language from fileContent
  * @param groups passed returns the map of groups defined in fileContent
- * @param mpiComm MPI Communicator passed from application
+ * @param debugMode if true will do more checks, exceptions, warnings, expect slower code
  */
-void SetMembers( const std::string& fileContent, std::string& hostLanguage, std::map< std::string, CGroup >& groups,
-                 const MPI_Comm mpiComm );
+void SetMembers( const std::string& fileContent, const MPI_Comm mpiComm, std::string& hostLanguage,
+                 std::map< std::string, CGroup >& groups );
+
+/**
+ * Called inside the ADIOS XML constructors to get contents from file, broadcast and set hostLanguage and groups from ADIOS class
+ * @param xmlConfigFile xml config file name
+ * @param mpiComm communicator used from broadcasting
+ * @param hostLanguage set from host-language in xml file
+ * @param groups passed returns the map of groups defined in fileContent
+ * @param debugMode if true will do more checks, exceptions, warnings, expect slower code
+ */
+void InitXML( const std::string xmlConfigFile, const MPI_Comm mpiComm, std::string& hostLanguage,
+              std::map< std::string, CGroup >& groups );
 
 } //end namespace
 
diff --git a/include/public/ADIOS.h b/include/public/ADIOS.h
index fade55c64..cc0ded834 100644
--- a/include/public/ADIOS.h
+++ b/include/public/ADIOS.h
@@ -38,34 +38,33 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO
     /**
      * @brief ADIOS empty constructor. Used for non XML config file API calls.
      */
-    ADIOS( );
+    ADIOS( const bool debugMode = false );
 
     /**
      * @brief Serial constructor for XML config file
      * @param xmlConfigFile passed to m_XMLConfigFile
      */
-    ADIOS( const std::string xmlConfigFile);
+    ADIOS( const std::string xmlConfigFile, const bool debugMode = false );
 
     /**
      * @brief Parallel constructor for XML config file and MPI
      * @param xmlConfigFile passed to m_XMLConfigFile
      * @param mpiComm MPI communicator ...const to be discussed
      */
-    ADIOS( const std::string xmlConfigFile, const MPI_Comm mpiComm );
+    ADIOS( const std::string xmlConfigFile, const MPI_Comm mpiComm, const bool debugMode = false );
 
     /**
      * @brief Parallel MPI communicator without XML config file
      * @param mpiComm MPI communicator passed to m_MPIComm
      */
-    ADIOS( const MPI_Comm mpiComm );
+    ADIOS( const MPI_Comm mpiComm, const bool debugMode = false );
 
     ~ADIOS( ); ///< virtual destructor overriden by children's own destructors
 
-    void Init( ); ///< calls to read XML file among other initialization tasks
     /**
      * @brief Open or Append to an output file
      * @param groupName should match an existing group from XML file or created through CreateGroup
-     * @param fileName associated file
+     * @param fileName associated file or stream
      * @param accessMode "w": write, "a": append, need more info on this
      */
     void Open( const std::string groupName, const std::string fileName, const std::string accessMode = "w" );
@@ -106,6 +105,7 @@ private:
     std::string m_XMLConfigFile; ///< XML File to be read containing configuration information
     MPI_Comm m_MPIComm = nullptr; ///< only used as reference to MPI communicator passed from parallel constructor, MPI_Comm is a pointer itself
     std::string m_HostLanguage; ///< Supported languages: C, C++, Fortran
+    const bool m_DebugMode = false; ///< if true will do more checks, exceptions, warnings, expect slower code
 
     /**
      * @brief List of groups defined from either ADIOS XML configuration file or the CreateGroup function.
diff --git a/include/transport/CNetCDF4.h b/include/transport/CNetCDF4.h
index 627ee0da8..a84f14b56 100644
--- a/include/transport/CNetCDF4.h
+++ b/include/transport/CNetCDF4.h
@@ -8,6 +8,7 @@
 #ifndef CNETCDF4_H_
 #define CNETCDF4_H_
 
+#include <netcdf.h>
 
 #include "core/CTransport.h"
 
diff --git a/include/transport/CPHDF5.h b/include/transport/CPHDF5.h
index 336a77679..74d9cecb1 100644
--- a/include/transport/CPHDF5.h
+++ b/include/transport/CPHDF5.h
@@ -8,6 +8,7 @@
 #ifndef CPHDF5_H_
 #define CPHDF5_H_
 
+#include <hdf5.h>
 
 #include "core/CTransport.h"
 
diff --git a/src/core/CGroup.cpp b/src/core/CGroup.cpp
index cebda7f8d..286345e9c 100644
--- a/src/core/CGroup.cpp
+++ b/src/core/CGroup.cpp
@@ -20,11 +20,13 @@ namespace adios
 {
 
 
-CGroup::CGroup( )
+CGroup::CGroup( const bool debugMode ):
+    m_DebugMode{ debugMode }
 { }
 
 
-CGroup::CGroup( const std::string& xmlGroup, std::string& groupName )
+CGroup::CGroup( const std::string& xmlGroup, std::string& groupName, const bool debugMode ):
+    m_DebugMode{ debugMode }
 {
     ParseXMLGroup( xmlGroup, groupName );
 }
@@ -44,10 +46,11 @@ void CGroup::Open( const std::string fileName, const std::string accessMode )
 void CGroup::SetVariable( const std::string name, const bool isGlobal, const std::string type, const std::string dimensionsCSV,
                           const std::string transform )
 {
-    auto itVariable = m_Variables.find( name );
-    if( itVariable == m_Variables.end() ) //name is not found
+    auto lf_SetVariable = [&] ( const std::string name, const bool isGlobal, const std::string type,
+                                const std::string dimensionsCSV,
+                                const std::string transform )
     {
-        if( type == "integer") //use copy constructor as it's a small struct
+        if( type == "integer") //using copy constructor as it's a small class, only metadata
             m_Variables[name] = std::make_shared< CVariableTemplate<int> >( isGlobal, type, dimensionsCSV, transform );
         else if( type == "unsigned integer")
             m_Variables[name] = std::make_shared< CVariableTemplate<unsigned int> >( isGlobal, type, dimensionsCSV, transform );
@@ -55,11 +58,22 @@ void CGroup::SetVariable( const std::string name, const bool isGlobal, const std
             m_Variables[name] = std::make_shared< CVariableTemplate<float> >( isGlobal, type, dimensionsCSV, transform );
         else if( type == "double")
             m_Variables[name] = std::make_shared< CVariableTemplate<double> >( isGlobal, type, dimensionsCSV, transform );
+    };
+
+    //Function body start  here
+    if( m_DebugMode == true )
+    {
+        if( m_Variables.count( name ) == 1 ) //variable exists
+            lf_SetVariable( name, isGlobal, type, dimensionsCSV, transform );
+        else //name is found
+            std::cout << "WARNING: variable " << name << " exists, NOT setting a new variable\n";
     }
-    else //name is found
+    else
     {
-        throw std::invalid_argument( "ERROR: variable " + name + " is defined twice\n" );
+        lf_SetVariable( name, isGlobal, type, dimensionsCSV, transform );
     }
+
+
 }
 
 
@@ -114,7 +128,6 @@ void CGroup::Monitor( std::ostream& logStream ) const
         logStream << "\t" << attribute.Name << " \t " << attribute.Type << " \t " << attribute.Value << "\n";
     }
 
-
     logStream << "\tTransport Method " << m_ActiveTransport << "\n";
     logStream << "\tIs Transport Method Unique?: " << std::boolalpha << m_Transport.unique() << "\n";
 }
diff --git a/src/functions/ADIOSFunctions.cpp b/src/functions/ADIOSFunctions.cpp
index 667db25ec..6d1e70e4b 100644
--- a/src/functions/ADIOSFunctions.cpp
+++ b/src/functions/ADIOSFunctions.cpp
@@ -30,32 +30,79 @@ void DumpFileToStream( const std::string fileName, std::string& fileContent )
     std::ostringstream fileSS;
     fileSS << fileStream.rdbuf();
     fileStream.close();
-
     fileContent = fileSS.str(); //convert to string and check
-    if( fileContent.empty() ) throw std::invalid_argument( "ERROR: file " + fileName + " is empty\n" );
+
+    if( fileContent.empty()  )
+        throw std::invalid_argument( "ERROR: file " + fileName + " is empty\n" );
 }
 
 
-void GetSubString ( const std::string initialTag, const std::string finalTag, const std::string content, std::string& subString,
-                    std::string::size_type& currentPosition )
+void GetSubString ( const std::string initialTag, const std::string finalTag, const std::string content,
+                    std::string& subString, std::string::size_type& currentPosition )
 {
-    std::string::size_type start( content.find(initialTag, currentPosition ) );
-    if( start == content.npos )
+    auto lf_Wipe =[]( std::string& subString, std::string::size_type& currentPosition )
     {
         subString.clear();
         currentPosition = std::string::npos;
+    };
+
+    std::string::size_type start( content.find(initialTag, currentPosition ) );
+    if( start == content.npos )
+    {
+        lf_Wipe( subString, currentPosition );
         return;
     }
     currentPosition = start;
 
-    std::string::size_type end( content.find(finalTag, currentPosition ) );
+    std::string::size_type end( content.find( finalTag, currentPosition ) );
     if( end == content.npos )
     {
-        subString.clear();
-        currentPosition = std::string::npos;
+        lf_Wipe( subString, currentPosition );
         return;
     }
 
+    //here make sure the finalTag is not a value surrounded by " " or ' ', if so find next
+    bool isValue = true;
+
+    while( isValue == true )
+    {
+        std::string::size_type quotePosition = content.find( '\'', currentPosition );
+        std::string::size_type doubleQuotePosition = content.find( '\"', currentPosition );
+
+        if( ( quotePosition == content.npos && doubleQuotePosition == content.npos ) ||
+            ( quotePosition == content.npos && end < doubleQuotePosition  ) ||
+            ( doubleQuotePosition == content.npos && end < quotePosition  ) ||
+            ( end < quotePosition && end < doubleQuotePosition )
+          ) break;
+
+        //first case
+        std::string::size_type closingPosition;
+        if( quotePosition < doubleQuotePosition ) //find the closing "
+        {
+            currentPosition = quotePosition;
+            closingPosition = content.find( '\'', currentPosition+1 );
+        }
+        else //find the closing '
+        {
+            currentPosition = doubleQuotePosition;
+            closingPosition = content.find( '\"', currentPosition+1 );
+        }
+
+        if( closingPosition == content.npos ) //if can't find closing it's open until the end
+        {
+            lf_Wipe( subString, currentPosition );
+            return;
+        }
+        if( closingPosition < end )
+        {
+            currentPosition = closingPosition+1;
+            continue;
+        }
+
+        //if this point is reached it means it's a value inside " " or ' ', move to the next end
+        end = content.find( finalTag, currentPosition );
+    }
+
     subString = content.substr( start, end-start+finalTag.size() );
     currentPosition = end;
 }
@@ -66,10 +113,10 @@ void GetQuotedValue( const char quote, const std::string::size_type& quotePositi
 {
     currentTag = currentTag.substr( quotePosition + 1 );
     auto nextQuotePosition = currentTag.find( quote );
+
     if( nextQuotePosition == currentTag.npos )
-    {
         throw std::invalid_argument( "ERROR: Invalid attribute in..." + currentTag + "...check XML file\n");
-    }
+
     value = currentTag.substr( 0, nextQuotePosition );
     currentTag = currentTag.substr( nextQuotePosition+1 );
 }
@@ -89,7 +136,6 @@ void GetPairs( const std::string tag, std::vector< std::pair<const std::string,
         const char quote = currentTag[equalPosition+1];
         if( quote == '\'' || quote == '"') //single quotes
         {
-            //quote position?
             GetQuotedValue( quote, equalPosition+1, currentTag, value );
         }
 
@@ -120,8 +166,8 @@ void GetPairsFromTag( const std::string& fileContent, const std::string tag,
     }
 }
 
-void SetMembers( const std::string& fileContent, std::string& hostLanguage, std::map< std::string, CGroup >& groups,
-                 const MPI_Comm mpiComm )
+void SetMembers( const std::string& fileContent, const MPI_Comm mpiComm,
+                 std::string& hostLanguage, std::map< std::string, CGroup >& groups )
 {
     //adios-config
     std::string currentContent;
@@ -212,6 +258,38 @@ void SetMembers( const std::string& fileContent, std::string& hostLanguage, std:
 }
 
 
+void InitXML( const std::string xmlConfigFile, const MPI_Comm mpiComm,
+              std::string& hostLanguage, std::map< std::string, CGroup >& groups )
+{
+    int xmlFileContentSize;
+    std::string xmlFileContent;
+
+    int rank;
+    MPI_Comm_rank( mpiComm, &rank );
+
+    if( rank == 0 ) //serial part
+    {
+        std::string xmlFileContent;
+        DumpFileToStream( xmlConfigFile, xmlFileContent ); //in ADIOSFunctions.h dumps all XML Config File to xmlFileContent
+        xmlFileContentSize = xmlFileContent.size( ) + 1; // add one for the null character
+
+        MPI_Bcast( &xmlFileContentSize, 1, MPI_INT, 0, mpiComm ); //broadcast size for allocation
+        MPI_Bcast( (char*)xmlFileContent.c_str(), xmlFileContentSize, MPI_CHAR, 0, mpiComm ); //broadcast contents
+    }
+    else
+    {
+        MPI_Bcast( &xmlFileContentSize, 1, MPI_INT, 0, mpiComm  ); //receive size
+
+        char* xmlFileContentMPI = new char[ xmlFileContentSize ]; //allocate xml C-char
+        MPI_Bcast( xmlFileContentMPI, xmlFileContentSize, MPI_CHAR, 0, mpiComm ); //receive xml C-char
+        xmlFileContent.assign( xmlFileContentMPI ); //copy to a string
+
+        delete []( xmlFileContentMPI ); //delete char* needed for MPI, might add size is moving to C++14 for optimization, avoid memory leak
+    }
+
+    SetMembers( xmlFileContent,  mpiComm, hostLanguage,  groups );
+}
+
 
 
 } //end namespace
diff --git a/src/public/ADIOS.cpp b/src/public/ADIOS.cpp
index 74ae36e9e..3db87f915 100644
--- a/src/public/ADIOS.cpp
+++ b/src/public/ADIOS.cpp
@@ -21,55 +21,32 @@ namespace adios
 {
 
 
-ADIOS::ADIOS( )
+ADIOS::ADIOS( const bool debugMode ):
+    m_DebugMode{ debugMode }
 { }
 
 
-ADIOS::ADIOS( const std::string xmlConfigFile ):
-    m_XMLConfigFile{ xmlConfigFile }
-{ }
+ADIOS::ADIOS( const std::string xmlConfigFile, const bool debugMode ):
+    m_XMLConfigFile{ xmlConfigFile },
+    m_DebugMode{ debugMode }
+{
+    InitXML( m_XMLConfigFile, m_MPIComm, m_HostLanguage, m_Groups );
+}
 
 
-ADIOS::ADIOS( const std::string xmlConfigFile, const MPI_Comm mpiComm  ):
+ADIOS::ADIOS( const std::string xmlConfigFile, const MPI_Comm mpiComm, const bool debugMode  ):
     m_XMLConfigFile{ xmlConfigFile },
-	m_MPIComm{ mpiComm }
-{ }
+	m_MPIComm{ mpiComm },
+	m_DebugMode{ debugMode }
+{
+    InitXML( m_XMLConfigFile, m_MPIComm, m_HostLanguage, m_Groups );
+}
 
 
 ADIOS::~ADIOS( )
 { }
 
 
-void ADIOS::Init( )
-{
-    int xmlFileContentSize;
-    std::string xmlFileContent;
-
-    int rank;
-    MPI_Comm_rank( m_MPIComm, &rank );
-
-    if( rank == 0 ) //serial part
-    {
-        std::string xmlFileContent;
-        DumpFileToStream( m_XMLConfigFile, xmlFileContent ); //in ADIOSFunctions.h dumps all XML Config File to xmlFileContent
-        xmlFileContentSize = xmlFileContent.size( ) + 1; // add one for the null character
-
-        MPI_Bcast( &xmlFileContentSize, 1, MPI_INT, 0, m_MPIComm  ); //broadcast size for allocation
-        MPI_Bcast( (char*)xmlFileContent.c_str(), xmlFileContentSize, MPI_CHAR, 0, m_MPIComm );
-        SetMembers( xmlFileContent, m_HostLanguage,  m_Groups, m_MPIComm );
-    }
-    else
-    {
-        MPI_Bcast( &xmlFileContentSize, 1, MPI_INT, 0, m_MPIComm  ); //broadcast size
-        char* xmlFileContentMPI = new char[ xmlFileContentSize ]; //allocate C char
-        MPI_Bcast( xmlFileContentMPI, xmlFileContentSize, MPI_CHAR, 0, m_MPIComm ); //receive from rank=0
-
-        xmlFileContent.assign( xmlFileContentMPI );
-        SetMembers( xmlFileContent, m_HostLanguage,  m_Groups, m_MPIComm );
-    }
-}
-
-
 void ADIOS::Open( const std::string groupName, const std::string fileName, const std::string accessMode )
 {
     m_Groups.at( groupName ).Open( fileName, accessMode );
diff --git a/src/transport/CPOSIX.cpp b/src/transport/CPOSIX.cpp
index 3a4bccb3c..929d32b73 100644
--- a/src/transport/CPOSIX.cpp
+++ b/src/transport/CPOSIX.cpp
@@ -5,19 +5,18 @@
  *      Author: wfg
  */
 
-#include "transport/CPOSIX.h"
 
 #include <iostream>
 
+#include "transport/CPOSIX.h"
 
 
 namespace adios
 {
 
 
-CPOSIX::CPOSIX( const unsigned int priority, const unsigned int iteration,
-                MPI_Comm mpiComm ):
-    CTransportMPI( "POSIX", priority, iteration, mpiComm )
+CPOSIX::CPOSIX( const unsigned int priority, const unsigned int iteration, MPI_Comm mpiComm ):
+    CTransport( "POSIX", priority, iteration, mpiComm )
 { }
 
 
@@ -27,14 +26,11 @@ CPOSIX::~CPOSIX( )
 
 void CPOSIX::Write( const CVariable& variable )
 {
-    int rank;
+    int rank, size;
     MPI_Comm_rank( m_MPIComm, &rank );
-
-    int size;
     MPI_Comm_size( m_MPIComm, &size );
 
     std::cout << "Just saying Hello from CPOSIX Write from process " << rank << "/" << size  << "\n";
-
 }
 
 
-- 
GitLab