Skip to content

Commit

Permalink
tutorial: Added skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
vicentebolea committed Sep 5, 2023
1 parent c8b7b66 commit 9efb23c
Show file tree
Hide file tree
Showing 11 changed files with 762 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/user_guide/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Funded by the `Exascale Computing Project (ECP) <https://www.exascaleproject.org
.. toctree::
:caption: Basics

tutorial/tutorial
components/components
engines/virtual_engines
engines/engines
Expand Down
107 changes: 107 additions & 0 deletions docs/user_guide/source/tutorial/tutorial.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
####################
Tutorial: ADIOS2 101
####################

********
Setup
********

- Install adios2
- Go to the tutorial dir
- cmake
- cmake --build


******************
(hello)adios world
******************

Solution at `tutorials/00_helloworld/helloworld_solution.cxx`
Source at `tutorials/00_helloworld/helloworld.cxx`

Open source.

In the writer side:

1. First we need to initialize ADIOS2

...

2. Second we need to declare an IO object which means ...

...

3. Then we can create an engine, which we have many types of ...

...

4. Now create a simpel variable ...

Pass an string ...

In the reader side:

5. repeat 1-4 steps.

...

6. Now read the variable

...

**********************************
(hello)adios world (Low level API)
**********************************

Solution at `tutorials/00_helloworld_basics/helloworld_solution.cxx`
Source at `tutorials/00_helloworld_basics/helloworld.cxx`

Open source.

In the writer side:

1. First we need to initialize ADIOS2

...

2. Second we need to declare an IO object which means ...

...

3. Then we can create an engine, which we have many types of ...

...

4. Now create a simpel variable ...

Pass an string ...

In the reader side:

5. repeat 1-4 steps.

...

6. Now read the variable

...


*********
Variables
*********

Concept of steps
Concept of Variables shape

Solution at `tutorials/01_variables/variables_solution.cxx`
Source at `tutorials/01_variables/variables.cxx`

*********
Operators
*********

Concept of Operators

Solution at `tutorials/02_operators/operators_solution.cxx`
Source at `tutorials/02_operators/operators.cxx`
9 changes: 9 additions & 0 deletions tutorial/00_helloworld/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#------------------------------------------------------------------------------#
# Distributed under the OSI-approved Apache License, Version 2.0. See
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#
cmake_minimum_required(VERSION 3.12)
project(adios2HelloWorld LANGUAGES C CXX)

add_executable(ADIOS2helloworld helloworld.cxx)
target_link_libraries(ADIOS2helloworld adios2::cxx11)
48 changes: 48 additions & 0 deletions tutorial/00_helloworld/helloworld.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* hello-world-hl.cpp : adios2 high-level API example to write and read a
* std::string Variable with a greeting
*
*/

#include <iostream>
#include <stdexcept>
#include <adios2.h>

void writer(const std::string &greeting)
{
// ToDo
}

std::string reader()
{
std::vector<std::string> output;
adios2::fstep iStep;

// ToDo

adios2::getstep(in, iStep);

// ToDo

return output.front();
}

int main(int argc, char *argv[])
{
try
{
const std::string greeting = "Hello World from ADIOS2";
writer(greeting);

const std::string message = reader();
std::cout << message << "\n";
}
catch (std::exception &e)
{
std::cout << "ERROR: ADIOS2 exception: " << e.what() << "\n";
}

return 0;
49 changes: 49 additions & 0 deletions tutorial/00_helloworld/helloworld_solution.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* hello-world-hl.cpp : adios2 high-level API example to write and read a
* std::string Variable with a greeting
*
*/

#include <iostream>
#include <stdexcept>
#include <adios2.h>

void writer(const std::string &greeting)
{
adios2::fstream out("hello-world-hl-cpp.bp", adios2::fstream::out);
out.write("Greeting", greeting);
out.close();
}

std::string reader()
{
std::vector<std::string> output;
adios2::fstep iStep;

adios2::fstream in("hello-world-hl-cpp.bp", adios2::fstream::in);
adios2::getstep(in, iStep);
output = in.read<std::string>("Greeting").front();
in.close()

return output.front();
}

int main(int argc, char *argv[])
{
try
{
const std::string greeting = "Hello World from ADIOS2";
writer(greeting);

const std::string message = reader();
std::cout << message << "\n";
}
catch (std::exception &e)
{
std::cout << "ERROR: ADIOS2 exception: " << e.what() << "\n";
}

return 0;
9 changes: 9 additions & 0 deletions tutorial/00_helloworld_basic/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#------------------------------------------------------------------------------#
# Distributed under the OSI-approved Apache License, Version 2.0. See
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#
cmake_minimum_required(VERSION 3.12)
project(adios2HelloWorldBasic LANGUAGES C CXX)

add_executable(ADIOS2helloworldBasic helloworld.cxx)
target_link_libraries(ADIOS2helloworldBasic adios2::cxx11)
52 changes: 52 additions & 0 deletions tutorial/00_helloworld_basic/helloworld.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* hello-world.cpp : adios2 low-level API example to write and read a
* std::string Variable with a greeting
*/

#include <iostream>
#include <stdexcept>

#include <adios2.h>

void writer(adios2::ADIOS &adios, const std::string &greeting)
{
// ToDo
}

std::string reader(adios2::ADIOS &adios)
{
// ToDo

reader.BeginStep();

// ToDo

reader.EndStep();

// ToDo

return greeting;
}

int main(int argc, char *argv[])
{
try
{
adios2::ADIOS adios;

const std::string greeting = "Hello World from ADIOS2";
writer(adios, greeting);

const std::string message = reader(adios);
std::cout << message << "\n";
}
catch (std::exception &e)
{
std::cout << "ERROR: ADIOS2 exception: " << e.what() << "\n";
}

return 0;
}
61 changes: 61 additions & 0 deletions tutorial/00_helloworld_basic/helloworld_solution.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* hello-world.cpp : adios2 low-level API example to write and read a
* std::string Variable with a greeting
*
* Created on: Nov 14, 2019
* Author: William F Godoy godoywf@ornl.gov
*/

#include <iostream>
#include <stdexcept>

#include <adios2.h>

void writer(adios2::ADIOS &adios, const std::string &greeting)
{
adios2::IO io = adios.DeclareIO("hello-world-writer");
adios2::Variable<std::string> varGreeting =
io.DefineVariable<std::string>("Greeting");

adios2::Engine writer = io.Open("hello-world-cpp.bp", adios2::Mode::Write);
writer.Put(varGreeting, greeting);
writer.Close();
}

std::string reader(adios2::ADIOS &adios)
{
adios2::IO io = adios.DeclareIO("hello-world-reader");
adios2::Engine reader = io.Open("hello-world-cpp.bp", adios2::Mode::Read);
reader.BeginStep();
adios2::Variable<std::string> varGreeting =
io.InquireVariable<std::string>("Greeting");
std::string greeting;
reader.Get(varGreeting, greeting);
reader.EndStep();
reader.Close();
return greeting;
}

int main(int argc, char *argv[])
{

try
{
adios2::ADIOS adios;

const std::string greeting = "Hello World from ADIOS2";
writer(adios, greeting);

const std::string message = reader(adios);
std::cout << message << "\n";
}
catch (std::exception &e)
{
std::cout << "ERROR: ADIOS2 exception: " << e.what() << "\n";
}

return 0;
}
Loading

0 comments on commit 9efb23c

Please sign in to comment.