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

Method TryForcedTerminate

examples/extended/parallel/MPI/source/src/G4MPIsession.cc:217–254  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

215
216// --------------------------------------------------------------------------
217G4bool G4MPIsession::TryForcedTerminate()
218{
219 if (!g4mpi_->CheckThreadStatus()) {
220 return true;
221 }
222
223 G4String xmessage;
224
225 // beamOn is still running
226 if (is_master_) {
227 char c[1024];
228 while (1) {
229 G4cout << "Run is still running. Do you abort a run? [y/N]:" << std::flush;
230 G4cin.getline(c, 1024);
231 G4String yesno = c;
232 if (yesno == "y" || yesno == "Y" || yesno == "n" || yesno == "N" || yesno == "") {
233 break;
234 }
235 }
236 if (c[0] == 'y' || c[0] == 'Y') {
237 G4cout << "Aborting a run..." << G4endl;
238 xmessage = g4mpi_->BcastCommand("kill me");
239 }
240 else {
241 xmessage = g4mpi_->BcastCommand("alive");
242 }
243 }
244 else {
245 xmessage = g4mpi_->BcastCommand("");
246 }
247
248 if (xmessage == "kill me") {
249 G4RunManager* runManager = G4RunManager::GetRunManager();
250 runManager->AbortRun(true); // soft abort
251 }
252
253 return false;
254}

Callers

nothing calls this directly

Calls 3

CheckThreadStatusMethod · 0.80
BcastCommandMethod · 0.80
AbortRunMethod · 0.45

Tested by

no test coverage detected