[MOAB-dev] r3846 - MOAB/trunk/src

Tim Tautges tautges at mcs.anl.gov
Wed May 5 13:40:53 CDT 2010


Please make sure this fits with the code in Interface::list_entities and Range::print (i.e. there's no duplicated 
functionality between the three), so it's clear what should get called for debug output.

- tim

kraftche at cae.wisc.edu wrote:
> Author: kraftche
> Date: 2010-05-05 13:33:53 -0500 (Wed, 05 May 2010)
> New Revision: 3846
> 
> Added:
>    MOAB/trunk/src/DebugOutput.cpp
>    MOAB/trunk/src/DebugOutput.hpp
> Modified:
>    MOAB/trunk/src/Makefile.am
> Log:
> Add utility class for debug output.  
> 
> Implements the usual features:
> o Optionally prefix all lines w/ user-sepcified string
> o Optionally prefix all lines w/ MPI rank
> o Filtering based on verbosity level
> o Runtime enable/disable
> o Utility method to print moab::Range 
> 
> 
> Added: MOAB/trunk/src/DebugOutput.cpp
> ===================================================================
> --- MOAB/trunk/src/DebugOutput.cpp	                        (rev 0)
> +++ MOAB/trunk/src/DebugOutput.cpp	2010-05-05 18:33:53 UTC (rev 3846)
> @@ -0,0 +1,236 @@
> +#include "DebugOutput.hpp"
> +#include "moab/Range.hpp"
> +#include "moab/CN.hpp"
> +#include "Internals.hpp"
> +#include <iostream>
> +#include <string.h>
> +#include <algorithm>
> +
> +#ifdef USE_MPI
> +#  include "moab_mpi.h"
> +#endif
> +
> +namespace moab {
> +
> +DebugOutputStream::~DebugOutputStream() {}
> +
> +class FILEDebugStream : public DebugOutputStream
> +{
> +private:
> +  FILE* filePtr;
> +public:
> +  FILEDebugStream( FILE* filep ) : filePtr(filep) {}
> +  void println( int rank, const char* pfx, const char* str );
> +  void println( const char* pfx, const char* str );
> +};
> +void FILEDebugStream::println( int rank, const char* pfx, const char* str )
> +  { fprintf(filePtr, "%3d  %s%s\n", rank, pfx, str); fflush(filePtr); }
> +void FILEDebugStream::println( const char* pfx, const char* str )
> +  { 
> +    fputs( pfx, filePtr ); 
> +    fputs( str, filePtr ); 
> +    fputc( '\n', filePtr ); 
> +    fflush(filePtr); 
> +  }
> +
> +
> +class CxxDebugStream : public DebugOutputStream
> +{
> +private:
> +  std::ostream& outStr;
> +public:
> +  CxxDebugStream( std::ostream& str ) : outStr(str) {}
> +  void println( int rank, const char* pfx, const char* str );
> +  void println( const char* pfx, const char* str );
> +};
> +void CxxDebugStream::println( int rank, const char* pfx, const char* str )
> 

-- 
================================================================
"You will keep in perfect peace him whose mind is
   steadfast, because he trusts in you."               Isaiah 26:3

              Tim Tautges            Argonne National Laboratory
          (tautges at mcs.anl.gov)      (telecommuting from UW-Madison)
          phone: (608) 263-8485      1500 Engineering Dr.
            fax: (608) 263-4499      Madison, WI 53706



More information about the moab-dev mailing list