From 89a04db7018cf0829b13c5fc605a6baa90b21806 Mon Sep 17 00:00:00 2001 From: Ruben Horn <> Date: Wed, 6 Nov 2024 10:34:07 +0100 Subject: [PATCH] Fixed creation of ".tsv" file without output --- src/plugins/EnergyRAPL.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/EnergyRAPL.cpp b/src/plugins/EnergyRAPL.cpp index e0cd5554db..dedcc3eaa6 100644 --- a/src/plugins/EnergyRAPL.cpp +++ b/src/plugins/EnergyRAPL.cpp @@ -69,10 +69,12 @@ void EnergyRAPL::init(ParticleContainer* particleContainer, DomainDecompBase* do MPI_Get_processor_name(_processorName, &processorNameLength); MPI_Comm_rank(MPI_COMM_WORLD, &_thisRank); #endif - std::ostringstream outputFilename; - outputFilename << _outputprefix << ".tsv"; - std::ofstream outputFile(outputFilename.str().c_str()); - outputFile << "milliseconds\tsimstep\tjoules" << std::endl; + if (!_outputprefix.empty()) { + std::ostringstream outputFilename; + outputFilename << _outputprefix << ".tsv"; + std::ofstream outputFile(outputFilename.str().c_str()); + outputFile << "milliseconds\tsimstep\tjoules" << std::endl; + } // For each package... const int numberOfPackages = getNumberOfPackages(); for (int packageIdx = 0; packageIdx < numberOfPackages; packageIdx++) {