Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4MPIstatus.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 // ********************************************************************
27 
28 #include "G4MPIstatus.hh"
29 #include "G4ApplicationState.hh"
30 
31 // --------------------------------------------------------------------------
33  : rank(0), runID(0), nEventToBeProcessed(0), eventID(0),
34  cputime(0.), g4state(G4State_Quit)
35 {
36  timer = new G4Timer;
37 }
38 
39 // --------------------------------------------------------------------------
41 {
42  delete timer;
43 }
44 
45 // --------------------------------------------------------------------------
46 void G4MPIstatus::SetStatus(G4int arank, G4int runid, G4int noe, G4int evtid,
47  G4ApplicationState state)
48 {
49  rank = arank;
50  runID = runid;
51  nEventToBeProcessed = noe;
52  eventID = evtid;
53  g4state = state;
54  if (timer-> IsValid()) cputime = timer-> GetUserElapsed();
55  else cputime = 0.;
56 }
57 
58 // --------------------------------------------------------------------------
60 {
61  data[0] = rank;
62  data[1] = runID;
63  data[2] = nEventToBeProcessed;
64  data[3] = eventID;
65  data[4] = g4state;
66 
67  G4double* ddata = (G4double*)(data+5);
68  ddata[0] = cputime;
69 }
70 
71 // --------------------------------------------------------------------------
73 {
74  rank = data[0];
75  runID = data[1];
76  nEventToBeProcessed = data[2];
77  eventID = data[3];
78  g4state = (G4ApplicationState)data[4];
79 
80  G4double* ddata = (G4double*)(data+5);
81  cputime = ddata[0];
82 }
83 
84 // --------------------------------------------------------------------------
85 void G4MPIstatus::Print() const
86 {
87  // * rank= 001 run= 10002 event= 00001 / 100000 state= Idle"
88  G4cout << "* rank= " << rank
89  << " run= " << runID
90  << " event= " << eventID << " / " << nEventToBeProcessed
91  << " state= " << GetStateString(g4state)
92  << " time= " << cputime << "s"
93  << G4endl;
94 }
95 
96 // --------------------------------------------------------------------------
97 G4String G4MPIstatus::GetStateString(G4ApplicationState astate) const
98 {
99  G4String sname;
100 
101  switch(astate) {
102  case G4State_PreInit:
103  sname = "PreInit";
104  break;
105  case G4State_Init:
106  sname = "Init";
107  break;
108  case G4State_Idle:
109  sname = "Idle";
110  break;
111  case G4State_GeomClosed:
112  sname = "GeomClosed";
113  break;
114  case G4State_EventProc:
115  sname = "EventProc";
116  break;
117  case G4State_Quit:
118  sname = "Quit";
119  break;
120  case G4State_Abort:
121  sname = "Abort";
122  break;
123  default:
124  sname = "Unknown";
125  break;
126  }
127 
128  return sname;
129 }