PlasCom2  1.0
XPACC Multi-physics simluation application
Global.H
Go to the documentation of this file.
1 #ifndef _GLOBAL_H_
7 #define _GLOBAL_H_
8 
9 #include "ComLine.H"
10 #include "UnixUtils.H"
11 #include "primitive_utilities.H"
12 
13 namespace ix {
14 
16  namespace global {
24  template<typename StackType,typename ErrorType,typename ProfilerType>
25  class GlobalObj {
26  private:
27 
29  unsigned char _debug_level;
30 
32  unsigned char _log_level;
33 
35  unsigned char _verb_level;
36 
39  std::list< StackType > _Stack;
40 
42  std::list< ErrorType > _Errors;
43 
45  bool _initd;
46 
47  protected:
51  std::ostream *_DebugStream;
52  std::ostream *_OutStream;
53  std::ostream *_LogStream;
54  std::ostream *_ErrStream;
57  private:
61  std::string _name;
62  std::ostream *_OutStreamSave;
63  std::ostream *_ErrStreamSave;
64  std::ostream *_DebugStreamSave;
65  public:
66 
68  GlobalObj() : _debug_level(0), _log_level(0), _verb_level(1),
69  _DebugStream(NULL),
70  _OutStream(&std::cout), _LogStream(NULL),
71  _ErrStream(&std::cerr),_Profiler(NULL),
72  _profiling_enabled(false),_profiler_mine(false),_write_profiles(true),
73  _name(""), _OutStreamSave(NULL), _ErrStreamSave(NULL),
74  _DebugStreamSave(NULL)
75  {
76  // _Stack.push_back("main");
77  // std::cout << "default constr" << std::endl;
78  };
79 
82  GlobalObj(int narg,char **args) :
83  _debug_level(0), _log_level(0), _verb_level(1),
84  _DebugStream(NULL),
85  _OutStream(&std::cout), _LogStream(NULL),
86  _ErrStream(&std::cerr),_Profiler(NULL),
87  _profiling_enabled(false),_profiler_mine(false),_write_profiles(true),
88  _name(""), _OutStreamSave(NULL), _ErrStreamSave(NULL),
89  _DebugStreamSave(NULL)
90  {
91  // std::cout << "std args constr" << std::endl;
92  assert(narg > 0); // lame effort to validate command line on all procs
93  Init(util::stripdirs(args[0]));
94  };
95 
99  _debug_level(globin._debug_level), _log_level(globin._log_level),_verb_level(globin._verb_level),
100  _DebugStream(globin._DebugStream), _OutStream(globin._OutStream),
101  _LogStream(globin._LogStream), _ErrStream(globin._ErrStream),
102  _Profiler(globin._Profiler),_profiling_enabled(globin._profiling_enabled),
103  _profiler_mine(false), _write_profiles(true),_name(globin._name), _OutStreamSave(globin._OutStreamSave),
104  _ErrStreamSave(globin._ErrStreamSave), _DebugStreamSave(globin._DebugStreamSave)
105  {
106  // std::cout << "copy constr" << std::endl;
107  if(!globin._Stack.empty()){
108  typename std::list<StackType>::iterator si = globin._Stack.begin();
109  while(si != globin._Stack.end())
110  _Stack.push_back(*si++);
111  }
112  _initd = false;
113  };
114 
115 
116 
119  GlobalObj(const StackType &name) : _debug_level(0) , _log_level(0), _verb_level(1)
120  {
121  // std::cout << "named constr" << std::endl;
122 
123  Init(name);
124  };
125 
128  GlobalObj(const StackType &name,int id) : _debug_level(0), _log_level(0), _verb_level(1)
129  {
130  // std::cout << "named&&numbered constr" << std::endl;
131  Init(name,id);
132  };
133 
136  virtual inline int Init(const StackType &name)
137  {
138  unsigned int id = 0;
139  _debug_level = 0;
140  _log_level = 0;
141  _verb_level = 1;
142  _name = name;
143  // _profiling_enabled = true;
144  if(_Profiler && _profiler_mine)
145  delete _Profiler;
146  _Profiler = new ProfilerType;
147  _Profiler->Init(name,id);
148  _profiler_mine = true;
149  _profiling_enabled = false;
150  _write_profiles = true;
151  // _DebugStream = &std::cout;
152  _DebugStream = &std::cout;
153  _ErrStream = &std::cerr;
154  _OutStream = &std::cout;
155  _LogStream = NULL;
156  _OutStreamSave = _OutStream;
157  _ErrStreamSave = _ErrStream;
158  _DebugStreamSave = _DebugStream;
159  // _Stack.clear();
160  _Stack.push_front(name);
161  _Errors.clear();
162  _initd = true;
163  return(0);
164  };
165 
168  virtual inline int Init(const StackType &name,unsigned int id)
169  {
170  _name = name;
171  _verb_level = 1;
172  _debug_level = 0;
173  _log_level = 0;
174  _profiling_enabled = false;
175  _write_profiles = false;
176  if(_Profiler && _profiler_mine)
177  delete _Profiler;
178  _Profiler = new ProfilerType;
179  _Profiler->Init(name,id);
180  _profiler_mine = true;
181  // _DebugStream = &std::cout;
182  _DebugStream = NULL;
183  _OutStream = NULL;
184  _ErrStream = NULL;
185  _LogStream = NULL;
186  if(id == 0){
187  _DebugStream = &std::cout;
188  _ErrStream = &std::cerr;
189  _OutStream = &std::cout;
190  }
191  _OutStreamSave = _OutStream;
192  _ErrStreamSave = _ErrStream;
193  _DebugStreamSave = _DebugStream;
194  // _Stack.clear();
195  _Stack.push_front(name);
196  _Errors.clear();
197  _initd = true;
198  return(0);
199  };
200 
202  virtual inline int Finalize()
203  {
204  int errcode = 0;
205  if(_initd){
206  if(_profiler_mine){
207  if(_Profiler->FinalizeReady() && _Profiler)
208  _Profiler->Finalize(_write_profiles);
209  else if(_profiling_enabled)
210  errcode = 1;
211  }
212  _profiling_enabled = false;
213  _initd = false;
214  }
215  return(errcode);
216  };
217 
219  virtual inline bool WriteProfiles(){
220  return(_write_profiles);
221  };
222 
224  virtual inline bool WriteProfiles(bool yn){
225  return(_write_profiles = yn);
226  };
227 
229  virtual inline bool Profiling(){
230  return(_profiling_enabled);
231  };
232 
234  virtual inline bool Profiling(bool yn){
235  _profiling_enabled = yn;
236  return(_profiling_enabled);
237  };
238 
240  virtual inline void Report(std::ostream &ReportStream)
241  {
242  if(_Profiler){
243  _Profiler->Finalize(_write_profiles);
244  if(_profiling_enabled)
245  _Profiler->SummarizeSerialExecution(ReportStream);
246  }
247  };
248 
251  virtual inline void Register(const StackType &stackentry){
252  _Stack.push_front(FName()+stackentry);
253  if(_debug_level > 1 && _DebugStream)
254  *_DebugStream << "GlobalDebugging:Register(" << FName()+stackentry << ")" << std::endl;
255  }
256 
260  virtual inline void DeRegister(const StackType &stackentry){
261  _Stack.pop_front();
262  if(_debug_level > 1 && _DebugStream)
263  *_DebugStream << "GlobalDebugging:DeRegister(" << FName() + stackentry << ")" << std::endl;
264  }
265 
267  virtual inline void FunctionEntry(const StackType &stackentry){
268  _Stack.push_front(FName()+stackentry);
269  if(_profiling_enabled && _Profiler)
270  _Profiler->FunctionEntry(FName()+stackentry);
271  if(_debug_level > 1 && _DebugStream)
272  *_DebugStream << "GlobalDebugging:FunctionEntry(" << FName() + stackentry << ")" << std::endl;
273  };
274 
276  virtual inline void FunctionExit(const StackType &stackentry){
277  _Stack.pop_front();
278  if(_profiling_enabled && _Profiler)
279  _Profiler->FunctionExit(FName()+stackentry);
280  if(_debug_level > 1 && _DebugStream)
281  *_DebugStream << "GlobalDebugging:FunctionExit(" << FName() + stackentry << ")" << std::endl;
282  };
283 
285  virtual inline void FunctionExitAll(){
286  if(_Profiler)
287  _Profiler->FunctionExitAll();
288  };
289 
291  virtual inline void Error(const ErrorType &error){
292  _Errors.push_front(error);
293  };
294 
296  virtual inline void DumpErrors(std::ostream &Ostr){
297  util::DumpContents(Ostr,_Errors);
298  };
299 
301  virtual inline void DumpStack(std::ostream &Ostr){
302  util::DumpContents(Ostr,_Stack);
303  };
304 
306  virtual inline void DumpProfile(std::ostream &Ostr){
307  if(_Profiler)
308  _Profiler->Dump(Ostr);
309  };
310 
312  bool DebugStreamReady() { return (_DebugStream != NULL); };
313 
315  void SetDebugStream(std::ostream &dbstream){
316  _DebugStream = &dbstream;
317  };
318 
320  std::ostream &DebugStream(){ assert(_DebugStream); return(*_DebugStream); };
321 
323  std::ostream *DebugStreamPtr(){ return(_DebugStream); };
324 
326  bool ErrStreamReady() { return (_ErrStream != NULL); };
327 
329  void SetErrStream(std::ostream &dbstream){
330  _ErrStream = &dbstream;
331  };
332 
334  std::ostream &ErrStream(){ assert(_ErrStream); return(*_ErrStream); };
335 
337  std::ostream *ErrStreamPtr(){ return(_ErrStream); };
338 
340  bool OutStreamReady() { return (_OutStream != NULL); };
341 
343  void SetOutStream(std::ostream &outstream){
344  _OutStream = &outstream;
345  };
346 
348  std::ostream &OutStream(){ assert(_OutStream); return(*_OutStream); };
349 
351  std::ostream *OutStreamPtr(){ return(_OutStream); };
352 
354  void UnsetOutStream(){ _OutStream = NULL; };
355 
357  bool LogStreamReady() { return (_LogStream != NULL); };
358 
360  void SetLogStream(std::ostream &logstream){
361  _LogStream = &logstream;
362  };
363 
365  std::ostream &LogStream(){ assert(_LogStream); return(*_LogStream); };
366 
368  std::ostream *LogStreamPtr(){ return(_LogStream); };
369 
371  void SetProfiler(ProfilerType &profiler){
372  if(_profiler_mine){
373  if(_profiling_enabled && _Profiler && _Profiler->FinalizeReady())
374  _Profiler->Finalize();
375  if(_Profiler)
376  delete _Profiler;
377  }
378  _Profiler = &profiler;
379  };
380 
381  virtual inline void SetName(const std::string &name) { _name = FName()+name; };
382  virtual inline void ReName(const std::string &name) { _name = name; };
383  virtual inline const std::string &Name(){return(_name);};
385  ProfilerType &Profiler(){ assert(_Profiler); return(*_Profiler); };
386 
388  void SetDebugLevel(unsigned char l){ _debug_level = l; };
389 
391  unsigned char DebugLevel(){ return(_debug_level); };
392 
393  void SetVerbLevel(unsigned char l) { _verb_level = l; };
394 
396  unsigned char VerbLevel(){ return (_verb_level); };
397 
398  void SetLogLevel(unsigned char l) { _log_level = l; };
399 
401  unsigned char LogLevel(){ return (_log_level); };
402 
404  void DeSyncIO()
405  {
406  _OutStreamSave = _OutStream;
407  _ErrStreamSave = _ErrStream;
408  _DebugStreamSave = _DebugStream;
409  _OutStream = &std::cout;
410  _ErrStream = &std::cerr;
411  _DebugStream = &std::cout;
412  };
413 
415  void SyncIO()
416  {
417  _OutStream = _OutStreamSave;
418  _ErrStream = _ErrStreamSave;
419  _DebugStream = _DebugStreamSave;
420  };
421 
422  virtual inline int ForceOut(const std::string &outstr,unsigned char inlev = 1)
423  {
424  if(_verb_level >= inlev){
425  std::string line;
426  std::istringstream Istr(outstr);
427  while(std::getline(Istr,line)){
428  std::cout << (Name().empty() ? "" : std::string(Name()+std::string(": ")))
429  << line;
430  std::cout << (Istr.good() ? "\n" : "");
431  }
432  std::flush(std::cout);
433  }
434  else
435  return(1);
436  return(0);
437  };
438 
439  virtual inline int StdOut(const std::string &outstr,unsigned char inlev = 1)
440  {
441  if(_OutStream && _verb_level >= inlev){
442  std::string line;
443  std::istringstream Istr(outstr);
444  while(std::getline(Istr,line)){
445  *_OutStream << (Name().empty() ? "" : std::string(Name()+std::string(": ")))
446  << line;
447  *_OutStream << (Istr.good() ? "\n" : "");
448  }
449  std::flush(*_OutStream);
450  }
451  else
452  return(1);
453  return(0);
454  };
455 
456  virtual inline int ErrOut(const std::string &outstr)
457  {
458  if(_ErrStream){
459  std::string line;
460  std::istringstream Istr(outstr);
461  while(std::getline(Istr,line)){
462  *_ErrStream << (Name().empty() ? "" : std::string(Name()+std::string(":")))
463  << "Error: " << line;
464  *_ErrStream << (Istr.good() ? "\n" : "");
465  }
466  std::flush(*_ErrStream);
467  }
468  else
469  return(1);
470  return(0);
471  };
472 
473  virtual inline int DebugOut(const std::string &outstr,int inlev=1)
474  {
475  if(_DebugStream && _debug_level >= inlev){
476  std::string line;
477  std::istringstream Istr(outstr);
478  while(std::getline(Istr,line)){
479  *_DebugStream << (Name().empty() ? "" : std::string(Name()+std::string(":")))
480  << "db: " << line;
481  *_DebugStream << (Istr.good() ? "\n" : "");
482  }
483  std::flush(*_DebugStream);
484  }
485  else
486  return(1);
487  return(0);
488  };
489 
490  virtual inline int LogOut(const std::string &outstr,int inlev=0)
491  {
492  std::string timestring(sys::LogTime());
493  if((_LogStream != NULL) && (_log_level >= inlev)){
494  std::string line;
495  std::istringstream Istr(outstr);
496  while(std::getline(Istr,line)){
497  *_LogStream << timestring
498  << (Name().empty() ? "" : std::string(Name()+std::string(": ")))
499  << line;
500  *_LogStream << (Istr.good() ? "\n" : "");
501  }
502  std::flush(*_LogStream);
503  }
504  else
505  return(1);
506  return(0);
507  };
508 
510  virtual inline ~GlobalObj()
511  {
512  if(_initd)
513  Finalize();
514  if(_profiler_mine && _Profiler){
515  delete _Profiler;
516  }
517  };
518  private:
519  std::string FName() { return((Name().empty() ?
520  std::string("") :
521  std::string(Name()+std::string(":")))); };
522  };
523 
524  template<typename CommunicatorType,typename StackType,
525  typename ErrorType,typename ProfilerType>
526  class ParallelGlobalObj : public GlobalObj<StackType,ErrorType,ProfilerType>
527  {
529  protected:
532  public:
534  GlobalType()
535  {
536  profilingBarrier = false;
537  };
538  ParallelGlobalObj(GlobalType &inglob) :
539  GlobalType(inglob)
540  {
541  profilingBarrier = false;
542  };
544  GlobalObj<StackType,ErrorType,ProfilerType>(pglobin)
545  {
546  globalCommunicator.Initialize(pglobin.globalCommunicator);
547  profilingBarrier = false;
548 
549  };
550  ParallelGlobalObj(const std::string &name) :
551  GlobalObj<StackType,ErrorType,ProfilerType>(name)
552  {
553  // Init(name);
554  profilingBarrier = false;
555 
556  };
557  ParallelGlobalObj(const std::string &name,unsigned int id) :
558  GlobalObj<StackType,ErrorType,ProfilerType>(name,id)
559  {
560  // Init(name);
561  profilingBarrier = false;
562  };
563  ParallelGlobalObj(int narg,char **args) :
564  GlobalObj<StackType,ErrorType,ProfilerType>(narg,args)
565  {
566  int result = Init(narg,args);
567  assert(result == 0);
568  profilingBarrier = false;
569 
570  };
571  ParallelGlobalObj(int narg,char **args,CommunicatorType &incomm) :
572  GlobalObj<StackType,ErrorType,ProfilerType>(narg,args)
573  {
574  int result = Init(util::stripdirs(args[0]),incomm);
575  assert(result == 0);
576  profilingBarrier = false;
577  };
578  virtual inline int Init(const std::string &name,CommunicatorType &incomm)
579  {
580  int retval = globalCommunicator.Initialize(incomm);
581  if(retval)
582  return(retval);
583  return(GlobalObj<StackType,ErrorType,ProfilerType>::Init(name,globalCommunicator.Rank()));
584  };
585  virtual inline int Init(const std::string &name)
586  {
588  };
589  virtual inline int Init(const std::string &name,unsigned int id)
590  {
592  };
593  virtual inline int Init(int narg,char **args)
594  {
595  int retval = globalCommunicator.Initialize(&narg,&args);
596  if(retval){
597  return(retval);
598  }
599  return(GlobalObj<StackType,ErrorType,ProfilerType>::Init(util::stripdirs(args[0]),globalCommunicator.Rank()));
600  };
601  bool ProfilingBarriers(){return(profilingBarrier);};
602  void EnableProfilingBarriers(){profilingBarrier = true;};
603  void DisableProfilingBarriers(){profilingBarrier = false;};
604  virtual inline void FunctionEntry(const StackType &stackentry){
605  if(profilingBarrier)
606  globalCommunicator.Barrier();
608  };
609  virtual inline void FunctionExit(const StackType &stackentry){
610  if(profilingBarrier)
611  globalCommunicator.Barrier();
613  };
614  virtual inline int Rank()
615  {
616  return(globalCommunicator.Rank());
617  };
618  virtual inline int NProc()
619  {
620  return(globalCommunicator.Size());
621  };
622  virtual inline int Finalize()
623  {
625  if(retval)
626  return(retval);
627  return(globalCommunicator.Finalize());
628  };
629  virtual inline CommunicatorType &Communicator(){return globalCommunicator; };
630  virtual ~ParallelGlobalObj(){ Finalize();};
631  };
632 
633  template<typename GlobalType,typename ComLineType>
634  class Program : public GlobalType
635  {
636  protected:
637  ComLineType _command_line;
638  public:
640  GlobalType()
641  {};
642  Program(GlobalType &inglob) :
643  GlobalType(inglob){};
644  Program(ComLineType &incom) :
645  GlobalType(),_command_line(incom)
646  {};
647  Program(int narg,char **args) :
648  GlobalType(narg,args)
649  {
650  _command_line.Record((const char **)args);
651  // SetName(_command_line.ProgramName());
652  };
653  Program(ComLineType &incom,GlobalType &inglob) :
654  GlobalType(inglob), _command_line(incom) {};
655  Program(int narg,char **args,GlobalType &inglob) :
656  GlobalType(inglob)
657  {
658  _command_line.Record((const char **)args);
659  // SetName(_command_line.ProgramName());
660  };
661  virtual inline int Initialize()
662  {
663  _command_line.Initialize();
664  return(_command_line.ProcessOptions());
665  };
666  ComLineType &CommandLine() {return _command_line; };
667  virtual inline int Run(){return(0);};
668  virtual inline int Finalize(){return(GlobalType::Finalize());};
669  virtual ~Program(){};
670  };
671  };
672 };
673 #endif
virtual int Init(const std::string &name)
Definition: Global.H:585
void SetDebugLevel(unsigned char l)
Sets the level of debugging.
Definition: Global.H:388
int FunctionExit(const std::string &name)
mark construct exit
Definition: Profiler.C:259
std::list< ErrorType > _Errors
Errors provides a list for storing caught execution errors for later processing.
Definition: Global.H:42
virtual int DebugOut(const std::string &outstr, int inlev=1)
Definition: Global.H:473
ComLineType _command_line
Definition: Global.H:637
bool FinalizeReady()
Ready to finalize?
Definition: Profiler.H:516
ProfilerType & Profiler()
Gets the debug stream object.
Definition: Global.H:385
virtual void DumpProfile(std::ostream &Ostr)
Dumps the timing profile to the indicated stream.
Definition: Global.H:306
GlobalObj< StackType, ErrorType, ProfilerType > GlobalType
Definition: Global.H:528
void UnsetOutStream()
Sets outstream to NULL.
Definition: Global.H:354
std::ostream * _ErrStream
Definition: Global.H:54
virtual void Report(std::ostream &ReportStream)
Creates the final profiling report on the specified stream.
Definition: Global.H:240
unsigned char VerbLevel()
Returns the verbosity level.
Definition: Global.H:396
Performance profiling object.
Definition: Profiler.H:398
std::ostream * ErrStreamPtr()
Gets the error stream pointer.
Definition: Global.H:337
virtual int ErrOut(const std::string &outstr)
Definition: Global.H:456
virtual int Finalize()
Finalizes the global object, and it&#39;s profiler object.
Definition: Global.H:202
std::ostream * _OutStream
Definition: Global.H:52
std::ostream & LogStream()
Gets the log stream object.
Definition: Global.H:365
unsigned char _verb_level
Verbosity level.
Definition: Global.H:35
void DumpContents(std::ostream &Ostr, const ContainerType &c, std::string del="\)
Dump container contents.
void SetLogLevel(unsigned char l)
Definition: Global.H:398
Basic utility header.
virtual bool Profiling()
Get profiling state.
Definition: Global.H:229
STL namespace.
std::ostream * _LogStream
Definition: Global.H:53
Program(int narg, char **args, GlobalType &inglob)
Definition: Global.H:655
virtual void FunctionExit(const StackType &stackentry)
FunctionExit updates the Stack as well as the Profiler.
Definition: Global.H:609
int Finalize(bool writeFiles=true)
Shut down profiler.
Definition: Profiler.C:493
std::ostream * _ErrStreamSave
Definition: Global.H:63
Defines MPI-specific parallel global and program classes.
GlobalObj(const StackType &name)
Constructor with args.
Definition: Global.H:119
std::ostream * _DebugStreamSave
Definition: Global.H:64
virtual int Initialize()
Definition: Global.H:661
std::ostream * _DebugStream
DebugStream is useful for parallel programs that cannot stream debugging information to the screen...
Definition: Global.H:51
void SetErrStream(std::ostream &dbstream)
Sets the error stream object.
Definition: Global.H:329
virtual void DeRegister(const StackType &stackentry)
DeRegister will pop from the stack only.
Definition: Global.H:260
std::ostream & OutStream()
Gets the stdout stream object.
Definition: Global.H:348
ComLineType & CommandLine()
Definition: Global.H:666
void SyncIO()
Syncronize IO - assume control over IO, using established streams.
Definition: Global.H:415
std::string FName()
Definition: Global.H:519
void SetDebugStream(std::ostream &dbstream)
Sets the debug stream object.
Definition: Global.H:315
Program(int narg, char **args)
Definition: Global.H:647
virtual int Init(int narg, char **args)
Definition: Global.H:593
profiler::ProfilerObj ProfilerType
Definition: MPIGlobal.H:13
virtual int Init(const std::string &name, CommunicatorType &incomm)
Definition: Global.H:578
ix::global::GlobalObj< std::string, std::string, ProfilerType > GlobalType
Definition: PCPPTypes.H:35
virtual void DumpErrors(std::ostream &Ostr)
Dumps the errors themselves to the indicated stream.
Definition: Global.H:296
std::ostream * DebugStreamPtr()
Gets the debug stream pointer.
Definition: Global.H:323
virtual void DumpStack(std::ostream &Ostr)
Dumps the code construct statck to the indicated stream.
Definition: Global.H:301
std::list< StackType > _Stack
Stack provides a list for storing the user defined "stack".
Definition: Global.H:39
void SummarizeSerialExecution(std::ostream &Ostr)
Profiling output for serial application.
Definition: Profiler.C:393
virtual void ReName(const std::string &name)
Definition: Global.H:382
unsigned char _log_level
Logging level.
Definition: Global.H:32
bool ErrStreamReady()
Checks error stream.
Definition: Global.H:326
virtual int Finalize()
Definition: Global.H:668
void SetProfiler(ProfilerType &profiler)
Sets the Profiler object.
Definition: Global.H:371
virtual void FunctionEntry(const StackType &stackentry)
FunctionEntry updates the Stack as well as the Profiler.
Definition: Global.H:604
virtual ~Program()
Definition: Global.H:669
ParallelGlobalObj(int narg, char **args, CommunicatorType &incomm)
Definition: Global.H:571
int Dump(std::ostream &Ostr)
dumps closed events, clears memory
Definition: Profiler.C:363
ParallelGlobalObj(const std::string &name)
Definition: Global.H:550
comm::CommunicatorObject CommunicatorType
Definition: MPIGlobal.H:12
Program(GlobalType &inglob)
Definition: Global.H:642
std::string LogTime()
Definition: UnixUtils.C:160
GlobalObj(GlobalObj< StackType, ErrorType, ProfilerType > &globin)
Constructor with args.
Definition: Global.H:98
unsigned char LogLevel()
Returns the verbosity level.
Definition: Global.H:401
unsigned char DebugLevel()
Returns the debugging level.
Definition: Global.H:391
int FunctionExitAll()
Force all open profiling Events to close (emergency)
Definition: Profiler.C:329
virtual int StdOut(const std::string &outstr, unsigned char inlev=1)
Definition: Global.H:439
ParallelGlobalObj(const std::string &name, unsigned int id)
Definition: Global.H:557
virtual int Init(const std::string &name, unsigned int id)
Definition: Global.H:589
Program(ComLineType &incom, GlobalType &inglob)
Definition: Global.H:653
bool LogStreamReady()
Checks log stream.
Definition: Global.H:357
ParallelGlobalObj(int narg, char **args)
Definition: Global.H:563
Main encapsulation of MPI.
Definition: COMM.H:62
std::ostream & DebugStream()
Gets the debug stream object.
Definition: Global.H:320
GlobalObj(int narg, char **args)
Default constructor.
Definition: Global.H:82
int Initialize(CommunicatorObject &incomm)
Definition: COMM.C:310
virtual void Register(const StackType &stackentry)
Register will push to the Stack only.
Definition: Global.H:251
virtual bool Profiling(bool yn)
Enable or disable profiling.
Definition: Global.H:234
std::ostream & ErrStream()
Gets the error stream object.
Definition: Global.H:334
const std::string stripdirs(const std::string &pname)
Strip absolute path.
ComLineObject header.
virtual void FunctionExitAll()
FunctionExitAll exits all from the Profiler only.
Definition: Global.H:285
void SetOutStream(std::ostream &outstream)
Sets the stdout stream object.
Definition: Global.H:343
bool OutStreamReady()
Checks out stream.
Definition: Global.H:340
Unix System Tools interface.
virtual CommunicatorType & Communicator()
Definition: Global.H:629
ParallelGlobalObj(ParallelGlobalObj< CommunicatorType, StackType, ErrorType, ProfilerType > &pglobin)
Definition: Global.H:543
virtual void FunctionEntry(const StackType &stackentry)
FunctionEntry updates the Stack as well as the Profiler.
Definition: Global.H:267
ParallelGlobalObj(GlobalType &inglob)
Definition: Global.H:538
std::ostream * LogStreamPtr()
Gets the log stream pointer.
Definition: Global.H:368
CommunicatorType globalCommunicator
Definition: Global.H:531
std::string _name
Definition: Global.H:61
Program(ComLineType &incom)
Definition: Global.H:644
Definition: EulerRHS.H:33
virtual int Init(const StackType &name, unsigned int id)
Initializes the global object and it&#39;s profiler object Profiling is ON by default if Init is invoked...
Definition: Global.H:168
GlobalObj()
Default constructor. Profiling is OFF by default.
Definition: Global.H:68
virtual void Error(const ErrorType &error)
Pushes an error onto the error stack.
Definition: Global.H:291
virtual ~GlobalObj()
Destructor.
Definition: Global.H:510
virtual int Run()
Definition: Global.H:667
bool _initd
has been initialized?
Definition: Global.H:45
virtual int Finalize()
Finalizes the global object, and it&#39;s profiler object.
Definition: Global.H:622
Base global object.
Definition: Global.H:25
std::ostream * _OutStreamSave
Definition: Global.H:62
void SetVerbLevel(unsigned char l)
Definition: Global.H:393
std::ostream * OutStreamPtr()
Gets the stdout stream pointer.
Definition: Global.H:351
bool DebugStreamReady()
Checks debug stream.
Definition: Global.H:312
int FunctionEntry(const std::string &name)
mark construct entry
Definition: Profiler.C:211
unsigned char _debug_level
Debugging level.
Definition: Global.H:29
int Init(int id)
integer only inteface for init
Definition: Profiler.C:166
ProfilerType * _Profiler
This is a placeholder for a generic profiling tool.
Definition: Global.H:56
virtual bool WriteProfiles()
Get state of enablement for writing profile files.
Definition: Global.H:219
bool _profiling_enabled
Definition: Global.H:58
void SetLogStream(std::ostream &logstream)
Sets the stdout stream object.
Definition: Global.H:360
virtual int LogOut(const std::string &outstr, int inlev=0)
Definition: Global.H:490
GlobalObj(const StackType &name, int id)
Constructor with args.
Definition: Global.H:128
virtual void FunctionExit(const StackType &stackentry)
FunctionExit updates the Stack as well as the Profiler.
Definition: Global.H:276
virtual int ForceOut(const std::string &outstr, unsigned char inlev=1)
Definition: Global.H:422
virtual bool WriteProfiles(bool yn)
Enable or disable profile file writing.
Definition: Global.H:224
void DeSyncIO()
DeSync IO - relinquish control over IO, revert to standard.
Definition: Global.H:404
virtual int Init(const StackType &name)
Initializes the global object and it&#39;s profiler object /// Initializes the global object and it&#39;s pro...
Definition: Global.H:136
virtual void SetName(const std::string &name)
Definition: Global.H:381
virtual const std::string & Name()
Definition: Global.H:383