LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
exMPI01.cc File Reference
#include "G4MPImanager.hh"
#include "G4MPIsession.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4VisExecutive.hh"
#include "ActionInitialization.hh"
#include "DetectorConstruction.hh"
#include "FTFP_BERT.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 A MPI example code. More...
 

Function Documentation

int main ( int  argc,
char **  argv 
)

A MPI example code.

Definition at line 48 of file exMPI01.cc.

References Initialize(), and session.

49 {
50  // random engine
51  CLHEP::MTwistEngine randomEngine;
52  G4Random::setTheEngine(&randomEngine);
53 
54  // --------------------------------------------------------------------
55  // MPI session
56  // --------------------------------------------------------------------
57  // At first, G4MPImanager/G4MPIsession should be created.
58  G4MPImanager* g4MPI = new G4MPImanager(argc, argv);
59 
60  // MPI session (G4MPIsession) instead of G4UIterminal
61  // Terminal availability depends on your MPI implementation.
62  G4MPIsession* session = g4MPI-> GetMPIsession();
63 
64  // LAM/MPI users can use G4tcsh.
65  G4String prompt = "";
66  prompt += "G4MPI";
67  prompt += "(%s)[%/]:";
68  session-> SetPrompt(prompt);
69 
70  // --------------------------------------------------------------------
71  // user application setting
72  // --------------------------------------------------------------------
73 #ifdef G4MULTITHREADED
74  G4MTRunManager* runManager = new G4MTRunManager();
75  runManager-> SetNumberOfThreads(4);
76 #else
77  G4RunManager* runManager = new G4RunManager();
78 #endif
79 
80  // setup your application
81  runManager-> SetUserInitialization(new DetectorConstruction);
82  runManager-> SetUserInitialization(new FTFP_BERT);
83  runManager-> SetUserInitialization(new ActionInitialization);
84 
85  runManager-> Initialize();
86 
87  G4VisExecutive* visManager = new G4VisExecutive;
88  visManager-> Initialize();
89  G4cout << G4endl;
90 
91  // --------------------------------------------------------------------
92  // ready for go
93  // MPIsession treats both interactive and batch modes.
94  // Just start your session as below.
95  // --------------------------------------------------------------------
96  session-> SessionStart();
97 
98  // --------------------------------------------------------------------
99  // termination
100  // --------------------------------------------------------------------
101  delete visManager;
102 
103  delete g4MPI;
104 
105  delete runManager;
106 
107  return EXIT_SUCCESS;
108 }
static G4UIterminal * session
void Initialize()
Definition: errprop.cc:100