Skip to content

Commit

Permalink
Merge pull request #989 from keichi/reorganize-params
Browse files Browse the repository at this point in the history
Allow specifying read/write method parameters in adios_reorganize
  • Loading branch information
pnorbert committed Nov 7, 2018
2 parents 79e162f + 3e5b97d commit ae4b1da
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
32 changes: 26 additions & 6 deletions source/utils/adios_reorganize/Reorganize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "adios2/core/Engine.h"
#include "adios2/core/IO.h"
#include "adios2/helper/adiosFunctions.h"
#include "adios2/helper/adiosString.h"

// C headers
#include <cerrno>
Expand All @@ -56,9 +57,9 @@ Reorganize::Reorganize(int argc, char *argv[])
infilename = std::string(argv[1]);
outfilename = std::string(argv[2]);
rmethodname = std::string(argv[3]);
rmethodparams = std::string(argv[4]);
rmethodparam_str = std::string(argv[4]);
wmethodname = std::string(argv[5]);
wmethodparams = std::string(argv[6]);
wmethodparam_str = std::string(argv[6]);

int nd = 0;
int j = 7;
Expand Down Expand Up @@ -113,9 +114,9 @@ void Reorganize::Run()
print0("Input stream = ", infilename);
print0("Output stream = ", outfilename);
print0("Read method = ", rmethodname);
print0("Read method parameters = ", rmethodparams);
print0("Read method parameters = ", rmethodparam_str);
print0("Write method = ", wmethodname);
print0("Write method parameters = ", wmethodparams);
print0("Write method parameters = ", wmethodparam_str);

#ifdef ADIOS2_HAVE_MPI
core::ADIOS adios(comm, true, "C++");
Expand All @@ -127,11 +128,12 @@ void Reorganize::Run()
print0("Waiting to open stream ", infilename, "...");

io.SetEngine(rmethodname);
io.SetParameter("verbose", "5");
io.SetParameters(rmethodparams);
core::Engine &rStream = io.Open(infilename, adios2::Mode::Read);
// rStream.FixedSchedule();

io.SetEngine(wmethodname);
io.SetParameters(wmethodparams);
core::Engine &wStream = io.Open(outfilename, adios2::Mode::Write);

int steps = 0;
Expand Down Expand Up @@ -205,7 +207,25 @@ void Reorganize::print0(Arg &&arg, Args &&... args)
}
}

void Reorganize::ParseArguments() {}
Params Reorganize::parseParams(const std::string &param_str)
{
std::istringstream ss(param_str);
std::vector<std::string> kvs;
std::string kv;

while (std::getline(ss, kv, ','))
{
kvs.push_back(kv);
}

return helper::BuildParametersMap(kvs, true);
}

void Reorganize::ParseArguments()
{
rmethodparams = parseParams(rmethodparam_str);
wmethodparams = parseParams(wmethodparam_str);
}

void Reorganize::ProcessParameters() const {}

Expand Down
17 changes: 11 additions & 6 deletions source/utils/adios_reorganize/Reorganize.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@ class Reorganize : public Utils
const core::DataMap &attributes, int step);
int ReadWrite(core::Engine &rStream, core::Engine &wStream, core::IO &io,
const core::DataMap &variables, int step);
Params parseParams(const std::string &param_str);

// Input arguments
std::string infilename; // File/stream to read
std::string outfilename; // File to write
std::string wmethodname; // ADIOS write method
std::string wmethodparams; // ADIOS write method
std::string rmethodname; // ADIOS read method
std::string rmethodparams; // ADIOS read method
std::string infilename; // File/stream to read
std::string outfilename; // File to write
std::string wmethodname; // ADIOS write method
std::string wmethodparam_str; // ADIOS write method parameter string
std::string rmethodname; // ADIOS read method
std::string rmethodparam_str; // ADIOS read method parameter string

static const int max_read_buffer_size = 1024 * 1024 * 1024;
static const int max_write_buffer_size = 1024 * 1024 * 1024;
Expand All @@ -86,6 +87,10 @@ class Reorganize : public Utils
int numproc = 1;
MPI_Comm comm;

// Read/write method parameters
Params rmethodparams;
Params wmethodparams;

uint64_t write_total = 0; // data size read/written by one processor
uint64_t largest_block = 0; // the largest variable block one process reads

Expand Down

0 comments on commit ae4b1da

Please sign in to comment.