1 #ifndef __PARALLEL_APPLICATION_H__ 9 #define __PARALLEL_APPLICATION_H__ 15 namespace ix {
namespace app {
42 ParallelProgramType(nargs,args)
64 ErrOut(
"Failed to initialize.\n");
65 ErrOut(
CommandLine().ErrorReport()+std::string(
"\n"));
66 ErrOut(
"Use -h,--help for usage help.\n\n");
67 ErrOut(
CommandLine().ShortUsage()+std::string(
"\n"));
74 std::string applicationName(
CommandLine().ProgramName());
89 int nZeros = std::log10((
double)nproc);
90 std::istringstream Istr(sverb);
93 SetVerbLevel(verbLevel);
96 outFilePtr =
new std::ofstream;
97 std::ostringstream outFileNameStream;
98 outFileNameStream << applicationName <<
"_";
99 for(
int i = nZeros;i > 0;i--){
100 int numRanks = std::pow((
double)10,(
double)i);
102 outFileNameStream <<
"0";
104 if(!ErrStreamReady())
105 SetErrStream(std::cerr);
106 outFileNameStream << rank;
107 outFileName.assign(outFileNameStream.str());
108 outFilePtr->open(outFileNameStream.str().c_str());
110 globalCommunicator.SetErr(1);
113 if(globalCommunicator.Check()){
115 ErrOut(
"Unable to open output on all processors.\n");
117 }
else if(rank > 0) {
118 SetOutStream(*outFilePtr);
120 SetDebugStream(OutStream());
121 SetDebugLevel(verbLevel - 2);
128 DisableProfilingBarriers();
130 if(sprof ==
".true.")
133 std::istringstream Istr(sprof);
141 EnableProfilingBarriers();
148 if(sdebug ==
".true.")
151 std::istringstream Istr(sdebug);
155 SetDebugLevel(debugLevel);
172 SetOutStream(std::cout);
183 ErrOut(
"Failed to finalize.\n");
185 DumpErrors(ErrStream());
ComLineType _command_line
ix::comm::CommunicatorObject CommunicatorType
std::string outFileName
Name of file for output.
Defines MPI-specific parallel global and program classes.
virtual int Initialize()
Populates native data structures from commandline.
ComLineType & CommandLine()
virtual int Run()
This function implements the main function executed by the program.
parallel_program(CommandLineType &comline, CommunicatorType &incomm)
Constructor designed to take all commandline args.
parallel_program()
Default constructor.
Definitions for serial applications.
Main encapsulation of MPI.
parallel_program(int nargs, char **args)
Constructor designed to take all commandline args.
ix::global::ParallelGlobalObj< CommunicatorType, std::string, int, ProfilerType > ParallelGlobalType
ix::global::Program< ParallelGlobalType, CommandLineType > ParallelProgramType
virtual ~parallel_program()
Destructor.
std::ofstream * outFilePtr
Output file stream object for output.