PlasCom2  1.0
XPACC Multi-physics simluation application
PC2Initialize.C
Go to the documentation of this file.
1 #include "PlasCom2.H"
2 #include "PCPPUtil.H"
12 {
14  AddOption('c',"config",2,"configfile");
15  AddHelp('c',"Set the configuration file.");
16  AddArgument("restartFile");
17  AddArgHelp("restartFile","HDF5 restart file.");
18  AddArgument("targetFile");
19  AddArgHelp("targetFile","HDF5 file with target data.");
20  SetDescription(std::string("PlasCom2 alpha development."));
21  SetNotes("Notes for PlasCom2.\n");
22 }
23 
24 namespace plascom2 {
25 
26  std::string Splash()
27  {
28  std::ostringstream outStream;
29  outStream << "*******************************" << std::endl
30  << "* XPACC PlasCom2 *" << std::endl
31  << "* Alpha development *" << std::endl
32  << "*******************************" << std::endl;
33  return(outStream.str());
34  };
35 
36 
37  int application::InitializeApplication()
38  {
40  if(error < 0){
41  ErrOut("Parallel program failed to initialize.\n");
42  return(1);
43  } else if (error > 0){
44  return(1);
45  }
46  error = 0;
47  StdOut(Splash(),1);
48  // Configuration file processing
49  globalCommunicator.Barrier();
50  return(error);
51  }
52 
53  // int application::ConfigureApplication()
54  // {
55  // if(InitializeNodeCommunicator())
56  // return(1);
57  // if(InitializeIOCommunicators())
58  // return(1);
59  // if(SetupIOTopology())
60  // return(1);
61  // if(PartitionGridsLogical())
62  // return(1);
63  // // if(PrepareHalos())
64  // // return(1);
65  // std::ostringstream Ostr;
66  // Ostr << "Plascom domain configuration" << std::endl
67  // << "----------------------------" << std::endl;
68  // plascomDomain.Report(Ostr);
69  // Ostr << "----------------------------" << std::endl;
70  // StdOut(Ostr.str(),2);
71  // if(InitializeGrids())
72  // return(1);
73  // if(DistributeGridsLogical())
74  // return(1);
75  // if(GenerateGrids())
76  // return(1);
77  // // Can be moved around (fixme: production)
78  // if(DistributeGrids())
79  // return(1);
80  // if(ExchangeIONeighborhood())
81  // return(1);
82  // if(ExchangeComputeNeighborhood())
83  // return(1);
84  // if(CollideComputeNeighbors())
85  // return(1);
86  // if(ExchangeCommunicationMaps())
87  // return(1);
88  // if(DistributeCommunicationMaps())
89  // return(1);
90  // if(CreateFieldDataBuffers())
91  // return(1);
92  // if(CreateCommunicationBuffers())
93  // return(1);
94  // // Not needed - included here as a test (fixme: production)
95  // // if(GatherGrids())
96  // // return(1);
97  // globalCommunicator.Barrier();
98  // FunctionExit("Setup");
99  // return(0);
100  // }
101 
102  int application::FinalizeApplication()
103  {
104 #ifdef USE_OVERKIT
105  FinalizeOverkit();
106 #endif
107  int numProcs = NProc();
108 // int numSteps = 0;
109 // size_t numPoints = 0;
110 // int numGrids = 0;
111  // maxSteps = plascomConfig.GetValue<int>("Stepping:NumSteps");
112  // if(!plascomDomain.empty()){
113  // numGrids = 1;
114  // pcpp::geometry::grid &a1Grid(plascomDomain[0]);
115  // pcpp::geometry::gridinfo &gridInfo(a1Grid.Info());
116  // std::vector<int> &globalSize(gridInfo.globalSize);
117  // std::vector<int>::iterator sizeIt = globalSize.begin();
118  // numPoints = 1;
119  // while(sizeIt != globalSize.end())
120  // numPoints *= *sizeIt++;
121  // }
122  std::ostringstream timerReportStream;
123  timerReportStream << "#Number of procs: "
124  << numProcs << std::endl
125  << "#Number of threads: "
126  << numThreads << std::endl
127  << "#Number of steps: "
128  << numSteps << std::endl
129  << "#Number of grids: "
130  << numGrids << std::endl;
131  if(numGrids > 0){
132  timerReportStream << "#Number of points: ";
133  for(int iGrid = 0;iGrid < numGrids;iGrid++)
134  timerReportStream << numPointsGrid[iGrid] << " ";
135  timerReportStream << std::endl;
136  }
137 
138  Report(timerReportStream);
139  std::ostringstream timingFileNameStream;
140  timingFileNameStream << "PlasCom2Timing_";
141  int nZeros = (numProcs > 99999 ? 0 :
142  numProcs > 9999 ? 1 :
143  numProcs > 999 ? 2 :
144  numProcs > 99 ? 3 :
145  numProcs > 9 ? 4 : 5);
146  int zeroCount = 0;
147  while(zeroCount++ < nZeros)
148  timingFileNameStream << "0";
149  timingFileNameStream << numProcs << ".txt";
150  std::ofstream timingFile;
151  if(Rank() == 0){
152  timingFile.open(timingFileNameStream.str().c_str());
153  timingFile << timerReportStream.str() << std::endl;
154  timingFile.close();
155  } else if(OutStreamReady()) {
156  OutStream() << timerReportStream.str() << std::endl;
157  }
159  ErrOut("Failed to finalize parallel program.\n");
160  if(ErrStreamReady())
161  DumpErrors(ErrStream());
162  return(1);
163  }
164  StdOut("Program finished - goodbye.\n",1);
165  return(0);
166  }
167 }
virtual void Initialize()
defines PlasCom2-specific command-line arguments
Definition: PC2Initialize.C:11
std::string Splash()
Definition: PC2Initialize.C:26
virtual int Finalize()
Finalizes the global object, and it&#39;s profiler object.
Definition: MPIGlobal.H:122
Definition: PC2IO.H:10
void SetDescription(const std::string &desc)
Set description string.
Definition: ComLine.H:318
void AddOption(char s, const std::string &l, int=0)
User interface to describe simple option.
Definition: ComLine.C:295
Definition: EulerRHS.H:33
void SetNotes(const std::string &notes)
Set notes string.
Definition: ComLine.H:322
void AddArgument(const std::string &a, int reqd=0)
User interface to describe an application argument.
Definition: ComLine.H:183
virtual int Initialize()
Populates native data structures from commandline.
Definition: PCPPProgram.H:194
void InitializeDefaults()
Definition: PCPPProgram.H:26
void AddHelp(char s, const std::string &help)
Specify usage for an option.
Definition: ComLine.H:227
void AddArgHelp(const std::string &a, const std::string &help)
Specify the usage info for application argument.
Definition: ComLine.H:197