Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/picongpu/plugins/openPMD/openPMDWriter.def
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <limits>
#include <list>
#include <memory> // std::unique_ptr
#include <optional>
#include <sstream>
#include <stdexcept> // throw std::runtime_error
#include <string>
Expand Down Expand Up @@ -124,7 +125,7 @@ namespace picongpu
/*
* If file is empty, read from command line parameters.
*/
void initFromConfig(Help&, size_t id, std::string const& dir, std::string const& file = "");
void initFromConfig(Help&, size_t id, std::string const& dir, std::optional<std::string> file = {});

/**
* Wrapper for ::openPMD::resetDataset, set dataset parameters
Expand Down
33 changes: 27 additions & 6 deletions include/picongpu/plugins/openPMD/openPMDWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,11 @@ make sure that environment variable OPENPMD_BP_BACKEND is not set to ADIOS1.
std::string const prefix = "openPMD";
};

void ThreadParams::initFromConfig(Help& help, size_t id, std::string const& dir, std::string const& file)
void ThreadParams::initFromConfig(
Help& help,
size_t id,
std::string const& dir,
std::optional<std::string> file)
{
std::string strategyString;
std::string jsonString;
Expand All @@ -373,23 +377,40 @@ make sure that environment variable OPENPMD_BP_BACKEND is not set to ADIOS1.
}
case ConfigurationVia::CommandLine:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that we don't need to fix the ConfigurationVia::Toml path since checkpoints cannot be configured via TOML.

{
if(!file.has_value())
{
/*
* If file is empty, then the openPMD plugin is running as a normal IO plugin.
* In this case, read the file from command line parameters.
* If there is a filename, it is running as a checkpoint and the filename
* has been supplied from outside.
* We must not read it from the command line since it's not there.
* Reason: A checkpoint is triggered by writing something like:
* > --checkpoint.file asdf --checkpoint.period 100
* ... and NOT by something like:
* > --checkpoint.openPMD.file asdf --checkpoint.period 100
*/
/* if file name is relative, prepend with common directory */
fileName = help.fileName.get(id);
}

/*
* These two however should always be read because they have default values.
*/
fileExtension = help.fileNameExtension.get(id);
fileInfix = help.fileNameInfix.get(id);
/* if file name is relative, prepend with common directory */
fileName = help.fileName.get(id);


strategyString = help.dataPreparationStrategy.get(id);
jsonString = help.jsonConfig.get(id);
break;
}
}

if(not file.empty())
if(file.has_value())
{
// If file was specified as function parameter (i.e. when checkpointing), ignore command line
// parameters for it
fileName = file;
fileName = file.value();
}

fileName = boost::filesystem::path(fileName).has_root_path() ? fileName : dir + "/" + fileName;
Expand Down