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