1 #ifndef __APPLICATION_H__ 9 #define __APPLICATION_H__ 15 namespace ix {
namespace app {
25 program2(
int narg,
char **args) : Global(narg,args){};
26 program2(
const std::string &name) : Global(name){};
27 program2(
const std::string &name,
int id) : Global(name,id){};
29 virtual int Run(){
return(0);};
34 template<
typename CommandLineT>
46 commandLine(incom) {};
49 commandLine.Record((
const char **)args);
53 commandLine.Initialize();
54 return(commandLine.ProcessOptions());
57 virtual int Run(){
return(0);};
69 AddOption(
'd',
"debuglevel",1);
70 AddOption(
'h',
"help");
71 AddOption(
'v',
"verblevel",1);
72 AddOption(
'p',
"enable-profiling",1);
73 AddHelp(
'h',
"Produces this long help message");
74 AddHelp(
'd',
"Set the debugging level for the program.(default=1)");
75 AddHelp(
'p',std::string(
"Enable profiling. Profiling level > 1 enables")+
76 std::string(
" profiling\n\t\tbarriers. (default=1)"));
77 AddHelp(
'v',std::string(
"Set the verbosity level for the program.")+
78 std::string(
" Anything\n\t\tlarger than 2 is debugging level.")+
79 std::string(
"\n\t\tExamples:\n\t\t\t-v (defaults to 1)\n\t\t\t")+
80 std::string(
"-v 0 (silence)\n\t\t\t--verblevel=2")+
81 std::string(
" (high verbosity)"));
82 SetDescription(std::string(
"This text should describe the program."));
93 ProgramType(narg,args){};
95 ProgramType(inglob){};
99 ProgramType(incom,inglob){};
103 ErrOut(
"Failed to initialize.\n");
104 ErrOut(CommandLine().ErrorReport()+std::string(
"\n"));
105 ErrOut(
"Use -h,--help for usage help.\n\n");
106 ErrOut(CommandLine().ShortUsage()+std::string(
"\n"));
109 if(!CommandLine().GetOption(
'h').empty()){
110 StdOut(CommandLine().LongUsage());
119 std::string sverb(CommandLine().GetOption(
'v'));
121 if(sverb ==
".true.")
124 std::istringstream Istr(sverb);
135 std::string sprof(CommandLine().GetOption(
'p'));
137 if(sprof ==
".true.")
140 std::istringstream Istr(sprof);
151 std::string sdebug(CommandLine().GetOption(
'd'));
153 if(sdebug ==
".true.")
156 std::istringstream Istr(sdebug);
165 virtual int Run(){
return(0);};
171 ErrOut(
"Failed to finalize.\n");
180 template<
typename ProgramType>
183 int errCode = applicationProgram.
Initialize();
185 applicationProgram.ErrOut(
"Failed to initialize.\n");
187 }
else if (errCode) {
190 applicationProgram.DebugOut(
"Initialized.\n",1);
192 if(applicationProgram.
Run()){
193 applicationProgram.ErrOut(
"Failed to run.\n");
196 applicationProgram.DebugOut(
"Ran.\n",1);
199 applicationProgram.ErrOut(
"Failed to finalize.\n");
202 applicationProgram.DebugOut(
"Finalized.\n",1);
void SetDebugLevel(unsigned char l)
Sets the level of debugging.
int ProgramDriver(ProgramType &applicationProgram)
virtual void Report(std::ostream &ReportStream)
Creates the final profiling report on the specified stream.
program(command_line &incom, Global &inglob)
Performance profiling object.
virtual void Initialize()
virtual function for program specific Initialization.
virtual int ErrOut(const std::string &outstr)
program(command_line &incom)
virtual int Finalize()
Finalizes the global object, and it's profiler object.
profiler::ProfilerObj Profiler
virtual bool Profiling()
Get profiling state.
virtual int Finalize()
Finalizes the global object, and it's profiler object.
Defines MPI-specific parallel global and program classes.
std::ostream & OutStream()
Gets the stdout stream object.
void SetDebugStream(std::ostream &dbstream)
Sets the debug stream object.
program2(int narg, char **args)
virtual void DumpErrors(std::ostream &Ostr)
Dumps the errors themselves to the indicated stream.
Performance Profiling interface definition.
command_line_program(CommandLineT &incom, Global &inglob)
virtual int StdOut(const std::string &outstr, unsigned char inlev=1)
program2(const std::string &name)
std::ostream & ErrStream()
Gets the error stream object.
global::GlobalObj< std::string, std::string, Profiler > Global
Base global object header.
bool OutStreamReady()
Checks out stream.
global::Program< Global, command_line > ProgramType
command_line_program(const std::string &name, int id)
command_line(command_line &inComLine)
CommandLineT & CommandLine()
void SetVerbLevel(unsigned char l)
command_line_program(Global &inglob)
command_line_program(int narg, char **args)
command_line(const char *args[])
program2(const std::string &name, int id)
program(int narg, char **args)
command_line_program(CommandLineT &incom)
virtual ~command_line_program()
command_line_program(const std::string &name)
virtual int Finalize()
Finalizes the global object, and it's profiler object.