Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
moab::DebugOutput Class Reference

Utility class for printing debug output. More...

#include <DebugOutput.hpp>

+ Collaboration diagram for moab::DebugOutput:

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 &copy)
 
DebugOutputoperator= (const DebugOutput &copy)
 
 ~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
 
DebugOutputStreamoutputImpl
 
int mpiRank
 
unsigned verbosityLimit
 
CpuTimer cpuTi
 
std::vector< char > lineBuffer
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ DebugOutput() [1/13]

moab::DebugOutput::DebugOutput ( DebugOutputStream str,
unsigned  verbosity = 0 
)
Parameters
strOutput stream to which to flush output
verbosityVerbosity 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.

◆ DebugOutput() [2/13]

moab::DebugOutput::DebugOutput ( DebugOutputStream str,
int  rank,
unsigned  verbosity = 0 
)
Parameters
strOutput stream to which to flush output
rankMPI rank with which to prefix output.
verbosityVerbosity 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.

◆ DebugOutput() [3/13]

moab::DebugOutput::DebugOutput ( FILE *  str,
unsigned  verbosity = 0 
)
Parameters
strOutput stream to which to flush output
enabledEnable 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 }

◆ DebugOutput() [4/13]

moab::DebugOutput::DebugOutput ( FILE *  str,
int  rank,
unsigned  verbosity = 0 
)
Parameters
strOutput stream to which to flush output
rankMPI rank with which to prefix output.
verbosityVerbosity limit.

Definition at line 78 of file DebugOutput.cpp.

79  : outputImpl( new FILEDebugStream( impl ) ), mpiRank( rank ), verbosityLimit( verbosity )
80 {
81 }

◆ DebugOutput() [5/13]

moab::DebugOutput::DebugOutput ( std::ostream &  str,
unsigned  verbosity = 0 
)
Parameters
strOutput stream to which to flush output
verbosityVerbosity limit.

Definition at line 82 of file DebugOutput.cpp.

83  : outputImpl( new CxxDebugStream( str ) ), mpiRank( -1 ), verbosityLimit( verbosity )
84 {
85 }

◆ DebugOutput() [6/13]

moab::DebugOutput::DebugOutput ( std::ostream &  str,
int  rank,
unsigned  verbosity = 0 
)
Parameters
strOutput stream to which to flush output
rankMPI rank with which to prefix output.
verbosityVerbosity limit.

Definition at line 86 of file DebugOutput.cpp.

87  : outputImpl( new CxxDebugStream( str ) ), mpiRank( rank ), verbosityLimit( verbosity )
88 {
89 }

◆ DebugOutput() [7/13]

moab::DebugOutput::DebugOutput ( const char *  pfx,
DebugOutputStream str,
unsigned  verbosity = 0 
)
Parameters
pfxPrefix for output
strOutput stream to which to flush output
verbosityVerbosity 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.

◆ DebugOutput() [8/13]

moab::DebugOutput::DebugOutput ( const char *  pfx,
DebugOutputStream str,
int  rank,
unsigned  verbosity = 0 
)
Parameters
pfxPrefix for output
strOutput stream to which to flush output
rankMPI rank with which to prefix output.
verbosityVerbosity 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.

◆ DebugOutput() [9/13]

moab::DebugOutput::DebugOutput ( const char *  pfx,
FILE *  str,
unsigned  verbosity = 0 
)
Parameters
pfxPrefix for output
strOutput stream to which to flush output
enabledEnable 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 }

◆ DebugOutput() [10/13]

moab::DebugOutput::DebugOutput ( const char *  pfx,
FILE *  str,
int  rank,
unsigned  verbosity = 0 
)
Parameters
pfxPrefix for output
strOutput stream to which to flush output
rankMPI rank with which to prefix output.
verbosityVerbosity limit.

Definition at line 106 of file DebugOutput.cpp.

107  : linePfx( pfx ), outputImpl( new FILEDebugStream( impl ) ), mpiRank( rank ), verbosityLimit( verbosity )
108 {
109 }

◆ DebugOutput() [11/13]

moab::DebugOutput::DebugOutput ( const char *  pfx,
std::ostream &  str,
unsigned  verbosity = 0 
)
Parameters
pfxPrefix for output
strOutput stream to which to flush output
verbosityVerbosity limit.

Definition at line 110 of file DebugOutput.cpp.

111  : linePfx( pfx ), outputImpl( new CxxDebugStream( str ) ), mpiRank( -1 ), verbosityLimit( verbosity )
112 {
113 }

◆ DebugOutput() [12/13]

moab::DebugOutput::DebugOutput ( const char *  pfx,
std::ostream &  str,
int  rank,
unsigned  verbosity = 0 
)
Parameters
pfxPrefix for output
strOutput stream to which to flush output
rankMPI rank with which to prefix output.
verbosityVerbosity limit.

Definition at line 114 of file DebugOutput.cpp.

115  : linePfx( pfx ), outputImpl( new CxxDebugStream( str ) ), mpiRank( rank ), verbosityLimit( verbosity )
116 {
117 }

◆ DebugOutput() [13/13]

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 {
124  assert( outputImpl->referenceCount > 1 );
125 }

References outputImpl, and moab::DebugOutputStream::referenceCount.

◆ ~DebugOutput()

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' );
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.

Member Function Documentation

◆ check()

bool moab::DebugOutput::check ( unsigned  verbosity)
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().

◆ get_prefix()

const std::string& moab::DebugOutput::get_prefix ( ) const
inline

Get line prefix.

