PlayaOut.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 // ************************************************************************
00003 // 
00004 //                 Playa: Programmable Linear Algebra
00005 //                 Copyright 2012 Sandia Corporation
00006 // 
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00008 // the U.S. Government retains certain rights in this software.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Kevin Long (kevin.long@ttu.edu)
00038 // 
00039 
00040 /* @HEADER@ */
00041 
00042 #ifndef PLAYA_OUT_HPP
00043 #define PLAYA_OUT_HPP
00044 
00045 #include "PlayaDefs.hpp"
00046 #include "Teuchos_Assert.hpp"
00047 #include "Teuchos_RefCountPtr.hpp"
00048 #include "Teuchos_FancyOStream.hpp"
00049 #include "PlayaMPIComm.hpp"
00050 
00051 namespace Teuchos
00052 {
00053 template <class T> class Array;
00054 }
00055 
00056 namespace Playa
00057 {
00058 class Tabs;
00059 using namespace Teuchos;
00060   using std::cout;
00061   using std::endl;
00062   using std::cerr;
00063 
00064 /**
00065  * Class Out provides standardized access to fancy streams for writing
00066  * diagnostic output. 
00067  */
00068 class Out
00069 {
00070 public:
00071       
00072   /** Print a line followed by termination */
00073   static void println(const std::string& str) 
00074     {
00075       if (!suppressStdout()) os() << str << std::endl;
00076     }
00077 
00078   /** */
00079   static std::ostream*& basicStream()
00080     {
00081       static std::ostream* rtn = &std::cout;
00082       return rtn;
00083     }
00084 
00085   /** Provide a fancy ostream wrapper to cout */
00086   static FancyOStream& os();
00087 
00088   /** Provide a fancy ostream wrapper to cout, ignoring output from
00089    * non-root processors*/
00090   static FancyOStream& root();
00091 
00092   /** */
00093   static bool& suppressStdout() {static bool rtn=false; return rtn;}
00094 };
00095 
00096 
00097 /** Write an array formatted to show a specified number of columns */
00098 void writeTable(std::ostream& os, const Tabs& tab,
00099   const Array<double>& a, int cols);
00100 /** Write an array formatted to show a specified number of columns */
00101 void writeTable(std::ostream& os, const Tabs& tab, 
00102   const Array<int>& a, int cols);
00103 
00104 }
00105 
00106 #define PLAYA_OUT(test, msg) \
00107   { \
00108     if (test) \
00109     { \
00110       TeuchosOStringStream omsg; \
00111       omsg << msg; \
00112       Out::println(omsg.str());                 \
00113     } \
00114   }
00115 
00116 #define PLAYA_ROOT_OUT(test, msg) \
00117   { \
00118     if (test) \
00119     { \
00120       TeuchosOStringStream omsg; \
00121       omsg << msg; \
00122       Out::root() << omsg.str() << std::endl;                 \
00123     } \
00124   }
00125 
00126 
00127 #define PLAYA_VERB_EXTREME(msg) PLAYA_MSG4(this->verb(), msg)
00128 #define PLAYA_VERB_HIGH(msg) PLAYA_MSG3(this->verb(), msg)
00129 #define PLAYA_VERB_MEDIUM(msg) PLAYA_MSG2(this->verb(), msg)
00130 #define PLAYA_VERB_LOW(msg) PLAYA_MSG1(this->verb(), msg)
00131 
00132 #define PLAYA_HEADER_LINE "\n------------------------------------------------------------------\n"
00133 
00134 #define PLAYA_MSG(context, level, msg) PLAYA_OUT(this->verbLevel(context) >= level, msg)
00135 
00136 #define PLAYA_LEVEL1(context, msg) PLAYA_MSG(context, 1, msg)
00137 
00138 #define PLAYA_LEVEL2(context, msg) PLAYA_MSG(context, 2, msg)
00139 
00140 #define PLAYA_LEVEL3(context, msg) PLAYA_MSG(context, 3, msg)
00141 
00142 #define PLAYA_LEVEL4(context, msg) PLAYA_MSG(context, 4, msg)
00143 
00144 #define PLAYA_LEVEL5(context, msg) PLAYA_MSG(context, 5, msg)
00145 
00146 
00147 #define PLAYA_MSG1(level, msg) PLAYA_OUT(level >= 1, msg)
00148 
00149 #define PLAYA_MSG2(level, msg) PLAYA_OUT(level >= 2, msg)
00150 
00151 #define PLAYA_MSG3(level, msg) PLAYA_OUT(level >= 3, msg)
00152 
00153 #define PLAYA_MSG4(level, msg) PLAYA_OUT(level >= 4, msg)
00154 
00155 #define PLAYA_MSG5(level, msg) PLAYA_OUT(level >= 5, msg)
00156 
00157 
00158 
00159 #define PLAYA_ROOT_MSG1(level, msg) PLAYA_ROOT_OUT(level >= 1, msg)
00160 
00161 #define PLAYA_ROOT_MSG2(level, msg) PLAYA_ROOT_OUT(level >= 2, msg)
00162 
00163 #define PLAYA_ROOT_MSG3(level, msg) PLAYA_ROOT_OUT(level >= 3, msg)
00164 
00165 #define PLAYA_ROOT_MSG4(level, msg) PLAYA_ROOT_OUT(level >= 4, msg)
00166 
00167 #define PLAYA_ROOT_MSG5(level, msg) PLAYA_ROOT_OUT(level >= 5, msg)
00168 
00169 
00170 
00171 
00172 #define PLAYA_BANNER1(level, tab, msg) \
00173   PLAYA_ROOT_MSG1(level, tab \
00174     << "===================================================================");\
00175   PLAYA_ROOT_MSG1(level, tab << std::endl << tab \
00176     << "  " << msg); \
00177   PLAYA_ROOT_MSG1(level, tab << std::endl << tab\
00178     << "===================================================================");
00179 
00180 
00181 #define PLAYA_BANNER2(level, tab, msg) \
00182   PLAYA_ROOT_MSG2(level, tab \
00183     << "-------------------------------------------------------------------");\
00184   PLAYA_ROOT_MSG2(level, tab << msg); \
00185   PLAYA_MSG2(level, tab\
00186     << "-------------------------------------------------------------------");
00187 
00188 
00189 
00190 #define PLAYA_BANNER3(level, tab, msg) \
00191   PLAYA_ROOT_MSG3(level, tab \
00192     << "-------------------------------------------------------------------");\
00193   PLAYA_ROOT_MSG3(level, tab << std::endl << tab \
00194     << msg); \
00195   PLAYA_ROOT_MSG3(level, tab << std::endl << tab\
00196     << "-------------------------------------------------------------------");
00197 
00198 #endif

Site Contact