diff --git a/examples/dataman/datamanNoXML.cpp b/examples/dataman/datamanNoXML.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2e0be204631414408e895131e0d4cac3176bae1e --- /dev/null +++ b/examples/dataman/datamanNoXML.cpp @@ -0,0 +1,86 @@ +/* + * dataman.cpp: Example for DataMan Transport usage + * + * Created on: Nov 15, 2016 + * Author: wfg + */ + + + + +#ifdef HAVE_MPI + #include <mpi.h> +#else + #include "public/mpidummy.h" +#endif + +#include "public/ADIOS.h" + + +int main( int argc, char* argv [] ) +{ + MPI_Init( &argc, &argv ); + int rank; + MPI_Comm_rank( MPI_COMM_WORLD, &rank ); + + try //need to think carefully how to handle C++ exceptions with MPI to avoid deadlocking + { + const unsigned int myCharsSize = 10; + std::vector<char> myChars( myCharsSize, '1' ); // 10 chars with value '1' + + //Equivalent to adios_init debug mode is on, MPI_COMM_WORLD is dummy nothing to worry about + adios::ADIOS adios( MPI_COMM_WORLD, true ); + + //Create group TCP and set up, this can be done from XML config file + const std::string group( "TCP" ); + adios.CreateGroup( group ); + adios.CreateVariable( group, "myCharsSize", "unsigned int" ); //scalar : group, name, type + adios.CreateVariable( group, "myChars", "char", "myCharsSize" ); //group, name, type, integer variable defining size + //here we tell group to be associate with a DataMan transport + //we can add more parameters if you require + adios.SetTransport( group, "DataMan" ); + + adios.Open( group, "TCPStream", "write" ); //here open a stream called TCPStream for writing (w or write) + adios.Write( group, "myCharsSize", &myCharsSize ); //calls your transport + adios.Write( group, "myChars" , &myChars[0] ); //calls your transport + adios.Close( group ); + } + catch( std::bad_alloc& e ) + { + if( rank == 0 ) + { + std::cout << "Bad allocation exception, STOPPING PROGRAM\n"; + std::cout << e.what() << "\n"; + } + } + catch( std::invalid_argument& e ) + { + if( rank == 0 ) + { + std::cout << "Invalid argument exception, STOPPING PROGRAM\n"; + std::cout << e.what() << "\n"; + } + } + catch( std::ios_base::failure& e ) + { + if( rank == 0 ) + { + std::cout << "System exception, STOPPING PROGRAM\n"; + std::cout << e.what() << "\n"; + } + } + catch( std::exception& e ) + { + if( rank == 0 ) + { + std::cout << "Exception, STOPPING PROGRAM\n"; + std::cout << e.what() << "\n"; + } + } + + + return 0; +} + + + diff --git a/examples/hello/helloFStream.cpp b/examples/hello/helloFStream.cpp index e2063c43b713b652ee55d5d457952e7b6b2fb5ac..bf808afe18b700aa85402bfddecd5521553bc5b0 100644 --- a/examples/hello/helloFStream.cpp +++ b/examples/hello/helloFStream.cpp @@ -36,11 +36,9 @@ int main( int argc, char* argv [] ) std::vector<int> myVector( 10 ); std::iota( myVector.begin(), myVector.end(), 1 ); - //testing with CFStream transport adios = adios::ADIOS( "fstream.xml", MPI_COMM_WORLD, true ); //debug mode is on adios.MonitorGroups( std::cout ); //Dump group info adios.Open( group, "helloVector.txt", "w" ); - adios.Open( group, "helloVector1.txt", "w" ); adios.Write( group, numbersVariable, &myVector ); //Write to helloVector.txt adios.Close( group ); } diff --git a/include/core/CCapsule.h b/include/core/CCapsule.h index 0be7624b61048f4cc38b8c5ef244d13a5ca4b43a..76cd526d27128a4e3ada77c3789a5a65b832f740 100644 --- a/include/core/CCapsule.h +++ b/include/core/CCapsule.h @@ -22,6 +22,7 @@ #include "public/mpidummy.h" #endif +#include "core/CGroup.h" #include "core/SVariable.h" #include "core/CTransform.h" #include "core/CTransport.h" @@ -70,6 +71,7 @@ public: /** * Unique constructor * @param mpiComm communicator passed from ADIOS + * @param debugMode true: on throws exceptions and do additional checks, false: off (faster, but unsafe) */ CCapsule( MPI_Comm mpiComm, const bool debugMode ); @@ -81,29 +83,18 @@ public: void SetBuffer( const std::string streamName, const unsigned int long maxBufferSize ); - /** * Open a certain stream based on transport method * @param streamName associated file or stream * @param accessMode "w": write, "a": append, need more info on this - * @param bufferSize */ void Open( const std::string streamName, const std::string accessMode ); - void WriteVariableToBuffer( const std::string streamName, const SVariable<char>& variable ); - void WriteVariableToBuffer( const std::string streamName, const SVariable<unsigned char>& variable ); - void WriteVariableToBuffer( const std::string streamName, const SVariable<short>& variable ); - void WriteVariableToBuffer( const std::string streamName, const SVariable<unsigned short>& variable ); - void WriteVariableToBuffer( const std::string streamName, const SVariable<int>& variable ); - void WriteVariableToBuffer( const std::string streamName, const SVariable<unsigned int>& variable ); - void WriteVariableToBuffer( const std::string streamName, const SVariable<long int>& variable ); - void WriteVariableToBuffer( const std::string streamName, const SVariable<unsigned long int>& variable ); - void WriteVariableToBuffer( const std::string streamName, const SVariable<long long int>& variable ); - void WriteVariableToBuffer( const std::string streamName, const SVariable<unsigned long long int>& variable ); - void WriteVariableToBuffer( const std::string streamName, const SVariable<float>& variable ); - void WriteVariableToBuffer( const std::string streamName, const SVariable<double>& variable ); - void WriteVariableToBuffer( const std::string streamName, const SVariable<long double>& variable ); + void WriteToBuffer( const void* data, size_t dataSize, const std::vector<unsigned long long int>& localDimensions, + const std::vector<unsigned long long int>& globalDimensions, + const std::vector<unsigned long long int>& globalOffsets ); + void WriteVariableToBuffer( const CGroup& group, const std::string variableName ); /** * Closes the buffer * @param streamName associated streamName to this buffer diff --git a/include/core/CGroup.h b/include/core/CGroup.h index d4990a349805399f1f4396b460330cc2a079ba05..35de7c4e551e17c8a9c14d075c463efb87939f77 100644 --- a/include/core/CGroup.h +++ b/include/core/CGroup.h @@ -46,7 +46,6 @@ public: * @brief Constructor for XML config file * @param hostLanguage reference from ADIOS class * @param xmlGroup contains <adios-group (tag excluded)....</adios-group> single group definition from XML config file - * @param groupName returns the groupName from <adios-group name=" " * @param debugMode from ADIOS */ CGroup( const std::string& hostLanguage, const std::string& xmlGroup, const bool debugMode ); @@ -98,24 +97,6 @@ public: void CreateAttribute( const std::string name, const std::string type, const std::string value, const std::string globalDimensionsCSV, const std::string globalOffsetsCSV ); - - /** - * Sets transport method super-seeding the existing one - * @param transport method name - */ - void SetTransport( const std::string transport ); - - /** - * Called from ADIOS open, sets group as active and passes associated bufferName and accessMode - * @param streamName associated buffer for this group - */ - void Open( const std::string streamName ); - - - - void Close( ); ///< sets m_IsOpen to false, and m_BufferName and m_AccessMode to empty - - /** * @brief Dumps groups information to a file stream or standard output. * Note that either the user closes this fileStream or it's closed at the end. @@ -123,6 +104,8 @@ public: */ void Monitor( std::ostream& logStream ) const; + std::vector<unsigned long long int> CGroup::GetDimensions( const std::string dimensionsCSV ) const; + private: @@ -188,6 +171,9 @@ private: * @return -1 variable is not associated with a transform, otherwise index in m_Transforms */ const int SetTransforms( const std::string transform ) noexcept; + + + const unsigned long long int GetIntVariableValue( const std::string variableName ) const; }; diff --git a/include/core/CTransport.h b/include/core/CTransport.h index 21c2227bc83ed2070fb637960ef9752ee8860004..15ca4069ba59e301b45ab309978d82a715317bad 100644 --- a/include/core/CTransport.h +++ b/include/core/CTransport.h @@ -44,8 +44,6 @@ public: /** * Base constructor that all derived classes pass * @param mpiComm passed to m_MPIComm - * @param priority passed to m_Priority - * @param iteration passed to m_Iteration * @param debugMode passed to m_DebugMode */ CTransport( MPI_Comm mpiComm, const bool debugMode ): @@ -67,7 +65,14 @@ public: */ virtual void Open( const std::string streamName, const std::string accessMode ) = 0; - virtual void SetBuffer( std::vector<char>& buffer ) + /** + * Sets the buffer and bufferSize for certain transport methods + * @param buffer to be set to transport + */ + virtual void SetBuffer( const std::vector<char>& buffer ) + { }; + + virtual void Write( std::vector<char>& buffer ) { }; virtual void Close( ) = 0; //here think what needs to be passed diff --git a/include/functions/ADIOSFunctions.h b/include/functions/ADIOSFunctions.h index 85e9b1f128cff11b4cedd19ba219788001872d87..197cc9642573f9c28a179f41a5ef180102718513 100644 --- a/include/functions/ADIOSFunctions.h +++ b/include/functions/ADIOSFunctions.h @@ -68,7 +68,6 @@ 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 ); @@ -79,7 +78,6 @@ void GetPairsFromTag( const std::string& fileContent, const std::string tag, * @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 debugMode if true will do more checks, exceptions, warnings, expect slower code */ void SetMembers( const std::string& fileContent, const MPI_Comm mpiComm, std::string& hostLanguage, std::map< std::string, CGroup >& groups ); @@ -96,6 +94,9 @@ void SetMembers( const std::string& fileContent, const MPI_Comm mpiComm, std::st void InitXML( const std::string xmlConfigFile, const MPI_Comm mpiComm, const bool debugMode, std::string& hostLanguage, std::map< std::string, CGroup >& groups ); + + + } //end namespace diff --git a/include/functions/ADIOSTemplates.h b/include/functions/ADIOSTemplates.h index b1db2016810dd0f7c4956770c71b2573ecda89c6..7a678c71086cfc06c5dbf3db5a2a281d971954a1 100644 --- a/include/functions/ADIOSTemplates.h +++ b/include/functions/ADIOSTemplates.h @@ -25,7 +25,7 @@ namespace adios * @param capsule */ template< class T > -void WriteVariable( const std::string variableName, const T* values, CGroup& group, CCapsule& capsule ) +void WriteVariableValues( CGroup& group, const std::string variableName, const T* values ) { const bool debugMode( group.m_DebugMode ); const std::string streamName( group.m_StreamName ); @@ -38,84 +38,52 @@ void WriteVariable( const std::string variableName, const T* values, CGroup& gro } const unsigned int index( itVariable->second.second ); //index is second in the pair Value of the m_Variables map - group.m_SetVariables.insert( variableName ); if( std::is_same<T,char>::value ) //maybe use type? - { - SVariable<char>& variable = group.m_Char[index]; - variable.m_Values = values; - capsule.WriteVariableToBuffer( streamName, variable ); - } + group.m_Char[index].m_Values = values; + else if( std::is_same<T,unsigned char>::value ) - { - SVariable<unsigned char>& variable = group.m_UChar[index]; - variable.m_Values = values; - capsule.WriteVariableToBuffer( streamName, variable ); - } + group.m_UChar[index].m_Values = values; + else if( std::is_same<T,short>::value ) - { - SVariable<short>& variable = group.m_Short[index]; - variable.m_Values = values; - capsule.WriteVariableToBuffer( streamName, variable ); - } + group.m_Short[index].m_Values = values; + else if( std::is_same<T,unsigned short>::value ) - { - SVariable<unsigned short>& variable = group.m_UShort[index]; - variable.m_Values = values; - capsule.WriteVariableToBuffer( streamName, variable ); - } + group.m_UShort[index].m_Values = values; + else if( std::is_same<T,int>::value ) - { - SVariable<int>& variable = group.m_Int[index]; - variable.m_Values = values; - capsule.WriteVariableToBuffer( streamName, variable ); - } + group.m_Int[index].m_Values = values; + else if( std::is_same<T,unsigned int>::value ) - { - SVariable<unsigned int>& variable = group.m_Int[index]; - variable.m_Values = values; - capsule.WriteVariableToBuffer( streamName, variable ); - } + group.m_UInt[index].m_Values = values; + else if( std::is_same<T,long int>::value ) - { - SVariable<long int>& variable = group.m_LInt[index]; - variable.m_Values = values; - capsule.WriteVariableToBuffer( streamName, variable ); - } + group.m_LInt[index].m_Values = values; + + else if( std::is_same<T,unsigned long int>::value ) + group.m_ULInt[index].m_Values = values; + else if( std::is_same<T,long long int>::value ) - { - SVariable<long int>& variable = group.m_LLInt[index]; - variable.m_Values = values; - capsule.WriteVariableToBuffer( streamName, variable ); - } + group.m_LLInt[index].m_Values = values; + else if( std::is_same<T,unsigned long long int>::value ) - { - SVariable<unsigned long long int>& variable = group.m_ULLInt[index]; - variable.m_Values = values; - capsule.WriteVariableToBuffer( streamName, variable ); - } + group.m_ULLInt[index].m_Values = values; + else if( std::is_same<T,float>::value ) - { - SVariable<float>& variable = group.m_Float[index]; - variable.m_Values = values; - capsule.WriteVariableToBuffer( streamName, variable ); - } + group.m_Float[index].m_Values = values; + else if( std::is_same<T,double>::value ) - { - SVariable<double>& variable = group.m_Double[index]; - variable.m_Values = values; - capsule.WriteVariableToBuffer( streamName, variable ); - } + group.m_Double[index].m_Values = values; + else if( std::is_same<T,long double>::value ) - { - SVariable<double>& variable = group.m_LDouble[index]; - variable.m_Values = values; - capsule.WriteVariableToBuffer( streamName, variable ); - } + group.m_LDouble[index].m_Values = values; + + group.m_SetVariables.insert( variableName ); } + } //end namespace diff --git a/include/public/ADIOS.h b/include/public/ADIOS.h index 277523bc575787752b1139314be65f6baa1b2f32..8d5d7b88efa43f4fac2b0db9bb1a61438fe2b926 100644 --- a/include/public/ADIOS.h +++ b/include/public/ADIOS.h @@ -52,7 +52,7 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO /** * @brief Serial constructor for XML config file * @param xmlConfigFile passed to m_XMLConfigFile - * @param debugMode true: on, false: off (faster, but unsafe) + * @param debugMode true: on throws exceptions and do additional checks, false: off (faster, but unsafe) */ ADIOS( const std::string xmlConfigFile, const bool debugMode = false ); @@ -78,13 +78,14 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO /** - * @brief Open or Append to an output file + * @brief Open to Write, Read or Append to a stream * @param groupName should match an existing group from XML file or created through CreateGroup - * @param fileName associated file or stream + * @param streamName associated file or stream * @param accessMode "w": write, "a": append, need more info on this * @param maxBufferSize used for transport */ - void Open( const std::string groupName, const std::string streamName, const std::string accessMode = "w", unsigned long int maxBufferSize ); + void Open( const std::string groupName, const std::string streamName, const std::string accessMode = "w", + unsigned long long int maxBufferSize ); /** @@ -104,7 +105,8 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO if( itGroup->second.m_IsOpen == false ) throw std::invalid_argument( "ERROR: group " + groupName + " is not open in Write function.\n" ); } - WriteVariable( variableName, values, itGroup->second, m_Capsule ); + WriteVariableValues( itGroup->second, variableName, values ); + m_Capsule.WriteVariableToBuffer( itGroup->second, variableName ); } /** @@ -155,7 +157,7 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO const std::string globalDimensionsCSV = "", const std::string globalOffsetsCSV = "" ); /** - * Sets a transport method to be associated with a group + * Sets a transport method to be associated with a group. Need to think variadic function for other methods * @param groupName unique name * @param transport transport method */ diff --git a/include/transport/CDataMan.h b/include/transport/CDataMan.h new file mode 100644 index 0000000000000000000000000000000000000000..c3e6af31e304d5c90a54f298301c46043c245cfa --- /dev/null +++ b/include/transport/CDataMan.h @@ -0,0 +1,79 @@ +/* + * CDataMan.h + * + * Created on: Nov 15, 2016 + * Author: wfg + */ + +#ifndef CDATAMAN_H_ +#define CDATAMAN_H_ + +#include "core/CTransport.h" + +//here include any external library headers only if needed by the declarations in this file, we can figure out linking them later + +namespace adios +{ + +class CDataMan : public CTransport +{ + + +public: + + CDataMan( MPI_Comm mpiComm, const bool debugMode ); + + ~CDataMan( ); + + /** + * Open your communication socket ? + * @param streamName message name ? + * @param accessMode w or write, r or read + */ + void Open( const std::string streamName, const std::string accessMode ); + + /** + * You might not need this one since Buffer has all data, we might turn it on for future reference + * @param buffer + */ + void SetBuffer( const std::vector<char>& buffer ); + + /** + * Here you will receive a reference (not a copy) to the variable being written as raw data ready to be sent. + * Your magic will go inside this function. From ADIOS it's just a single call per variable. + * @param buffer contains a reference to the raw data variable. This backtraces to ADIOS.Write( group, variableName, * value ) + */ + void Write( std::vector<char>& buffer ); + + /** + * Required to terminate your acquire system resource (file, socket, stream, etc.) if hanging to avoid memory leaks + */ + void Close( ); + + +// FILE* m_File; //here put your unique, particular form of communication. See CPOSIX and CFStream for files. +// You have your own structs, objects etc. put them in protected (if inherited) or private space +// We can also work on initializing them in the constructor + +//protected: + +//private: + + +}; + + + + + + + + + + + + +} //end namespace + + +#endif /* CDATAMAN_H_ */ diff --git a/src/core/CCapsule.cpp b/src/core/CCapsule.cpp index 9529733c1070f9a16522ca4cae873be7446d9edc..f270c15f4c437ff7703ff8cc21d6afa60bc78f00 100644 --- a/src/core/CCapsule.cpp +++ b/src/core/CCapsule.cpp @@ -71,6 +71,10 @@ void CCapsule::SetTransport( const std::string streamName, const std::string tra else if( transport == "FStream" ) m_Transports[streamName] = std::make_shared<CFStream>( m_MPIComm, debugMode ); + + else if( transport == "DataMan" ) + m_Transports[streamName] = std::make_shared<CDataMan>( m_MPIComm, debugMode ); + } @@ -84,7 +88,7 @@ void CCapsule::SetBuffer( const std::string streamName, const unsigned int long throw std::invalid_argument( "ERROR: buffer for stream " + streamName + " not found, not setting size\n" ); } - itBuffer->second.reserve( maxBufferSize ); + itBuffer->second.resize( maxBufferSize * 1000000 ); //use resize not reserve } @@ -92,6 +96,71 @@ void CCapsule::Open( const std::string streamName, const std::string accessMode { m_Transports[streamName]->Open( streamName, accessMode ); m_Transports[streamName]->SetBuffer( m_Buffer[streamName] ); +} + + +void CCapsule::WriteVariableToBuffer( const CGroup& group, const std::string variableName ) +{ + const std::string streamName( group.m_StreamName ); + std::vector<unsigned long long int> dimensions = group.GetDimensions( variableName ); + const auto itVariable = group.m_Variables.find( variableName ); + const std::string type( itVariable->second.first ); + const unsigned int index( itVariable->second.second ); + + if( type == "char" || type == "character" ) + group.m_Char[index]; + + else if( type == "unsigned char" ) + group.m_UChar[index]; + + else if( type == "short" || type == "integer*2" ) + group.m_Short[index]; + + else if( type == "unsigned short" ) + group.m_UShort[index]; + + else if( type == "int" || type == "integer" ) + group.m_Int[index]; + + else if( type == "unsigned int" || type == "unsigned integer" ) + group.m_UInt[index]; + + else if( type == "long int" || type == "long" || type == "long integer" ) + group.m_LInt[index]; + + else if( type == "long long int" || type == "long long" || type == "long long integer" ) + group.m_LLInt[index]; + + else if( type == "unsigned long long int" || type == "unsigned long long" || type == "unsigned long long integer" ) + group.m_ULLInt[index]; + + else if( type == "float" || type == "real" || type == "real*4" ) + group.m_Float[index]; + + else if( type == "double" || type == "double precision" || type == "real*8" ) + group.m_Double[index]; + + + else if( type == "long double" || type == "real*16" ) + m_LDouble.push_back( SVariable<long double>{ dimensionsCSV, nullptr, transformIndex, globalBoundsIndex } ); + + + + + + + + if( group.m_Transport == "DataMan" ) // send a single buffer to DataMan with the entire data + { + + + } + + + + + + } diff --git a/src/core/CGroup.cpp b/src/core/CGroup.cpp index e1f731e2d571e496c2cb14b3140ccc1d5eb37aaf..0832a1d11c43cd34e1ab40124d7962a2f7a3ea1e 100644 --- a/src/core/CGroup.cpp +++ b/src/core/CGroup.cpp @@ -8,6 +8,7 @@ #include <iostream> #include <algorithm> // find +#include <sstream> //istringstream #include "core/CGroup.h" #include "core/SVariable.h" //for cast implementation of CVariableBase::Set that calls CVariable::Set @@ -130,15 +131,68 @@ void CGroup::CreateAttribute( const std::string name, const std::string type, co } -void CGroup::Open( const std::string streamName ) +const unsigned long long int CGroup::GetIntVariableValue( const std::string variableName ) const { - m_StreamName = streamName; + if( m_DebugMode == true ) + { + if( m_SetVariables.count( variableName ) == 0 ) + throw std::invalid_argument( "ERROR: variable value for " + variableName + " was not set with Write function\n" ); + } + + const std::string type( m_Variables.at( variableName ).first ); + const unsigned int index = m_Variables.at( variableName ).second; + const unsigned long long int value = 0; + + if( type == "short" ) + value = *( m_Short[index].m_Values ); + + else if( type == "unsigned short" ) + value = *( m_UShort[index].m_Values ); + + else if( type == "int" ) + value = *( m_Int[index].m_Values ); + + else if( type == "unsigned int" ) + value = *( m_UInt[index].m_Values ); + + else if( type == "long int" ) + value = *( m_LInt[index].m_Values ); + + else if( type == "unsigned long int" ) + value = *( m_ULInt[index].m_Values ); + + else if( type == "long long int" ) + value = *( m_LLInt[index].m_Values ); + + else if( type == "unsigned long long int" ) + value = *( m_ULLInt[index].m_Values ); + + else + throw std::invalid_argument( "ERROR: variable " + variableName + " must be of short, int or associated type (long int, unsigned long int, etc.)\n" ); + + return value; } -void CGroup::SetTransport( const std::string transport ) +std::vector<unsigned long long int> CGroup::GetDimensions( const std::string dimensionsCSV ) const { - m_Transport = transport; + std::vector<unsigned long long int> dimensions; + + if( dimensionsCSV.find(',') == dimensionsCSV.npos ) //check if 1D + { + const std::string dimension( dimensionsCSV ); + dimensions.push_back( GetIntVariableValue( dimension ) ); + return dimensions; + } + + std::istringstream dimensionsSS( dimensionsCSV ); + std::string dimension; + while( std::getline( dimensionsSS, dimension, ',' ) ) + { + dimensions.push_back( GetIntVariableValue( dimension ) ); + } + + return dimensions; } diff --git a/src/public/ADIOS.cpp b/src/public/ADIOS.cpp index fc9692dc92481ef810044a8e2fedf57019271b0c..8ff3ff4643b432f9da805bda1fa424f354359152 100644 --- a/src/public/ADIOS.cpp +++ b/src/public/ADIOS.cpp @@ -72,9 +72,14 @@ void ADIOS::Open( const std::string groupName, const std::string streamName, con auto itGroup = m_Groups.find( groupName ); if( m_DebugMode == true ) - CheckGroup( itGroup, groupName, " from call to Open with file " + streamName ); + CheckGroup( itGroup, groupName, " from call to Open with stream " + streamName + + ", access mode " + accessMode ); + + //Set Group + CGroup& group = itGroup->second; + group.m_IsOpen = true; + group.m_StreamName = streamName; - itGroup->second.Open( streamName ); m_Capsule.SetTransport( streamName, itGroup->second.m_Transport, m_DebugMode ); //Set Transport m_Capsule.SetBuffer( streamName, maxBufferSize ); m_Capsule.Open( streamName, accessMode ); @@ -92,8 +97,12 @@ void ADIOS::Close( const std::string groupName ) throw std::invalid_argument( "ERROR: group " + groupName + " is not open in Write function.\n" ); } - //m_Capsule->CloseGroupBuffer( itGroup->second ); - itGroup->second.Close( ); + CGroup& group = itGroup->second; + + //m_Capsule->CloseGroupBuffer( itGroup->second ); //need to think about it + group.m_StreamName.clear(); + group.m_Transport.clear(); + group.m_IsOpen = false; } @@ -127,7 +136,7 @@ void ADIOS::SetTransport( const std::string groupName, const std::string transpo if( m_DebugMode == true ) CheckGroup( itGroup, groupName, " from call to SetTransport \n" ); - itGroup->second.SetTransport( transport ); + itGroup->second.m_Transport = transport; } diff --git a/src/transport/CDataMan.cpp b/src/transport/CDataMan.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0422a486b15fcb50e881c4515f1b5dd3d1d375b6 --- /dev/null +++ b/src/transport/CDataMan.cpp @@ -0,0 +1,52 @@ +/* + * CDataMan.cpp Implementation of ./include/transport/CDataMan.h + * + * Created on: Nov 15, 2016 + * Author: wfg + */ + +#include "transport/CDataMan.h" + +//here include any external library headers, we can figure out linking them later + + +namespace adios +{ + +CDataMan::CDataMan( MPI_Comm mpiComm, const bool debugMode ): + CTransport( mpiComm, debugMode ) +{ } + +CDataMan::~CDataMan( ) +{ } + + +void CDataMan::Open( const std::string streamName, const std::string accessMode ) +{ + if( accessMode == "w" || accessMode == "write" ) + { + //here open your socket and assign it to this streamName; + } +} + + +void CDataMan::SetBuffer( const std::vector<char>& buffer ) +{ + //empty for now +} + + +void CDataMan::Write( std::vector<char>& buffer ) +{ + //here comes your magic, expect buffer to contain the raw data (using memcpy or insert) from the ADIOS.Write variable + //for now it's a reference, if later it goes out of scope we can move buffer here +} + + +void CDataMan::Close( ) +{ + //close any hanging resources from your transport +} + + +} //end namespace