source: trunk/examples/extended/parallel/MPI/mpi_interface/src/G4MPImessenger.cc @ 1337

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

tag geant4.9.4 beta 1 + modifs locales

File size: 7.5 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: G4MPImessenger.cc,v 1.2 2010/05/18 06:06:21 kmura Exp $
27// $Name: geant4-09-04-beta-01 $
28//
29// ====================================================================
30//   G4MPImessenger.cc
31//
32//                                         2007 Q
33// ====================================================================
34#include "G4MPImessenger.hh"
35#include "G4MPImanager.hh"
36#include "G4VMPIseedGenerator.hh"
37#include "G4UIdirectory.hh"
38#include "G4UIcmdWithoutParameter.hh"
39#include "G4UIcmdWithAnInteger.hh"
40#include "G4UIcmdWithAString.hh"
41#include "G4UIcmdWithADouble.hh"
42#include "G4UIcommand.hh"
43#include "G4UIparameter.hh"
44#include <sstream>
45
46// ====================================================================
47//
48// class description
49//
50// ====================================================================
51
52//////////////////////////////////////////////////////
53G4MPImessenger::G4MPImessenger( G4MPImanager* manager)
54  : G4UImessenger(), g4MPI(manager)
55//////////////////////////////////////////////////////
56{
57  // /mpi
58  dir= new G4UIdirectory("/mpi/");
59  dir-> SetGuidance("MPI control commands");
60
61  // /mpi/verbose
62  verbose= new G4UIcmdWithAnInteger("/mpi/verbose", this);
63  verbose-> SetGuidance("Set verbose level.");
64  verbose-> SetParameterName("verbose", false, false);
65  verbose->SetRange("verbose>=0 && verbose<=1");
66
67  // /mpi/status
68  status= new G4UIcmdWithoutParameter("/mpi/status", this);
69  status-> SetGuidance( "Show mpi status.");
70
71  // /mpi/execute
72  execute= new G4UIcmdWithAString("/mpi/execute", this);
73  execute-> SetGuidance("Execute a macro file. (=/control/execute)");
74  execute-> SetParameterName("fileName", false, false);
75
76  // /mpi/beamOn
77  beamOn= new G4UIcommand("/mpi/beamOn", this);
78  beamOn-> SetGuidance("Start a parallel run w/ thread.");
79
80  G4UIparameter* p1= new G4UIparameter("numberOfEvent", 'i', true);
81  p1-> SetDefaultValue(1);
82  p1-> SetParameterRange("numberOfEvent>=0");
83  beamOn-> SetParameter(p1);
84
85  G4UIparameter* p2= new G4UIparameter("divide", 'b', true);
86  p2-> SetDefaultValue(true);
87  beamOn-> SetParameter(p2);
88
89  // /mpi/.beamOn
90  dotbeamOn= new G4UIcommand("/mpi/.beamOn", this);
91  dotbeamOn-> SetGuidance("Start a parallel run w/o thread.");
92
93  p1= new G4UIparameter("numberOfEvent", 'i', true);
94  p1-> SetDefaultValue(1);
95  p1-> SetParameterRange("numberOfEvent>=0");
96  dotbeamOn-> SetParameter(p1);
97
98  p2= new G4UIparameter("divide", 'b', true);
99  p2-> SetDefaultValue(true);
100  dotbeamOn-> SetParameter(p2);
101
102  // /mpi/weightForMaster
103  masterWeight= new G4UIcmdWithADouble("/mpi/masterWeight", this);
104  masterWeight-> SetGuidance("Set weight for master node.");
105  masterWeight-> SetParameterName("weight", false, false);
106  masterWeight-> SetRange("weight>=0. && weight<=1.");
107
108  // /mpi/wait
109  waitall= new G4UIcmdWithoutParameter("/mpi/wait", this);
110  waitall-> SetGuidance( "Wait until beamOn-s on all nodes are done. "
111                         "(batch mode only)");
112
113  // /mpi/showSeeds
114  showSeeds= new G4UIcmdWithoutParameter("/mpi/showSeeds", this);
115  showSeeds-> SetGuidance("Show seeds of MPI nodes.");
116
117  // /mpi/setMasterSeed
118  setMasterSeed= new G4UIcmdWithAnInteger("/mpi/setMasterSeed", this);
119  setMasterSeed-> SetGuidance("Set a master seed for the seed generator.");
120  setMasterSeed-> SetParameterName("seed", false, false);
121
122  // /mpi/setSeed
123  setSeed= new G4UIcommand("/mpi/setSeed", this);
124  setSeed-> SetGuidance("Set a seed for a specified node.");
125
126  p1= new G4UIparameter("node", 'i', false);
127  p1-> SetParameterRange("node>=0");
128  setSeed-> SetParameter(p1);
129
130  p2= new G4UIparameter("seed", 'i', false);
131  setSeed-> SetParameter(p2);
132}
133
134
135/////////////////////////////////
136G4MPImessenger::~G4MPImessenger()
137/////////////////////////////////
138{
139  delete verbose;
140  delete status;
141  delete execute;
142  delete beamOn;
143  delete dotbeamOn;
144  delete masterWeight;
145  delete waitall;
146  delete showSeeds;
147  delete setMasterSeed;
148  delete setSeed;
149
150  delete dir;
151}
152
153
154//////////////////////////////////////////////////////////////////////////
155void G4MPImessenger::SetNewValue( G4UIcommand* command, G4String newValue)
156//////////////////////////////////////////////////////////////////////////
157{
158  if (command == verbose) { // /mpi/verbose
159    G4int lv= verbose-> GetNewIntValue(newValue);
160    g4MPI-> SetVerbose(lv);
161
162  } else if (command == status){ // /mpi/status
163    g4MPI-> ShowStatus();
164
165  } else if (command == execute){ // /mpi/execute
166    g4MPI-> ExecuteMacroFile(newValue);
167
168  } else if (command == beamOn){ // /mpi/beamOn
169    std::istringstream is(newValue);
170    G4int nevent;
171    G4bool qdivide;
172    is >> nevent >> qdivide;
173    g4MPI-> BeamOn(nevent, qdivide);
174
175  } else if (command == dotbeamOn){ // /mpi/.beamOn
176    std::istringstream is(newValue);
177    G4int nevent;
178    G4bool qdivide;
179    is >> nevent >> qdivide;
180    g4MPI-> BeamOn(nevent, qdivide);
181
182  } else if (command == masterWeight){ // /mpi/masterWeight
183    G4double weight= masterWeight-> GetNewDoubleValue(newValue);
184    g4MPI-> SetMasterWeight(weight);
185
186  } else if (command == waitall) {
187    g4MPI-> WaitBeamOn();
188
189  } else if (command == showSeeds){ // /mpi/showSeeds
190    g4MPI-> ShowSeeds();
191
192  } else if (command == setMasterSeed){ // /mpi/setMasterSeed
193    std::istringstream is(newValue);
194    G4long seed;
195    is >> seed;
196    g4MPI-> GetSeedGenerator()-> SetMasterSeed(seed);
197    g4MPI-> DistributeSeeds();
198
199  } else if (command == setSeed){ // /mpi/setSeed
200    std::istringstream is(newValue);
201    G4int inode;
202    G4long seed;
203    is >> inode >> seed;
204    g4MPI-> SetSeed(inode, seed);
205  }
206
207  return;
208}
209
210
211/////////////////////////////////////////////////////////////
212G4String G4MPImessenger::GetCurrentValue(G4UIcommand* command)
213/////////////////////////////////////////////////////////////
214{
215 G4String cv;
216
217 if (command == verbose) {
218   cv= verbose-> ConvertToString(g4MPI->GetVerbose());
219 } else if (command == masterWeight) {
220   cv= masterWeight-> ConvertToString(g4MPI->GetMasterWeight());
221 }
222
223 return cv;
224}
225
Note: See TracBrowser for help on using the repository browser.