source: trunk/examples/extended/parallel/MPI/mpi_interface/src/G4MPIstatus.cc @ 1279

Last change on this file since 1279 was 807, checked in by garnier, 16 years ago

update

File size: 4.6 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: G4MPIstatus.cc,v 1.1 2007/11/16 14:05:41 kmura Exp $
27// $Name:  $
28//
29// ====================================================================
30//   G4MPIstatus.cc
31//
32//                                         2007 Q
33// ====================================================================
34#include "G4MPIstatus.hh"
35#include "G4ApplicationState.hh"
36
37// ====================================================================
38//
39// class description
40//
41// ====================================================================
42
43//////////////////////////
44G4MPIstatus::G4MPIstatus()
45  : rank(0), runID(0), 
46    nEventToBeProcessed(0),
47    eventID(0),
48    cputime(0.),
49    g4state(G4State_Quit)
50//////////////////////////
51{
52  timer= new G4Timer;
53  timer-> Start();
54}
55
56
57//////////////////////////
58G4MPIstatus::~G4MPIstatus()
59//////////////////////////
60{
61  delete timer;
62}
63
64
65/////////////////////////////////////////////////////
66void G4MPIstatus::SetStatus(G4int arank, G4int runid, 
67                            G4int noe, G4int evtid,
68                            G4ApplicationState state)
69/////////////////////////////////////////////////////
70{
71  rank= arank;
72  runID= runid;
73  nEventToBeProcessed= noe;
74  eventID= evtid;
75  g4state= state;
76
77  timer-> Stop();
78  cputime= timer-> GetUserElapsed();
79}
80
81
82/////////////////////////////////////////
83void G4MPIstatus::Pack(G4int* data) const
84/////////////////////////////////////////
85{ 
86  data[0]= rank;
87  data[1]= runID;
88  data[2]= nEventToBeProcessed;
89  data[3]= eventID;
90  data[4]= g4state;
91
92  G4double* ddata= (G4double*)(data+5);
93  ddata[0]= cputime;
94}
95
96
97/////////////////////////////////////
98void G4MPIstatus::UnPack(G4int* data)
99/////////////////////////////////////
100{
101  rank= data[0];
102  runID= data[1];
103  nEventToBeProcessed= data[2];
104  eventID= data[3];
105  g4state= (G4ApplicationState)data[4];
106
107  G4double* ddata= (G4double*)(data+5);
108  cputime= ddata[0];
109}
110
111
112///////////////////////////////
113void G4MPIstatus::Print() const
114///////////////////////////////
115{
116  // * rank= 001 run= 10002 event= 00001 / 100000 state= Idle"
117  G4cout << "* rank= " << rank
118         << " run= " << runID
119         << " event= " << eventID << " / " << nEventToBeProcessed
120         << " state= " << GetStateString(g4state)
121         << " time= " << cputime << "s"
122         << G4endl;
123}
124
125
126/////////////////////////////////////////////////////////////////////
127G4String G4MPIstatus::GetStateString(G4ApplicationState astate) const
128/////////////////////////////////////////////////////////////////////
129{
130  G4String sname;
131
132  switch(astate) {
133  case G4State_PreInit:
134    sname = "PreInit";
135    break;
136  case G4State_Init:
137    sname = "Init";
138    break;
139  case G4State_Idle:
140    sname = "Idle";
141    break;
142  case G4State_GeomClosed:
143    sname = "GeomClosed";
144    break;
145  case G4State_EventProc:
146    sname = "EventProc";
147    break;
148  case G4State_Quit:
149    sname = "Quit";
150    break;
151  case G4State_Abort:
152    sname = "Abort";
153    break;
154  default:
155    sname = "Unknown";
156    break;
157  }
158
159  return sname;
160}
161
Note: See TracBrowser for help on using the repository browser.