From ee915116c3174fde2645d9546efb002b5eca1b2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?JulienD=C3=B6rner?= Date: Thu, 5 Sep 2024 11:51:36 +0200 Subject: [PATCH] add dumping of index list --- include/crpropa/module/TextOutput.h | 2 ++ src/module/TextOutput.cpp | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/crpropa/module/TextOutput.h b/include/crpropa/module/TextOutput.h index 817fc1c0f..0c21caf43 100644 --- a/include/crpropa/module/TextOutput.h +++ b/include/crpropa/module/TextOutput.h @@ -71,6 +71,8 @@ class TextOutput: public Output { */ static void load(const std::string &filename, ParticleCollector *collector); std::string getDescription() const; + + void dumpIndexList(std::vector indicies); }; /** @}*/ diff --git a/src/module/TextOutput.cpp b/src/module/TextOutput.cpp index e979c85dc..2dda875da 100644 --- a/src/module/TextOutput.cpp +++ b/src/module/TextOutput.cpp @@ -7,6 +7,7 @@ #include "kiss/string.h" +#include #include #include #include @@ -378,4 +379,17 @@ void TextOutput::gzip() { #endif } +void TextOutput::dumpIndexList(std::vector indices) { +#pragma omp critical(FileOutput) + { + std::stringstream ss; + ss << "#" << "\t"; + for (int i = 0; i < indices.size(); i++) + ss << indices[i] << "\t"; + + const std::string cstr = ss.str(); + out-> write(cstr.c_str(), cstr.length()); + } +} + } // namespace crpropa