Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4VMPIsession Class Reference

#include <G4VMPIsession.hh>

Inheritance diagram for G4VMPIsession:
Collaboration diagram for G4VMPIsession:

Public Member Functions

 G4VMPIsession ()
 
 ~G4VMPIsession ()
 
virtual void PauseSessionStart (const G4String &msg)
 
virtual G4int ReceiveG4cout (const G4String &coutString)
 
virtual G4int ReceiveG4cerr (const G4String &cerrString)
 
- Public Member Functions inherited from G4VBasicShell
 G4VBasicShell ()
 
virtual ~G4VBasicShell ()
 
virtual G4UIsessionSessionStart ()=0
 
- Public Member Functions inherited from G4UIsession
 G4UIsession ()
 
 G4UIsession (G4int iBatch)
 
virtual ~G4UIsession ()
 
- Public Member Functions inherited from G4coutDestination
 G4coutDestination ()
 
virtual ~G4coutDestination ()
 

Protected Member Functions

G4int ExecCommand (const G4String &acommand)
 
G4String TruncateCommand (const G4String &command) const
 
G4String BypassCommand (const G4String &command) const
 
virtual G4bool GetHelpChoice (G4int &aval)
 
virtual void ExitHelp () const
 
- Protected Member Functions inherited from G4VBasicShell
G4String ModifyToFullPathCommand (const char *aCommandLine) const
 
G4String GetCurrentWorkingDirectory () const
 
G4bool ChangeDirectory (const char *newDir)
 
G4UIcommandTreeFindDirectory (const char *dirName) const
 
G4UIcommandFindCommand (const char *commandName) const
 
G4String Complete (const G4String &)
 
G4String FindMatchingPath (G4UIcommandTree *, const G4String &)
 
virtual void ExecuteCommand (const G4String &)
 
void ApplyShellCommand (const G4String &, G4bool &, G4bool &)
 
void ShowCurrent (const G4String &) const
 
void ChangeDirectoryCommand (const G4String &)
 
void ListDirectory (const G4String &) const
 
void TerminalHelp (const G4String &)
 

Protected Attributes

G4MPImanagerg4mpi_
 
G4bool is_master_
 
G4bool is_slave_
 
G4int rank_
 
- Protected Attributes inherited from G4UIsession
G4int ifBatch
 

Additional Inherited Members

- Static Public Member Functions inherited from G4UIsession
static G4int InSession ()
 
- Static Protected Attributes inherited from G4UIsession
static G4int inSession = 0
 
- Static Protected Attributes inherited from G4coutDestination
static G4coutDestinationmasterG4coutDestination = 0
 

Detailed Description

Definition at line 38 of file G4VMPIsession.hh.

Constructor & Destructor Documentation

G4VMPIsession::G4VMPIsession ( )

Definition at line 35 of file G4VMPIsession.cc.

36  : G4VBasicShell()
37 {
39 
40  is_master_ = g4mpi_-> IsMaster();
41  is_slave_ = g4mpi_-> IsSlave();
42  rank_ = g4mpi_-> GetRank();
43 
44 }
G4MPImanager * g4mpi_
static G4MPImanager * GetManager()

Here is the call graph for this function:

G4VMPIsession::~G4VMPIsession ( )

Definition at line 47 of file G4VMPIsession.cc.

48 {
49 }

Member Function Documentation

G4String G4VMPIsession::BypassCommand ( const G4String command) const
protected

Definition at line 173 of file G4VMPIsession.cc.

