| 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.2 2010/05/18 06:07:43 kmura Exp $
|
|---|
| 27 | // $Name: geant4-09-04-beta-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 |
|
|---|
| 46 | #ifdef G4VIS_USE
|
|---|
| 47 | #include "G4VisExecutive.hh"
|
|---|
| 48 | #endif
|
|---|
| 49 |
|
|---|
| 50 | int main(int argc,char** argv)
|
|---|
| 51 | {
|
|---|
| 52 | // random engine
|
|---|
| 53 | //CLHEP::HepJamesRandom randomEngine;
|
|---|
| 54 | CLHEP::Ranlux64Engine randomEngine;
|
|---|
| 55 | CLHEP::HepRandom::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= "[40;01;33m";
|
|---|
| 69 | prompt+= "G4MPI";
|
|---|
| 70 | prompt+= "[40;31m(%s)[40;36m[%/][00;30m:";
|
|---|
| 71 | session-> SetPrompt(prompt);
|
|---|
| 72 |
|
|---|
| 73 | // --------------------------------------------------------------------
|
|---|
| 74 | // user application setting
|
|---|
| 75 | // --------------------------------------------------------------------
|
|---|
| 76 | G4RunManager* runManager= new G4RunManager();
|
|---|
| 77 |
|
|---|
| 78 | // setup your application
|
|---|
| 79 | runManager-> SetUserInitialization(new DetectorConstruction);
|
|---|
| 80 | runManager-> SetUserInitialization(new PhysicsList);
|
|---|
| 81 | runManager-> SetUserAction(new PrimaryGeneratorAction);
|
|---|
| 82 |
|
|---|
| 83 | runManager-> Initialize();
|
|---|
| 84 |
|
|---|
| 85 | #ifdef G4VIS_USE
|
|---|
| 86 | G4VisExecutive* visManager= new G4VisExecutive;
|
|---|
| 87 | visManager-> Initialize();
|
|---|
| 88 | G4cout << G4endl;
|
|---|
| 89 | #endif
|
|---|
| 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 | #ifdef G4VIS_USE
|
|---|
| 102 | delete visManager;
|
|---|
| 103 | #endif
|
|---|
| 104 |
|
|---|
| 105 | delete g4MPI;
|
|---|
| 106 |
|
|---|
| 107 | delete runManager;
|
|---|
| 108 |
|
|---|
| 109 | return 0;
|
|---|
| 110 | }
|
|---|