34 : fname_m(fname), mode_m(
std::ios::out), indent_m(
" ") {
35 namespace fs = boost::filesystem;
37 if (fs::exists(
fname_m) && restart) {
39 *
gmsg<<
"* Appending data to existing data file: '" <<
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);
59 while (getline(fs, line)) {
64 fs.open(
fname_m.c_str(), std::fstream::out);
69 while (allLines.size() > numberOfLines) {
70 fs << allLines.front() <<
"\n";
80 std::string versionFile;
86 std::queue<std::string> allLines;
89 fs.open(
fname_m.c_str(), std::fstream::in);
94 while (getline(fs, line)) {
99 fs.open(
fname_m.c_str(), std::fstream::out);
104 while (!allLines.empty()) {
105 line = allLines.front();
107 if (line != versionFile) {
134 os_m.setf(std::ios::scientific, std::ios::floatfield);
160 os_m <<
"&description\n"
170 os_m <<
"¶meter\n"
171 <<
indent_m <<
"name=" << std::get<0>(param) <<
",\n"
172 <<
indent_m <<
"type=" << std::get<1>(param) <<
",\n"
173 <<
indent_m <<
"description=\"" << std::get<2>(param) <<
"\"\n"
200 std::stringstream revision;
208 flavor =
"opal-cycl";
215 addParameter(
"revision",
"string",
"git revision of opal", revision.str());
217 addParameter(
"flavor",
"string",
"OPAL flavor that wrote file", flavor);
#define OPAL_PROJECT_VERSION
#define OPAL_PROJECT_NAME
Inform & endl(Inform &inf)
std::string getGitRevision()
std::unique_ptr< mpi::Communicator > Comm
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)
Converts the string value of a parameter to a value of type T.
void getValue(int t, std::string column_name, T &nval)
Converts the string value of a parameter at timestep t to a value of type T.