Geant4  10.00.p03
exMPI01.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
26 // $Id: exMPI01.cc 78126 2013-12-03 17:43:56Z gcosmo $
27 //
29 
30 #include "G4MPImanager.hh"
31 #include "G4MPIsession.hh"
32 
33 #ifdef G4MULTITHREADED
34 #include "G4MTRunManager.hh"
35 #else
36 #include "G4RunManager.hh"
37 #endif
38 
39 #include "G4UImanager.hh"
40 
41 #ifdef G4VIS_USE
42 #include "G4VisExecutive.hh"
43 #endif
44 
45 #include "ActionInitialization.hh"
46 #include "DetectorConstruction.hh"
47 #include "FTFP_BERT.hh"
48 
49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
50 
51 int main(int argc, char** argv)
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 }
A terminal session for MPI application.
void Initialize()
Definition: errprop.cc:96
int main(int argc, char **argv)
A MPI example code.
Definition: exMPI01.cc:51
G4GLOB_DLL std::ostream G4cout
MPI manager class.
static G4UIterminal * session
Action initialization class.
Detector construction class to demonstrate various ways of placement.
#define G4endl
Definition: G4ios.hh:61