diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 4f27787615b8e4604cdeee78ddd67c510ff981c5..cff55b7612dea88c6033417e74a3e199434fde0a 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -5,4 +5,4 @@ add_subdirectory(hello) add_subdirectory(heatTransfer) -add_subdirectory(groupless) +add_subdirectory(experimental) diff --git a/examples/groupless/CMakeLists.txt b/examples/experimental/CMakeLists.txt similarity index 82% rename from examples/groupless/CMakeLists.txt rename to examples/experimental/CMakeLists.txt index 5f37a0bb41ec07985f272f2a6f0b06b85e5eebbb..5d46e776b55df9085089e8cc35a5af4304e33310 100644 --- a/examples/groupless/CMakeLists.txt +++ b/examples/experimental/CMakeLists.txt @@ -3,4 +3,6 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_subdirectory(multistep) +if(ADIOS_USE_ADIOS1) + add_subdirectory(multistep) +endif() diff --git a/examples/groupless/multistep/CMakeLists.txt b/examples/experimental/multistep/CMakeLists.txt similarity index 100% rename from examples/groupless/multistep/CMakeLists.txt rename to examples/experimental/multistep/CMakeLists.txt diff --git a/examples/groupless/multistep/reader_allsteps.cpp b/examples/experimental/multistep/reader_allsteps.cpp similarity index 100% rename from examples/groupless/multistep/reader_allsteps.cpp rename to examples/experimental/multistep/reader_allsteps.cpp diff --git a/examples/groupless/multistep/reader_stepping.cpp b/examples/experimental/multistep/reader_stepping.cpp similarity index 100% rename from examples/groupless/multistep/reader_stepping.cpp rename to examples/experimental/multistep/reader_stepping.cpp diff --git a/examples/groupless/multistep/writer_multistep.cpp b/examples/experimental/multistep/writer_multistep.cpp similarity index 100% rename from examples/groupless/multistep/writer_multistep.cpp rename to examples/experimental/multistep/writer_multistep.cpp diff --git a/examples/globalArray/globalArrayNoXML.cpp b/examples/globalArray/globalArrayNoXML.cpp deleted file mode 100644 index aa4a3d5c652118830efb50f840f9ef4178aad773..0000000000000000000000000000000000000000 --- a/examples/globalArray/globalArrayNoXML.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Distributed under the OSI-approved Apache License, Version 2.0. See - * accompanying file Copyright.txt for details. - * - * globalArrayNoXML.cpp - * - * Created on: Oct 31, 2016 - * Author: pnorbert - */ - -#include <fstream> -#include <iostream> -#include <mpi.h> -#include <stdexcept> -#include <string> -#include <vector> - -#include "adios2/../../include/ADIOS.h" - -int main(int argc, char *argv[]) -{ - int rank, size; - const int NX = 10; - double t[NX]; - std::vector<double> p(NX); - MPI_Comm comm = MPI_COMM_WORLD; - - MPI_Init(&argc, &argv); - MPI_Comm_rank(comm, &rank); - MPI_Comm_size(comm, &size); - - try - { - // ADIOS manager object creation. MPI must be initialized - adios::ADIOS adios("globalArrayNoXML.xml", comm, true); - - // set a maximum buffersize that ADIOS can use (for one group). - // multiple groups may use each such buffersize if they are overlapped - // or - // use time-aggregation or use zero-copy staging - - // Define Group and its variables - // The group's transport can be defined at runtime in the input XML file - adios.CreateGroup("arrays"); - - // Set the maximum buffersize for this group. This must happen before - // defining a zero copy variable, which will cause the group's internal - // buffer - // allocated (during the variable definition call) - // adios.SetMaxBuffersize ("arrays", 10000000); - - adios.CreateVariable("arrays", "NX", "int"); // scalar variable - adios.CreateVariable("arrays", "size", "int"); - adios.CreateVariable("arrays", "size", "rank"); - - // define a 2D array with 1D decomposition - adios.CreateVariable("arrays", "temperature", "double", "1,NX", "NONE", - "size,NX", "rank,0"); - - // // set a variable-level transformation for this variable - // adios.SetVariableTransform ("arrays", "temperature", "none"); - - adios.CreateVariable("arrays", "pressure", "std::vector<double>", - "1,NX", "size,NX", "rank,0"); - - // set a group-level transport - adios.SetTransport("arrays", - "time-aggregate"); // no options passed here - - // Get Monitor info - std::ofstream logStream("info_" + std::to_string(rank) + ".log"); - adios.MonitorGroups(logStream); - - adios.Open("arrays", "globalArray.bp", "w", 100000000); - - for (int it = 1; it <= 13; it++) - { - - for (int i = 0; i < NX; i++) - { - t[i] = it * 100.0 + rank * NX + i; - p[i] = it * 1000.0 + rank * NX + i; - } - - // if (it==1) - // - // else - // adios.Open("arrays", "globalArray.bp", "a", - // 100000000 ); - - // uint64_t adios_groupsize, adios_totalsize; - // adios_groupsize = 4 + 4 + 4 + 2*NX*sizeof(double); - // adios_totalsize = adios.GroupSize("arrays", adios_groupsize); - - adios.Write("arrays", "NX", &NX); - adios.Write("arrays", "size", &size); - adios.Write("arrays", "rank", &rank); - adios.Write("arrays", "temperature", t); - adios.Write("arrays", "pressure", &p); - - MPI_Barrier(comm); - if (rank == 0) - printf("Timestep %d written\n", it); - } - - adios.Close("arrays"); - - MPI_Barrier(comm); - // need barrier before we destroy the ADIOS object here automatically - if (rank == 0) - printf("Finalize adios\n"); - } - catch (std::exception &e) // need to think carefully how to handle C++ - // exceptions with MPI to avoid deadlocking - { - if (rank == 0) - { - std::cout << e.what() << "\n"; - } - } - - if (rank == 0) - printf("Finalize MPI\n"); - MPI_Finalize(); - return 0; -} diff --git a/examples/globalArray/globalArrayNoXML.xml b/examples/globalArray/globalArrayNoXML.xml deleted file mode 100644 index 87cceeab1b8f3e06b107059797a506182f52fe91..0000000000000000000000000000000000000000 --- a/examples/globalArray/globalArrayNoXML.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0"?> -<adios-config> - - <method group="arrays" method="MPI">ts_buffersize=32000;verbose=4</method> - <!-- - <method group="arrays" method="MPI_AGGREGATE">num_aggregators=1;num_ost=1</method> - --> - - <buffer max-size-MB="1"/> - -</adios-config> - diff --git a/examples/globalArray/globalArrayXML.cpp b/examples/globalArray/globalArrayXML.cpp deleted file mode 100644 index 9ab2027674e73ec31d8a5a1320fbd889f9317b62..0000000000000000000000000000000000000000 --- a/examples/globalArray/globalArrayXML.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Distributed under the OSI-approved Apache License, Version 2.0. See - * accompanying file Copyright.txt for details. - * - * globalArrayXML.cpp - * - * Created on: Oct 31, 2016 - * Author: pnorbert - */ - -#include <fstream> -#include <iostream> -#include <mpi.h> -#include <stdexcept> -#include <string> -#include <vector> - -#include "adios2/../../include/ADIOS.h" - -int main(int argc, char *argv[]) -{ - int rank, size; - const int NX = 10; - double t[NX]; - std::vector<double> p(NX); - MPI_Comm comm = MPI_COMM_WORLD; - - MPI_Init(&argc, &argv); - MPI_Comm_rank(comm, &rank); - MPI_Comm_size(comm, &size); - - try - { - // ADIOS manager object creation. MPI must be initialized - adios::ADIOS adios("globalArrayXML.xml", comm, true); - - adios::ADIOS_OUTPUT &ckptfile = - adios.Open("globalArray.bp", comm, "a", "POSIX"); - - adios::ADIOS_OUTPUT ckptfile("globalArray.bp", subcomm, "a", "POSIX"); - // adios::ADIOS_OUTPUT *ckptfile = adios.Open( "globalArray.bp", - // "POSIX"); - - // Get Monitor info - std::ofstream logStream("info_" + std::to_string(rank) + ".log"); - adios.MonitorGroups(logStream); - - for (int it = 1; it <= 13; it++) - { - - for (int i = 0; i < NX; i++) - { - t[i] = it * 100.0 + rank * NX + i; - p[i] = it * 1000.0 + rank * NX + i; - } - - // if (it==1) - // adios.Open("arrays", "globalArray.bp", "w"); - // else - // adios.Open("arrays", "globalArray.bp", "a"); - - // uint64_t adios_groupsize, adios_totalsize; - // adios_groupsize = 4 + 4 + 4 + 2*NX*sizeof(double); - // adios_totalsize = adios.GroupSize("arrays", adios_groupsize); - - ckptfile.Write("NX", &NX); - ckptfile.Write("pressure", &p); - // adios.Write ("arrays", "NX", &NX); - // adios.Write ("arrays", "size", &size); - // adios.Write ("arrays", "rank", &rank); - // adios.Write ("arrays", "temperature", t); - // adios.Write ("arrays", "pressure", &p); - - // adios.Close ("arrays"); - ckptfile.PerformIO(); - MPI_Barrier(comm); - if (rank == 0) - printf("Timestep %d written\n", it); - } - MPI_Barrier(comm); - ckptfile.Close(); - // need barrier before we destroy the ADIOS object here automatically - if (rank == 0) - printf("Finalize adios\n"); - } - catch (std::exception &e) // need to think carefully how to handle C++ - // exceptions with MPI to avoid deadlocking - { - if (rank == 0) - { - std::cout << e.what() << "\n"; - } - } - - if (rank == 0) - printf("Finalize MPI\n"); - MPI_Finalize(); - return 0; -} diff --git a/examples/globalArray/globalArrayXML.xml b/examples/globalArray/globalArrayXML.xml deleted file mode 100644 index 315ba12963a9d6bbc4574c85bb769f668d1255ef..0000000000000000000000000000000000000000 --- a/examples/globalArray/globalArrayXML.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0"?> -<adios-config> - <adios-group name="arrays"> - <var name="NX" type="integer"/> - <var name="size" type="integer"/> - <var name="rank" type="integer"/> - - <global-bounds dimensions="size,NX" offsets="rank,0"> - <var name="temperature" gwrite="t" type="double" dimensions="1,NX"/> - <var name="pressure" gwrite="p" type="std::vector<double>" dimensions="1,NX"/> - </global-bounds> - - <attribute name="temperature/description" - value="Global array written from 'size' processes over several timesteps" - type="string"/> - </adios-group> - - <method group="arrays" method="MPI">ts_buffersize=32000;verbose=4</method> - <!-- - <method group="arrays" method="MPI_AGGREGATE">num_aggregators=1;num_ost=1</method> - --> - - <buffer max-size-MB="1"/> - -</adios-config> - diff --git a/examples/globalArray/globalArrayZeroCopy.cpp b/examples/globalArray/globalArrayZeroCopy.cpp deleted file mode 100644 index 7b7506eb974f34b1fb41fa9ef66d2f4065667652..0000000000000000000000000000000000000000 --- a/examples/globalArray/globalArrayZeroCopy.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Distributed under the OSI-approved Apache License, Version 2.0. See - * accompanying file Copyright.txt for details. - * - * globalArrayZeroCopy.cpp - * - * Created on: Oct 31, 2016 - * Author: pnorbert - */ - -#include <fstream> -#include <iostream> -#include <mpi.h> -#include <stdexcept> -#include <string> -#include <vector> - -#include "adios2/../../include/ADIOS.h" - -int main(int argc, char *argv[]) -{ - int rank, size; - const int NX = 10; - MPI_Comm comm = MPI_COMM_WORLD; - - MPI_Init(&argc, &argv); - MPI_Comm_rank(comm, &rank); - MPI_Comm_size(comm, &size); - - try - { - // ADIOS manager object creation. MPI must be initialized - adios::ADIOS adios("globalArrayNoXML.xml", comm, true); - - // set a maximum buffersize that ADIOS can use (for one group). - // multiple groups may use each such buffersize if they are overlapped - // or - // use time-aggregation or use zero-copy staging - adios.SetMaxBuffersize(100000000); - - // Define Group and its variables - // The group's transport can be defined at runtime in the input XML file - adios.CreateGroup("arrays", adios_stat_default); - - // Set the maximum buffersize for this group. This must happen before - // defining a zero copy variable, which will cause the group's internal - // buffer - // allocated (during the variable definition call) - adios.SetMaxBuffersize("arrays", 10000000); - - adios.DefineVariable("arrays", "NX", "int"); // scalar variable - adios.DefineVariable("arrays", "size", "int"); - adios.DefineVariable("arrays", "size", "rank"); - - // Define and allocate a 2D array with 1D decomposition and get back a - // pre-allocated typed pointer. - // The size of the array must be known at this point, so no scalar - // variables - // can - // be used for its dimensions. - std::string ldim = "1," + std::to_string(NX); // == "1,10" if NX==10 - std::string gdim = std::to_string(size) + "," + std::to_string(NX); - std::string offs = std::to_string(rank) + ",0"; - - double *t = adios.DefineZeroCopyVariable("arrays", "temperature", - "double", ldim, gdim, offs); - - // set a variable-level transformation for this variable - adios.SetVariableTransform("arrays", "temperature", "none"); - - std::vector<double> p = adios.DefineZeroCopyVariable( - "arrays", "pressure", "std::vector<double>", ldim, gdim, offs); - - // set a group-level transformation - adios.SetGroupTransform("arrays", "time-aggregate", - ""); // no options passed here - - // Get Monitor info - std::ofstream logStream("info_" + std::to_string(rank) + ".log"); - adios.MonitorGroups(logStream); - - for (int it = 1; it <= 13; it++) - { - - for (int i = 0; i < NX; i++) - { - t[i] = it * 100.0 + rank * NX + i; - p[i] = it * 1000.0 + rank * NX + i; - } - - if (it == 1) - adios.Open("arrays", "globalArray.bp", "w"); - else - adios.Open("arrays", "globalArray.bp", "a"); - - // uint64_t adios_groupsize, adios_totalsize; - // adios_groupsize = 4 + 4 + 4 + 2*NX*sizeof(double); - // adios_totalsize = adios.GroupSize("arrays", adios_groupsize); - - adios.Write("arrays", "NX", &NX); - adios.Write("arrays", "size", &size); - adios.Write("arrays", "rank", &rank); - adios.Write("arrays", "temperature", t); - adios.Write("arrays", "pressure", &p); - - adios.Close("arrays"); - MPI_Barrier(comm); - if (rank == 0) - printf("Timestep %d written\n", it); - } - MPI_Barrier(comm); - // need barrier before we destroy the ADIOS object here automatically - if (rank == 0) - printf("Finalize adios\n"); - } - catch (std::exception &e) // need to think carefully how to handle C++ - // exceptions with MPI to avoid deadlocking - { - if (rank == 0) - { - std::cout << e.what() << "\n"; - } - } - - if (rank == 0) - printf("Finalize MPI\n"); - MPI_Finalize(); - return 0; -} diff --git a/examples/groupless/basic/reader.cpp b/examples/groupless/basic/reader.cpp deleted file mode 100644 index c65cbe3a31da986f361e1abcb51c731dde146074..0000000000000000000000000000000000000000 --- a/examples/groupless/basic/reader.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Distributed under the OSI-approved Apache License, Version 2.0. See - * accompanying file Copyright.txt for details. - * - * reader.cpp - * - * Created on: Feb 13, 2017 - * Author: pnorbert - */ - -#include <iostream> -#include <vector> - -#include <adios2.h> -#include <mpi.h> - -int main(int argc, char *argv[]) -{ - int rank, nproc; - MPI_Init(&argc, &argv); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &nproc); - const bool adiosDebug = true; - - adios::ADIOS adios(MPI_COMM_WORLD, adiosDebug); - - // Application variable - std::vector<double> NiceArray; - std::vector<float> RaggedArray; - unsigned int Nx; - int Nparts; - int Nwriters; - - try - { - // Define method for engine creation - // 1. Get method def from config file or define new one - adios::Method &bpReaderSettings = adios.GetMethod("input"); - if (bpReaderSettings.undeclared()) - { - // if not defined by user, we can change the default settings - bpReaderSettings.SetEngine("BP"); // BP is the default engine - } - - // Create engine smart pointer due to polymorphism, - // Default behavior - // auto bpReader = adios.Open( "myNumbers.bp", "r" ); - // this would just open with a default transport, which is "BP" - auto bpReader = adios.Open("myNumbers.bp", "r", bpReaderSettings); - - // All the above is same as default use: - // auto bpReader = adios.Open( "myNumbers.bp", "r"); - - if (bpReader == nullptr) - throw std::ios_base::failure( - "ERROR: failed to open ADIOS bpReader\n"); - - /* Variable names are available as a vector of strings */ - std::cout << "List of variables in file: " << bpReader->VariableNames - << "\n"; - - /* NX */ - bpReader->Read<unsigned int>( - "NX", - Nx); // read a Global scalar which has a single value in a step - - /* nproc */ - bpReader->Read<int>("nproc", Nwriters); // also a global scalar - - /* Nparts */ - // Nparts local scalar is presented as a 1D array of Nwriters elements. - // We need to read a specific value the same way as reading from any 1D - // array. - // Make a single-value selection to describe our rank's position in the - // 1D array of Nwriters values. - if (rank < Nwriters) - { - std::shared_ptr<adios::Variable> varNparts = - bpReader.InquiryVariable("Nparts"); - std::unique_ptr<adios::Selection> selNparts = - adios.SelectionBoundingBox({1}, {rank}); - varNparts->SetSelection(selNparts); - bpReader->Read<int>(varNparts, Nparts); - } - // or we could just read the whole array by every process - std::vector<int> partsV(Nwriters); - bpReader->Read<int>("Nparts", - partsV.data()); // read with string name, no - // selection => read whole array - - std::vector<int> partsV; - bpReader->Read<int>("Nparts", - partsV); // read with string name, no selection => - // read whole array - (Nwriters == partsV.size()) - - /* Nice */ - // inquiry about a variable, whose name we know - std::shared_ptr<adios::Variable> - varNice = bpReader.InquiryVariable("Nice"); - - if (varNice == nullptr) - throw std::ios_base::failure("ERROR: failed to find variable " - "'myDoubles' in input file\n"); - - // ? how do we know about the type? std::string varNice->m_Type - uint64_t gdim = varNice->m_Shape[0]; // ?member var or member func? - uint64_t ldim = gdim / nproc; - uint64_t offs = rank * ldim; - if (rank == nproc - 1) - { - ldim = gdim - (ldim * gdim); - } - - NiceArray.reserve(ldim); - - // Make a 1D selection to describe the local dimensions of the variable - // we - // READ and - // its offsets in the global spaces - std::unique_ptr<adios::Selection> bbsel = adios.SelectionBoundingBox( - {ldim}, {offs}); // local dims and offsets; both as list - varNice->SetSelection(bbsel); - bpReader->Read<double>(varNice, NiceArray.data()); - - /* Ragged */ - // inquiry about a variable, whose name we know - std::shared_ptr<adios::Variable<void>> varRagged = - bpReader.InquiryVariable("Ragged"); - if (varRagged->m_Shape[1] != adios::VARYING_DIMENSION) - { - throw std::ios_base::failure( - "Unexpected condition: Ragged array's fast dimension " - "is supposed to be VARYING_DIMENSION\n"); - } - // We have here varRagged->sum_nblocks, nsteps, nblocks[], global - if (rank < - varRagged->nblocks[0]) // same as rank < Nwriters in this example - { - // get per-writer size information - varRagged->InquiryBlocks(); - // now we have the dimensions per block - - unsigned long long int ldim = - varRagged->blockinfo[rank].m_Dimensions[1]; - RaggedArray.resize(ldim); - - std::unique_ptr<adios::Selection> wbsel = - adios.SelectionWriteblock(rank); - varRagged->SetSelection(wbsel); - bpReader->Read<float>(varRagged, RaggedArray.data()); - - // We can use bounding box selection as well - std::unique_ptr<adios::Selection> rbbsel = - adios.SelectionBoundingBox({1, ldim}, {rank, 0}); - varRagged->SetSelection(rbbsel); - bpReader->Read<float>(varRagged, RaggedArray.data()); - } - - /* Extra help to process Ragged */ - int maxRaggedDim = - varRagged->GetMaxGlobalDimensions(1); // contains the largest - std::vector<int> raggedDims = varRagged->GetVaryingGlobalDimensions( - 1); // contains all individual sizes in that dimension - - // Close file/stream - bpReader->Close(); - } - 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"; - } - } - - MPI_Finalize(); - - return 0; -} diff --git a/examples/groupless/basic/writer.cpp b/examples/groupless/basic/writer.cpp deleted file mode 100644 index fb4e9c76d6dd212c53b8a62a03724ec7b9d9275c..0000000000000000000000000000000000000000 --- a/examples/groupless/basic/writer.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Distributed under the OSI-approved Apache License, Version 2.0. See - * accompanying file Copyright.txt for details. - * - * writer.cpp - * - * Created on: Feb 13, 2017 - * Author: pnorbert - */ - -#include <iostream> -#include <vector> - -#include <adios2.h> -#include <mpi.h> - -namespace adios -{ -typedef enum { VARYING_DIMENSION = -1, LOCAL_VALUE = 0, GLOBAL_VALUE = 1 }; -} - -int main(int argc, char *argv[]) -{ - int rank, nproc; - MPI_Init(&argc, &argv); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &nproc); - const bool adiosDebug = true; - - adios::ADIOS adios(MPI_COMM_WORLD, adiosDebug); - - // Application variable - const unsigned int Nx = 10; - const int Nparts = rand() % 6 + 5; // random size per process, 5..10 each - - std::vector<double> NiceArray(Nx); - for (int i = 0; i < Nx; i++) - { - NiceArray[i] = rank * Nx + (double)i; - } - - std::vector<float> RaggedArray(Nparts); - for (int i = 0; i < Nparts; i++) - { - RaggedArray[i] = rank * Nx + (float)i; - } - - try - { - // Define group and variables with transforms, variables don't have - // functions, only group can access variables - adios::Variable<unsigned int> &varNX = - adios.DefineVariable<unsigned int>( - "NX"); // global single-value across processes - adios::Variable<int> &varNproc = adios.DefineVariable<int>( - "nproc", adios::GLOBAL_VALUE); // same def for global value - adios::Variable<int> &varNparts = - adios.DefineVariable<int>("Nparts", - adios::LOCAL_VALUE); // a single-value - // different on - // every process - adios::Variable<double> &varNice = adios.DefineVariable<double>( - "Nice", {nproc * Nx}); // 1D global array - adios::Variable<float> &varRagged = adios.DefineVariable<float>( - "Ragged", {nproc, adios::VARYING_DIMENSION}); // ragged array - - // add transform to variable in group...not executed (just testing API) - adios::Transform bzip2 = adios::transform::BZIP2(); - varNice->AddTransform(bzip2, 1); - - // Define method for engine creation - // 1. Get method def from config file or define new one - adios::Method &bpWriterSettings = adios.GetMethod("output"); - if (bpWriterSettings.undeclared()) - { - // if not defined by user, we can change the default settings - bpWriterSettings.SetEngine("BP"); // BP is the default engine - bpWriterSettings.AddTransport( - "File", - "lucky=yes"); // ISO-POSIX file is the default transport - // Passing parameters to the transport - bpWriterSettings.SetParameters( - "have_metadata_file", - "yes"); // Passing parameters to the engine - bpWriterSettings.SetParameters("Aggregation", - (nproc + 1) / - 2); // number of aggregators - } - - // Open returns a smart pointer to Engine containing the Derived class - // Writer - // "w" means we overwrite any existing file on disk, but AdvanceStep - // will - // append steps later. - auto bpWriter = adios.Open("myNumbers.bp", "w", bpWriterSettings); - - if (bpWriter == nullptr) - throw std::ios_base::failure( - "ERROR: failed to open ADIOS bpWriter\n"); - - if (rank == 0) - { - // Writing a global scalar from only one process - bpWriter->Write<unsigned int>(varNX, Nx); - } - // Writing a local scalar on every process. Will be shown at reading as - // a 1D - // array - bpWriter->Write<int>(varNparts, Nparts); - - // Writing a global scalar on every process is useless. Information will - // be - // thrown away - // and only rank 0's data will be in the output - bpWriter->Write<int>(varNproc, nproc); - - // Make a 1D selection to describe the local dimensions of the variable - // we - // write and - // its offsets in the global spaces - adios::Selection &sel = adios.SelectionBoundingBox( - {Nx}, {rank * Nx}); // local dims and offsets; both as list - varNice.SetSelection(sel); - bpWriter->Write<double>(varNice, - NiceArray.data()); // Base class Engine own - // the Write<T> that - // will call overloaded - // Write from Derived - - adios::Selection &lsel = - adios.SelectionBoundingBox({1, Nparts}, {rank, 0}); - varRagged.SetSelection(sel); - bpWriter->Write<float>(varRagged, - RaggedArray.data()); // Base class Engine - // own the Write<T> - // that will call - // overloaded Write - // from Derived - - // Indicate we are done for this step - // N-to-M Aggregation, disk I/O will be performed during this call, - // unless - // time aggregation postpones all of that to some later step - bpWriter->Advance(); - bpWriter->AdvanceAsync(callback_func_to_notify_me); - - // Called once: indicate that we are done with this output for the run - bpWriter->Close(); - } - 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"; - } - } - - MPI_Finalize(); - - return 0; -} diff --git a/examples/groupless/compound/reader.cpp b/examples/groupless/compound/reader.cpp deleted file mode 100644 index aa6ff6d3168ec0d05065f5eb832ced3a908f24b5..0000000000000000000000000000000000000000 --- a/examples/groupless/compound/reader.cpp +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Distributed under the OSI-approved Apache License, Version 2.0. See - * accompanying file Copyright.txt for details. - * - * reader.cpp - * - * Created on: Feb 21, 2017 - * Author: eisen, modified from basic by pnorbert - */ - -#include <iostream> -#include <vector> - -#include <adios2.h> -#include <mpi.h> - -int main(int argc, char *argv[]) -{ - int rank, nproc; - MPI_Init(&argc, &argv); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &nproc); - const bool adiosDebug = true; - - adios::ADIOS adios(MPI_COMM_WORLD, adiosDebug); - - // Application variable - // GSE === user-defined structure - // - // Like HDF5 example, read with a subset of the structure that was written. - // Easily handled by FFS and HDF5, but ambitious for ADIOS - typedef struct s2_t - { - double c; - int a; - }; - unsigned int Nx; - int Nparts; - int Nwriters; - - try - { - // Define method for engine creation - // 1. Get method def from config file or define new one - adios::Method &bpReaderSettings = adios.GetMethod("input"); - if (bpReaderSettings.undeclared()) - { - // if not defined by user, we can change the default settings - bpReaderSettings.SetEngine("BP"); // BP is the default engine - } - - // Create engine smart pointer due to polymorphism, - // Default behavior - // auto bpReader = adios.Open( "myNumbers.bp", "r" ); - // this would just open with a default transport, which is "BP" - auto bpReader = adios.Open("myNumbers.bp", "r", bpReaderSettings); - - // All the above is same as default use: - // auto bpReader = adios.Open( "myNumbers.bp", "r"); - - if (bpReader == nullptr) - throw std::ios_base::failure( - "ERROR: failed to open ADIOS bpReader\n"); - - /* Variable names are available as a vector of strings */ - std::cout << "List of variables in file: " << bpReader->VariableNames - << "\n"; - - /* NX */ - bpReader->Read<unsigned int>( - "NX", - Nx); // read a Global scalar which has a single value in a step - - /* nproc */ - bpReader->Read<int>("nproc", Nwriters); // also a global scalar - - /* Nparts */ - // Nparts local scalar is presented as a 1D array of Nwriters elements. - // We need to read a specific value the same way as reading from any 1D - // array. - // Make a single-value selection to describe our rank's position in the - // 1D array of Nwriters values. - if (rank < Nwriters) - { - std::shared_ptr<adios::Variable> varNparts = - bpReader.InquiryVariable("Nparts"); - std::unique_ptr<adios::Selection> selNparts = - adios.SelectionBoundingBox({1}, {rank}); - varNparts->SetSelection(selNparts); - bpReader->Read<int>(varNparts, Nparts); - } - // or we could just read the whole array by every process - std::vector<int> partsV(Nwriters); - bpReader->Read<int>("Nparts", - partsV.data()); // read with string name, no - // selection => read whole array - - std::vector<int> partsV; - bpReader->Read<int>("Nparts", - partsV); // read with string name, no selection => - // read whole array - (Nwriters == partsV.size()) - - /* Nice */ - // inquiry about a variable, whose name we know - /* GSE === compound type declaration borrowed heavily from HDF5 - style */ - adios::CompType mtype(sizeof(s2_t)); - mtype.insertMember("c_name", OFFSET(s2_t, c), PredType::NATIVE_DOUBLE); - mtype.insertMember("a_name", OFFSET(s2_t, a), PredType::NATIVE_INT); - - /* - * GSE === this is a bit conceptually different. There was no real - * check in the prior API that the variable in the file was in any way - * "compatible" with how we planned to read it. This could be done - * here, by providing the details of the structure that we are - * prepared to read in the inquiryVariable, or if we had an API that - * allowed more introspection, we could perhaps support a query on the - * adios::Variable and a later operation that informed it of the data - * type that we were prepared to extract from it. - */ - std::shared_ptr<adios::Variable> varNice = - bpReader.InquiryVariable("Nice", mtype); - - if (varNice == nullptr) - throw std::ios_base::failure("ERROR: failed to find variable " - "'myDoubles' in input file\n"); - - // ? how do we know about the type? std::string varNice->m_Type - uint64_t gdim = varNice->m_Shape[0]; // ?member var or member func? - uint64_t ldim = gdim / nproc; - uint64_t offs = rank * ldim; - if (rank == nproc - 1) - { - ldim = gdim - (ldim * gdim); - } - - NiceArray.reserve(ldim); - - // Make a 1D selection to describe the local dimensions of the variable - // we - // READ and - // its offsets in the global spaces - std::unique_ptr<adios::Selection> bbsel = adios.SelectionBoundingBox( - {ldim}, {offs}); // local dims and offsets; both as list - varNice->SetSelection(bbsel); - // GSE === Again, templated here? - bpReader->Read<s2_t>(varNice, NiceArray.data()); - - /* Ragged */ - // inquiry about a variable, whose name we know - std::shared_ptr<adios::Variable<void>> varRagged = - bpReader.InquiryVariable("Ragged"); - if (varRagged->m_Shape[1] != adios::VARYING_DIMENSION) - { - throw std::ios_base::failure( - "Unexpected condition: Ragged array's fast dimension " - "is supposed to be VARYING_DIMENSION\n"); - } - // We have here varRagged->sum_nblocks, nsteps, nblocks[], global - if (rank < - varRagged->nblocks[0]) // same as rank < Nwriters in this example - { - // get per-writer size information - varRagged->InquiryBlocks(); - // now we have the dimensions per block - - unsigned long long int ldim = - varRagged->blockinfo[rank].m_Dimensions[1]; - RaggedArray.resize(ldim); - - std::unique_ptr<adios::Selection> wbsel = - adios.SelectionWriteblock(rank); - varRagged->SetSelection(wbsel); - bpReader->Read<float>(varRagged, RaggedArray.data()); - - // We can use bounding box selection as well - std::unique_ptr<adios::Selection> rbbsel = - adios.SelectionBoundingBox({1, ldim}, {rank, 0}); - varRagged->SetSelection(rbbsel); - bpReader->Read<float>(varRagged, RaggedArray.data()); - } - - /* Extra help to process Ragged */ - int maxRaggedDim = - varRagged->GetMaxGlobalDimensions(1); // contains the largest - std::vector<int> raggedDims = varRagged->GetVaryingGlobalDimensions( - 1); // contains all individual sizes in that dimension - - // Close file/stream - bpReader->Close(); - } - 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"; - } - } - - MPI_Finalize(); - - return 0; -} diff --git a/examples/groupless/compound/writer.cpp b/examples/groupless/compound/writer.cpp deleted file mode 100644 index 9c49ddf1e528344dd6a7206b898c1b69013d65db..0000000000000000000000000000000000000000 --- a/examples/groupless/compound/writer.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Distributed under the OSI-approved Apache License, Version 2.0. See - * accompanying file Copyright.txt for details. - * - * writer.cpp - * - * Created on: Feb 13, 2017 - * Author: pnorbert - */ - -#include <iostream> -#include <vector> - -#include <adios2.h> -#include <mpi.h> - -namespace adios -{ -typedef enum { VARYING_DIMENSION = -1, LOCAL_VALUE = 0, GLOBAL_VALUE = 1 }; -} - -int main(int argc, char *argv[]) -{ - int rank, nproc; - MPI_Init(&argc, &argv); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &nproc); - const bool adiosDebug = true; - - adios::ADIOS adios(MPI_COMM_WORLD, adiosDebug); - - // Application variable - const unsigned int Nx = 10; - // GSE === user-defined structure - typedef struct s1_t - { - int a; - float b; - double c; - }; - const int Nparts = rand() % 6 + 5; // random size per process, 5..10 each - - std::vector<s1_t> NiceArray(Nx); - for (int i = 0; i < Nx; i++) - { - NiceArray.push_back(ss1_t()); - NiceArray[i].a = rank * Nx + (double)i; - NiceArray[i].b = 100.0 * rank * Nx + 100.0 * (double)i; - NiceArray[i].c = 10000.0 * rank * Nx + 10000.0 * (double)i; - } - - try - { - /* GSE === compound type declaration borrowed heavily from HDF5 style */ - adios::CompType mtype(sizeof(s1_t)); - mtype.insertMember("a_name", OFFSET(s1_t, a), PredType::NATIVE_INT); - mtype.insertMember("c_name", OFFSET(s1_t, c), PredType::NATIVE_DOUBLE); - mtype.insertMember("b_name", OFFSET(s1_t, b), PredType::NATIVE_FLOAT); - - // Define group and variables with transforms, variables don't have - // functions, only group can access variables - adios::Variable<unsigned int> &varNX = - adios.DefineVariable<unsigned int>( - "NX"); // global single-value across processes - adios::Variable<int> &varNproc = adios.DefineVariable<int>( - "nproc", adios::GLOBAL_VALUE); // same def for global value - adios::Variable<int> &varNparts = - adios.DefineVariable<int>("Nparts", - adios::LOCAL_VALUE); // a single-value - // different on - // every process - - // GSE === template necessary or useful here? Extra argument for - // previously-built compound type information */ - adios::Variable<s1_t> &varNice = adios.DefineVariable<s1_t>( - "Nice", {nproc * Nx}, mtype); // 1D global array - - // add transform to variable in group...not executed (just testing API) - adios::Transform bzip2 = adios::transform::BZIP2(); - varNice->AddTransform(bzip2, 1); - - // Define method for engine creation - // 1. Get method def from config file or define new one - adios::Method &bpWriterSettings = adios.GetMethod("output"); - if (bpWriterSettings.undeclared()) - { - // if not defined by user, we can change the default settings - bpWriterSettings.SetEngine("BP"); // BP is the default engine - bpWriterSettings.AddTransport( - "File", - "lucky=yes"); // ISO-POSIX file is the default transport - // Passing parameters to the transport - bpWriterSettings.SetParameters( - "have_metadata_file", - "yes"); // Passing parameters to the engine - bpWriterSettings.SetParameters("Aggregation", - (nproc + 1) / - 2); // number of aggregators - } - - // Open returns a smart pointer to Engine containing the Derived class - // Writer - // "w" means we overwrite any existing file on disk, but AdvanceStep - // will - // append steps later. - auto bpWriter = adios.Open("myNumbers.bp", "w", bpWriterSettings); - - if (bpWriter == nullptr) - throw std::ios_base::failure( - "ERROR: failed to open ADIOS bpWriter\n"); - - if (rank == 0) - { - // Writing a global scalar from only one process - bpWriter->Write<unsigned int>(varNX, Nx); - } - // Writing a local scalar on every process. Will be shown at reading as - // a 1D - // array - bpWriter->Write<int>(varNparts, Nparts); - - // Writing a global scalar on every process is useless. Information will - // be - // thrown away - // and only rank 0's data will be in the output - bpWriter->Write<int>(varNproc, nproc); - - // Make a 1D selection to describe the local dimensions of the variable - // we - // write and - // its offsets in the global spaces - adios::Selection &sel = adios.SelectionBoundingBox( - {Nx}, {rank * Nx}); // local dims and offsets; both as list - varNice.SetSelection(sel); - - // GSE === Template useful or necessary here? We have to treat this as - // a - // void* inside ADIOS... - bpWriter->Write<sl_t>(varNice, NiceArray.data()); - - // Indicate we are done for this step - // N-to-M Aggregation, disk I/O will be performed during this call, - // unless - // time aggregation postpones all of that to some later step - bpWriter->Advance(); - bpWriter->AdvanceAsync(callback_func_to_notify_me); - - // Called once: indicate that we are done with this output for the run - bpWriter->Close(); - } - 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"; - } - } - - MPI_Finalize(); - - return 0; -} diff --git a/examples/hello/C/fstream.xml b/examples/hello/C/fstream.xml deleted file mode 100644 index f43942fb1e13329c05a43c714ee3f8e2c6807ac5..0000000000000000000000000000000000000000 --- a/examples/hello/C/fstream.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?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 deleted file mode 100644 index 58cca1452e86c5dc2ffb22451b47f7bd0122fdd2..0000000000000000000000000000000000000000 --- a/examples/hello/C/helloFStream.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Distributed under the OSI-approved Apache License, Version 2.0. See - * accompanying file Copyright.txt for details. - * - * helloFStream.c Test for C API version of helloFStream - * Created on: Nov 2, 2016 - * Author: wfg - */ - -#include "../../../include/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/README b/examples/hello/README deleted file mode 100644 index 5966d87b721fe4e925ca70c1d3e959c382b7a6d2..0000000000000000000000000000000000000000 --- a/examples/hello/README +++ /dev/null @@ -1,10 +0,0 @@ -Test if ADIOS MPI and noMPI code can be separated at compilation stage -Single Makefile handles different binaries - -make mpi -> for MPI code, links ../../lib/libadios.a -make nompi -> for noMPI code links ../../lib/libadios_nompi.a - -Choose different BASE_NAMES - -make nompi BASE_NAME=helloFStream -make nompi BASE_NAME=helloADIOS \ No newline at end of file diff --git a/examples/hello/README.md b/examples/hello/README.md new file mode 100644 index 0000000000000000000000000000000000000000..0c780bd6b2830759ef4f16846646dd326d3e0404 --- /dev/null +++ b/examples/hello/README.md @@ -0,0 +1,19 @@ +examples/hello + +Provides tests and illustrates how to use very basic functionality for a new component in adios2 + + +* adios1Writer (ADIOS_USE_ADIOS1=ON) + 1. Write BP format files using adios1 library through adios2 interface + +* bpWriter + 1. Write BP format files + +* datamanReader (to be deprecated, ADIOS_USE_DataMan=ON) + 1. Read real-time WAN streams using dataman + +* datamanWriter + 1. Write real-time WAN streams using dataman + +* hdf5Writer (ADIOS_USE_HDF5=ON) + 1. Write HDF5 files using interoperability through the adios2 interface \ No newline at end of file diff --git a/examples/hello/bpReader/helloBPReader.cpp b/examples/hello/bpReader/helloBPReader.cpp deleted file mode 100644 index e83a66c3f7e4a88714334ef4e9843862415dc2f7..0000000000000000000000000000000000000000 --- a/examples/hello/bpReader/helloBPReader.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Distributed under the OSI-approved Apache License, Version 2.0. See - * accompanying file Copyright.txt for details. - * - * helloWriter.cpp - * - * Created on: Feb 16, 2017 - * Author: wfg - */ - -#include <iostream> -#include <vector> - -#include <mpi.h> - -#include <adios2.h> - -int main(int argc, char *argv[]) -{ - MPI_Init(&argc, &argv); - int rank; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - const bool adiosDebug = true; - adios::ADIOS adios(MPI_COMM_WORLD, adiosDebug); - - try - { - // Define method for engine creation, it is basically straight-forward - // parameters - adios::Method &bpReaderSettings = adios.DeclareMethod( - "SingleFile"); // default method type is BPWriter - bpReaderSettings.AddTransport("File"); // uses default POSIX library - - // Create engine smart pointer due to polymorphism, - // Open returns a smart pointer to Engine containing the Derived class - // Writer - auto bpReader = adios.Open("myDoubles_nompi.bp", "r", bpReaderSettings); - - if (bpReader == nullptr) - throw std::ios_base::failure( - "ERROR: couldn't create bpReader at Open\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"; - } - } - - MPI_Finalize(); - - return 0; -} diff --git a/examples/hello/bpReader/helloBPReader_nompi.cpp b/examples/hello/bpReader/helloBPReader_nompi.cpp deleted file mode 100644 index fff9b96d42106b5975789771dcd1ad1569520084..0000000000000000000000000000000000000000 --- a/examples/hello/bpReader/helloBPReader_nompi.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Distributed under the OSI-approved Apache License, Version 2.0. See - * accompanying file Copyright.txt for details. - * - * helloADIOSNoXML_OOP.cpp - * - * Created on: Jan 9, 2017 - * Author: wfg - */ - -#include <iostream> -#include <vector> - -#include <adios2.h> - -int main(int argc, char *argv[]) -{ - const bool adiosDebug = true; - adios::ADIOS adios(adiosDebug); - - try - { - // Define method for engine creation, it is basically straight-forward - // parameters - adios::Method &bpReaderSettings = adios.DeclareMethod( - "SingleFile"); // default method type is BPWriter/BPReader - bpReaderSettings.AddTransport("File"); // uses default POSIX library - - // Create engine smart pointer due to polymorphism, - // Open returns a smart pointer to Engine containing the Derived class - // Writer - auto bpReader = adios.Open("myDoubles.bp", "r", bpReaderSettings); - - if (bpReader == nullptr) - throw std::ios_base::failure( - "ERROR: couldn't create bpReader at Open\n"); - } - catch (std::invalid_argument &e) - { - std::cout << "Invalid argument exception, STOPPING PROGRAM\n"; - std::cout << e.what() << "\n"; - } - catch (std::ios_base::failure &e) - { - std::cout << "System exception, STOPPING PROGRAM\n"; - std::cout << e.what() << "\n"; - } - catch (std::exception &e) - { - std::cout << "Exception, STOPPING PROGRAM\n"; - std::cout << e.what() << "\n"; - } - - return 0; -} diff --git a/examples/hello/compound/helloCompound.cpp b/examples/hello/compound/helloCompound.cpp deleted file mode 100644 index 50fed574af830c509dfc6c7a27ef230f312cf583..0000000000000000000000000000000000000000 --- a/examples/hello/compound/helloCompound.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Distributed under the OSI-approved Apache License, Version 2.0. See - * accompanying file Copyright.txt for details. - * - * helloCompound.cpp - * - * Created on: Feb 20, 2017 - * Author: wfg - */ - -#include <cstddef> // offsetof -#include <iostream> -#include <vector> - -#include <mpi.h> - -#include <adios2.h> - -struct Particle -{ - char Type[10]; ///< alpha, beta, gamma, etc. - double Position[3]; ///< x, y, z - double Velocity[3]; ///< Vx, Vy, Vz -}; - -int main(int argc, char *argv[]) -{ - MPI_Init(&argc, &argv); - int rank; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - const bool adiosDebug = true; - adios::ADIOS adios(MPI_COMM_WORLD, adiosDebug); - - // Application variable - std::vector<double> myDoubles = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; - const std::size_t Nx = myDoubles.size(); - - Particle myParticle; - sprintf(myParticle.Type, "%s", "photon"); - myParticle.Position[0] = 0; - myParticle.Position[1] = 1; - myParticle.Position[2] = 2; - - myParticle.Velocity[0] = 10; - myParticle.Velocity[1] = 11; - myParticle.Velocity[2] = 12; - - try - { - // Define variable and local size - adios::Variable<double> &ioMyDoubles = - adios.DefineVariable<double>("myDoubles", adios::Dims{Nx}); - - adios::VariableCompound &ioMyParticle = - adios.DefineVariableCompound<Particle>("myParticle", - adios::Dims{1}); - ioMyParticle.InsertMember<std::string>("Type", - offsetof(Particle, Type)); - ioMyParticle.InsertMember<std::vector<double>>( - "Position", offsetof(Particle, Position)); - ioMyParticle.InsertMember<std::vector<double>>( - "Velocity", offsetof(Particle, Velocity)); - - // Define method for engine creation, it is basically straight-forward - // parameters - adios::Method &bpWriterSettings = adios.DeclareMethod( - "SingleFile"); // default method type is BPWriter - bpWriterSettings.AddTransport( - "File", "have_metadata_file=yes"); // uses default POSIX library - - // Create engine smart pointer due to polymorphism, - // Open returns a smart pointer to Engine containing the Derived class - // Writer - auto bpWriter = adios.Open("myDoubles.bp", "w", bpWriterSettings); - - if (bpWriter == nullptr) - throw std::ios_base::failure( - "ERROR: couldn't create bpWriter at Open\n"); - - bpWriter->Write(ioMyDoubles, - myDoubles.data()); // Base class Engine own the - // Write<T> that will call - // overloaded Write from - // Derived - bpWriter->Close(); - } - 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"; - } - } - - MPI_Finalize(); - - return 0; -} diff --git a/examples/hello/compound/helloCompound_nompi.cpp b/examples/hello/compound/helloCompound_nompi.cpp deleted file mode 100644 index e14995a6d025483fa002cb97d54fcb296d7c350c..0000000000000000000000000000000000000000 --- a/examples/hello/compound/helloCompound_nompi.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Distributed under the OSI-approved Apache License, Version 2.0. See - * accompanying file Copyright.txt for details. - * - * helloCompound.cpp - * - * Created on: Feb 20, 2017 - * Author: wfg - */ - -#include <cstddef> // offsetof -#include <cstdio> -#include <iostream> -#include <vector> - -#include <adios2.h> - -struct Particle -{ - char Type[10]; ///< alpha, beta, gamma, etc. - double Position[3]; ///< x, y, z - double Velocity[3]; ///< Vx, Vy, Vz -}; - -int main(int argc, char *argv[]) -{ - const bool adiosDebug = true; - adios::ADIOS adios(adiosDebug); - - // Application variable - std::vector<double> myDoubles = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; - const std::size_t Nx = myDoubles.size(); - - Particle myParticle; - sprintf(myParticle.Type, "%s", "photon"); - myParticle.Position[0] = 0; - myParticle.Position[1] = 1; - myParticle.Position[2] = 2; - - myParticle.Velocity[0] = 10; - myParticle.Velocity[1] = 11; - myParticle.Velocity[2] = 12; - - try - { - // Define variable and local size - adios::Variable<double> &ioMyDoubles = - adios.DefineVariable<double>("myDoubles", adios::Dims{Nx}); - - adios::VariableCompound &ioMyParticle = - adios.DefineVariableCompound<Particle>("myParticle"); - ioMyParticle.InsertMember<char>("Type", offsetof(Particle, Type)); - ioMyParticle.InsertMember<double>("Position", - offsetof(Particle, Position)); - ioMyParticle.InsertMember<double>("Velocity", - offsetof(Particle, Velocity)); - - // Define method for engine creation, it is basically straight-forward - // parameters - adios::Method &bpWriterSettings = adios.DeclareMethod( - "SingleFile"); // default method type is BPWriter - bpWriterSettings.AddTransport( - "File", "have_metadata_file=yes"); // uses default POSIX library - - // Create engine smart pointer due to polymorphism, - // Open returns a smart pointer to Engine containing the Derived class - // Writer - auto bpWriter = adios.Open("myDoubles.bp", "w", bpWriterSettings); - - if (bpWriter == nullptr) - throw std::ios_base::failure( - "ERROR: couldn't create bpWriter at Open\n"); - - bpWriter->Write(ioMyDoubles, - myDoubles.data()); // Base class Engine own the - // Write<T> that will call - // overloaded Write from - // Derived - bpWriter->Close(); - } - catch (std::invalid_argument &e) - { - std::cout << "Invalid argument exception, STOPPING PROGRAM\n"; - std::cout << e.what() << "\n"; - } - catch (std::ios_base::failure &e) - { - std::cout << "System exception, STOPPING PROGRAM\n"; - std::cout << e.what() << "\n"; - } - catch (std::exception &e) - { - std::cout << "Exception, STOPPING PROGRAM\n"; - std::cout << e.what() << "\n"; - } - - return 0; -} diff --git a/examples/hello/fstream.xml b/examples/hello/fstream.xml deleted file mode 100644 index e46437445a1af49d4a8ee0465ea5a8762cfd430e..0000000000000000000000000000000000000000 --- a/examples/hello/fstream.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0"?> -<adios-config host-language="C++"> - <adios-group name="Vector"> - <var name="size" type="unsigned int"/> - <var name="numbers" type="int" dimension="size"/> - <attribute name="description" value="1 to 10"/> - </adios-group> - - - <transform type="bzip2" > - </transform> - - <!-- transport group="Types" method="FStream">verbose=3</transport> --> - - <method name="SingleFile" profile_units="mus" max_buffer_size="10000"> - <transport type="File" have_metadata_file="no" aggregators="10" profile_units="mus"/> - </method> - - <!-- <buffer size-MB="40" allocate-time="now"/> --> - -</adios-config> diff --git a/examples/hello/writer.xml b/examples/hello/writer.xml deleted file mode 100644 index 3a467ddc39c54a042e4e8e18e037d7dbb0ca43dc..0000000000000000000000000000000000000000 --- a/examples/hello/writer.xml +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version="1.0"?> -<adios-config host-language="Fortran"> - <adios-group name="writer2D"> - - <var name="nproc" path="/info" type="integer"/> - <attribute name="description" path="/info/nproc" value="Number of writers"/> - <var name="npx" path="/info" type="integer"/> - <attribute name="description" path="/info/npx" value="Number of processors in x dimension"/> - <var name="npy" path="/info" type="integer"/> - <attribute name="description" path="/info/npy" value="Number of processors in y dimension"/> - - <var name="gdx" type="integer"/> - <attribute name="description" path="/gdx" value="Global array size in x dimension"/> - <var name="gdy" type="integer"/> - <attribute name="description" path="/gdy" value="Global array size in y dimension"/> - - <!-- Auxiliary variables for global array indexing written (overwritten) by each process --> - <var name="ox" type="integer"/> - <var name="oy" type="integer"/> - <var name="ldx" type="integer"/> - <var name="ldy" type="integer"/> - - <!-- 2D array to write with block,block decomposition --> - <global-bounds dimensions="gdx,gdy" offsets="ox,oy"> - <var name="xy" type="double" dimensions="ldx,ldy"/> - </global-bounds> - <attribute name="description" path="/xy" - value="2D array with 2D decomposition"/> - - </adios-group> - - <!-- Use transport method - DATASPACES for staging data in memory coupling or - FLEXPATH for socket based staging between applications - MPI for file-based coupling - --> - <!--transport group="writer2D" method="MPI">verbose=2</transport--> - <!--transport group="writer2D" method="DATASPACES">verbose=3</transport--> - <transport group="writer2D" method="DIMES">verbose=3</transport> - <!--transport group="writer2D" method="FLEXPATH">QUEUE_SIZE=10;verbose=3</transport--> - - <buffer size-MB="40" allocate-time="now"/> - -</adios-config> diff --git a/examples/hello/writer2Groups.xml b/examples/hello/writer2Groups.xml deleted file mode 100644 index d019bdfdc3699c4f91e5c2c3963127e671b5d582..0000000000000000000000000000000000000000 --- a/examples/hello/writer2Groups.xml +++ /dev/null @@ -1,72 +0,0 @@ -<?xml version="1.0"?> -<adios-config host-language="Fortran"> - <adios-group name="writer2D"> - - <var name="nproc" path="/info" type="integer"/> - <attribute name="description" path="/info/nproc" value="Number of writers"/> - <var name="npx" path="/info" type="integer"/> - <attribute name="description" path="/info/npx" value="Number of processors in x dimension"/> - <var name="npy" path="/info" type="integer"/> - <attribute name="description" path="/info/npy" value="Number of processors in y dimension"/> - - <var name="gdx" type="integer"/> - <attribute name="description" path="/gdx" value="Global array size in x dimension"/> - <var name="gdy" type="integer"/> - <attribute name="description" path="/gdy" value="Global array size in y dimension"/> - - <!-- Auxiliary variables for global array indexing written (overwritten) by each process --> - <var name="ox" type="integer"/> - <var name="oy" type="integer"/> - <var name="ldx" type="integer"/> - <var name="ldy" type="integer"/> - - <!-- 2D array to write with block,block decomposition --> - <global-bounds dimensions="gdx,gdy" offsets="ox,oy"> - <var name="xy" type="double" dimensions="ldx,ldy"/> - </global-bounds> - <attribute name="description" path="/xy" - value="2D array with 2D decomposition"/> - - </adios-group> - - <!-- Use transport method - DATASPACES for staging data in memory coupling or - FLEXPATH for socket based staging between applications - MPI for file-based coupling - --> - <!--transport group="writer2D" method="MPI">verbose=2</transport--> - <!--transport group="writer2D" method="DATASPACES">verbose=3</transport--> - <transport group="writer2D" method="DIMES">verbose=3</transport> - <!--transport group="writer2D" method="FLEXPATH">QUEUE_SIZE=10;verbose=3</transport--> - <adios-group name="writer3D"> - - <var name="nproc" path="/info" type="integer"/> - <attribute name="description" path="/info/nproc" value="Number of writers"/> - <var name="npx" path="/info" type="integer"/> - <attribute name="description" path="/info/npx" value="Number of processors in x dimension"/> - <var name="npy" path="/info" type="integer"/> - <attribute name="description" path="/info/npy" value="Number of processors in y dimension"/> - - <var name="gdx" type="integer"/> - <attribute name="description" path="/gdx" value="Global array size in x dimension"/> - <var name="gdy" type="integer"/> - <attribute name="description" path="/gdy" value="Global array size in y dimension"/> - - <!-- Auxiliary variables for global array indexing written (overwritten) by each process --> - <var name="ox" type="integer"/> - <var name="oy" type="integer"/> - <var name="ldx" type="integer"/> - <var name="ldy" type="integer"/> - - <!-- 2D array to write with block,block decomposition --> - <global-bounds dimensions="gdx,gdy" offsets="ox,oy"> - <var name="xy" type="double" dimensions="ldx,ldy"/> - </global-bounds> - <attribute name="description" path="/xy" - value="2D array with 2D decomposition"/> - - </adios-group> - - <buffer size-MB="40" allocate-time="now"/> - -</adios-config> diff --git a/examples/solidfluid/solidfluid.xml b/examples/solidfluid/solidfluid.xml deleted file mode 100644 index 84cb101326dffce082b2a2870e23e48a9657d7ad..0000000000000000000000000000000000000000 --- a/examples/solidfluid/solidfluid.xml +++ /dev/null @@ -1,128 +0,0 @@ -<?xml version="1.0"?> -<adios-config host-language="C"> - - <!-- Changes to ADIOS-1 XML - Accommodate for the following extensions and flexiblity: - - Multiple engines e.g. SIRIUS can have it's own - - Do not bind one transport to a group, i.e. we can reuse a group in multiple I/O - with different transports - - Do not bind one group to each output file, i.e., we can write variables from - different groups into a single file at the same step - --> - - <!-- Execution Engines: default-engine, sirius, dataman, hdf5 - --> - - - <adios-group name="solid"> - <var name="NX" type="integer"/> - <var name="size" type="integer"/> - <var name="rank" type="integer"/> - - <global-bounds dimensions="size,NX" offsets="rank,0"> - <var name="temperature" gwrite="solid.t" type="double" dimensions="1,NX"/> - <var name="pressure" gwrite="solid.p" type="std::vector<double>" dimensions="1,NX"/> - </global-bounds> - - <attribute name="temperature/description" - value="Global array written from 'size' processes over several timesteps" - type="string"/> - </adios-group> - - - <adios-group name="fluid"> - <var name="NX" type="integer"/> - <var name="size" type="integer"/> - <var name="rank" type="integer"/> - - <global-bounds dimensions="size,NX" offsets="rank,0"> - <var name="temperature" gwrite="fluid.t" type="double" dimensions="1,NX"/> - <var name="pressure" gwrite="fluid.p" type="std::vector<double>" dimensions="1,NX"/> - </global-bounds> - - <attribute name="temperature/description" - value="Global array written from 'size' processes over several timesteps" - type="string"/> - </adios-group> - - - <adios-group name="checkpoint"> - <!-- Add all variables from group 'solid' with a path-prefix 'solid/...' - In adios write then one must refer to NX as "solid/NX", "solid/temperature", etc - If prefix is not defined, the variables are simply merged in with their path, but - then there should be no name collisions - --> - <add-group name="solid" prefix="solid" /> - <add-group name="fluid" prefix="fluid/" /> - </adios-group> - - - <!-- Method is with what we create an Output. It specifies either - 1. a group + a transport - 2. a group + a data manager - 3. a transport only - 4. a data manager only - - 1 & 3. default manager is used - 2 & 4. manager must have transports defined - 3 & 4. each write needs explicit group + variable as argument - --> - - <!-- Associate a single transport with a group. - The manager will be the default manager when opening an output with this group - The name of the method will be the same as the group ("checkpoint") - This ensures full backward-compatibility for ADIOS-1 XML files - --> - <method group="solid" transport="POSIX">options to POSIX transport</method> - - <!-- the statement below is equivalent to the one above plus --> - <method group="solid" > - <transport="POSIX">options to POSIX transport</transport> - </method> - - <method group="solid" <!-- engine="default-engine" --> > - <transport="POSIX" fname="out_p.bp">options to POSIX transport</transport> - <transport="MPI" fname="outsingle.bp">options to MPI transport</transport> - <!-- filenames overwrite the value provided in Open() call --> - </method> - - <!-- Same as above but we can name the method separately from group name. - Hence multiple methods can be declared for one group - --> - <method name="viz1" group="viz" transport="STAGING"></method> - <method name="viz2" group="viz" transport="MPI"></method> - - <!-- Associate an engine with a group and parameterize it here - The manager will define the transport(s) used in an output - --> - <method name="fluid" group="fluid" engine="sirius" fname="x.bp"> - <level transport="SHMEM">options to SHMEM transport</level> - <level target="ssd" target-path="/ssd/pnorbert/" transport="POSIX"/> - <level target="wan" transport="ICEE" /> - </method> - - <method group="checkpoint" transport="MPI_AGGREGATE"> - num_aggregators=1;num_ost=1 - </method> - - <!-- We can set a transport to a group which is not defined yet. - The group can/should be defined in the source code before use. - --> - <method group="grouptobe" transport="POSIX">options to transport</method> - - <!-- We can set a transport/engine without any group - All variables at writing should come from some existing group. - Each write call needs to add an extra argument to identify the variable's group - --> - <method name="groupless" transport="POSIX">options to transport</method> - <method name="groupless" > - <transport="POSIX">options to POSIX transport</transport> - </method> - - <!-- Global options for ADIOS that are not tied to a specific method --> - <options>verbose=2</options> - - <buffer max-size-MB="1"/> - -</adios-config> - diff --git a/examples/solidfluid/solidfluid_read.cpp b/examples/solidfluid/solidfluid_read.cpp deleted file mode 100644 index f451ff12d76a37317ebca73477997943b8c22247..0000000000000000000000000000000000000000 --- a/examples/solidfluid/solidfluid_read.cpp +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Distributed under the OSI-approved Apache License, Version 2.0. See - * accompanying file Copyright.txt for details. - * - * globalArrayXML.cpp - * - * Created on: Oct 31, 2016 - * Author: pnorbert - */ - -#include <fstream> -#include <iostream> -#include <mpi.h> -#include <stdexcept> -#include <string> -#include <vector> - -#include "adios2/ADIOS_OOP.h" - -struct MYDATA -{ - int NX; - double *t; - std::vector<double> p; -}; - -const int N = 10; -struct MYDATA solid, fluid; -MPI_Comm comm = MPI_COMM_WORLD; -int rank, size; - -void read_ckpt(adios::ADIOS adios, struct MYDATA &solid, struct MYDATA &fluid) -{ - try - { - // Open an input which was written with an expected Method - // The write transport is associated with the group in the XML - // ADIOS pairs that with the corresponding read transport - // "r" is required to indicate we are reading - auto ckptfile = adios.Open("checkpoint.bp", "r", comm, "checkpoint"); - // We can also manually set the read transport - // auto ckptfile = adios.Open("checkpoint.bp", adios::READ_METHOD_BP, - // "r", - // comm); - - // Note: we only see a single step in the input but the checkpoint has - // only one step anyway. This makes this code simple - - // simple immediate read of a scalar - ckptfile->ReadScalar("solid/NX", &solid.NX); - // solid.NX is filled at this point - - // scheduled version of read of another scalar - // //ckptfile->ScheduleRead ("fluid/NX", &fluid.NX); - // //ckptfile->Read(); // perform reading now - ckptfile->Read("fluid/NX", &fluid.NX); - // fluid.NX is filled at this point - - solid.t = new double(solid.NX); - solid.p = std::vector<double>(solid.NX); - - fluid.t = new double(fluid.NX); - fluid.p = std::vector<double>(fluid.NX); - - adios::ADIOS_SELECTION_WRITEBLOCK sel(rank); - adios.Read(ckptfile, sel, "solid/temperature", solid.t); - adios.Read(ckptfile, sel, "solid/pressure", solid.p); - adios.Read(ckptfile, sel, "fluid/temperature", fluid.t); - // force checking if the allocated space equals to the size of the - // selection: - adios.Read(ckptfile, sel, "fluid/pressure", fluid.p, - fluid.NX * sizeof(double)); - adios.Read(ckptfile, - true); // true: blocking read, which is also default - adios.Close( - ckptfile); // Should this do Read() if user misses or should we - // complain? - } - catch (std::exception &e) // need to think carefully how to handle C++ - // exceptions with MPI to avoid deadlocking - { - if (rank == 0) - { - std::cout << e.what() << "\n"; - } - } -} - -void read_solid(adios::ADIOS adios, struct MYDATA &solid) -{ - float timeout_sec = 1.0; - int retval = 0; - - try - { - // Open a file for input, no group defined - // A reading transport should be defined if not file based - // "r" is required to indicate we are reading - int solidfile = adios.Open("solid.bp", "r", - comm); //, ADIOS_LOCKMODE_NONE, timeout_sec); - // int solidfile = adios.Open("solid.bp", adios::READ_METHOD_BP, "r", - // comm); - /* process file here... */ - const adios::ADIOS_VARINFO &v = adios.InqVar(solidfile, "temperature"); - v.GetBlockInfo(); - - printf("ndim = %d\n", v.ndim); - // printf ("nsteps = %d\n", v.nsteps); - printf("dims[%" PRIu64 "][%" PRIu64 "]\n", v.dims[0], v.dims[1]); - - uint64_t slice_size = v.dims[0] / size; - - if (rank == size - 1) - slice_size = slice_size + v.dims[0] % size; - - start[0] = rank * slice_size; - count[0] = slice_size; - start[1] = 0; - count[1] = v.dims[1]; - - auto data = std::make_unique<double[]>(slice_size * v.dims[1] * 8); - - adios::ADIOS_SELECTION_BOUNDINGBOX sel(v.ndim, start, count); - - /* Processing loop over the steps (we are already in the first one) */ - while (adios_errno != err_end_of_stream) - { - steps++; // steps start counting from 1 - - solidfile.ScheduleRead(sel, "temperature", solid.t); - solidfile.Read(true); - - if (rank == 0) - printf("--------- Step: %d --------------------------------\n", - solidfile.getCurrentStep()); - - printf("rank=%d: [0:%" PRIu64 ",0:%" PRIu64 "] = [", rank, - v.dims[0], v.dims[1]); - for (i = 0; i < slice_size; i++) - { - printf(" ["); - for (j = 0; j < v.dims[1]; j++) - { - printf("%g ", *((double *)data + i * v.dims[1] + j)); - } - printf("]"); - } - printf(" ]\n\n"); - - // advance to 1) next available step with 2) blocking wait - solidfile.AdvanceStep(false, timeout_sec); - if (adios_errno == err_step_notready) - { - printf("rank %d: No new step arrived within the timeout. Quit. " - "%s\n", - rank, adios_errmsg()); - break; // quit while loop - } - } - solidfile.Close(); - } - catch (std::exception &e) - { - if (adios_errno == err_file_not_found) - { - printf("rank %d: Stream not found after waiting %f seconds: %s\n", - rank, timeout_sec, adios_errmsg()); - retval = adios_errno; - } - else if (adios_errno == err_end_of_stream) - { - printf("rank %d: Stream terminated before open. %s\n", rank, - adios_errmsg()); - retval = adios_errno; - } - else if (f == NULL) - { - printf("rank %d: Error at opening stream: %s\n", rank, - adios_errmsg()); - retval = adios_errno; - } - } -} - -void read_fluid(adios::ADIOS adios, struct MYDATA &fluid) -{ - float timeout_sec = 1.0; - int retval = 0; - - // Open a file for input, no group defined - // A reading transport should be defined if not file based - // "r" is required to indicate we are reading - adios::ADIOS_INPUT fluidfile(comm, "r"); - - try - { - fluidfile.Open("fluid.bp"); //, ADIOS_LOCKMODE_NONE, timeout_sec); - - /* process file here... */ - const adios::ADIOS_VARINFO &v = fluidfile.InqVar("temperature"); - v.GetBlockInfo(); - - printf("ndim = %d\n", v.ndim); - // printf ("nsteps = %d\n", v.nsteps); - printf("dims[%" PRIu64 "][%" PRIu64 "]\n", v.dims[0], v.dims[1]); - - uint64_t slice_size = v.dims[0] / size; - - if (rank == size - 1) - slice_size = slice_size + v.dims[0] % size; - - start[0] = rank * slice_size; - count[0] = slice_size; - start[1] = 0; - count[1] = v.dims[1]; - - data = malloc(slice_size * v.dims[1] * 8); - - adios::ADIOS_SELECTION_BOUNDINGBOX sel(v.ndim, start, count); - - /* Processing loop over the steps (we are already in the first one) */ - while (adios_errno != err_end_of_stream) - { - steps++; // steps start counting from 1 - - fluidfile.ScheduleRead(sel, "temperature", fluid.t); - fluidfile.Read(true); - - if (rank == 0) - printf("--------- Step: %d --------------------------------\n", - fluidfile.getCurrentStep()); - - printf("rank=%d: [0:%" PRIu64 ",0:%" PRIu64 "] = [", rank, - v.dims[0], v.dims[1]); - for (i = 0; i < slice_size; i++) - { - printf(" ["); - for (j = 0; j < v.dims[1]; j++) - { - printf("%g ", *((double *)data + i * v.dims[1] + j)); - } - printf("]"); - } - printf(" ]\n\n"); - - // advance to 1) next available step with 2) blocking wait - fluidfile.AdvanceStep(false, timeout_sec); - if (adios_errno == err_step_notready) - { - printf("rank %d: No new step arrived within the timeout. Quit. " - "%s\n", - rank, adios_errmsg()); - break; // quit while loop - } - } - fluidfile.Close(); - } - catch (std::exception &e) - { - if (adios_errno == err_file_not_found) - { - printf("rank %d: Stream not found after waiting %f seconds: %s\n", - rank, timeout_sec, adios_errmsg()); - retval = adios_errno; - } - else if (adios_errno == err_end_of_stream) - { - printf("rank %d: Stream terminated before open. %s\n", rank, - adios_errmsg()); - retval = adios_errno; - } - else if (f == NULL) - { - printf("rank %d: Error at opening stream: %s\n", rank, - adios_errmsg()); - retval = adios_errno; - } - } -} - -int main(int argc, char **argv) -{ - - MPI_Init(&argc, &argv); - MPI_Comm_rank(comm, &rank); - MPI_Comm_size(comm, &size); - - try - { - // ADIOS manager object creation. MPI must be initialized - adios::ADIOS adios("globalArrayXML.xml", comm, true); - - read_ckpt(adios, solid, fluid); - - read_solid(adios, solid); - - read_fluid(adios, fluid); - } - catch (std::exception &e) // need to think carefully how to handle C++ - // exceptions with MPI to avoid deadlocking - { - if (rank == 0) - { - std::cout << e.what() << "\n"; - } - } - if (rank == 0) - printf("We have processed %d steps\n", steps); - - free(data); - MPI_Finalize(); - - return retval; -} diff --git a/examples/solidfluid/solidfluid_write.cpp b/examples/solidfluid/solidfluid_write.cpp deleted file mode 100644 index a746dd52b6312dce6524f318690ee369cd288ccd..0000000000000000000000000000000000000000 --- a/examples/solidfluid/solidfluid_write.cpp +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Distributed under the OSI-approved Apache License, Version 2.0. See - * accompanying file Copyright.txt for details. - * - * solid fluid example - * - * Created on: Oct 31, 2016 - * Author: pnorbert - */ - -#include <fstream> -#include <iostream> -#include <stdexcept> -#include <string> -#include <vector> - -#include <adios2.h> - -using adiosFile = std::shared_ptr<adios::Engine>; - -struct MYDATA -{ - int NX; - double *t; - std::vector<double> p; -}; - -const int N = 10; -struct MYDATA solid, fluid; -MPI_Comm comm = MPI_COMM_WORLD; -int rank, size; - -void write_data(adiosFile writer, struct MYDATA &data) -{ - writer->Write("NX", &data.NX); - writer->Write("rank", &rank); - writer->Write("size", &size); - writer->Write("temperature", data.t); - writer->Write("pressure", data.p.data()); - // writer->Flush(); AdvanceStep()??? -} - -void write_checkpoint(adiosFile ckptfile, const struct MYDATA &solid, - const struct MYDATA &fluid) -{ - try - { - ckptfile->Write("solid/NX", &solid.NX); - ckptfile->Write("solid/rank", &rank); - ckptfile->Write("solid/size", &size); - ckptfile->Write("solid/temperature", solid.t); - ckptfile->Write("solid/pressure", &solid.p[0]); - - ckptfile->Write("fluid/NX", &fluid.NX); - ckptfile->Write("fluid/rank", &rank); - ckptfile->Write("fluid/size", &size); - ckptfile->Write("fluid/temperature", fluid.t); - ckptfile->Write("fluid/pressure", fluid.p.data()); - // ckptfile->AdvanceStep(); ?? - } - catch (std::exception &e) // need to think carefully how to handle C++ - // exceptions with MPI to avoid deadlocking - { - if (rank == 0) - { - std::cout << "ERROR: caught an exception from write_checkpoint\n"; - std::cout << e.what() << "\n"; - } - } -} - -void write_viz(std::shared_ptr<adios::Engine> vizstream, struct MYDATA &solid, - struct MYDATA &fluid) -{ - // This stream is not associated with a group, so we must say for each write - // which group to use - // The output variable is re-defined inside as <groupname>/<varname>, unless - // given as third string argument - // An array variable's dimension definitions are also re-defined with - // dimensions <groupname>/<dimensionvar> - - // vizstream->Write ("solid", "NX", &solid.NX); - // vizstream->Write ("solid", "rank", &rank); - // vizstream->Write ("solid", "size", &size); - - // write solid group's temperature simply as temperature, risking - // overloading - // the 'temperature' variable when - // reading from a file - - // vizstream->Write ("solid", "temperature", "my/tempvarinfile", solid.t); - - // vizstream->Write ("fluid", "NX", &fluid.NX); - // vizstream->Write ("fluid", "rank", &rank); - // vizstream->Write ("fluid", "size", &size); - - // vizstream->Write ("fluid", "temperature", "temperature", fluid.t); - - // vizstream->Flush(); // flushes all data to disk; required operation - // vizstream.AdvanceStep(); -} - -void compute(int it, struct MYDATA &solid, struct MYDATA &fluid) -{ - for (int i = 0; i < solid.NX; i++) - { - solid.t[i] = it * 100.0 + rank * solid.NX + i; - solid.p[i] = it * 1000.0 + rank * solid.NX + i; - } - for (int i = 0; i < fluid.NX; i++) - { - fluid.t[i] = it * 200.0 + rank * fluid.NX + i; - fluid.p[i] = it * 2000.0 + rank * fluid.NX + i; - } -} - -int main(int argc, char *argv[]) -{ - MPI_Init(&argc, &argv); - MPI_Comm_rank(comm, &rank); - MPI_Comm_size(comm, &size); - - solid.NX = N; - solid.t = new double[N]; - solid.p = std::vector<double>(N); - - fluid.NX = N; - fluid.t = new double[N]; - fluid.p = std::vector<double>(N); - - try - { - // ADIOS manager object creation. MPI must be initialized - adios::ADIOS adios(comm, true); - - adios::Method &fileSettings = - adios.DeclareMethod("Reusable"); // default engine is BP writer - fileSettings.AddTransport("POSIX", "have_metadata_file=no"); - - // Open a file with a Method which has selected a group and a transport - // in - // the XML. - // "a" will append to an already existing file, "w" would create a new - // file - // Multiple writes to the same file work as append in this application - // run - // FIXME: how do we support Update to same step? - - auto solidfile = adios.Open("solid.bp", "w", comm, fileSettings); - - // "solid" is a method but incidentally also a group - // Constructor only creates an object and what is needed there but does - // not - // open a stream/file - // It can be used to initialize a staging connection if not declared - // before - // FIXME: which argument can be post-poned into Open() instead of - // constructor? - // solidfile.Open("solid.bp"); - - // Open a file with a Method that has selected a group and an engine in - // the - // XML - // The transport method(s) are (must be) associated with the engines - // "a" will append to an already existing file, "w" would create a new - // file - // Multiple writes to the same file work as append in this application - // run - // FIXME: how do we support Update to same step? - auto fluidfile = adios.Open("fluid.bp", "w", comm, fileSettings); - - auto checkpointFile = - adios.Open("checkpoint.bp", "w", comm, fileSettings); - - // int ckptfile = adios.Open("checkpoint.bp", "checkpoint", "w", comm); - // we do not open this here, but every time when needed in a function - - // Another output not associated with a single group, so that we can mix - // variables to it - // adios:handle vizstream = adios.Open( "stream.bp", comm, "w", - // "STAGING", - // "options to staging method"); - auto vizstream = adios.Open("stream.bp", "w", comm, fileSettings); - - // This creates an empty group inside, and we can write all kinds of - // variables to it - - // Get Monitor info - std::ofstream logStream("info_" + std::to_string(rank) + ".log"); - adios.MonitorVariables(logStream); - - int checkPointSteps = 10; - - for (int it = 1; it <= 100; it++) - { - compute(it, solid, fluid); - - write_data(solidfile, solid); - write_data(fluidfile, fluid); - - if (it % checkPointSteps == 0) - { - write_checkpoint(checkpointFile, solid, fluid); - - MPI_Barrier(comm); - if (rank == 0) - { - std::cout - << "New checkpoint step, current = " << checkPointSteps - << "\n"; - std::cin >> checkPointSteps; - MPI_Bcast(&checkPointSteps, 1, MPI_INT, 0, comm); - } - MPI_Barrier(comm); - } - - write_viz(vizstream, solid, fluid); - - MPI_Barrier(comm); - if (rank == 0) - printf("Timestep %d written\n", it); - } - - solidfile->Close(); - fluidfile->Close(); - vizstream->Close(); - - // need barrier before we destroy the ADIOS object here automatically - MPI_Barrier(comm); - if (rank == 0) - printf("Finalize adios\n"); - } - catch (std::exception &e) // need to think carefully how to handle C++ - // exceptions with MPI to avoid deadlocking - { - if (rank == 0) - { - std::cout << "ERROR: " << e.what() << "\n"; - } - } - - delete[] solid.t; - delete[] fluid.t; - - if (rank == 0) - printf("Finalize MPI\n"); - MPI_Finalize(); - return 0; -} diff --git a/examples/solidfluid/solidfluid_write_nompi.cpp b/examples/solidfluid/solidfluid_write_nompi.cpp deleted file mode 100644 index ef8732ca2d5b951b65315298007ec30a813aa4a4..0000000000000000000000000000000000000000 --- a/examples/solidfluid/solidfluid_write_nompi.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Distributed under the OSI-approved Apache License, Version 2.0. See - * accompanying file Copyright.txt for details. - * - * solid fluid example - * - * Created on: Oct 31, 2016 - * Author: pnorbert - */ - -#include <fstream> -#include <iostream> -#include <stdexcept> -#include <string> -#include <vector> - -#include <adios2.h> - -using adiosFile = std::shared_ptr<adios::Engine>; - -struct MYDATA -{ - int NX; - double *t; - std::vector<double> p; -}; - -const int N = 10; -struct MYDATA solid, fluid; -int rank = 0, size = 1; - -void set_io_variables(adios::ADIOS &adios, const std::string process) -{ - adios.DefineVariable<int>(process + "/NX"); - adios.DefineVariable<int>(process + "/rank"); - adios.DefineVariable<int>(process + "/size"); - adios.DefineVariable<double>(process + "/temperature", adios::Dims{N}); - adios.DefineVariable<double>(process + "/pressure", adios::Dims{N}); -} - -void write_data(adiosFile writer, const std::string process, - struct MYDATA &data) -{ - writer->Write(process + "/NX", &data.NX); - writer->Write(process + "/rank", &rank); - writer->Write(process + "/size", &size); - writer->Write(process + "/temperature", data.t); - writer->Write(process + "/pressure", data.p.data()); - // writer->Flush(); AdvanceStep()??? -} - -void write_checkpoint(adiosFile ckptfile, const struct MYDATA &solid, - const struct MYDATA &fluid) -{ - try - { - ckptfile->Write("solid/NX", &solid.NX); - ckptfile->Write("solid/rank", &rank); - ckptfile->Write("solid/size", &size); - ckptfile->Write("solid/temperature", solid.t); - ckptfile->Write("solid/pressure", &solid.p[0]); - - ckptfile->Write("fluid/NX", &fluid.NX); - ckptfile->Write("fluid/rank", &rank); - ckptfile->Write("fluid/size", &size); - ckptfile->Write("fluid/temperature", fluid.t); - ckptfile->Write("fluid/pressure", fluid.p.data()); - // ckptfile->AdvanceStep(); ?? - } - catch (std::exception &e) // need to think carefully how to handle C++ - // exceptions with MPI to avoid deadlocking - { - if (rank == 0) - { - std::cout << "ERROR: caught an exception from write_checkpoint\n"; - std::cout << e.what() << "\n"; - } - } -} - -void write_viz(adiosFile vizstream, struct MYDATA &solid, struct MYDATA &fluid) -{ - // This stream is not associated with a group, so we must say for each write - // which group to use - // The output variable is re-defined inside as <groupname>/<varname>, unless - // given as third string argument - // An array variable's dimension definitions are also re-defined with - // dimensions <groupname>/<dimensionvar> - - // vizstream->Write ("solid", "NX", &solid.NX); - // vizstream->Write ("solid", "rank", &rank); - // vizstream->Write ("solid", "size", &size); - - // write solid group's temperature simply as temperature, risking - // overloading - // the 'temperature' variable when - // reading from a file - - // vizstream->Write ("solid", "temperature", "my/tempvarinfile", solid.t); - - // vizstream->Write ("fluid", "NX", &fluid.NX); - // vizstream->Write ("fluid", "rank", &rank); - // vizstream->Write ("fluid", "size", &size); - - // vizstream->Write ("fluid", "temperature", "temperature", fluid.t); - - // vizstream->Flush(); // flushes all data to disk; required operation - // vizstream.AdvanceStep(); -} - -void compute(int it, struct MYDATA &solid, struct MYDATA &fluid) -{ - for (int i = 0; i < solid.NX; i++) - { - solid.t[i] = it * 100.0 + rank * solid.NX + i; - solid.p[i] = it * 1000.0 + rank * solid.NX + i; - } - for (int i = 0; i < fluid.NX; i++) - { - fluid.t[i] = it * 200.0 + rank * fluid.NX + i; - fluid.p[i] = it * 2000.0 + rank * fluid.NX + i; - } -} - -int main(int argc, char *argv[]) -{ - solid.NX = N; - solid.t = new double[N]; - solid.p = std::vector<double>(N); - - fluid.NX = N; - fluid.t = new double[N]; - fluid.p = std::vector<double>(N); - - try - { - // ADIOS manager object creation. MPI must be initialized - adios::ADIOS adios(true); - set_io_variables(adios, "solid"); - set_io_variables(adios, "fluid"); - - adios::Method &fileSettings = - adios.DeclareMethod("Reusable"); // default engine is BP writer - fileSettings.AddTransport("POSIX", "have_metadata_file=no"); - - // Open a file with a Method which has selected a group and a transport - // in - // the XML. - // "a" will append to an already existing file, "w" would create a new - // file - // Multiple writes to the same file work as append in this application - // run - // FIXME: how do we support Update to same step? - - auto solidfile = adios.Open("solid.bp", "w", fileSettings); - - // "solid" is a method but incidentally also a group - // Constructor only creates an object and what is needed there but does - // not - // open a stream/file - // It can be used to initialize a staging connection if not declared - // before - // FIXME: which argument can be post-poned into Open() instead of - // constructor? - // solidfile.Open("solid.bp"); - - // Open a file with a Method that has selected a group and an engine in - // the - // XML - // The transport method(s) are (must be) associated with the engines - // "a" will append to an already existing file, "w" would create a new - // file - // Multiple writes to the same file work as append in this application - // run - // FIXME: how do we support Update to same step? - auto fluidfile = adios.Open("fluid.bp", "w", fileSettings); - - auto checkpointFile = adios.Open("checkpoint.bp", "w", fileSettings); - - // int ckptfile = adios.Open("checkpoint.bp", "checkpoint", "w", comm); - // we do not open this here, but every time when needed in a function - - // Another output not associated with a single group, so that we can mix - // variables to it - // adios:handle vizstream = adios.Open( "stream.bp", comm, "w", - // "STAGING", - // "options to staging method"); - auto vizstream = adios.Open("stream.bp", "w", fileSettings); - - // This creates an empty group inside, and we can write all kinds of - // variables to it - - // Get Monitor info - std::ofstream logStream("info_nompi.log"); - adios.MonitorVariables(logStream); - - int checkPointSteps = 10; - - for (int it = 1; it <= 100; it++) - { - compute(it, solid, fluid); - - write_data(solidfile, "solid", solid); - write_data(fluidfile, "fluid", fluid); - - if (it % checkPointSteps == 0) - { - write_checkpoint(checkpointFile, solid, fluid); - - { - std::cout - << "New checkpoint step, current = " << checkPointSteps - << "\n"; - std::cin >> checkPointSteps; - } - } - - write_viz(vizstream, solid, fluid); - - std::cout << "Timestep " << it << " written\n"; - } - - solidfile->Close(); - fluidfile->Close(); - vizstream->Close(); - checkpointFile->Close(); - - // need barrier before we destroy the ADIOS object here automatically - // ...no! - std::cout << "Finalize adios\n"; - } - catch (std::exception &e) // need to think carefully how to handle C++ - // exceptions with MPI to avoid deadlocking - { - std::cout << e.what() << "\n"; - } - - delete[] solid.t; - delete[] fluid.t; - - return 0; -} diff --git a/examples/xmlParser/xmlParser.cpp b/examples/xmlParser/xmlParser.cpp deleted file mode 100644 index e19295e5dc59196895a40b4ff57900c079aa24cb..0000000000000000000000000000000000000000 --- a/examples/xmlParser/xmlParser.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Distributed under the OSI-approved Apache License, Version 2.0. See - * accompanying file Copyright.txt for details. - * - * xmlParser.cpp - * - * Created on: Nov 2, 2016 - * Author: wfg - */ - -#include <iostream> -#include <stdexcept> -#include <string> - -#include "adios2/../../include/ADIOS.h" - -#ifdef HAVE_MPI -#include <mpi.h> -#else -#include "adios2/../../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"; -}