174 {
175  // bypass some commands
176  // * /mpi/beamOn
177  // -> /mpi/.beamOn (batch session)
178  // -> /mpi/.beamOn (MT mode)
179  //
180  // * /run/beamOn
181  // -> /mpi/.beamOn (batch session)
182  // -> /mpi/beamOn (interactive session)
183  // -> /mpi/.beamOn (MT mode)
184  //
185  // * /control/execute -> /mpi/execute
186 
187  G4String acommand = command;
188 
189  // /mpi/beamOn
190  if( acommand(0,11) == "/mpi/beamOn" ) {
191 #ifdef G4MULTITHREADED
192  acommand = "/mpi/.beamOn";
193  if(command.length() > 11) {
194  acommand += command.substr(11);
195  }
196 #else
197  if( g4mpi_-> IsBatchMode()) {
198  acommand = "/mpi/.beamOn";
199  if(command.length() > 11) {
200  acommand += command.substr(11);
201  }
202  }
203 #endif
204  }
205 
206  // /run/beamOn
207  if( acommand(0,11) == "/run/beamOn" ) {
208  G4String strarg = "";
209  G4bool qget = false;
210  G4bool qdone = false;
211 
212  for ( str_size idx = 10; idx < command.size(); idx++ ) {
213  if( command[idx] == ' ' || command[idx] == '\011' ) {
214  qget = true;
215  if(qdone) break;
216  continue;
217  }
218  if( qget ) {
219  strarg += command[idx];
220  qdone = true;
221  }
222  }
223 
224  if( g4mpi_-> IsBatchMode() ) { // batch session
225  acommand = "/mpi/.beamOn ";
226  if( command.length() > 11 ) acommand += strarg;
227  } else { // interactive session
228 #ifdef G4MULTITHREADED
229  if( g4mpi_-> GetVerbose()>0 && is_master_ ) {
230  G4cout << "/run/beamOn is overridden by /mpi/.beamOn" << G4endl;
231  }
232  acommand = "/mpi/.beamOn ";
233  if( command.length() > 11 ) acommand += strarg;
234 #else
235  if( g4mpi_-> GetVerbose()>0 && is_master_ ) {
236  G4cout << "/run/beamOn is overridden by /mpi/beamOn" << G4endl;
237  }
238  acommand = "/mpi/beamOn ";
239  if( command.length() > 11 ) acommand += strarg;
240 #endif
241  }
242  }
243 
244  // /control/execute
245  if( acommand(0,16) == "/control/execute" ) {
246  if( g4mpi_-> GetVerbose()>0 && is_master_ ) {
247  G4cout << "/control/execute is overridden by /mpi/execute"
248  << G4endl;
249  }
250  acommand.replace(0, 16, "/mpi/execute ");
251  }
252 
253  return acommand;
254 }
std::string::size_type str_size
Definition: G4String.hh:57
G4MPImanager * g4mpi_
G4String & replace(unsigned int, unsigned int, const char *, unsigned int)
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

Here is the caller graph for this function:

G4int G4VMPIsession::ExecCommand ( const G4String acommand)
protected

Definition at line 76 of file G4VMPIsession.cc.

77 {
78  if( acommand.length() < 2 ) return fCommandSucceeded;
79 
81  G4int returnVal = 0;
82 
83  G4String command = BypassCommand(acommand);
84 
85  // "/mpi/beamOn is threaded out.
86  if( command(0,11) == "/mpi/beamOn" ) {
87  g4mpi_-> ExecuteBeamOnThread(command);
88  returnVal = fCommandSucceeded;
89  } else if( command(0,12) == "/mpi/.beamOn" ) { // care for beamOn
90  G4bool threadStatus = g4mpi_-> CheckThreadStatus();
91  if ( threadStatus ) { // still /run/beamOn is active
92  if( is_master_ ) {
93  G4cout << "G4MPIsession:: beamOn is still running." << G4endl;
94  }
95  returnVal = fCommandSucceeded;
96  } else {
97  returnVal = UI-> ApplyCommand(command);
98  }
99  } else { // normal command
100  returnVal = UI-> ApplyCommand(command);
101  }
102 
103  G4int paramIndex = returnVal % 100;
104  // 0 - 98 : paramIndex-th parameter is invalid
105  // 99 : convination of parameters is invalid
106  G4int commandStatus = returnVal - paramIndex;
107 
108  G4UIcommand* cmd = 0;
109  if( commandStatus != fCommandSucceeded ) {
110  cmd = FindCommand(command);
111  }
112 
113  switch( commandStatus ) {
114  case fCommandSucceeded:
115  break;
116  case fCommandNotFound:
117  G4cerr << "command <" << UI-> SolveAlias(command)
118  << "> not found" << G4endl;
119  break;
121  G4cerr << "illegal application state -- command refused" << G4endl;
122  break;
124  // ...
125  break;
127  G4cerr << "Parameter is out of candidate list (index "
128  << paramIndex << ")" << G4endl;
129  G4cerr << "Candidates : "
130  << cmd->GetParameter(paramIndex)-> GetParameterCandidates()
131  << G4endl;
132  break;
134  G4cerr << "Parameter is wrong type and/or is not omittable (index "
135  << paramIndex << ")" << G4endl;
136  break;
137  case fAliasNotFound:
138  // ...
139  break;
140  default:
141  G4cerr << "command refused (" << commandStatus << ")" << G4endl;
142  }
143 
144  return returnVal;
145 }
G4MPImanager * g4mpi_
int G4int
Definition: G4Types.hh:78
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:59
G4String BypassCommand(const G4String &command) const
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
G4UIparameter * GetParameter(G4int i) const
Definition: G4UIcommand.hh:145
#define G4endl
Definition: G4ios.hh:61
G4UIcommand * FindCommand(const char *commandName) const
G4GLOB_DLL std::ostream G4cerr