Definition at line 167 of file DebugOutput.hpp.

168  {
169  return linePfx;
170  }

References linePfx.

◆ get_rank()

int moab::DebugOutput::get_rank ( ) const
inline

Get MPI rank.

Definition at line 136 of file DebugOutput.hpp.

137  {
138  return mpiRank;
139  }

References mpiRank.

Referenced by process_line_buffer().

◆ get_verbosity()

◆ have_rank()

bool moab::DebugOutput::have_rank ( ) const
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().

◆ limit_output_to_first_N_procs()

void moab::DebugOutput::limit_output_to_first_N_procs ( int  N)
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().

◆ list_ints_real()

void moab::DebugOutput::list_ints_real ( const char *  pfx,
const Range range 
)
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' );
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().

◆ list_range_real()

void moab::DebugOutput::list_range_real ( const char *  pfx,
const Range range 
)
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' );
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().

◆ operator=()

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;
134  assert( outputImpl->referenceCount > 1 );
135  return *this;
136 }

References linePfx, mpiRank, outputImpl, moab::DebugOutputStream::referenceCount, and verbosityLimit.

◆ print() [1/4]

void moab::DebugOutput::print ( int  verbosity,
const char *  pfx,
const Range range 
)
inline

Print the contents of a moab::Range.

Parameters
pfxString 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().

◆ print() [2/4]

◆ print() [3/4]

void moab::DebugOutput::print ( int  verbosity,
const Range range 
)
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().

◆ print() [4/4]

void moab::DebugOutput::print ( int  verbosity,
const std::string &  str 
)
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().

◆ print_ints() [1/2]

void moab::DebugOutput::print_ints ( int  verbosity,
const char *  pfx,
const Range range 
)
inline

Print the contents of a moab::Range as numerical values only.

Parameters
pfxString 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().

◆ print_ints() [2/2]

void moab::DebugOutput::print_ints ( int  verbosity,
const Range range 
)
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().

◆ print_real() [1/3]

void moab::DebugOutput::print_real ( const char *  buffer)
private

Definition at line 162 of file DebugOutput.cpp.

163 {
164  lineBuffer.insert( lineBuffer.end(), buffer, buffer + strlen( buffer ) );
166 }

References buffer, lineBuffer, and process_line_buffer().

Referenced by list_ints_real(), list_range_real(), print(), printf(), and tprint_real().

◆ print_real() [2/3]

void moab::DebugOutput::print_real ( const char *  buffer,
va_list  args1,
va_list  args2 
)
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 );
224 }

References lineBuffer, process_line_buffer(), and size.

◆ print_real() [3/3]

void moab::DebugOutput::print_real ( const std::string &  str)
private

Definition at line 174 of file DebugOutput.cpp.

175 {
176  lineBuffer.insert( lineBuffer.end(), str.begin(), str.end() );
178 }

References lineBuffer, and process_line_buffer().

◆ printf()

void moab::DebugOutput::printf ( int  verbosity,
const char *  fmt,
  ... 
)
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().

◆ process_line_buffer()

void moab::DebugOutput::process_line_buffer ( )
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().

◆ set_prefix()

◆ set_rank()

void moab::DebugOutput::set_rank ( int  rank)
inline

◆ set_verbosity()

void moab::DebugOutput::set_verbosity ( unsigned  val)
inline

◆ tprint() [1/3]

void moab::DebugOutput::tprint ( )
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().

◆ tprint() [2/3]

◆ tprint() [3/3]

void moab::DebugOutput::tprint ( int  verbosity,
const std::string &  str 
)
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().

◆ tprint_real() [1/3]

void moab::DebugOutput::tprint_real ( const char *  buffer)
private

Definition at line 168 of file DebugOutput.cpp.

169 {
170  tprint();
171  print_real( buffer );
172 }

References buffer, print_real(), and tprint().

Referenced by tprint(), and tprintf().

◆ tprint_real() [2/3]

void moab::DebugOutput::tprint_real ( const char *  buffer,
va_list  args1,
va_list  args2 
)
private

Definition at line 226 of file DebugOutput.cpp.

227 {
228  tprint();
229  print_real( fmt, args1, args2 );
230 }

References print_real(), and tprint().

◆ tprint_real() [3/3]

void moab::DebugOutput::tprint_real ( const std::string &  str)
private

Definition at line 180 of file DebugOutput.cpp.

181 {
182  tprint();
183  print_real( str );
184 }

References print_real(), and tprint().

◆ tprintf()

void moab::DebugOutput::tprintf ( int  verbosity,
const char *  fmt,
  ... 
)
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().

◆ use_world_rank()

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.

Member Data Documentation

◆ cpuTi

CpuTimer moab::DebugOutput::cpuTi
private

Definition at line 242 of file DebugOutput.hpp.

Referenced by tprint().

◆ lineBuffer

std::vector< char > moab::DebugOutput::lineBuffer
private

◆ linePfx

std::string moab::DebugOutput::linePfx
private

Definition at line 238 of file DebugOutput.hpp.

Referenced by get_prefix(), operator=(), process_line_buffer(), and set_prefix().

◆ mpiRank

int moab::DebugOutput::mpiRank
private

◆ outputImpl

DebugOutputStream* moab::DebugOutput::outputImpl
private

Definition at line 239 of file DebugOutput.hpp.

Referenced by DebugOutput(), operator=(), process_line_buffer(), and ~DebugOutput().

◆ verbosityLimit

unsigned moab::DebugOutput::verbosityLimit
private

The documentation for this class was generated from the following files: