[807] | 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 | // |
---|
[1337] | 26 | // $Id: G4MPIstatus.cc,v 1.2 2010/05/18 06:06:21 kmura Exp $ |
---|
| 27 | // $Name: geant4-09-04-beta-01 $ |
---|
[807] | 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 | ////////////////////////// |
---|
| 44 | G4MPIstatus::G4MPIstatus() |
---|
[1337] | 45 | : rank(0), runID(0), |
---|
[807] | 46 | nEventToBeProcessed(0), |
---|
| 47 | eventID(0), |
---|
| 48 | cputime(0.), |
---|
| 49 | g4state(G4State_Quit) |
---|
| 50 | ////////////////////////// |
---|
| 51 | { |
---|
| 52 | timer= new G4Timer; |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | |
---|
| 56 | ////////////////////////// |
---|
| 57 | G4MPIstatus::~G4MPIstatus() |
---|
| 58 | ////////////////////////// |
---|
| 59 | { |
---|
| 60 | delete timer; |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | |
---|
| 64 | ///////////////////////////////////////////////////// |
---|
[1337] | 65 | void G4MPIstatus::SetStatus(G4int arank, G4int runid, |
---|
[807] | 66 | G4int noe, G4int evtid, |
---|
| 67 | G4ApplicationState state) |
---|
| 68 | ///////////////////////////////////////////////////// |
---|
| 69 | { |
---|
| 70 | rank= arank; |
---|
| 71 | runID= runid; |
---|
| 72 | nEventToBeProcessed= noe; |
---|
| 73 | eventID= evtid; |
---|
| 74 | g4state= state; |
---|
[1337] | 75 | if (timer-> IsValid()) cputime= timer-> GetUserElapsed(); |
---|
| 76 | else cputime = 0.; |
---|
[807] | 77 | } |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | ///////////////////////////////////////// |
---|
| 81 | void G4MPIstatus::Pack(G4int* data) const |
---|
| 82 | ///////////////////////////////////////// |
---|
[1337] | 83 | { |
---|
[807] | 84 | data[0]= rank; |
---|
| 85 | data[1]= runID; |
---|
| 86 | data[2]= nEventToBeProcessed; |
---|
| 87 | data[3]= eventID; |
---|
| 88 | data[4]= g4state; |
---|
| 89 | |
---|
| 90 | G4double* ddata= (G4double*)(data+5); |
---|
| 91 | ddata[0]= cputime; |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | |
---|
| 95 | ///////////////////////////////////// |
---|
| 96 | void G4MPIstatus::UnPack(G4int* data) |
---|
| 97 | ///////////////////////////////////// |
---|
| 98 | { |
---|
| 99 | rank= data[0]; |
---|
| 100 | runID= data[1]; |
---|
| 101 | nEventToBeProcessed= data[2]; |
---|
| 102 | eventID= data[3]; |
---|
| 103 | g4state= (G4ApplicationState)data[4]; |
---|
| 104 | |
---|
| 105 | G4double* ddata= (G4double*)(data+5); |
---|
| 106 | cputime= ddata[0]; |
---|
| 107 | } |
---|
| 108 | |
---|
| 109 | |
---|
| 110 | /////////////////////////////// |
---|
| 111 | void G4MPIstatus::Print() const |
---|
| 112 | /////////////////////////////// |
---|
| 113 | { |
---|
| 114 | // * rank= 001 run= 10002 event= 00001 / 100000 state= Idle" |
---|
[1337] | 115 | G4cout << "* rank= " << rank |
---|
| 116 | << " run= " << runID |
---|
[807] | 117 | << " event= " << eventID << " / " << nEventToBeProcessed |
---|
| 118 | << " state= " << GetStateString(g4state) |
---|
| 119 | << " time= " << cputime << "s" |
---|
| 120 | << G4endl; |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | |
---|
| 124 | ///////////////////////////////////////////////////////////////////// |
---|
| 125 | G4String G4MPIstatus::GetStateString(G4ApplicationState astate) const |
---|
| 126 | ///////////////////////////////////////////////////////////////////// |
---|
| 127 | { |
---|
| 128 | G4String sname; |
---|
| 129 | |
---|
| 130 | switch(astate) { |
---|
| 131 | case G4State_PreInit: |
---|
| 132 | sname = "PreInit"; |
---|
| 133 | break; |
---|
| 134 | case G4State_Init: |
---|
| 135 | sname = "Init"; |
---|
| 136 | break; |
---|
| 137 | case G4State_Idle: |
---|
| 138 | sname = "Idle"; |
---|
| 139 | break; |
---|
| 140 | case G4State_GeomClosed: |
---|
| 141 | sname = "GeomClosed"; |
---|
| 142 | break; |
---|
| 143 | case G4State_EventProc: |
---|
| 144 | sname = "EventProc"; |
---|
| 145 | break; |
---|
| 146 | case G4State_Quit: |
---|
| 147 | sname = "Quit"; |
---|
| 148 | break; |
---|
| 149 | case G4State_Abort: |
---|
| 150 | sname = "Abort"; |
---|
| 151 | break; |
---|
| 152 | default: |
---|
| 153 | sname = "Unknown"; |
---|
| 154 | break; |
---|
| 155 | } |
---|
| 156 | |
---|
| 157 | return sname; |
---|
| 158 | } |
---|
| 159 | |
---|