Utility class for printing debug output. More...
#include <DebugOutput.hpp>
Public Member Functions | |
DebugOutput (DebugOutputStream *str, unsigned verbosity=0) | |
DebugOutput (DebugOutputStream *str, int rank, unsigned verbosity=0) | |
DebugOutput (FILE *str, unsigned verbosity=0) | |
DebugOutput (FILE *str, int rank, unsigned verbosity=0) | |
DebugOutput (std::ostream &str, unsigned verbosity=0) | |
DebugOutput (std::ostream &str, int rank, unsigned verbosity=0) | |
DebugOutput (const char *pfx, DebugOutputStream *str, unsigned verbosity=0) | |
DebugOutput (const char *pfx, DebugOutputStream *str, int rank, unsigned verbosity=0) | |
DebugOutput (const char *pfx, FILE *str, unsigned verbosity=0) | |
DebugOutput (const char *pfx, FILE *str, int rank, unsigned verbosity=0) | |
DebugOutput (const char *pfx, std::ostream &str, unsigned verbosity=0) | |
DebugOutput (const char *pfx, std::ostream &str, int rank, unsigned verbosity=0) | |
DebugOutput (const DebugOutput ©) | |
DebugOutput & | operator= (const DebugOutput ©) |
~DebugOutput () | |
bool | have_rank () const |
Check if MPI rank has been set. More... | |
int | get_rank () const |
Get MPI rank. More... | |
void | set_rank (int rank) |
Set MPI rank. More... | |
void | use_world_rank () |
Set MPI rank to the rank of this proccess in MPI_COMM_WORLD, or zero if MOAB is build w/out MPI. More... | |
void | limit_output_to_first_N_procs (int N) |
Only print debug output from N processes. More... | |
unsigned | get_verbosity () const |
Get verbosity limit. More... | |
void | set_verbosity (unsigned val) |
Set verbosity limit. More... | |
const std::string & | get_prefix () const |
Get line prefix. More... | |
void | set_prefix (const std::string &str) |
Set line prefix. More... | |
void | print (int verbosity, const char *str) |
Output the specified string iff output is enabled. More... | |
void | print (int verbosity, const std::string &str) |
Output the specified string iff output is enabled. More... | |
void | printf (int verbosity, const char *fmt,...) MB_PRINTF(2) |
Output the specified printf-formatted output iff output is enabled. More... | |
void | tprint (int verbosity, const char *str) |
Output the specified string iff output is enabled. More... | |
void | tprint (int verbosity, const std::string &str) |
Output the specified string iff output is enabled. More... | |
void | tprintf (int verbosity, const char *fmt,...) MB_PRINTF(2) |
Output the specified printf-formatted output iff output is enabled. More... | |
void | print (int verbosity, const char *pfx, const Range &range) |
Print the contents of a moab::Range. More... | |
void | print (int verbosity, const Range &range) |
Print the contents of a moab::Range. More... | |
void | print_ints (int verbosity, const char *pfx, const Range &range) |
Print the contents of a moab::Range as numerical values only. More... | |
void | print_ints (int verbosity, const Range &range) |
Print the contents of a moab::Range as numerical values only. More... | |
Private Member Functions | |
void | tprint () |
void | list_range_real (const char *pfx, const Range &range) |
void | list_ints_real (const char *pfx, const Range &range) |
void | print_real (const char *buffer) |
void | print_real (const std::string &str) |
void | tprint_real (const char *buffer) |
void | tprint_real (const std::string &str) |
void | print_real (const char *buffer, va_list args1, va_list args2) |
void | tprint_real (const char *buffer, va_list args1, va_list args2) |
void | process_line_buffer () |
bool | check (unsigned verbosity) |
Private Attributes | |
std::string | linePfx |
DebugOutputStream * | outputImpl |
int | mpiRank |
unsigned | verbosityLimit |
CpuTimer | cpuTi |
std::vector< char > | lineBuffer |
Utility class for printing debug output.
This class implements line-oriented output. That is, it buffers output data until a newline is encountered, at which point it sends the output to the output stream followed by an explicit flush, and optionally prefixed with the MPI rank.
This class also implements a verbosity filter for all output. The class instance has a verbosity limit. Each request for output has an associated verbosity level. If the verbosity level for the output is is less greater than the limit then the output is discarded. By convetion a verbosity limit of zero should indicate no output. Therefore all requests for output should have an associated verbosity level greater than or equal to one.
\Note Any output not terminated with an newline character or followed by later output containing a newline character will not be flushed until the destructor is invoked. \Note C++-style IO (i.e. std::ostream) is not supported because it is necessarily inefficient for debug-type output. All formatting (e.g. converting arguments to strings, etc.) must be done even when output is disabled.
Definition at line 43 of file DebugOutput.hpp.
moab::DebugOutput::DebugOutput | ( | DebugOutputStream * | str, |
unsigned | verbosity = 0 |
||
) |
str | Output stream to which to flush output |
verbosity | Verbosity limit. |
Definition at line 62 of file DebugOutput.cpp.
63 : outputImpl( impl ), mpiRank( -1 ), verbosityLimit( verbosity )
64 {
65 impl->referenceCount++;
66 assert( impl->referenceCount > 1 );
67 }
References moab::DebugOutputStream::referenceCount.
moab::DebugOutput::DebugOutput | ( | DebugOutputStream * | str, |
int | rank, | ||
unsigned | verbosity = 0 |
||
) |
str | Output stream to which to flush output |
rank | MPI rank with which to prefix output. |
verbosity | Verbosity limit. |
Definition at line 68 of file DebugOutput.cpp.
69 : outputImpl( impl ), mpiRank( rank ), verbosityLimit( verbosity )
70 {
71 impl->referenceCount++;
72 assert( impl->referenceCount > 1 );
73 }
References moab::DebugOutputStream::referenceCount.
moab::DebugOutput::DebugOutput | ( | FILE * | str, |
unsigned | verbosity = 0 |
||
) |
str | Output stream to which to flush output |
enabled | Enable output: if not true, all output operations to nothing. |
Definition at line 74 of file DebugOutput.cpp.
75 : outputImpl( new FILEDebugStream( impl ) ), mpiRank( -1 ), verbosityLimit( verbosity )
76 {
77 }
moab::DebugOutput::DebugOutput | ( | FILE * | str, |
int | rank, | ||
unsigned | verbosity = 0 |
||
) |
str | Output stream to which to flush output |
rank | MPI rank with which to prefix output. |
verbosity | Verbosity limit. |
Definition at line 78 of file DebugOutput.cpp.
79 : outputImpl( new FILEDebugStream( impl ) ), mpiRank( rank ), verbosityLimit( verbosity )
80 {
81 }
moab::DebugOutput::DebugOutput | ( | std::ostream & | str, |
unsigned | verbosity = 0 |
||
) |
str | Output stream to which to flush output |
verbosity | Verbosity limit. |
Definition at line 82 of file DebugOutput.cpp.
83 : outputImpl( new CxxDebugStream( str ) ), mpiRank( -1 ), verbosityLimit( verbosity )
84 {
85 }
moab::DebugOutput::DebugOutput | ( | std::ostream & | str, |
int | rank, | ||
unsigned | verbosity = 0 |
||
) |
str | Output stream to which to flush output |
rank | MPI rank with which to prefix output. |
verbosity | Verbosity limit. |
Definition at line 86 of file DebugOutput.cpp.
87 : outputImpl( new CxxDebugStream( str ) ), mpiRank( rank ), verbosityLimit( verbosity )
88 {
89 }
moab::DebugOutput::DebugOutput | ( | const char * | pfx, |
DebugOutputStream * | str, | ||
unsigned | verbosity = 0 |
||
) |
pfx | Prefix for output |
str | Output stream to which to flush output |
verbosity | Verbosity limit. |
Definition at line 90 of file DebugOutput.cpp.
91 : linePfx( pfx ), outputImpl( impl ), mpiRank( -1 ), verbosityLimit( verbosity )
92 {
93 impl->referenceCount++;
94 assert( impl->referenceCount > 1 );
95 }
References moab::DebugOutputStream::referenceCount.
moab::DebugOutput::DebugOutput | ( | const char * | pfx, |
DebugOutputStream * | str, | ||
int | rank, | ||
unsigned | verbosity = 0 |
||
) |
pfx | Prefix for output |
str | Output stream to which to flush output |
rank | MPI rank with which to prefix output. |
verbosity | Verbosity limit. |
Definition at line 96 of file DebugOutput.cpp.
97 : linePfx( pfx ), outputImpl( impl ), mpiRank( rank ), verbosityLimit( verbosity )
98 {
99 impl->referenceCount++;
100 assert( impl->referenceCount > 1 );
101 }
References moab::DebugOutputStream::referenceCount.
moab::DebugOutput::DebugOutput | ( | const char * | pfx, |
FILE * | str, | ||
unsigned | verbosity = 0 |
||
) |
pfx | Prefix for output |
str | Output stream to which to flush output |
enabled | Enable output: if not true, all output operations to nothing. |
Definition at line 102 of file DebugOutput.cpp.
103 : linePfx( pfx ), outputImpl( new FILEDebugStream( impl ) ), mpiRank( -1 ), verbosityLimit( verbosity )
104 {
105 }
moab::DebugOutput::DebugOutput | ( | const char * | pfx, |
FILE * | str, | ||
int | rank, | ||
unsigned | verbosity = 0 |
||
) |
pfx | Prefix for output |
str | Output stream to which to flush output |
rank | MPI rank with which to prefix output. |
verbosity | Verbosity limit. |
Definition at line 106 of file DebugOutput.cpp.
107 : linePfx( pfx ), outputImpl( new FILEDebugStream( impl ) ), mpiRank( rank ), verbosityLimit( verbosity )
108 {
109 }
moab::DebugOutput::DebugOutput | ( | const char * | pfx, |
std::ostream & | str, | ||
unsigned | verbosity = 0 |
||
) |
pfx | Prefix for output |
str | Output stream to which to flush output |
verbosity | Verbosity limit. |
Definition at line 110 of file DebugOutput.cpp.
111 : linePfx( pfx ), outputImpl( new CxxDebugStream( str ) ), mpiRank( -1 ), verbosityLimit( verbosity )
112 {
113 }
moab::DebugOutput::DebugOutput | ( | const char * | pfx, |
std::ostream & | str, | ||
int | rank, | ||
unsigned | verbosity = 0 |
||
) |
pfx | Prefix for output |
str | Output stream to which to flush output |
rank | MPI rank with which to prefix output. |
verbosity | Verbosity limit. |
Definition at line 114 of file DebugOutput.cpp.
115 : linePfx( pfx ), outputImpl( new CxxDebugStream( str ) ), mpiRank( rank ), verbosityLimit( verbosity )
116 {
117 }
moab::DebugOutput::DebugOutput | ( | const DebugOutput & | copy | ) |
Definition at line 119 of file DebugOutput.cpp.
120 : linePfx( copy.linePfx ), outputImpl( copy.outputImpl ), mpiRank( copy.mpiRank ),
121 verbosityLimit( copy.verbosityLimit )
122 {
123 outputImpl->referenceCount++;
124 assert( outputImpl->referenceCount > 1 );
125 }
References outputImpl, and moab::DebugOutputStream::referenceCount.
moab::DebugOutput::~DebugOutput | ( | ) |
Destructor flushes any remaining output that wasn't followed by a newline character.
Definition at line 138 of file DebugOutput.cpp.
139 {
140 if( !lineBuffer.empty() )
141 {
142 lineBuffer.push_back( '\n' );
143 process_line_buffer();
144 }
145 if( outputImpl )
146 {
147 assert( outputImpl->referenceCount > 0 );
148 if( !--outputImpl->referenceCount ) delete outputImpl;
149 outputImpl = 0;
150 }
151 }
References lineBuffer, outputImpl, process_line_buffer(), and moab::DebugOutputStream::referenceCount.
|
inlineprivate |
Definition at line 263 of file DebugOutput.hpp.
264 {
265 return verbosity <= verbosityLimit;
266 }
References verbosityLimit.
Referenced by print(), print_ints(), printf(), tprint(), and tprintf().
|
inline |
Get line prefix.
Definition at line 167 of file DebugOutput.hpp.
168 {
169 return linePfx;
170 }
References linePfx.
|
inline |
Get MPI rank.
Definition at line 136 of file DebugOutput.hpp.
137 {
138 return mpiRank;
139 }
References mpiRank.
Referenced by process_line_buffer().
|
inline |
Get verbosity limit.
Definition at line 156 of file DebugOutput.hpp.
157 {
158 return verbosityLimit;
159 }
References verbosityLimit.
Referenced by moab::WriteHDF5Parallel::communicate_shared_set_ids(), moab::ParallelComm::correct_thin_ghost_layers(), moab::ScdNCHelper::create_mesh(), moab::WriteHDF5Parallel::create_tag_tables(), moab::ReadHDF5::debug_barrier_line(), moab::WriteHDF5Parallel::debug_barrier_line(), moab::ParallelComm::define_mpe(), moab::ParallelComm::exchange_ghost_cells(), moab::ParallelComm::exchange_owned_mesh(), moab::ParallelComm::exchange_tags(), moab::ParallelComm::get_debug_verbosity(), moab::ParallelComm::pack_tag(), moab::ReadNC::parse_options(), moab::WriteNC::parse_options(), moab::ParallelComm::print_debug_recd(), moab::ParallelComm::print_debug_waitany(), moab::print_type_sets(), moab::ScdNCHelper::read_scd_variables_to_nonset(), moab::NCHelperGCRM::read_ucd_variables_to_nonset(), moab::NCHelperHOMME::read_ucd_variables_to_nonset(), moab::NCHelperMPAS::read_ucd_variables_to_nonset(), moab::NCHelper::read_variables_to_set(), moab::ParallelComm::recv_entities(), moab::ParallelComm::reduce_tags(), moab::ParallelComm::resolve_shared_ents(), moab::ParallelComm::send_entities(), moab::ParallelComm::send_recv_entities(), moab::ParallelComm::settle_intersection_points(), and moab::ParallelComm::unpack_buffer().
|
inline |
Check if MPI rank has been set.
Definition at line 131 of file DebugOutput.hpp.
132 {
133 return mpiRank >= 0;
134 }
References mpiRank.
Referenced by process_line_buffer().
|
inline |
Only print debug output from N processes.
Definition at line 150 of file DebugOutput.hpp.
151 { 152 if( mpiRank >= N ) verbosityLimit = 0; 153 }
References mpiRank, and verbosityLimit.
Referenced by moab::WriteHDF5Parallel::parallel_create_file(), and moab::ReadHDF5::set_up_read().
|
private |
Definition at line 309 of file DebugOutput.cpp.
310 {
311 if( range.empty() )
312 {
313 print_real( "<empty>\n" );
314 return;
315 }
316
317 if( pfx )
318 {
319 lineBuffer.insert( lineBuffer.end(), pfx, pfx + strlen( pfx ) );
320 lineBuffer.push_back( ' ' );
321 }
322
323 char numbuf[48]; // unsigned 64 bit integer can't have more than 20 decimal digits
324 Range::const_pair_iterator i;
325 for( i = range.const_pair_begin(); i != range.const_pair_end(); ++i )
326 {
327 if( i->first == i->second )
328 snprintf( numbuf, 48, " %lu,", (unsigned long)( i->first ) );
329 else
330 print_range( numbuf, 48, (unsigned long)( i->first ), (unsigned long)( i->second ) );
331 lineBuffer.insert( lineBuffer.end(), numbuf, numbuf + strlen( numbuf ) );
332 }
333
334 lineBuffer.push_back( '\n' );
335 process_line_buffer();
336 }
References moab::Range::const_pair_begin(), moab::Range::const_pair_end(), moab::Range::empty(), lineBuffer, moab::print_range(), print_real(), and process_line_buffer().
Referenced by print_ints().
|
private |
Definition at line 273 of file DebugOutput.cpp.
274 {
275 if( pfx )
276 {
277 lineBuffer.insert( lineBuffer.end(), pfx, pfx + strlen( pfx ) );
278 lineBuffer.push_back( ' ' );
279 }
280
281 if( range.empty() )
282 {
283 print_real( "<empty>\n" );
284 return;
285 }
286
287 char numbuf[48]; // unsigned 64 bit integer can't have more than 20 decimal digits
288 Range::const_pair_iterator i;
289 EntityType type = MBMAXTYPE;
290 for( i = range.const_pair_begin(); i != range.const_pair_end(); ++i )
291 {
292 if( TYPE_FROM_HANDLE( i->first ) != type )
293 {
294 type = TYPE_FROM_HANDLE( i->first );
295 const char* name = CN::EntityTypeName( type );
296 lineBuffer.insert( lineBuffer.end(), name, name + strlen( name ) );
297 }
298 if( i->first == i->second )
299 snprintf( numbuf, 48, " %lu,", (unsigned long)( ID_FROM_HANDLE( i->first ) ) );
300 else
301 print_range( numbuf, 48, ID_FROM_HANDLE( i->first ), ID_FROM_HANDLE( i->second ) );
302 lineBuffer.insert( lineBuffer.end(), numbuf, numbuf + strlen( numbuf ) );
303 }
304
305 lineBuffer.push_back( '\n' );
306 process_line_buffer();
307 }
References moab::Range::const_pair_begin(), moab::Range::const_pair_end(), moab::Range::empty(), moab::CN::EntityTypeName(), moab::ID_FROM_HANDLE(), lineBuffer, MBMAXTYPE, moab::print_range(), print_real(), process_line_buffer(), and moab::TYPE_FROM_HANDLE().
Referenced by print().
DebugOutput & moab::DebugOutput::operator= | ( | const DebugOutput & | copy | ) |
Definition at line 127 of file DebugOutput.cpp.
128 {
129 linePfx = copy.linePfx;
130 outputImpl = copy.outputImpl;
131 mpiRank = copy.mpiRank;
132 verbosityLimit = copy.verbosityLimit;
133 outputImpl->referenceCount++;
134 assert( outputImpl->referenceCount > 1 );
135 return *this;
136 }
References linePfx, mpiRank, outputImpl, moab::DebugOutputStream::referenceCount, and verbosityLimit.
|
inline |
Print the contents of a moab::Range.
pfx | String to print after default class prefix and before range contents |
Definition at line 215 of file DebugOutput.hpp.
216 {
217 if( check( verbosity ) ) list_range_real( pfx, range );
218 }
References check(), and list_range_real().
|
inline |
Output the specified string iff output is enabled.
Definition at line 178 of file DebugOutput.hpp.
179 {
180 if( check( verbosity ) ) print_real( str );
181 }
References check(), and print_real().
Referenced by moab::WriteHDF5Parallel::communicate_shared_set_ids(), moab::WriteHDF5Parallel::create_tag_tables(), moab::ReadHDF5::delete_non_side_elements(), moab::ReadParallel::delete_nonlocal_entities(), moab::WriteHDF5Parallel::gather_interface_meshes(), moab::ReadHDF5::get_partition(), moab::ReadParallel::load_file(), moab::ReadHDF5::load_file_partial(), main(), moab::WriteHDF5Parallel::negotiate_type_list(), moab::WriteHDF5Parallel::parallel_create_file(), moab::ParallelComm::print_debug_waitany(), moab::WriteHDF5Parallel::print_set_sharing_data(), moab::print_type_sets(), moab::ReadHDF5::read_nodes(), moab::ReadHDF5::read_sparse_tag_indices(), moab::ParallelComm::resolve_shared_ents(), moab::ReadHDF5::set_up_read(), moab::ParallelComm::unpack_buffer(), moab::WriteHDF5::write_adjacencies(), moab::WriteHDF5::write_elems(), moab::WriteHDF5::write_nodes(), moab::WriteHDF5::write_qa(), moab::WriteHDF5::write_set_data(), moab::WriteHDF5::write_sets(), moab::WriteHDF5::write_sparse_ids(), moab::WriteHDF5::write_tag_values(), moab::WriteHDF5::write_var_len_data(), and moab::WriteHDF5::write_var_len_indices().
|
inline |
Print the contents of a moab::Range.
Definition at line 220 of file DebugOutput.hpp.
221 {
222 if( check( verbosity ) ) list_range_real( 0, range );
223 }
References check(), and list_range_real().
|
inline |
Output the specified string iff output is enabled.
Definition at line 184 of file DebugOutput.hpp.
185 {
186 if( check( verbosity ) ) print_real( str );
187 }
References check(), and print_real().
|
inline |
Print the contents of a moab::Range as numerical values only.
pfx | String to print after default class prefix and before range contents |
Definition at line 227 of file DebugOutput.hpp.
228 {
229 if( check( verbosity ) ) list_ints_real( pfx, range );
230 }
References check(), and list_ints_real().
Referenced by moab::ReadHDF5::load_file_partial(), and moab::ReadHDF5::read_set_ids_recursive().
|
inline |
Print the contents of a moab::Range as numerical values only.
Definition at line 232 of file DebugOutput.hpp.
233 {
234 if( check( verbosity ) ) list_ints_real( 0, range );
235 }
References check(), and list_ints_real().
|
private |
Definition at line 162 of file DebugOutput.cpp.
163 {
164 lineBuffer.insert( lineBuffer.end(), buffer, buffer + strlen( buffer ) );
165 process_line_buffer();
166 }
References buffer, lineBuffer, and process_line_buffer().
Referenced by list_ints_real(), list_range_real(), print(), printf(), and tprint_real().
|
private |
Definition at line 186 of file DebugOutput.cpp.
187 {
188 size_t idx = lineBuffer.size();
189 #ifdef MOAB_HAVE_VSNPRINTF
190 // try once with remaining space in buffer
191 lineBuffer.resize( lineBuffer.capacity() );
192 unsigned size = vsnprintf( &lineBuffer[idx], lineBuffer.size() - idx, fmt, args1 );
193 ++size; // trailing null
194 // if necessary, increase buffer size and retry
195 if( size > ( lineBuffer.size() - idx ) )
196 {
197 lineBuffer.resize( idx + size );
198 size = vsnprintf( &lineBuffer[idx], lineBuffer.size() - idx, fmt, args2 );
199 ++size; // trailing null
200 }
201 #else
202 // Guess how much space might be required.
203 // If every character is a format code then there are len/3 format codes.
204 // Guess a random large value of num_chars characters per formatted argument.
205 const unsigned num_chars = 180;
206 unsigned exp_size = ( num_chars / 3 ) * strlen( fmt );
207 lineBuffer.resize( idx + exp_size );
208 unsigned size = vsnprintf( &lineBuffer[idx], exp_size, fmt, args1 );
209 ++size; // trailing null
210 // check if we overflowed the buffer
211 if( size > exp_size )
212 {
213 // crap!
214 fprintf( stderr, "ERROR: Buffer overflow at %s:%d\n", __FILE__, __LINE__ );
215 lineBuffer.resize( idx + exp_size );
216 size = vsnprintf( &lineBuffer[idx], exp_size, fmt, args2 );
217 ++size; // trailing null
218 }
219 #endif
220
221 // less one because we don't want the trailing '\0'
222 lineBuffer.resize( idx + size - 1 );
223 process_line_buffer();
224 }
References lineBuffer, process_line_buffer(), and size.
|
private |
Definition at line 174 of file DebugOutput.cpp.
175 {
176 lineBuffer.insert( lineBuffer.end(), str.begin(), str.end() );
177 process_line_buffer();
178 }
References lineBuffer, and process_line_buffer().
|
inline |
Output the specified printf-formatted output iff output is enabled.
Definition at line 282 of file DebugOutput.hpp.
283 {
284 if( check( verbosity ) )
285 {
286 va_list args1, args2;
287 va_start( args1, fmt );
288 va_start( args2, fmt );
289 print_real( fmt, args1, args2 );
290 va_end( args2 );
291 va_end( args1 );
292 }
293 }
References check(), and print_real().
Referenced by moab::WriteHDF5::assign_ids(), moab::WriteHDF5Parallel::communicate_shared_set_data(), moab::WriteHDF5Parallel::communicate_shared_set_ids(), moab::WriteHDF5Parallel::create_meshset_tables(), moab::WriteHDF5Parallel::create_tag_tables(), CreateTempestMesh(), moab::ReadHDF5::debug_barrier_line(), moab::WriteHDF5Parallel::debug_barrier_line(), moab::ReadHDF5::delete_non_side_elements(), moab::WriteHDF5Parallel::exchange_file_ids(), moab::ReadHDF5::find_sets_containing(), moab::ReadHDF5::load_file_partial(), main(), moab::WriteHDF5Parallel::negotiate_type_list(), moab::ParallelComm::print_debug_irecv(), moab::ParallelComm::print_debug_waitany(), moab::WriteHDF5Parallel::print_set_sharing_data(), moab::print_type_sets(), moab::ReadHDF5::read_adjacencies(), moab::ReadHDF5VarLen::read_data(), moab::ReadHDF5::read_dense_tag(), moab::ReadHDF5::read_elems(), moab::ReadHDF5::read_node_adj_elems(), moab::ReadHDF5::read_nodes(), moab::ReadHDF5VarLen::read_offsets(), moab::ScdNCHelper::read_scd_variables_to_nonset(), moab::ReadHDF5::read_set_data(), moab::ReadHDF5::read_sparse_tag(), moab::ReadHDF5::read_sparse_tag_indices(), moab::ReadHDF5::read_tag(), moab::ReadHDF5::read_tag_values_partial(), moab::NCHelperGCRM::read_ucd_variables_to_nonset(), moab::NCHelperHOMME::read_ucd_variables_to_nonset(), moab::NCHelperMPAS::read_ucd_variables_to_nonset(), moab::NCHelper::read_variables_to_set(), moab::ParallelComm::resolve_shared_ents(), moab::WriteHDF5::write_elems(), moab::WriteHDF5::write_nodes(), moab::WriteHDF5::write_sets(), and moab::WriteHDF5::write_tag().
|
private |
Definition at line 338 of file DebugOutput.cpp.
339 {
340 size_t last_idx = 0;
341 std::vector< char >::iterator i;
342 for( i = std::find( lineBuffer.begin(), lineBuffer.end(), '\n' ); i != lineBuffer.end();
343 i = std::find( i, lineBuffer.end(), '\n' ) )
344 {
345 *i = '\0';
346 if( have_rank() )
347 outputImpl->println( get_rank(), linePfx.c_str(), &lineBuffer[last_idx] );
348 else
349 outputImpl->println( linePfx.c_str(), &lineBuffer[last_idx] );
350 ++i;
351 last_idx = i - lineBuffer.begin();
352 }
353
354 if( last_idx )
355 {
356 i = std::copy( lineBuffer.begin() + last_idx, lineBuffer.end(), lineBuffer.begin() );
357 lineBuffer.erase( i, lineBuffer.end() );
358 }
359 }
References get_rank(), have_rank(), lineBuffer, linePfx, outputImpl, and moab::DebugOutputStream::println().
Referenced by list_ints_real(), list_range_real(), print_real(), and ~DebugOutput().
|
inline |
Set line prefix.
Definition at line 172 of file DebugOutput.hpp.
173 {
174 linePfx = str;
175 }
References linePfx.
Referenced by moab::TempestRemapper::ComputeOverlapMesh(), moab::TempestRemapper::convert_tempest_mesh_private(), moab::TempestRemapper::ConvertMeshToTempest(), moab::ReadNC::parse_options(), moab::WriteNC::parse_options(), moab::ReadHDF5::set_up_read(), and ToolContext::ToolContext().
|
inline |
Set MPI rank.
Definition at line 141 of file DebugOutput.hpp.
142 { 143 mpiRank = rank; 144 }
References mpiRank.
Referenced by moab::ParallelComm::initialize(), main(), moab::WriteHDF5Parallel::parallel_create_file(), moab::ReadNC::parse_options(), moab::WriteNC::parse_options(), moab::ReadParallel::ReadParallel(), and moab::ReadHDF5::set_up_read().
|
inline |
Set verbosity limit.
Definition at line 161 of file DebugOutput.hpp.
162 { 163 verbosityLimit = val; 164 }
References verbosityLimit.
Referenced by moab::ReadParallel::load_file(), main(), moab::ReadNC::parse_options(), moab::WriteNC::parse_options(), moab::ReadParallel::ReadParallel(), moab::ParallelComm::set_debug_verbosity(), moab::ReadHDF5::set_up_read(), and moab::WriteHDF5::write_file().
|
private |
Definition at line 361 of file DebugOutput.cpp.
362 {
363 size_t s = lineBuffer.size();
364 lineBuffer.resize( s + 64 );
365 size_t ss = snprintf( &lineBuffer[s], 64, "(%.2f s) ", cpuTi.time_since_birth() );
366 lineBuffer.resize( s + ss );
367 }
References cpuTi, lineBuffer, and moab::CpuTimer::time_since_birth().
Referenced by tprint_real().
|
inline |
Output the specified string iff output is enabled.
Include current CPU time (as returned by clock()) in output.
Definition at line 195 of file DebugOutput.hpp.
196 {
197 if( check( verbosity ) ) tprint_real( str );
198 }
References check(), and tprint_real().
Referenced by moab::WriteHDF5Parallel::communicate_shared_set_ids(), moab::WriteHDF5Parallel::create_tag_tables(), moab::ReadParallel::delete_nonlocal_entities(), moab::ReadHDF5::get_set_contents(), moab::ReadParallel::load_file(), moab::ReadHDF5::load_file(), moab::ReadHDF5::load_file_impl(), moab::ReadHDF5::load_file_partial(), moab::WriteHDF5Parallel::parallel_create_file(), moab::ReadNC::read_header(), moab::WriteHDF5::serial_create_file(), moab::ReadHDF5::set_up_read(), and moab::WriteHDF5::write_file_impl().
|
inline |
Output the specified string iff output is enabled.
Include current CPU time (as returned by clock()) in output.
Definition at line 203 of file DebugOutput.hpp.
204 {
205 if( check( verbosity ) ) tprint_real( str );
206 }
References check(), and tprint_real().
|
private |
Definition at line 168 of file DebugOutput.cpp.
169 { 170 tprint(); 171 print_real( buffer ); 172 }
References buffer, print_real(), and tprint().
|
private |
Definition at line 226 of file DebugOutput.cpp.
227 {
228 tprint();
229 print_real( fmt, args1, args2 );
230 }
References print_real(), and tprint().
|
private |
Definition at line 180 of file DebugOutput.cpp.
181 {
182 tprint();
183 print_real( str );
184 }
References print_real(), and tprint().
|
inline |
Output the specified printf-formatted output iff output is enabled.
Include current CPU time (as returned by clock()) in output.
Definition at line 295 of file DebugOutput.hpp.
296 {
297 if( check( verbosity ) )
298 {
299 va_list args1, args2;
300 va_start( args1, fmt );
301 va_start( args2, fmt );
302 tprint_real( fmt, args1, args2 );
303 va_end( args2 );
304 va_end( args1 );
305 }
306 }
References check(), and tprint_real().
Referenced by moab::NCWriteHelper::collect_variable_data(), moab::WriteHDF5Parallel::communicate_shared_set_data(), moab::NCHelper::create_conventional_tags(), moab::NCHelper::create_dummy_variables(), moab::NCHelperGCRM::create_local_edges(), moab::NCHelperMPAS::create_local_edges(), moab::NCHelperESMF::create_local_vertices(), moab::NCHelperGCRM::create_local_vertices(), moab::NCHelperMPAS::create_local_vertices(), moab::ScdNCHelper::create_mesh(), moab::NCHelperDomain::create_mesh(), moab::NCHelperESMF::create_mesh(), moab::NCHelperGCRM::create_mesh(), moab::NCHelperHOMME::create_mesh(), moab::NCHelperMPAS::create_mesh(), moab::NCHelperScrip::create_mesh(), moab::ParallelComm::exchange_ghost_cells(), moab::ParallelComm::exchange_owned_mesh(), moab::ParallelComm::exchange_tags(), moab::ReadNC::get_attributes(), moab::ReadNC::get_dimensions(), moab::NCHelper::get_tag_to_nonset(), moab::NCHelper::get_tag_to_set(), moab::ReadNC::get_variables(), moab::NCWriteHelper::init_file(), moab::NCHelperDomain::init_mesh_vals(), moab::NCHelperEuler::init_mesh_vals(), moab::NCHelperFV::init_mesh_vals(), moab::ReadParallel::load_file(), moab::ReadHDF5::load_file(), moab::ReadNC::load_file(), moab::ReadHDF5::load_file_partial(), moab::ParallelComm::pack_entities(), moab::ParallelComm::pack_entity_seq(), moab::ParallelComm::pack_sets(), moab::ParallelComm::pack_tag(), moab::ParallelComm::pack_tags(), moab::WriteHDF5Parallel::parallel_create_file(), moab::ParallelComm::print_debug_irecv(), moab::ParallelComm::print_debug_isend(), moab::ParallelComm::print_debug_recd(), moab::ParallelComm::print_debug_waitany(), moab::WriteNC::process_concatenated_attribute(), moab::WriteNC::process_conventional_tags(), moab::ReadHDF5::read_elems(), moab::ReadNC::read_header(), moab::ReadHDF5::read_nodes(), moab::ScdNCHelper::read_scd_variables_to_nonset(), moab::ScdNCHelper::read_scd_variables_to_nonset_allocate(), moab::ReadHDF5::read_set_ids_recursive(), moab::ReadHDF5::read_tag(), moab::NCHelperGCRM::read_ucd_variables_to_nonset(), moab::NCHelperHOMME::read_ucd_variables_to_nonset(), moab::NCHelperMPAS::read_ucd_variables_to_nonset(), moab::NCHelperGCRM::read_ucd_variables_to_nonset_allocate(), moab::NCHelperHOMME::read_ucd_variables_to_nonset_allocate(), moab::NCHelperMPAS::read_ucd_variables_to_nonset_allocate(), moab::NCHelper::read_variables_to_set(), moab::NCHelper::read_variables_to_set_allocate(), moab::ParallelComm::recv_entities(), moab::ParallelComm::reduce_tags(), moab::ParallelComm::resolve_shared_ents(), moab::ParallelComm::send_entities(), moab::ParallelComm::send_recv_entities(), moab::ReadHDF5::set_up_read(), moab::ParallelComm::settle_intersection_points(), moab::ParallelComm::unpack_buffer(), moab::ParallelComm::unpack_entities(), moab::ParallelComm::unpack_sets(), moab::ParallelComm::unpack_tags(), moab::WriteNC::write_file(), and moab::WriteHDF5::write_tag().
void moab::DebugOutput::use_world_rank | ( | ) |
Set MPI rank to the rank of this proccess in MPI_COMM_WORLD, or zero if MOAB is build w/out MPI.
Definition at line 153 of file DebugOutput.cpp.
154 {
155 mpiRank = 0;
156 #ifdef MOAB_HAVE_MPI
157 int flag = 0;
158 if( MPI_SUCCESS == MPI_Initialized( &flag ) && flag ) MPI_Comm_rank( MPI_COMM_WORLD, &mpiRank );
159 #endif
160 }
References mpiRank.
|
private |
Definition at line 242 of file DebugOutput.hpp.
Referenced by tprint().
|
private |
Definition at line 261 of file DebugOutput.hpp.
Referenced by list_ints_real(), list_range_real(), print_real(), process_line_buffer(), tprint(), and ~DebugOutput().
|
private |
Definition at line 238 of file DebugOutput.hpp.
Referenced by get_prefix(), operator=(), process_line_buffer(), and set_prefix().
|
private |
Definition at line 240 of file DebugOutput.hpp.
Referenced by get_rank(), have_rank(), limit_output_to_first_N_procs(), operator=(), set_rank(), and use_world_rank().
|
private |
Definition at line 239 of file DebugOutput.hpp.
Referenced by DebugOutput(), operator=(), process_line_buffer(), and ~DebugOutput().
|
private |
Definition at line 241 of file DebugOutput.hpp.
Referenced by check(), get_verbosity(), limit_output_to_first_N_procs(), operator=(), and set_verbosity().