diff --git a/examples/hello/C/fstream.xml b/examples/hello/C/fstream.xml new file mode 100644 index 0000000000000000000000000000000000000000..f43942fb1e13329c05a43c714ee3f8e2c6807ac5 --- /dev/null +++ b/examples/hello/C/fstream.xml @@ -0,0 +1,14 @@ +<?xml version="1.0"?> +<adios-config host-language="C"> + <adios-group name="Types"> + <var name="NumbersSize" type="int"/> + <var name="Numbers" type="double"/> + <attribute name="description" value="1 to 10"/> + + </adios-group> + + <transport group="Types" method="FStream">verbose=3</transport> + + <!-- <buffer size-MB="40" allocate-time="now"/> --> + +</adios-config> diff --git a/examples/hello/C/helloFStream.c b/examples/hello/C/helloFStream.c new file mode 100644 index 0000000000000000000000000000000000000000..b9978fd1e4a8105173b5de82382d033c524a165b --- /dev/null +++ b/examples/hello/C/helloFStream.c @@ -0,0 +1,46 @@ +/* + * helloFStream.c Test for C API version of helloFStream + * Created on: Nov 2, 2016 + * Author: wfg + */ + + + +#include "public/ADIOS_C.h" + + +void main( int argc, char* argv [] ) +{ + MPI_Init( &argc, &argv ); + int rank; + MPI_Comm_rank( MPI_COMM_WORLD, &rank ); + + //populate values + double* myNumbers; + myNumbers = (double*) malloc( 10 * sizeof(double) ); + + int i; + for( i = 0; i < 10; ++i ) + myNumbers[i] = i+1; + + //start ADIOS + ADIOS* adiosC, adiosC2; + const char group [] = "Types"; + const char group2 [] = "Types2"; + + + adiosC2 = adios_init_debug( "fstream.xml", MPI_COMM_WORLD ); //debug mode + + adios_create_group( adiosC, "groupCFD"); + adios_create_variable( adiosC, "groupCFD", "temperature" ); + adios_create_group( adiosC2, "groupFEM", "temperature" ); + /// + adios_open( adiosC, group, "helloVector.txt", "w" ); //open group Types associated with file "helloVector.txt" for writing + adios_open( adiosC, group2, "Vector.txt", "w" ); //open group Types associated with file "helloVector.txt" for writing + adios_write( adiosC, group, "Types", myNumbers ); + adios_close( adiosC, group ); + + + free( myNumbers ); + +} diff --git a/examples/hello/helloFStream.cpp b/examples/hello/helloFStream.cpp index 11f48f0826487083ca8077e5a29e0cd173dc911d..e2063c43b713b652ee55d5d457952e7b6b2fb5ac 100644 --- a/examples/hello/helloFStream.cpp +++ b/examples/hello/helloFStream.cpp @@ -40,6 +40,7 @@ int main( int argc, char* argv [] ) 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/examples/xmlParser/Makefile b/examples/xmlParser/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..12d521a344cadbceb9fdfc458dfd7d53b6501f69 --- /dev/null +++ b/examples/xmlParser/Makefile @@ -0,0 +1,35 @@ +# Makefile for testing purposes, will build libadios.a +# Created on: Oct 4, 2016 +# Author: wfg + + +BASE_NAME=xmlParser + +TOOL_DIR=/usr/bin + +CC=$(TOOL_DIR)/g++ +MPICC=$(TOOL_DIR)/mpic++ +AR=$(TOOL_DIR)/ar + +#ADIOS LOCATION +ADIOS_DIR=../../ +ADIOS_LIB=$(ADIOS_DIR)/lib/libadios.a +ADIOS_NOMPI_LIB=$(ADIOS_DIR)/lib/libadios_nompi.a + +ADIOS_INCLUDE=-I$(ADIOS_DIR)/include + + +#FLAGS +CFLAGS=-Wall -O0 -g -Wpedantic -std=c++11 + +all: mpi + +mpi: $(ADIOS_LIB) $(ADIOS_HFiles) + $(MPICC) $(CFLAGS) $(ADIOS_INCLUDE) -DHAVE_MPI $(BASE_NAME).cpp -o $(BASE_NAME)_mpi $(ADIOS_LIB) + +nompi: $(ADIOS_NOMPI_LIB) $(NoMPI_HFiles) + $(CC) $(CFLAGS) $(ADIOS_INCLUDE) $(BASE_NAME).cpp -o $(BASE_NAME)_nompi $(ADIOS_NOMPI_LIB) + +clean: + rm *_mpi; rm *_nompi + diff --git a/examples/xmlParser/xmlParser.cpp b/examples/xmlParser/xmlParser.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9e4c37335d61cf3a58bf4c3108eb32493b232623 --- /dev/null +++ b/examples/xmlParser/xmlParser.cpp @@ -0,0 +1,65 @@ +/* + * xmlParser.cpp + * + * Created on: Nov 2, 2016 + * Author: wfg + */ + +#include <stdexcept> +#include <iostream> +#include <string> + +#include "public/ADIOS.h" + +#ifdef HAVE_MPI + #include <mpi.h> +#else + #include "mpidummy.h" + using namespace adios; +#endif + + +static void Usage( ); + + +int main( int argc, char* argv [] ) +{ + MPI_Init( &argc, &argv ); + int rank; + MPI_Comm_rank( MPI_COMM_WORLD, &rank ); + + try + { + if( argc != 2 ) + { + Usage( ); + } + else + { + const std::string xmlConfigFile( argv[1] ); + adios::ADIOS adios( xmlConfigFile, MPI_COMM_WORLD, true ); + adios.MonitorGroups( std::cout ); + } + } + catch( std::exception& e ) + { + if( rank == 0 ) + { + std::cout << "ERROR: exception caught\n"; + std::cout << e.what() << "\n"; + } + } + + MPI_Finalize( ); + return 0; +} + + +static void Usage( ) +{ + std::cout << "Program to test XML Config file parsing\n"; + std::cout << "Usage: \n"; + std::cout << "\t MPI version: ./xmlParser_mpi xmlConfigFile\n"; + std::cout << "\t Non-MPI version: ./xmlParser_nompi xmlConfigFile\n"; +} + diff --git a/include/core/CGroup.h b/include/core/CGroup.h index f33f396da13e9772e3b56b7cdd7b49638a692ab5..c363f90ef183748acc83db74002f3309a0068de1 100644 --- a/include/core/CGroup.h +++ b/include/core/CGroup.h @@ -90,8 +90,12 @@ public: * @param dimensionsCSV comma separated dimensions, default 1D = {1} * @param transform method, format = lib or lib:level, where lib = zlib, bzip2, szip, and level=1:9 . If no level is defined then library default is taken */ - void SetVariable( const std::string name, const bool isGlobal, const std::string type, - const std::string dimensionsCSV = "1", const std::string transform = "" ); + void CreateLocalVariable( const std::string name, const std::string type, + const std::string dimensionsCSV, const std::string transform ); + + void CreateGlobalVariable( 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 variable in current Group @@ -101,15 +105,8 @@ public: * @param path * @param value */ - void SetAttribute( const std::string name, const bool isGlobal, const std::string type, const std::string path, const std::string value ); - + void CreateAttribute( const std::string name, const bool isGlobal, const std::string type, const std::string path, const std::string value ); - /** - * @brief Sets global dimensions and offsets - * @param dimensionsCSV global dimensions in comma-separated-value format "gdx,gdy" - * @param offsetsCSV global offsets in comma-separated-value format "gdx,gdy" - */ - void SetGlobalBounds( const std::string dimensionsCSV, const std::string offsetsCSV = "" ); /** * @brief Sets m_Transport with available supported method @@ -118,8 +115,8 @@ public: * @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 CreateTransport( const std::string method, const unsigned int priority, const unsigned int iteration, + const MPI_Comm mpiComm ); /** diff --git a/include/core/CVariable.h b/include/core/CVariable.h index 20bc10a7ee25f9246da250354d9854a8916cc460..2a3961661301f049cedefb1dcc2012aaddf5acf5 100644 --- a/include/core/CVariable.h +++ b/include/core/CVariable.h @@ -31,8 +31,13 @@ public: * @param dimensionsCSV * @param transform */ - CVariable( const bool isGlobal, const std::string type, const std::string dimensionsCSV = "1", const std::string transform = "" ): - CVariableBase( isGlobal, type, dimensionsCSV, transform ) + CVariable( const std::string type, const std::string dimensionsCSV, const std::string transform ): + CVariableBase( type, dimensionsCSV, transform ) + { } + + CVariable( const std::string type, const std::string dimensionsCSV, const std::string transform, + const std::string globalDimensionsCSV, const std::string globalOffsetsCSV ): + CVariableBase( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ) { } ~CVariable( ) diff --git a/include/core/CVariableBase.h b/include/core/CVariableBase.h index a6eede4c05d52de3cbc8dcc0ca9164b3144bb916..9dab28e0a082785548b46e2b3cb3c16e79b0caf2 100644 --- a/include/core/CVariableBase.h +++ b/include/core/CVariableBase.h @@ -26,20 +26,27 @@ class CVariableBase public: - CVariableBase( const bool isGlobal, const std::string type, const std::string dimensionsCSV = "1", const std::string transform = "" ); + CVariableBase( const std::string type, const std::string dimensionsCSV, const std::string transform ); + + CVariableBase( const std::string type, const std::string dimensionsCSV, const std::string transform, + const std::string globalDimensionsCSV, const std::string globalOffsetsCSV ); + virtual ~CVariableBase( ); template<class T> const T* Get( ) const; template<class T> void Set( const void* values ); -//protected: turned off for testing - bool m_IsGlobal = false; - std::string m_Type = "NONE"; ///< mandatory, double, float, unsigned integer, integer, etc. - std::vector<std::string> m_Dimensions = {"1"}; ///< if empty variable is a scalar, else N-dimensional variable - std::string m_Transform; ///< data transform: zlib, bzip2, szip - unsigned int m_CompressionLevel = 0; ///< taken from m_Transform, 1 to 9, if zero the default library value is taken - //To do/understand gwrite, gread, read + +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 + const std::string m_Transform; ///< data transform: zlib:1, bzip2:4, szip:9 which level of compression + const std::string m_GlobalDimensionsCSV; ///< comma separated list for variables to search for global dimensions + const std::string m_GlobalOffsetsCSV; ///< comma separated list for variables to search for global offsets + const bool m_IsGlobal = false; ///< boolean flag that identifies is a variable is global or not + }; diff --git a/src/core/CVariableBase.cpp b/src/core/CVariableBase.cpp index 60b2e5226cc0fd90f3b3c1e03ff24f53472acb69..6f71277605be21da734eedab4ccd45cefcf370dc 100644 --- a/src/core/CVariableBase.cpp +++ b/src/core/CVariableBase.cpp @@ -12,24 +12,22 @@ namespace adios { -CVariableBase::CVariableBase( const bool isGlobal, const std::string type, const std::string dimensionsCSV, const std::string transform ): - m_IsGlobal( isGlobal ), - m_Type( type ), - m_Transform( transform ) -{ - if( dimensionsCSV == "1" ) - { - m_Dimensions.push_back( "1" ); - return; - } - - std::istringstream dimensionsCSVSS( dimensionsCSV ); - std::string dimension; - while( std::getline( dimensionsCSVSS, dimension, ',' ) ) - { - m_Dimensions.push_back( dimension ); - } -} +CVariableBase::CVariableBase( const std::string type, const std::string dimensionsCSV, const std::string transform ): + m_Type{ type }, + m_DimensionsCSV{ dimensionsCSV }, + m_Transform{ transform }, + m_IsGlobal{ false } +{ } + +CVariableBase::CVariableBase( 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 }, + m_IsGlobal{ true } +{ } CVariableBase::~CVariableBase()