00001
00002
00003
00004
00005 #include "PlayaOut.hpp"
00006 #include "PlayaTabs.hpp"
00007 #include "Teuchos_Array.hpp"
00008
00009 using namespace Playa;
00010 using namespace Teuchos;
00011 using namespace std;
00012
00013
00014 namespace Playa
00015 {
00016
00017
00018 FancyOStream& Out::os()
00019 {
00020 static RCP<std::ostream> os = rcp(basicStream(), false);
00021 static RCP<FancyOStream> rtn = fancyOStream(os);
00022 static bool first = true;
00023 if (first)
00024 {
00025 rtn->setShowProcRank(true);
00026 first = false;
00027 }
00028 return *rtn;
00029 }
00030
00031 FancyOStream& Out::root()
00032 {
00033 static bool isRoot = MPIComm::world().getRank()==0;
00034
00035 static RCP<std::ostream> os = rcp(basicStream(), false);
00036 static RCP<FancyOStream> rtn = fancyOStream(os);
00037
00038 static RCP<FancyOStream> blackHole
00039 = rcp(new FancyOStream(rcp(new oblackholestream())));
00040
00041 if (isRoot)
00042 {
00043 return *rtn;
00044 }
00045 else
00046 {
00047 return *blackHole;
00048 }
00049 }
00050
00051
00052
00053
00054 void writeTable(std::ostream& os, const Tabs& tab,
00055 const Array<double>& a, int cols)
00056 {
00057 int rows = a.size() / cols;
00058
00059 for (int i=0; i<rows; i++)
00060 {
00061 os << tab << setw(10) << i << ":";
00062 for (int j=0; j<cols; j++)
00063 os << setw(12) << setprecision(6) << a[i*cols+j];
00064 os << std::endl;
00065 }
00066 int n = a.size() - rows * cols;
00067 if (n==0) return ;
00068 os << tab << setw(10) << rows << ":" ;
00069 for (int j=0; j<n; j++)
00070 os << setw(12) << setprecision(6) << a[rows*cols+j];
00071 os << std::endl;
00072 }
00073
00074
00075 void writeTable(std::ostream& os, const Tabs& tab,
00076 const Array<int>& a, int cols)
00077 {
00078 int rows = a.size() / cols;
00079
00080 for (int i=0; i<rows; i++)
00081 {
00082 os << tab << setw(10) << i << ":";
00083 for (int j=0; j<cols; j++)
00084 os << setw(10) << a[i*cols+j];
00085 os << std::endl;
00086 }
00087 int n = a.size() - rows * cols;
00088 if (n==0) return ;
00089 os << tab << setw(10) << rows << ":" ;
00090 for (int j=0; j<n; j++)
00091 os << setw(10) << a[rows*cols+j];
00092 os << std::endl;
00093 }
00094
00095
00096 }
00097
00098
00099
00100
00101
00102
00103