Here is the call graph for this function:

Here is the caller graph for this function:

void G4VMPIsession::ExitHelp ( ) const
protectedvirtual

Implements G4VBasicShell.

Definition at line 64 of file G4VMPIsession.cc.

65 {
66  char temp[100];
67  G4cin.getline(temp, 100);
68 }
#define G4cin
Definition: G4ios.hh:60
G4bool G4VMPIsession::GetHelpChoice ( G4int aval)
protectedvirtual

Implements G4VBasicShell.

Definition at line 52 of file G4VMPIsession.cc.

53 {
54  G4cin >> aval;
55  if( !G4cin.good() ){
56  G4cin.clear();
57  G4cin.ignore(30,'\n');
58  return false;
59  }
60  return true;
61 }
#define G4cin
Definition: G4ios.hh:60
void G4VMPIsession::PauseSessionStart ( const G4String msg)
virtual

Implements G4VBasicShell.

Definition at line 71 of file G4VMPIsession.cc.

72 {
73 }
G4int G4VMPIsession::ReceiveG4cerr ( const G4String cerrString)
virtual

Reimplemented from G4UIsession.

Definition at line 264 of file G4VMPIsession.cc.

265 {
266  g4mpi_-> Print(cerrString);
267  return 0;
268 }
G4MPImanager * g4mpi_
void Print(const std::vector< T > &data)
Definition: DicomRun.hh:109

Here is the call graph for this function:

G4int G4VMPIsession::ReceiveG4cout ( const G4String coutString)
virtual

Reimplemented from G4UIsession.

Definition at line 257 of file G4VMPIsession.cc.

258 {
259  g4mpi_-> Print(coutString);
260  return 0;
261 }
G4MPImanager * g4mpi_
void Print(const std::vector< T > &data)
Definition: DicomRun.hh:109

Here is the call graph for this function:

G4String G4VMPIsession::TruncateCommand ( const G4String command) const
protected

Definition at line 148 of file G4VMPIsession.cc.

149 {
150  // replace "//" with "/" in G4command
151  G4String acommand = command;
152  G4String strarg;
153 
154  str_size iarg = acommand.find(' ');
155  if( iarg != G4String::npos ) {
156  strarg = acommand(iarg, acommand.size()-iarg);
157  acommand = acommand(0,iarg);
158  }
159 
160  str_size idx;
161  while( (idx = acommand.find("//")) != G4String::npos) {
162  G4String command1 = acommand(0,idx+1);
163  G4String command2 = acommand(idx+2, acommand.size()-idx-2);
164  acommand = command1 + command2;
165  }
166 
167  acommand += strarg;
168 
169  return acommand;
170 }
std::string::size_type str_size
Definition: G4String.hh:57

Member Data Documentation

G4MPImanager* G4VMPIsession::g4mpi_
protected

Definition at line 49 of file G4VMPIsession.hh.

G4bool G4VMPIsession::is_master_
protected

Definition at line 52 of file G4VMPIsession.hh.

G4bool G4VMPIsession::is_slave_
protected

Definition at line 53 of file G4VMPIsession.hh.

G4int G4VMPIsession::rank_
protected

Definition at line 54 of file G4VMPIsession.hh.


The documentation for this class was generated from the following files: