source: trunk/examples/extended/parallel/MPI/exMPI01/exMPI01.cc @ 1279

Last change on this file since 1279 was 1230, checked in by garnier, 14 years ago

update to geant4.9.3

File size: 4.2 KB
Line 
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// ********************************************************************
25//
26// $Id: exMPI01.cc,v 1.1 2007/11/16 14:16:46 kmura Exp $
27// $Name: geant4-09-03-cand-01 $
28//
29// ====================================================================
30//   exMPI01.cc
31//
32//                                         2007 Q
33// ====================================================================
34#include "G4RunManager.hh"
35#include "G4UImanager.hh"
36
37// my application
38#include "DetectorConstruction.hh"
39#include "PhysicsList.hh"
40#include "PrimaryGeneratorAction.hh"
41
42// MPI session
43#include "G4MPImanager.hh"
44#include "G4MPIsession.hh"
45#include "G4UItcsh.hh"
46
47#ifdef G4VIS_USE
48#include "G4VisExecutive.hh"
49#endif
50
51int main(int argc,char** argv)
52{
53  // random engine
54  //CLHEP::HepJamesRandom randomEngine;
55  CLHEP::Ranlux64Engine randomEngine;
56  CLHEP::HepRandom::setTheEngine(&randomEngine);
57
58  // --------------------------------------------------------------------
59  // MPI session
60  // --------------------------------------------------------------------
61  // At first, G4MPImanager/G4MPIsession should be created.
62  G4MPImanager* g4MPI= new G4MPImanager(argc,argv);
63
64  // MPI session (G4MPIsession) instead of G4UIterminal
65  // Terminal availability depends on your MPI implementation.
66  G4MPIsession* session= g4MPI-> GetMPIsession();
67
68  // LAM/MPI users can use G4tcsh.
69  G4String prompt= "[40;01;33m";
70  prompt+= "G4MPI";
71  prompt+= "[40;31m(%s)[40;36m[%/][00;30m:";
72
73  G4UItcsh* tcsh= new G4UItcsh(prompt);
74  tcsh-> SetLsColor(BLUE,RED);
75  session-> SetShell(tcsh);
76
77  // --------------------------------------------------------------------
78  // user application setting
79  // --------------------------------------------------------------------
80  G4RunManager* runManager= new G4RunManager();
81
82  // setup your application
83  runManager-> SetUserInitialization(new DetectorConstruction);
84  runManager-> SetUserInitialization(new PhysicsList);
85  runManager-> SetUserAction(new PrimaryGeneratorAction);
86
87  runManager-> Initialize();
88
89#ifdef G4VIS_USE
90  G4VisExecutive* visManager= new G4VisExecutive;
91  visManager-> Initialize();
92  G4cout << G4endl;
93#endif
94
95  // --------------------------------------------------------------------
96  // ready for go
97  // MPIsession treats both interactive and batch modes.
98  // Just start your session as below.
99  // --------------------------------------------------------------------
100  session-> SessionStart();
101
102  // --------------------------------------------------------------------
103  // termination
104  // --------------------------------------------------------------------
105#ifdef G4VIS_USE
106  delete visManager;
107#endif
108
109  delete g4MPI;
110
111  delete runManager;
112
113  return 0;
114}
Note: See TracBrowser for help on using the repository browser.