SST  11.1.0
StructuralSimulationToolkit
statoutputtxt.h
1 // Copyright 2009-2021 NTESS. Under the terms
2 // of Contract DE-NA0003525 with NTESS, the U.S.
3 // Government retains certain rights in this software.
4 //
5 // Copyright (c) 2009-2021, NTESS
6 // All rights reserved.
7 //
8 // This file is part of the SST software package. For license
9 // information, see the LICENSE file in the top level directory of the
10 // distribution.
11 
12 #ifndef SST_CORE_STATAPI_STATOUTPUTTXT_H
13 #define SST_CORE_STATAPI_STATOUTPUTTXT_H
14 
15 #include "sst/core/sst_types.h"
16 #include "sst/core/statapi/statoutput.h"
17 
18 #ifdef HAVE_LIBZ
19 #include <zlib.h>
20 #endif
21 
22 namespace SST {
23 namespace Statistics {
24 
25 /**
26  \class StatisticOutputTxt
27 
28  The class for statistics output to a text file.
29 */
31 {
32 public:
36  "sst",
37  "statoutputtxt",
38  SST_ELI_ELEMENT_VERSION(1,0,0),
39  "Output directly to console screen"
40  )
41 
42  /** Construct a StatOutputTxt
43  * @param outputParameters - Parameters used for this Statistic Output
44  */
45  StatisticOutputTxt(Params& outputParameters);
46 
47 protected:
48  /** Perform a check of provided parameters
49  * @return True if all required parameters and options are acceptable
50  */
51  bool checkOutputParameters() override;
52 
53  /** Print out usage for this Statistic Output */
54  void printUsage() override;
55 
56  /** Indicate to Statistic Output that simulation started.
57  * Statistic output may perform any startup code here as necessary.
58  */
59  void startOfSimulation() override;
60 
61  /** Indicate to Statistic Output that simulation ended.
62  * Statistic output may perform any shutdown code here as necessary.
63  */
64  void endOfSimulation() override;
65 
66  /** Implementation function for the start of output.
67  * This will be called by the Statistic Processing Engine to indicate that
68  * a Statistic is about to send data to the Statistic Output for processing.
69  * @param statistic - Pointer to the statistic object than the output can
70  * retrieve data from.
71  */
72  void implStartOutputEntries(StatisticBase* statistic) override;
73 
74  /** Implementation function for the end of output.
75  * This will be called by the Statistic Processing Engine to indicate that
76  * a Statistic is finished sending data to the Statistic Output for processing.
77  * The Statistic Output can perform any output related functions here.
78  */
79  void implStopOutputEntries() override;
80 
81  /** Implementation functions for output.
82  * These will be called by the statistic to provide Statistic defined
83  * data to be output.
84  * @param fieldHandle - The handle to the registered statistic field.
85  * @param data - The data related to the registered field to be output.
86  */
87  void outputField(fieldHandle_t fieldHandle, int32_t data) override;
88  void outputField(fieldHandle_t fieldHandle, uint32_t data) override;
89  void outputField(fieldHandle_t fieldHandle, int64_t data) override;
90  void outputField(fieldHandle_t fieldHandle, uint64_t data) override;
91  void outputField(fieldHandle_t fieldHandle, float data) override;
92  void outputField(fieldHandle_t fieldHandle, double data) override;
93 
94 protected:
95  StatisticOutputTxt() { ; } // For serialization
96 
97 private:
98  bool openFile();
99  void closeFile();
100  int print(const char* fmt, ...);
101 
102 private:
103 #ifdef HAVE_LIBZ
104  gzFile m_gzFile;
105 #endif
106  FILE* m_hFile;
107  std::string m_outputBuffer;
108  std::string m_FilePath;
109  bool m_outputTopHeader;
110  bool m_outputInlineHeader;
111  bool m_outputSimTime;
112  bool m_outputRank;
113  bool m_useCompression;
114 };
115 
116 } // namespace Statistics
117 } // namespace SST
118 
119 #endif // SST_CORE_STATAPI_STATOUTPUTTXT_H
void startOfSimulation() override
Indicate to Statistic Output that simulation started.
Definition: statoutputtxt.cc:84
void implStartOutputEntries(StatisticBase *statistic) override
Implementation function for the start of output.
Definition: statoutputtxt.cc:153
Forms the base class for statistics output generation within the SST core.
Definition: statoutput.h:49
Forms the base class for statistics gathering within SST.
Definition: statbase.h:63
bool checkOutputParameters() override
Perform a check of provided parameters.
Definition: statoutputtxt.cc:32
void endOfSimulation() override
Indicate to Statistic Output that simulation ended.
Definition: statoutputtxt.cc:146
The class for statistics output to a text file.
Definition: statoutputtxt.h:30
void outputField(fieldHandle_t fieldHandle, int32_t data) override
Implementation functions for output.
Definition: statoutputtxt.cc:199
void implStopOutputEntries() override
Implementation function for the end of output.
Definition: statoutputtxt.cc:192
Definition: statoutput.h:142
void printUsage() override
Print out usage for this Statistic Output.
Definition: statoutputtxt.cc:69
Parameter store.
Definition: params.h:43
SST_ELI_REGISTER_DERIVED(StatisticOutput, StatisticOutputTxt,"sst","statoutputtxt", SST_ELI_ELEMENT_VERSION(1, 0, 0),"Output directly to console screen") StatisticOutputTxt(Params &outputParameters)
Construct a StatOutputTxt.