27#include "Utility/IpplInfo.h"
34 : fname_m(fname), mode_m(
std::ios::out), indent_m(
" ") {
35 namespace fs = std::filesystem;
37 if (fs::exists(
fname_m) && restart) {
39 *
gmsg <<
"* Appending data to existing data file: '" <<
fname_m <<
"'" << endl;
41 *
gmsg <<
"* Creating new file for data: '" <<
fname_m <<
"'" << endl;
46 if (numberOfLines == 0 || ippl::Comm->rank() != 0) {
51 std::queue<std::string> allLines;
54 fs.open(
fname_m.c_str(), std::fstream::in);
56 if (!fs.is_open())
return;
58 while (getline(fs, line)) {
63 fs.open(
fname_m.c_str(), std::fstream::out);
65 if (!fs.is_open())
return;
67 while (allLines.size() > numberOfLines) {
68 fs << allLines.front() <<
"\n";
75 if (ippl::Comm->rank() != 0)
return;
77 std::string versionFile;
83 std::queue<std::string> allLines;
86 fs.open(
fname_m.c_str(), std::fstream::in);
88 if (!fs.is_open())
return;
90 while (getline(fs, line)) {
95 fs.open(
fname_m.c_str(), std::fstream::out);
97 if (!fs.is_open())
return;
99 while (!allLines.empty()) {
100 line = allLines.front();
102 if (line != versionFile) {
105 fs << buildinfo::project_name <<
" " << buildinfo::project_version <<
" git rev. #"
124 if (ippl::Comm->rank() != 0 ||
os_m.is_open())
return;
128 os_m.setf(std::ios::scientific, std::ios::floatfield);
132 if (ippl::Comm->rank() == 0 &&
os_m.is_open()) {
138 if (ippl::Comm->rank() != 0 ||
mode_m == std::ios::app)
return;
152 os_m <<
"SDDS1" << std::endl;
153 os_m <<
"&description\n"
163 os_m <<
"¶meter\n"
164 <<
indent_m <<
"name=" << std::get<0>(param) <<
",\n"
165 <<
indent_m <<
"type=" << std::get<1>(param) <<
",\n"
166 <<
indent_m <<
"description=\"" << std::get<2>(param) <<
"\"\n"
191 std::stringstream revision;
192 revision << buildinfo::project_name <<
" " << buildinfo::project_version <<
" "
199 flavor =
"opal-cycl";
204 addParameter(
"processors",
"long",
"Number of Cores used", ippl::Comm->size());
206 addParameter(
"revision",
"string",
"git revision of opal", revision.str());
208 addParameter(
"flavor",
"string",
"OPAL flavor that wrote file", flavor);
Template PIC bunch: IPPL PicManager, shared field mesh/solver, and multiple particle containers.
static OpalData * getInstance()
void writeHeader(std::ostream &os, const std::string &indent) const
void replaceVersionString()
SDDSWriter(const std::string &fname, bool restart)
void rewindLines(size_t numberOfLines)
delete the last 'numberOfLines' lines of the file 'fileName'
static constexpr unsigned int precision_m
double getLastValue(const std::string &column)
void addDefaultParameters()
std::queue< std::string > paramValues_m
void writeHeader()
Write SDDS header.
std::ios_base::openmode mode_m
First write to the statistics output file.
std::tuple< std::string, std::string, std::string > param_t
std::queue< param_t > params_m
void addParameter(const std::string &name, const std::string &type, const std::string &desc, const T &value)
void getParameterValue(std::string parameter_name, T &nval)
void getValue(int t, std::string column_name, T &nval)
std::string getGitRevision()