Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
exMPI01.cc File Reference
#include "G4MPImanager.hh"
#include "G4MPIsession.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "ActionInitialization.hh"
#include "DetectorConstruction.hh"
#include "FTFP_BERT.hh"
Include dependency graph for exMPI01.cc:

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 51 of file exMPI01.cc.

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

Here is the call graph for this function: