Advanced Multi-Physics (AMP)
On-Line Documentation
PIO.h
Go to the documentation of this file.
1#ifndef included_AMP_PIO
2#define included_AMP_PIO
3
4#include <cstdarg>
5#include <cstdint>
6#include <functional>
7#include <iostream>
8
9
10namespace AMP {
11
12
19class ParallelStreamBuffer final : public std::streambuf
20{
21public:
22 enum StreamOutputType : uint8_t {
23 null = 0,
24 out = 1,
25 log = 2,
26 err = 4,
28 err_log = 6
29 };
30
37
43
48 void setOutputStream( std::ofstream *stream );
49
55
59 int sync() override;
60
65 std::streamsize xsputn( const char *text, std::streamsize n ) override;
66
71 int overflow( int ch ) override;
72
78 int underflow() override;
79
83 void reset();
84
85private:
87 size_t d_size;
89 char *d_buffer;
90 std::ofstream *d_stream;
91 inline void reserve( size_t size );
92};
93
94
100extern std::ostream pout;
101
106extern std::ostream perr;
107
112extern std::ostream plog;
113
120inline int printp( const char *format, ... )
121{
122 va_list ap;
123 va_start( ap, format );
124 char tmp[4096];
125 int n = vsnprintf( tmp, sizeof( tmp ), format, ap );
126 va_end( ap );
127 pout << tmp;
128 pout.flush();
129 return n;
130}
131
132
137void logOnlyNodeZero( const std::string &filename );
138
144void logAllNodes( const std::string &filename, bool singleStream = false );
145
150
154void overrideCout( std::function<void( const char * )> fun );
155
159void overrideCerr( std::function<void( const char * )> fun );
160
161
162} // namespace AMP
163
164
165#endif
int overflow(int ch) override
ParallelStreamBuffer(StreamOutputType type)
int underflow() override
std::ofstream * d_stream
Definition PIO.h:90
StreamOutputType d_type
Definition PIO.h:86
std::streamsize xsputn(const char *text, std::streamsize n) override
void setOutputStream(std::ofstream *stream)
void setOutputType(StreamOutputType type)
void reserve(size_t size)
std::ostream plog
void logAllNodes(const std::string &filename, bool singleStream=false)
void logOnlyNodeZero(const std::string &filename)
void overrideCout(std::function< void(const char *)> fun)
void overrideCerr(std::function< void(const char *)> fun)
void stopLogging()
int printp(const char *format,...)
Definition PIO.h:120
std::ostream perr
std::ostream pout



Advanced Multi-Physics (AMP)
Oak Ridge National Laboratory
Idaho National Laboratory
Los Alamos National Laboratory
This page automatically produced from the
source code by doxygen
Last updated: Tue Mar 10 2026 13:06:40.
Comments on this page