diff --git a/include/core/CCapsule.h b/include/core/CCapsule.h new file mode 100644 index 0000000000000000000000000000000000000000..b5673c3373c3b525be03e61cf7cca3727963b51a --- /dev/null +++ b/include/core/CCapsule.h @@ -0,0 +1,70 @@ +/* + * CCapsule.h + * + * Created on: Nov 7, 2016 + * Author: wfg + */ + +#ifndef CCAPSULE_H_ +#define CCAPSULE_H_ + +#include <vector> + +#ifdef HAVE_MPI + #include <mpi.h> +#else + #include "public/mpidummy.h" +#endif + +#include "core/CGroup.h" +#include "core/SVariable.h" +#include "core/CTransform.h" +#include "core/CTransport.h" + + +namespace adios +{ + +class CCapsule +{ + +public: + + #ifdef HAVE_MPI + MPI_Comm m_MPIComm = NULL; ///< only used as reference to MPI communicator passed from parallel constructor, MPI_Comm is a pointer itself. Public as called from C + #else + MPI_Comm m_MPIComm = 0; ///< only used as reference to MPI communicator passed from parallel constructor, MPI_Comm is a pointer itself. Public as called from C + #endif + + + std::vector<char> m_Buffer; ///< buffer to be managed, just one type for now + std::map< std::string, std::shared_ptr<CTransform> > m_Transforms; ///< transforms associated with ADIOS run + std::map< std::string, std::shared_ptr<CTransport> > m_Transports; ///< transports associated with ADIOS run + + + CCapsule( ); ///< default empty constructor + + ~CCapsule( ); + + /** + * This will add to the m_Transports and m_Transforms map + * @param group + */ + void OpenGroupBuffer( const CGroup& group ); + + + template< class T> + void WriteVariableToBuffer( const CGroup& group, const SVariable<T>& variable ); + + /** + * Closes the buffer and moves it into the + * @param group + */ + void CloseGroupBuffer( const CGroup& group ); + +}; + + +} //end namespace + +#endif /* CCAPSULE_H_ */ diff --git a/include/core/CGroup.h b/include/core/CGroup.h index 4cb83d8a38eefecb80c4415a6ae889121583d3f2..c94f99c151bb6dcfa2f19a4abaffb58849932e7c 100644 --- a/include/core/CGroup.h +++ b/include/core/CGroup.h @@ -23,7 +23,7 @@ #endif -#include "core/CVariable.h" +#include <core/SVariable.h> #include "core/SAttribute.h" #include "core/CTransport.h" @@ -62,28 +62,15 @@ public: ~CGroup( ); ///< Using STL containers, no deallocation /** - * Opens group and passes fileName and accessMode to m_Transport - * @param fileName - * @param accessMode + * Called from ADIOS open, sets group as active and passes associated bufferName and accessMode + * @param bufferName associated buffer for this group + * @param accessMode associated access mode (read, write, append) for bufferName */ - void Open( const std::string fileName, const std::string accessMode = "w" ); + void Open( const std::string bufferName, const std::string accessMode ); /** - * Passes variableName and values to m_Transport - * @param variableName - * @param values - */ - void Write( const std::string variableName, const void* values ); - - /** - * Must think what to do with Capsule and Transport - */ - void Close( ); - - - /** - * Sets a new variable in the group object + * Creates a new variable in the group object * @param name variable name, must be unique. If name exists it removes the current variable. In debug mode program will exit. * @param type variable type, must be in SSupport::Datatypes[hostLanguage] in public/SSupport.h * @param dimensionsCSV comma separated variable local dimensions (e.g. "Nx,Ny,Nz") @@ -91,29 +78,23 @@ public: * @param globalDimensionsCSV comma separated variable global dimensions (e.g. "gNx,gNy,gNz"), if globalOffsetsCSV is also empty variable is local * @param globalOffsetsCSV comma separated variable global dimensions (e.g. "gNx,gNy,gNz"), if globalOffsetsCSV is also empty variable is local */ - void SetVariable( const std::string name, const std::string type, - const std::string dimensionsCSV, const std::string transform, - const std::string globalDimensionsCSV, const std::string globalOffsetsCSV ); + void CreateVariable( const std::string name, const std::string type, + const std::string dimensionsCSV, const std::string transform, + const std::string globalDimensionsCSV, const std::string globalOffsetsCSV ); /** - * @brief Sets a new attribute in current Group - * @param name attribute name, must be unique. If name exists it removes the current variable. In debug mode program will exit. - * @param isGlobal - * @param type - * @param value + * + * @param name attribute name, must be unique. If name exists it removes the current variable. In debug mode program will exit. + * @param type attribute type string or numeric type + * @param value information about the attribute + * @param globalDimensionsCSV comma separated variable global dimensions (e.g. "gNx,gNy,gNz"), if globalOffsetsCSV is also empty variable is local + * @param globalOffsetsCSV comma separated variable global dimensions (e.g. "gNx,gNy,gNz"), if globalOffsetsCSV is also empty variable is local */ - void SetAttribute( const std::string name, const bool isGlobal, const std::string type, const std::string value ); + void CreateAttribute( const std::string name, const std::string type, const std::string value, + const std::string globalDimensionsCSV, const std::string globalOffsetsCSV ); - /** - * @brief Sets m_Transport with available supported method - * @param method supported values in SSupport.h TransportMethods - * @param priority numeric priority for the I/O to schedule this write with others that might be pending - * @param iteration iterations between writes of a group to gauge how quickly this data should be evacuated from the compute node - * @param mpiComm MPI communicator from User->ADIOS->Group - */ - void SetTransport( const std::string method, const unsigned int priority, const unsigned int iteration, - const MPI_Comm mpiComm ); + void Close( ); ///< set m_IsOpen to false and sets m_BufferName and m_AccessMode to empty /** @@ -127,18 +108,27 @@ public: private: const std::string& m_HostLanguage; ///< reference to class ADIOS m_HostLanguage, this erases the copy constructor. Might be moved later to non-reference const - const bool m_DebugMode = false; ///< if true will do more checks, exceptions, warnings, expect slower code + const bool m_DebugMode = false; ///< if true will do more checks, exceptions, warnings, expect slower code, known at compile time - /** - * @brief Contains all group variables (from XML Config file). - * <pre> - * Key: std::string unique variable name - * Value: Polymorphic value is always unique child defined in SVariableTemplate.h, allow different variable types - * </pre> - */ - std::map< std::string, CVariable > m_Variables; - std::vector< std::string > m_VariableTransforms; ///< if a variable has a transform it fills this container, the variable hold an index + std::map< std::string, std::pair< std::string, unsigned int > > m_Variables; ///< Makes variable name unique, key: variable name, value: pair.first = type, pair.second = index in corresponding vector of CVariable + + std::vector< SVariable<char> > m_Char; ///< Key: variable name, Value: variable of type char + std::vector< SVariable<unsigned char> > m_UChar; ///< Key: variable name, Value: variable of type unsigned char + std::vector< SVariable<short> > m_Short; ///< Key: variable name, Value: variable of type short + std::vector< SVariable<unsigned short> > m_UShort; ///< Key: variable name, Value: variable of type unsigned short + std::vector< SVariable<int> > m_Int; ///< Key: variable name, Value: variable of type int + std::vector< SVariable<unsigned int> > m_UInt; ///< Key: variable name, Value: variable of type unsigned int + std::vector< SVariable<long int> > m_LInt; ///< Key: variable name, Value: variable of type long int + std::vector< SVariable<unsigned long int> > m_ULInt; ///< Key: variable name, Value: variable of type unsigned long int + std::vector< SVariable<long long int> > m_LLInt; ///< Key: variable name, Value: variable of type long long int + std::vector< SVariable<unsigned long long int> > m_ULLInt; ///< Key: variable name, Value: variable of type unsigned long long int + std::vector< SVariable<float> > m_Float; ///< Key: variable name, Value: variable of type float + std::vector< SVariable<double> > m_Double; ///< Key: variable name, Value: variable of type double + std::vector< SVariable<long double> > m_LDouble; ///< Key: variable name, Value: variable of type double + + std::set<std::string> m_SetVariables; ///< set of variables whose T* values have been set (no nullptr) + std::vector< std::string > m_Transforms; ///< if a variable has a transform it fills this container, the variable holds an index /** * @brief Contains all group attributes from SAttribute.h @@ -151,8 +141,9 @@ private: std::vector< std::pair< std::string, std::string > > m_GlobalBounds; ///< if a variable or an attribute is global it fills this container, from global-bounds in XML File, data in global space, pair.first = global dimensions, pair.second = global bounds - std::string m_CurrentTransport; ///< current transport method associated with this group - std::string m_OutputName; ///< associated output (file, stream, buffer, etc.) if the Group is opened. + std::string m_Transport; ///< current transport method associated with this group + std::string m_BufferName; ///< associated buffer (file, stream, vector, etc.) if the Group is opened. + std::string m_AccessMode; /// associated access mode for associated buffer from m_BufferName unsigned long int m_SerialSize; ///< size used for potential serialization of metadata into a std::vector<char>. Counts sizes from m_Variables, m_Attributes, m_GlobalBounds @@ -162,11 +153,23 @@ private: */ void ParseXMLGroup( const std::string& xmlGroup ); + + const unsigned int CurrentTypeIndex( const std::string type ) const noexcept; + + /** + * Used by SetVariable and SetAttribute to check if global bounds exist in m_GlobalBounds + * @param globalDimensionsCSV comma separated variables defining global dimensions (e.g. "Nx,NY,Nz") + * @param globalOffsetsCSV comma separated variables defining global offsets (e.g. "oNx,oNY,oNz") + * @return -1 if not global -> both inputs are empty, otherwise index in m_GlobalBounds if exist or create a new element in m_GlobalBounds; + */ + const int SetGlobalBounds( const std::string globalDimensionsCSV, const std::string globalOffsetsCSV ) noexcept; + /** - * Function that checks if transport method is valid, called from overloaded SetTransform functions - * @param method transport method to be checked from SSupport + * Used by SetVariable to check if transform exists in m_Transform + * @param transform variable transformation method (e.g. bzip2, szip, zlib ) + * @return -1 variable is not associated with a transform, otherwise index in m_Transforms */ - void CheckTransport( const std::string method ); + const int SetTransforms( const std::string transform ) noexcept; }; diff --git a/include/core/CTransform.h b/include/core/CTransform.h index 97c899e0fa17378a09d35128efdab840795dc3b0..7d5e457038cbfb3ec322037630f39f9affecf958 100644 --- a/include/core/CTransform.h +++ b/include/core/CTransform.h @@ -10,7 +10,7 @@ /// \cond EXCLUDE_FROM_DOXYGEN -#include <core/CVariable.h> +#include <core/SVariable.h> #include <string> /// \endcond @@ -29,17 +29,14 @@ public: const std::string m_Method; ///< name of the transformation method const unsigned int m_CompressionLevel; ///< depends on library implementation - CVariableBase& m_Variable; ///< variable to be transformed /** * Initialize parent method * @param method zlib, bzip2, szip * @param variable */ - CTransform( const std::string method, const unsigned int compressionLevel, CVariableBase& variable ): - m_Method( method ), - m_CompressionLevel( compressionLevel ), - m_Variable( variable ) + CTransform( const unsigned int compressionLevel ): + m_CompressionLevel( compressionLevel ) { } virtual ~CTransform( ){ }; diff --git a/include/core/CTransport.h b/include/core/CTransport.h index c68219cafdf5a28491f870e3789c9c5aade616ab..b125e74ac4d18024a1e6aca2e1583e4bd5d36e7c 100644 --- a/include/core/CTransport.h +++ b/include/core/CTransport.h @@ -18,7 +18,6 @@ #include "public/mpidummy.h" #endif -#include <core/CVariable.h> namespace adios @@ -29,7 +28,6 @@ class CTransport public: - const std::string m_Method; ///< method name, must be defined in SSupport.h TransportMethods const unsigned int m_Priority; ///< writing priority for this transport const unsigned int m_Iteration; ///< iteration number for this transport MPI_Comm m_MPIComm; ///< passed MPI communicator @@ -50,7 +48,6 @@ public: */ CTransport( const std::string method, const unsigned int priority, const unsigned int iteration, MPI_Comm mpiComm, const bool debugMode ): - m_Method( method ), m_Priority( priority ), m_Iteration( iteration ), m_MPIComm( mpiComm ), @@ -71,9 +68,6 @@ public: */ virtual void Open( const std::string outputName, const std::string accessMode ) = 0; - virtual void Write( const CVariableBase& variable ) - { }; - virtual void Close( ) = 0; //here think what needs to be passed virtual void Finalize( ) diff --git a/include/core/CVariable.h b/include/core/CVariable.h deleted file mode 100644 index 82e575b019fd37acc06a1b3b84cf7e723b7a34b0..0000000000000000000000000000000000000000 --- a/include/core/CVariable.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * CVariable.h - * - * Created on: Oct 6, 2016 - * Author: wfg - */ - -#ifndef CVARIABLE_H_ -#define CVARIABLE_H_ - -/// \cond EXCLUDE_FROM_DOXYGEN -#include <string> -#include <vector> -#include <typeinfo> // for typeid -#include <sstream> -/// \endcond - - -namespace adios -{ -/** - * @param Base (parent) class for template derived (child) class CVariable. Required to put CVariable objects in STL containers. - */ -class CVariable -{ - -public: - - /** - * Unique constructor for local and global variables - * @param type variable type, must be in SSupport::Datatypes[hostLanguage] in public/SSupport.h - * @param dimensionsCSV comma separated variable local dimensions (e.g. "Nx,Ny,Nz") - * @param transformIndex - * @param globalIndex - */ - CVariable( const std::string type, const std::string dimensionsCSV, - const int globalIndex, const int transformIndex ); - - virtual ~CVariable( ); - - void* m_Values; - - -protected: - - const std::string m_Type; ///< mandatory, double, float, unsigned integer, integer, etc. - const std::string m_DimensionsCSV; ///< comma separated list for variables to search for local dimensions -}; - - -} //end namespace - - - -#endif /* CVARIABLE_H_ */ diff --git a/include/core/SVariable.h b/include/core/SVariable.h new file mode 100644 index 0000000000000000000000000000000000000000..f4dc4738598c1884ede07c767ca7fbb959f8fa60 --- /dev/null +++ b/include/core/SVariable.h @@ -0,0 +1,40 @@ +/* + * CVariable.h + * + * Created on: Oct 6, 2016 + * Author: wfg + */ + +#ifndef SVARIABLE_H_ +#define SVARIABLE_H_ + +/// \cond EXCLUDE_FROM_DOXYGEN +#include <string> +#include <vector> +#include <typeinfo> // for typeid +#include <sstream> +/// \endcond + +#include "core/CGroup.h" //friend class (manager) + +namespace adios +{ + +/** + * @param Base (parent) class for template derived (child) class CVariable. Required to put CVariable objects in STL containers. + */ +template< class T > +struct SVariable +{ + const std::string m_DimensionsCSV; ///< comma separated list for variables to search for local dimensions + const T* m_Values; + const int m_TransformIndex; ///< if global > 0, index corresponds to , if local then = -1 + const int m_GlobalBoundsIndex; ///< if global > 0, index corresponds to global-bounds in m_GlobalBounds in CGroup, if local then = -1 +}; + + +} //end namespace + + + +#endif /* SVARIABLE_H_ */ diff --git a/include/functions/ADIOSTemplates.h b/include/functions/ADIOSTemplates.h new file mode 100644 index 0000000000000000000000000000000000000000..4ad576df0daffb1c0468ef320bf7334d912c1183 --- /dev/null +++ b/include/functions/ADIOSTemplates.h @@ -0,0 +1,107 @@ +/* + * GroupTemplates.h + * + * Created on: Nov 7, 2016 + * Author: wfg + */ + +#ifndef ADIOSTEMPLATES_H_ +#define ADIOSTEMPLATES_H_ + +#include "core/CGroup.h" +#include "core/SVariable.h" +#include "core/CCapsule.h" + + +namespace adios +{ + +template< class T > +void WriteVariable( const std::string variableName, const T* values, CGroup& group, CCapsule& capsule ) noexcept +{ + auto itVariable = group.m_Variables.find( variableName ); + const std::string type( itVariable->second.first ); + const unsigned int index( itVariable->second.second ); + group.m_SetVariables.insert( variableName ); + + if( std::is_same<T,char> ) + { + SVariable<char>& variable = group.m_Char[index]; + variable.m_Values = values; + capsule.WriteVariableToBuffer( group, variable ); + } + else if( std::is_same<T,unsigned char> ) + { + SVariable<unsigned char>& variable = group.m_UChar[index]; + variable.m_Values = values; + capsule.WriteVariableToBuffer( group, variable ); + } + else if( std::is_same<T,short> ) + { + SVariable<short>& variable = group.m_Short[index]; + variable.m_Values = values; + capsule.WriteVariableToBuffer( group, variable ); + } + else if( std::is_same<T,unsigned short> ) + { + SVariable<unsigned short>& variable = group.m_UShort[index]; + variable.m_Values = values; + capsule.WriteVariableToBuffer( group, variable ); + } + else if( std::is_same<T,int> ) + { + SVariable<int>& variable = group.m_Int[index]; + variable.m_Values = values; + capsule.WriteVariableToBuffer( group, variable ); + } + else if( std::is_same<T,unsigned int> ) + { + SVariable<unsigned int>& variable = group.m_Int[index]; + variable.m_Values = values; + capsule.WriteVariableToBuffer( group, variable ); + } + else if( std::is_same<T,long int> ) + { + SVariable<long int>& variable = group.m_LInt[index]; + variable.m_Values = values; + capsule.WriteVariableToBuffer( group, variable ); + } + else if( std::is_same<T,long long int> ) + { + SVariable<long int>& variable = group.m_LLInt[index]; + variable.m_Values = values; + capsule.WriteVariableToBuffer( group, variable ); + } + else if( std::is_same<T,unsigned long long int> ) + { + SVariable<unsigned long long int>& variable = group.m_ULLInt[index]; + variable.m_Values = values; + capsule.WriteVariableToBuffer( group, variable ); + } + else if( std::is_same<T,float> ) + { + SVariable<float>& variable = group.m_Float[index]; + variable.m_Values = values; + capsule.WriteVariableToBuffer( group, variable ); + } + else if( std::is_same<T,double> ) + { + SVariable<double>& variable = group.m_Double[index]; + variable.m_Values = values; + capsule.WriteVariableToBuffer( group, variable ); + } + else if( std::is_same<T,long double> ) + { + SVariable<double>& variable = group.m_Double[index]; + variable.m_Values = values; + capsule.WriteVariableToBuffer( group, variable ); + } +} + + + +} //end namespace + + + +#endif /* ADIOSTEMPLATES_H_ */ diff --git a/include/functions/GroupFunctions.h b/include/functions/GroupFunctions.h deleted file mode 100644 index 81d3c669731f1faa17c8d5702f6461a09d6a9a4f..0000000000000000000000000000000000000000 --- a/include/functions/GroupFunctions.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -ri * GroupFunctions.h helper functions for class CGroup - * - * Created on: Oct 27, 2016 - * Author: wfg - */ - -#ifndef GROUPFUNCTIONS_H_ -#define GROUPFUNCTIONS_H_ - -/// \cond EXCLUDE_FROM_DOXYGEN -#include <string> -#include <map> -#include <memory> //unique_ptr -/// \endcond - -#ifdef HAVE_MPI - #include <mpi.h> -#else - #include "public/mpidummy.h" -#endif - -#include <core/CVariable.h> -#include "core/CTransport.h" - - -namespace adios -{ - -/** - * Create a language (C++, C, Fortran, etc.) supported type variable and add it to variables map - * @param name key in variables map - * @param type variable type, must be in SSupport::Datatypes[hostLanguage] in public/SSupport.h - * @param dimensionsCSV comma separated variable local dimensions (e.g. "Nx,Ny,Nz") - * @param transform method, format = lib or lib:level, where lib = zlib, bzip2, szip, and level=1:9 - * @param globalDimensionsCSV comma separated variable global dimensions (e.g. "gNx,gNy,gNz"), if globalOffsetsCSV is also empty variable is local - * @param globalOffsetsCSV comma separated variable global dimensions (e.g. "gNx,gNy,gNz"), if globalOffsetsCSV is also empty variable is local - * @param variables map belonging to class CGroup - */ -void CreateVariableLanguage( const std::string name, const std::string type, - const std::string dimensionsCSV, const std::string transform, - const std::string globalDimensionsCSV, const std::string globalOffsetsCSV, - std::map<std::string, std::shared_ptr<CVariableBase> >& variables ) noexcept; - - -/** - * Looks up the variable type and cast the appropriate values type to m_Value in CVariable - * @param variables always a derived CVariable object from CVariableBase - * @param values to be casted to the right type - */ -void SetVariableValues( CVariableBase& variable, const void* values ) noexcept; - - - -/** - * Create a derived (child) class of CTransport in transport unique_ptr - * @param method supported values in SSupport.h TransportMethods - * @param priority numeric priority for the I/O to schedule this write with others that might be pending - * @param iteration iterations between writes of a group to gauge how quickly this data should be evacuated from the compute node - * @param mpiComm MPI communicator from User->ADIOS->Group - * @param transport passed from CGroup m_Transport member - */ -void CreateTransport( const std::string method, const unsigned int priority, const unsigned int iteration, - const MPI_Comm mpiComm, const bool debugMode, std::shared_ptr<CTransport>& transport ) noexcept; - - - -} //end namespace - -#endif /* GROUPFUNCTIONS_H_ */ diff --git a/include/public/ADIOS.h b/include/public/ADIOS.h index d0c3687cb0f1cc2211d63a7930a1450d5cf07eea..cab0a546580750b4973d2eb537460cad401d73cf 100644 --- a/include/public/ADIOS.h +++ b/include/public/ADIOS.h @@ -21,9 +21,9 @@ #endif #include "core/CGroup.h" -#include "core/CTransport.h" -#include "core/CTransform.h" +#include "core/CCapsule.h" #include "public/SSupport.h" +#include "functions/ADIOSTemplates.h" namespace adios @@ -70,6 +70,7 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO */ ADIOS( const MPI_Comm mpiComm, const bool debugMode = false ); + ~ADIOS( ); ///< virtual destructor overriden by children's own destructors /** @@ -86,7 +87,19 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO * @param variableName name of existing scalar or vector variable in the XML file or created with CreateVariable * @param values pointer to the variable values passed from the user application, use dynamic_cast to check that pointer is of the same value type */ - void Write( const std::string groupName, const std::string variableName, const void* values ); + template< class T> + void Write( const std::string groupName, const std::string variableName, T* values ) + { + auto itGroup = m_Groups.find( groupName ); + if( m_DebugMode == true ) + { + CheckGroup( itGroup, groupName, " from call to Write with variable " + variableName ); + + 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 ); + } /** * Close a particular group, group will be out of scope and destroyed @@ -118,7 +131,7 @@ private: */ std::map< std::string, CGroup > m_Groups; - std::map< std::string, std::shared_ptr<CTransform> > m_Transforms; + CCapsule m_Capsule; ///< manager of data transports, transforms and movement operations /** * @brief Maximum buffer size in ADIOS write() operation. From buffer max - size - MB in XML file diff --git a/include/transport/CDIMES.h b/include/transport/CDIMES.h index 81f7a4fd886ea0c70e521e363a5a69a4131d707b..e9589b8a61f65b324ef1982e08710eaabee56306 100644 --- a/include/transport/CDIMES.h +++ b/include/transport/CDIMES.h @@ -26,7 +26,6 @@ public: ~CDIMES( ); - void Write( const CVariable& variable ); }; diff --git a/include/transport/CDataspaces.h b/include/transport/CDataspaces.h index d0aec4748e7a6c6cbb46da893b87a870c6892f24..b07bda23b8857fa2ba971d712b7e7f0e1c174374 100644 --- a/include/transport/CDataspaces.h +++ b/include/transport/CDataspaces.h @@ -25,7 +25,6 @@ public: ~CDataspaces( ); - void Write( const CVariable& variable ); }; diff --git a/include/transport/CFStream.h b/include/transport/CFStream.h index b31419ed04a6ff17047cd69e402ce3d847ceaef3..084c88ee818d627b11af86536316703c59307002 100644 --- a/include/transport/CFStream.h +++ b/include/transport/CFStream.h @@ -30,8 +30,6 @@ public: void Open( const std::string fileName, const std::string accessMode ); - void Write( const CVariableBase& variable ); - void Close( ); private: diff --git a/include/transport/CFlexpath.h b/include/transport/CFlexpath.h index f789369cbcb25b62232cdb9fb1f5dddd7a63c44a..d4ded095a445e7659794a4d3b646190c0de5f970 100644 --- a/include/transport/CFlexpath.h +++ b/include/transport/CFlexpath.h @@ -24,7 +24,6 @@ public: ~CFlexpath( ); - void Write( const CVariable& variable ); }; diff --git a/include/transport/CICEE.h b/include/transport/CICEE.h index a9aef64a9546ee7150175d814c821581fd2a5533..d151badbe2c48a56634fdced8592a02f1260200d 100644 --- a/include/transport/CICEE.h +++ b/include/transport/CICEE.h @@ -24,8 +24,6 @@ public: ~CICEE( ); - void Write( const CVariable& variable ); - }; diff --git a/include/transport/CMPI.h b/include/transport/CMPI.h index 5f44ee743f602785f6b89d543797eedd0f610375..b48582664ad9a8506efed1a3e4b6dbbfa72a5b99 100644 --- a/include/transport/CMPI.h +++ b/include/transport/CMPI.h @@ -26,7 +26,6 @@ public: ~CMPI( ); - void Write( const CVariable& variable ); }; diff --git a/include/transport/CMPIAggregate.h b/include/transport/CMPIAggregate.h index dbec7c8c7855c1fc826eadbcd0bdf391c10b8fa8..24f387f96ab06de1cac8bd8fd01835f94de82252 100644 --- a/include/transport/CMPIAggregate.h +++ b/include/transport/CMPIAggregate.h @@ -26,7 +26,6 @@ public: ~CMPIAggregate( ); - void Write( const CVariable& variable ); }; diff --git a/include/transport/CMPILustre.h b/include/transport/CMPILustre.h index bb3d012030f030a18083630fc5b981d6e3db3419..28ec77c953f56e7f1b205f2a7edc82eb39304391 100644 --- a/include/transport/CMPILustre.h +++ b/include/transport/CMPILustre.h @@ -25,7 +25,6 @@ public: ~CMPILustre( ); - void Write( const CVariable& variable ); }; diff --git a/include/transport/CNetCDF4.h b/include/transport/CNetCDF4.h index a84f14b568a8d9024a7f7e94d270098f0424b7fe..5108040e2b37c11d0c2913ea42da65bedad92795 100644 --- a/include/transport/CNetCDF4.h +++ b/include/transport/CNetCDF4.h @@ -26,8 +26,6 @@ public: ~CNetCDF4( ); - void Write( const CVariable& variable ); - }; diff --git a/include/transport/CPHDF5.h b/include/transport/CPHDF5.h index 74d9cecb1eb3b50493674f68955b27b411c8c750..285ead7b2f008e1d7b2c6b598a349ed87608a4af 100644 --- a/include/transport/CPHDF5.h +++ b/include/transport/CPHDF5.h @@ -26,7 +26,6 @@ public: ~CPHDF5( ); - void Write( const CVariable& variable ); }; diff --git a/include/transport/CPOSIX.h b/include/transport/CPOSIX.h index ee6567fca49915cb04781f9a092070e2e30ab552..e1ca3b8ca9ba7ee33ff1645c0af141f147d84a5a 100644 --- a/include/transport/CPOSIX.h +++ b/include/transport/CPOSIX.h @@ -27,8 +27,6 @@ public: void Open( const std::string fileName, const std::string accessMode ); - void Write( const CVariableBase& variable ); - void Close( ); }; diff --git a/include/transport/CVarMerge.h b/include/transport/CVarMerge.h index b2dfe61724605f59ea00e46f803bc6305424195d..bb80499cabb60bbbcc0a984af16dbb5f001d4b64 100644 --- a/include/transport/CVarMerge.h +++ b/include/transport/CVarMerge.h @@ -25,8 +25,6 @@ public: ~CVarMerge( ); - void Write( const CVariable& variable ); - }; diff --git a/src/core/CCapsule.cpp b/src/core/CCapsule.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6e39ebbe685f31249a05e0ff3ccb4c8296001e1c --- /dev/null +++ b/src/core/CCapsule.cpp @@ -0,0 +1,22 @@ +/* + * CCapsule.cpp + * + * Created on: Nov 7, 2016 + * Author: wfg + */ + + + +#include "core/CCapsule.h" + + + +namespace adios +{ + + + + +} + + diff --git a/src/core/CGroup.cpp b/src/core/CGroup.cpp index a178628e4015ef5543171183873a19eb360619cc..0a266f3822595b5bab4253e617c7dd2dc9490ec6 100644 --- a/src/core/CGroup.cpp +++ b/src/core/CGroup.cpp @@ -5,13 +5,14 @@ * Author: wfg */ + #include <iostream> +#include <algorithm> // find #include "core/CGroup.h" -#include "functions/GroupFunctions.h" //for CreateVariableLanguage +#include "core/SVariable.h" //for cast implementation of CVariableBase::Set that calls CVariable::Set #include "public/SSupport.h" #include "functions/ADIOSFunctions.h" //for XML Parsing functions (e.g. GetTag) -#include "core/CVariable.h" //for cast implementation of CVariableBase::Set that calls CVariable::Set namespace adios @@ -38,87 +39,99 @@ CGroup::~CGroup( ) { } -void CGroup::Open( const std::string fileName, const std::string accessMode ) +void CGroup::Open( const std::string bufferName, const std::string accessMode ) { m_IsOpen = true; + m_BufferName = bufferName; + m_AccessMode = accessMode; } -void CGroup::SetVariable( const std::string name, const std::string type, - const std::string dimensionsCSV, const std::string transform, - const std::string globalDimensionsCSV, const std::string globalOffsetsCSV ) +void CGroup::CreateVariable( const std::string name, const std::string type, + const std::string dimensionsCSV, const std::string transform, + const std::string globalDimensionsCSV, const std::string globalOffsetsCSV ) { if( m_DebugMode == true ) { if( SSupport::Datatypes.at( m_HostLanguage ).count( type ) == 0 ) throw std::invalid_argument( "ERROR: type " + type + " for variable " + name + " is not supported.\n" ); - if( m_Variables.count( name ) == 0 ) //variable doesn't exists - CreateVariableLanguage( name, type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV, m_Variables ); + m_Variables[name] = std::make_pair( type, CurrentTypeIndex( type ) ); else //name is found throw std::invalid_argument( "ERROR: variable " + name + " exists more than once.\n" ); } else { - CreateVariableLanguage( name, type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV, m_Variables ); + m_Variables[name] = std::make_pair( type, CurrentTypeIndex( type ) ); } -} + int transformIndex = SetTransforms( transform ); + int globalBoundsIndex = SetGlobalBounds( globalDimensionsCSV, globalOffsetsCSV ); -void CGroup::SetAttribute( const std::string name, const bool isGlobal, const std::string type, - const std::string value ) -{ - if( m_DebugMode == true ) - { - if( m_Attributes.count( name ) == 0 ) //variable doesn't exists - m_Attributes.emplace( name, SAttribute{ isGlobal, type, value } ); - else //name is found - throw std::invalid_argument( "ERROR: attribute " + name + " exists, NOT setting a new variable\n" ); - } - else - { - m_Attributes.emplace( name, SAttribute{ isGlobal, type, value } ); - } -} + if( type == "char" || type == "character" ) + m_Char.push_back( SVariable<char>{ dimensionsCSV, nullptr, transformIndex, globalBoundsIndex } ); + else if( type == "unsigned char" ) + m_UChar.push_back( SVariable<unsigned char>{ dimensionsCSV, nullptr, transformIndex, globalBoundsIndex } ); -void CGroup::SetTransport( const std::string method, const unsigned int priority, const unsigned int iteration, - const MPI_Comm mpiComm ) -{ - if( m_DebugMode == true ) - { - if( SSupport::Transports.count( method ) == 0 ) - throw std::invalid_argument( "ERROR: transport method " + method + " not supported. Check spelling or case sensitivity.\n" ); - } + else if( type == "short" || type == "integer*2" ) + m_Short.push_back( SVariable<short>{ dimensionsCSV, nullptr, transformIndex, globalBoundsIndex } ); + + else if( type == "unsigned short" ) + m_UShort.push_back( SVariable<unsigned short>{ dimensionsCSV, nullptr, transformIndex, globalBoundsIndex } ); - if( m_ActiveTransport.empty() == false ) //there is an existing transport method, so reset - m_Transport.reset(); + else if( type == "int" || type == "integer" ) + m_Int.push_back( SVariable<int>{ dimensionsCSV, nullptr, transformIndex, globalBoundsIndex } ); - CreateTransport( method, priority, iteration, mpiComm, m_DebugMode, m_Transport ); - m_ActiveTransport = method; + else if( type == "unsigned int" || type == "unsigned integer" ) + m_UInt.push_back( SVariable<unsigned int>{ dimensionsCSV, nullptr, transformIndex, globalBoundsIndex } ); + + else if( type == "long int" || type == "long" || type == "long integer" ) + m_LInt.push_back( SVariable<long int>{ dimensionsCSV, nullptr, transformIndex, globalBoundsIndex } ); + + else if( type == "long long int" || type == "long long" || type == "long long integer" ) + m_LLInt.push_back( SVariable<long long int>{ dimensionsCSV, nullptr, transformIndex, globalBoundsIndex } ); + + else if( type == "unsigned long long int" || type == "unsigned long long" || type == "unsigned long long integer" ) + m_ULLInt.push_back( SVariable<unsigned long long int>{ dimensionsCSV, nullptr, transformIndex, globalBoundsIndex } ); + + else if( type == "float" || type == "real" || type == "real*4" ) + m_Float.push_back( SVariable<float>{ dimensionsCSV, nullptr, transformIndex, globalBoundsIndex } ); + + else if( type == "double" || type == "double precision" || type == "real*8" ) + m_Double.push_back( SVariable<double>{ dimensionsCSV, nullptr, transformIndex, globalBoundsIndex } ); + + else if( type == "long double" || type == "real*16" ) + m_LDouble.push_back( SVariable<long double>{ dimensionsCSV, nullptr, transformIndex, globalBoundsIndex } ); } -void CGroup::Write( const std::string variableName, const void* values ) +void CGroup::CreateAttribute( const std::string name, const std::string type, const std::string value, + const std::string globalDimensionsCSV, const std::string globalOffsetsCSV ) { - auto itVariable = m_Variables.find( variableName ); + auto lf_EmplaceVariable = [&]( const std::string name, const std::string type, const std::string value, + const std::string globalDimensionsCSV, const std::string globalOffsetsCSV ) + { + const int globalBoundsIndex = SetGlobalBounds( globalDimensionsCSV, globalOffsetsCSV ); + m_Attributes.emplace( name, SAttribute{ type, value, globalBoundsIndex } ); + }; if( m_DebugMode == true ) { - if( itVariable == m_Variables.end() ) - throw std::invalid_argument( "ERROR: variable " + variableName + " is undefined.\n" ); + if( m_Attributes.count( name ) == 0 ) //variable doesn't exists + lf_EmplaceVariable( name, type, value, globalDimensionsCSV, globalOffsetsCSV ); + else //name is found + throw std::invalid_argument( "ERROR: attribute " + name + " exists, NOT setting a new variable\n" ); } - - SetVariableValues( *itVariable->second, values ); //will check type and cast to appropriate template<type> - //here must do something with Capsule or transport - m_Transport->Write( *itVariable->second ); //transport will write? + else + lf_EmplaceVariable( name, type, value, globalDimensionsCSV, globalOffsetsCSV ); } - void CGroup::Close( ) { - //here must think what to do with Capsule and close Transport - m_Transport->Close( ); + m_IsOpen = false; + m_BufferName.clear(); + m_AccessMode.clear(); } //PRIVATE FUNCTIONS BELOW @@ -127,7 +140,7 @@ void CGroup::Monitor( std::ostream& logStream ) const logStream << "\tVariable \t Type\n"; for( auto& variablePair : m_Variables ) { - logStream << "\t" << variablePair.first << " \t " << variablePair.second->m_Type << "\n"; + logStream << "\t" << variablePair.first << " \t " << variablePair.second.first << "\n"; } std::cout << "\n"; @@ -138,7 +151,7 @@ void CGroup::Monitor( std::ostream& logStream ) const } std::cout << "\n"; - logStream << "\tTransport Method " << m_ActiveTransport << "\n"; + logStream << "\tTransport Method " << m_Transport << "\n"; std::cout << "\n"; } @@ -146,7 +159,6 @@ void CGroup::Monitor( std::ostream& logStream ) const void CGroup::ParseXMLGroup( const std::string& xmlGroup ) { std::string::size_type currentPosition( 0 ); - bool isGlobal = false; //used to set attributes std::string globalDimensionsCSV; //used to set variables std::string globalOffsetsCSV; //used to set variables @@ -159,7 +171,6 @@ void CGroup::ParseXMLGroup( const std::string& xmlGroup ) if( tag == "</global-bounds>" ) { - isGlobal = false; //used for attributes globalDimensionsCSV.clear(); //used for variables globalOffsetsCSV.clear(); //used for variables } @@ -189,7 +200,7 @@ void CGroup::ParseXMLGroup( const std::string& xmlGroup ) else if( pair.first == "dimensions" ) dimensionsCSV = pair.second; else if( pair.first == "transform" ) transform = pair.second; } - SetVariable( name, type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); + CreateVariable( name, type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); } else if( tagName == "attribute" ) { @@ -200,7 +211,7 @@ void CGroup::ParseXMLGroup( const std::string& xmlGroup ) else if( pair.first == "value" ) value = pair.second; else if( pair.first == "type" ) type = pair.second; } - SetAttribute( name, isGlobal, type, value ); + CreateAttribute( name, type, value, globalDimensionsCSV, globalOffsetsCSV ); } else if( tagName == "global-bounds" ) { @@ -217,14 +228,103 @@ void CGroup::ParseXMLGroup( const std::string& xmlGroup ) if( globalDimensionsCSV.empty() ) throw std::invalid_argument( "ERROR: dimensions missing in global-bounds tag\n"); - if( globalDimensionsCSV.empty() ) + if( globalOffsetsCSV.empty() ) throw std::invalid_argument( "ERROR: offsets missing in global-bounds tag\n"); } - - isGlobal = true; } } //end while loop } +const unsigned int CGroup::CurrentTypeIndex( const std::string type ) const noexcept +{ + unsigned int index; + + if( type == "char" || type == "character" ) + index = m_Char.size(); + + else if( type == "unsigned char" ) + index = m_UChar.size(); + + else if( type == "short" || type == "integer*2" ) + index = m_Short.size(); + + else if( type == "unsigned short" ) + index = m_UShort.size(); + + else if( type == "int" || type == "integer" ) + index = m_Int.size(); + + else if( type == "unsigned int" || type == "unsigned integer" ) + index = m_UInt.size(); + + else if( type == "long int" || type == "long" || type == "long integer" ) + index = m_LInt.size(); + + else if( type == "unsigned long int" || type == "unsigned long" || type == "unsigned long integer" ) + index = m_ULInt.size(); + + else if( type == "long long int" || type == "long long" || type == "long long integer" ) + index = m_LLInt.size(); + + else if( type == "unsigned long long int" || type == "unsigned long long" || type == "unsigned long long integer" ) + index = m_ULLInt.size(); + + else if( type == "float" || type == "real" || type == "real*4" ) + index = m_Float.size(); + + else if( type == "double" || type == "double precision" || type == "real*8" ) + index = m_Double.size(); + + else if( type == "long double" || type == "real*16" ) + index = m_LDouble.size(); + + return index; +} + + +const int CGroup::SetGlobalBounds( const std::string globalDimensionsCSV, const std::string globalOffsetsCSV ) noexcept +{ + if( globalDimensionsCSV.empty() || globalOffsetsCSV.empty() ) + return -1; + + int globalBoundsIndex = -1; + const auto globalBounds = std::make_pair( globalDimensionsCSV, globalOffsetsCSV ); + auto itGlobalBounds = std::find( m_GlobalBounds.begin(), m_GlobalBounds.end(), globalBounds ); + + if( itGlobalBounds != m_GlobalBounds.end() ) + { + globalBoundsIndex = std::distance( m_GlobalBounds.begin(), itGlobalBounds ); + } + else + { + m_GlobalBounds.push_back( globalBounds ); + globalBoundsIndex = m_GlobalBounds.size(); + } + + return globalBoundsIndex; +} + + +const int CGroup::SetTransforms( const std::string transform ) noexcept +{ + if( transform.empty() ) + return -1; + + int transformIndex = -1; + auto itTransform = std::find( m_Transforms.begin(), m_Transforms.end(), transform ); + if( itTransform != m_Transforms.end() ) + { + transformIndex = std::distance( m_Transforms.begin(), itTransform ); + } + else + { + m_Transforms.push_back( transform ); + transformIndex = m_Transforms.size(); + } + + return transformIndex; +} + + } //end namespace diff --git a/src/core/CVariable.cpp b/src/core/CVariable.cpp deleted file mode 100644 index eec3520ee564abee07c62ee7b6343a51948706b8..0000000000000000000000000000000000000000 --- a/src/core/CVariable.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* - * CVariable.cpp - * - * Created on: Oct 18, 2016 - * Author: wfg - */ - - -#include "core/CVariable.h" - -namespace adios -{ - -CVariable::CVariable( const std::string type, const std::string dimensionsCSV, const std::string transform, - const std::string globalDimensionsCSV, const std::string globalOffsetsCSV ): - m_Type{ type }, - m_DimensionsCSV{ dimensionsCSV }, - m_Transform{ transform }, - m_GlobalDimensionsCSV{ globalDimensionsCSV }, - m_GlobalOffsetsCSV{ globalOffsetsCSV } -{ - if( m_GlobalDimensionsCSV.empty() || m_GlobalOffsetsCSV.empty() ) - m_IsGlobal = false; - else - m_IsGlobal = true; -} - - -CVariable::~CVariable() -{ } - - -} //end namespace diff --git a/src/functions/GroupFunctions.cpp b/src/functions/GroupFunctions.cpp deleted file mode 100644 index dafe410d561e11fabf900cd667742f5f8d2569bb..0000000000000000000000000000000000000000 --- a/src/functions/GroupFunctions.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/* - * GroupFunctions.cpp - * - * Created on: Oct 27, 2016 - * Author: wfg - */ -#include <complex> - -#include "functions/GroupFunctions.h" -#include "core/CVariable.h" - -//transports -#include "transport/CPOSIX.h" -#include "transport/CFStream.h" - - -namespace adios -{ - - -void CreateVariableLanguage( const std::string name, const std::string type, - const std::string dimensionsCSV, const std::string transform, - const std::string globalDimensionsCSV, const std::string globalOffsetsCSV, - std::map<std::string, std::shared_ptr<CVariableBase> >& variables ) noexcept -{ - std::shared_ptr<CVariableBase> variable; - //Common Primitive types to most languages - if( type == "char" || type == "character" ) - variable = std::make_shared< CVariable<char> >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "unsigned char" ) - variable = std::make_shared< CVariable<unsigned char> >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "short" || type == "integer*2" ) - variables = std::make_shared< CVariable<short> >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "unsigned short" ) - variables = std::make_shared< CVariable<unsigned short> >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "int" || type == "integer" ) - variables = std::make_shared< CVariable<int> >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "unsigned int" || type == "unsigned integer" ) - variable = std::make_shared< CVariable<unsigned int> >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "long int" || type == "long" || type == "long integer" ) - variable = std::make_shared< CVariable<long int> >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "long long int" || type == "long long" || type == "long long integer" ) - variable = std::make_shared< CVariable<long long int> >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "float" || type == "real" || type == "real*4" ) - variable = std::make_shared< CVariable<float> >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "double" || type == "double precision" || type == "real*8" ) - variable = std::make_shared< CVariable<double> >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "long double" || type == "real*16" ) - variable = std::make_shared< CVariable<long double> >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - //C++ - else if( type == "std::string" || type == "string" ) - variable = std::make_shared< CVariable<std::string> >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "std::vector<char>" || type == "vector<char>" ) - variable = std::make_shared< CVariable< std::vector<char> > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "std::vector<int>" || type == "vector<int>" ) - variable = std::make_shared< CVariable< std::vector<int> > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "std::vector<unsigned int>" || type == "vector<unsigned int>" ) - variable = std::make_shared< CVariable< std::vector<unsigned int> > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "std::vector<long int>" || type == "std::vector<long>" || - type == "vector<long int>" || type == "vector<long>" ) - variable = std::make_shared< CVariable<std::vector<long int> > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "std::vector<long long int>" || type == "std::vector<long long>" || - type == "vector<long long int>" || type == "vector<long long>" ) - variable = std::make_shared< CVariable< std::vector<long long int> > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "std::vector<float>" || type == "vector<float>" ) - variable = std::make_shared< CVariable< std::vector<float> > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "std::vector<double>" || type == "vector<double>" ) - variable = std::make_shared< CVariable< std::vector<double> > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "std::vector<long double>" || type == "vector<long double>" ) - variable = std::make_shared< CVariable< std::vector<long double> > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - //STL Complex types - else if( type == "std::complex<float>" || type == "complex<float>" ) - variable = std::make_shared< CVariable< std::complex<float> > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "std::complex<double>" || type == "complex<double>" ) - variable = std::make_shared< CVariable< std::complex<double> > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "std::complex<long double>" || type == "complex<long double>" ) - variable = std::make_shared< CVariable< std::complex<long double> > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "std::vector<std::complex<float>>" || type == "vector<complex<float>>" ) - variable = std::make_shared< CVariable< std::vector< std::complex<float> > > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "std::vector<std::complex<double>>" || type == "vector<complex<double>>" ) - variable = std::make_shared< CVariable< std::vector< std::complex<double> > > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "std::vector<std::complex<long double>>" || type == "vector<complex<long double>>" ) - variable = std::make_shared< CVariable< std::vector< std::complex<long double> > > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - variables[name] = variable; -} - - -void SetVariableValues( CVariableBase& variable, const void* values ) noexcept -{ - const std::string type( variable.m_Type ); - - if( type == "char" || type == "character" ) - variable.Set<char>( values ); - - else if( type == "unsigned char" ) - variable.Set<unsigned char>( values ); - - else if( type == "short" || type == "integer*2" ) - variable.Set<short>( values ); - - else if( type == "unsigned short" ) - variable.Set<unsigned short>( values ); - - else if( type == "int" || type == "integer" ) - variable.Set<int>( values ); - - else if( type == "unsigned int" || type == "unsigned integer" ) - variable.Set<unsigned int>( values ); - - else if( type == "long int" || type == "long" || type == "long integer" ) - variable.Set<long int>( values ); - - else if( type == "long long int" || type == "long long" || type == "long long integer" ) - variable.Set<long long int>( values ); - - else if( type == "float" || type == "real" || type == "real*4" ) - variable.Set<float>( values ); - - else if( type == "double" || type == "double precision" || type == "real*8" ) - variable.Set<double>( values ); - - else if( type == "long double" || type == "real*16" ) - variable.Set<long double>( values ); - - //C++ - else if( type == "std::string" || type == "string" ) - variable.Set<std::string>( values ); - - else if( type == "std::vector<char>" || type == "vector<char>" ) - variable.Set< std::vector<char> >( values ); - - else if( type == "std::vector<int>" || type == "vector<int>" ) - variable.Set< std::vector<int> >( values ); - - else if( type == "std::vector<unsigned int>" || type == "vector<unsigned int>" ) - variable.Set< std::vector<unsigned int> >( values ); - - else if( type == "std::vector<long int>" || type == "std::vector<long>" || - type == "vector<long int>" || type == "vector<long>" ) - variable.Set<std::vector<long int> >( values ); - - else if( type == "std::vector<long long int>" || type == "std::vector<long long>" || - type == "vector<long long int>" || type == "vector<long long>" ) - variable.Set< std::vector<long long int> >( values ); - - else if( type == "std::vector<float>" || type == "vector<float>" ) - variable.Set< std::vector<float> >( values ); - - else if( type == "std::vector<double>" || type == "vector<double>" ) - variable.Set< std::vector<double> >( values ); - - else if( type == "std::vector<long double>" || type == "vector<long double>" ) - variable.Set< std::vector<long double> >( values ); - - //STL Complex types - else if( type == "std::complex<float>" || type == "complex<float>" ) - variable.Set< std::complex<float> >( values ); - - else if( type == "std::complex<double>" || type == "complex<double>" ) - variable.Set< std::complex<double> >( values ); - - else if( type == "std::complex<long double>" || type == "complex<long double>" ) - variable.Set< std::complex<long double> >( values ); - - else if( type == "std::vector<std::complex<float>>" || type == "vector<complex<float>>" ) - variable.Set< std::vector< std::complex<float> > >( values ); - - else if( type == "std::vector<std::complex<double>>" || type == "vector<complex<double>>" ) - variable.Set< std::vector< std::complex<double> > >( values ); - - else if( type == "std::vector<std::complex<long double>>" || type == "vector<complex<long double>>" ) - variable.Set< std::vector< std::complex<long double> > >( values ); -} - - -void CreateTransport( const std::string method, const unsigned int priority, const unsigned int iteration, - const MPI_Comm mpiComm, const bool debugMode, std::shared_ptr<CTransport>& transport ) noexcept -{ - if( method == "POSIX" ) - transport = std::make_shared<CPOSIX>( priority, iteration, mpiComm, debugMode ); - - else if( method == "FStream" ) - transport = std::make_shared<CFStream>( priority, iteration, mpiComm, debugMode ); -} - - -} //end namespace - - diff --git a/src/public/ADIOS.cpp b/src/public/ADIOS.cpp index 1683c65ffa2872337d8c90f36fd34b3d59d46503..b228262385f09f8365ba7e0c5d33ebbf97d9f5a2 100644 --- a/src/public/ADIOS.cpp +++ b/src/public/ADIOS.cpp @@ -53,21 +53,7 @@ void ADIOS::Open( const std::string groupName, const std::string fileName, const CheckGroup( itGroup, groupName, " from call to Open with file " + fileName ); itGroup->second.Open( fileName, accessMode ); -} - - -void ADIOS::Write( const std::string groupName, const std::string variableName, const void* values ) -{ - auto itGroup = m_Groups.find( groupName ); - if( m_DebugMode == true ) - { - CheckGroup( itGroup, groupName, " from call to Write with variable " + variableName ); - - if( itGroup->second.m_IsOpen == false ) - throw std::invalid_argument( "ERROR: group " + groupName + " is not open in Write function.\n" ); - } - itGroup->second.Write( variableName, values ); } @@ -82,8 +68,9 @@ void ADIOS::Close( const std::string groupName ) throw std::invalid_argument( "ERROR: group " + groupName + " is not open in Write function.\n" ); } - itGroup->second.Close( ); //calling capsule and transport - //m_Groups.erase( groupName ); //make group unavailable ? + m_Capsule.CloseGroupBuffer( itGroup->second ); + + itGroup->second.Close( ); } diff --git a/src/public/SSupport.cpp b/src/public/SSupport.cpp index 94dae63fefb0d60d27d04a919bc5d2fdeb81b362..eeafd7c177e2a6d639a8f8614e923b917bbc53cc 100644 --- a/src/public/SSupport.cpp +++ b/src/public/SSupport.cpp @@ -31,8 +31,6 @@ const std::set<std::string> SSupport::Transforms{ }; - - const std::map<std::string, std::set<std::string> > SSupport::Datatypes { { "C++", diff --git a/src/transport/CFStream.cpp b/src/transport/CFStream.cpp index ea14fa2f8f9312dc7ad0256ee2b30da28dc500bd..cf5f492413d973d59b5848c255b12c86405ba885 100644 --- a/src/transport/CFStream.cpp +++ b/src/transport/CFStream.cpp @@ -6,7 +6,8 @@ */ /// \cond EXCLUDED_FROM_DOXYGEN -#include <core/CVariable.h> +#include <core/SVariable.h> +#include <core/SVariable.h> #include <iostream> #include <sstream> #include <cmath> @@ -15,7 +16,6 @@ /// \endcond #include "transport/CFStream.h" -#include "core/CVariable.h" #include "functions/GroupFunctions.h" #include "functions/Templates.h"