MCPcopy Create free account
hub / github.com/Geant4/geant4 / ExecCommand

Method ExecCommand

examples/extended/parallel/MPI/source/src/G4VMPIsession.cc:72–141  ·  view source on GitHub ↗

--------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

70
71// --------------------------------------------------------------------------
72G4int G4VMPIsession::ExecCommand(const G4String& acommand)
73{
74 if (acommand.length() < 2) return fCommandSucceeded;
75
76 G4UImanager* UI = G4UImanager::GetUIpointer();
77 G4int returnVal = 0;
78
79 G4String command = BypassCommand(acommand);
80
81 // "/mpi/beamOn is threaded out.
82 if (command.substr(0, 11) == "/mpi/beamOn") {
83 g4mpi_->ExecuteBeamOnThread(command);
84 returnVal = fCommandSucceeded;
85 }
86 else if (command.substr(0, 12) == "/mpi/.beamOn") { // care for beamOn
87 G4bool threadStatus = g4mpi_->CheckThreadStatus();
88 if (threadStatus) { // still /run/beamOn is active
89 if (is_master_) {
90 G4cout << "G4MPIsession:: beamOn is still running." << G4endl;
91 }
92 returnVal = fCommandSucceeded;
93 }
94 else {
95 returnVal = UI->ApplyCommand(command);
96 }
97 }
98 else { // normal command
99 returnVal = UI->ApplyCommand(command);
100 }
101
102 G4int paramIndex = returnVal % 100;
103 // 0 - 98 : paramIndex-th parameter is invalid
104 // 99 : convination of parameters is invalid
105 G4int commandStatus = returnVal - paramIndex;
106
107 G4UIcommand* cmd = 0;
108 if (commandStatus != fCommandSucceeded) {
109 cmd = FindCommand(command);
110 }
111
112 switch (commandStatus) {
113 case fCommandSucceeded:
114 break;
115 case fCommandNotFound:
116 G4cerr << "command <" << UI->SolveAlias(command) << "> not found" << G4endl;
117 break;
118 case fIllegalApplicationState:
119 G4cerr << "illegal application state -- command refused" << G4endl;
120 break;
121 case fParameterOutOfRange:
122 // ...
123 break;
124 case fParameterOutOfCandidates:
125 G4cerr << "Parameter is out of candidate list (index " << paramIndex << ")" << G4endl;
126 G4cerr << "Candidates : " << cmd->GetParameter(paramIndex)->GetParameterCandidates()
127 << G4endl;
128 break;
129 case fParameterUnreadable:

Callers

nothing calls this directly

Calls 7

substrMethod · 0.80
ExecuteBeamOnThreadMethod · 0.80
CheckThreadStatusMethod · 0.80
SolveAliasMethod · 0.80
GetParameterMethod · 0.80
lengthMethod · 0.45
ApplyCommandMethod · 0.45

Tested by

no test coverage detected