Import Geant4 9.6.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 17:01:34 +02:00
parent b1eb5424d2
commit e2d2f9810a
10384 changed files with 698580 additions and 628834 deletions
@@ -0,0 +1,50 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
/// @file G4MPIbatch.hh
/// @brief MPI batch session
#ifndef G4MPI_BATCH_H
#define G4MPI_BATCH_H
#include "G4VMPIsession.hh"
#include <fstream>
class G4MPIbatch : public G4VMPIsession {
public:
G4MPIbatch(const G4String& fname = "", G4bool qbatch = false);
~G4MPIbatch();
virtual G4UIsession* SessionStart();
protected:
std::ifstream batchStream;
G4bool isOpened;
G4bool isBatchMode;
// get a command from a batch script file
G4String ReadCommand();
};
#endif
@@ -0,0 +1,227 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
/// @file G4MPImanager.hh
/// @brief MPI manager class
#ifndef G4MPI_MANAGER_H
#define G4MPI_MANAGER_H
#include "mpi.h"
#include "globals.hh"
#include <pthread.h>
#include <fstream>
class G4MPImessenger;
class G4MPIsession;
class G4MPIstatus;
class G4VMPIseedGenerator;
class G4MPImanager {
public:
// MPI master rank
enum { RANK_MASTER = 0 };
enum { // MPI tag
TAG_G4COMMAND = 100,
TAG_G4STATUS = 200,
TAG_G4SEED = 300,
TAG_DATA = 1000
};
G4MPImanager();
G4MPImanager(int argc, char** argv);
~G4MPImanager();
static G4MPImanager* GetManager();
// set/get methods
G4MPIsession* GetMPIsession() const;
G4int GetVerbose() const;
void SetVerbose(G4int iverbose);
G4int GetSize() const;
G4int GetRank() const;
G4bool IsMaster() const;
G4bool IsSlave() const;
G4bool IsInitMacro() const;
const G4String& GetInitFileName() const;
G4bool IsBatchMode() const;
const G4String& GetMacroFileName() const;
void SetMasterWeight(G4double aweight);
G4double GetMasterWeight() const;
G4VMPIseedGenerator* GetSeedGenerator() const;
// MPI methods
G4String BcastCommand(const G4String& command);
void ShowStatus();
void ShowSeeds();
void SetSeed(G4int inode, G4long seed);
void WaitBeamOn();
// methods for MPI environment
void DistributeSeeds();
void ExecuteMacroFile(const G4String& fname, G4bool qbatch=false);
G4bool CheckThreadStatus();
void ExecuteThreadCommand(const G4String& command);
void ExecuteBeamOnThread(const G4String& command);
void JoinBeamOnThread();
void BeamOn(G4int nevent, G4bool qdivide=true);
void Print(const G4String& message);
// misc
void ShowHelp() const;
private:
static G4MPImanager* theManager;
G4MPImessenger* messenger;
G4MPIsession* session;
G4int verbose;
G4MPIstatus* status; // status for each node
// MPI rank
G4bool isMaster;
G4bool isSlave;
G4int rank;
G4int size;
// MPI communicator
MPI::Intracomm COMM_G4COMMAND;
// cout/cerr control
G4bool qfcout;
std::ofstream fscout;
// init/macro file
G4bool qinitmacro;
G4String initFileName;
G4bool qbatchmode;
G4String macroFileName;
// internal use
void Initialize();
void ParseArguments(G4int argc, char** argv);
void Wait(G4int ausec) const;
void UpdateStatus();
// for beamOn
pthread_t threadID;
// seed generator
G4VMPIseedGenerator* seedGenerator;
// parallel parameters
G4double masterWeight;
};
// ====================================================================
inline G4MPIsession* G4MPImanager::GetMPIsession() const
{
return session;
}
inline G4int G4MPImanager::GetVerbose() const
{
return verbose;
}
inline void G4MPImanager::SetVerbose(G4int iverbose)
{
G4int lv=iverbose;
if(iverbose>1) lv=1;
if(iverbose<0) lv=0;
verbose= lv;
return;
}
inline G4int G4MPImanager::GetRank() const
{
return rank;
}
inline G4int G4MPImanager::GetSize() const
{
return size;
}
inline G4bool G4MPImanager::IsMaster() const
{
return isMaster;
}
inline G4bool G4MPImanager::IsSlave() const
{
return isSlave;
}
inline G4bool G4MPImanager::IsInitMacro() const
{
return qinitmacro;
}
inline const G4String& G4MPImanager::GetInitFileName() const
{
return initFileName;
}
inline G4bool G4MPImanager::IsBatchMode() const
{
return qbatchmode;
}
inline const G4String& G4MPImanager::GetMacroFileName() const
{
return macroFileName;
}
inline void G4MPImanager::SetMasterWeight(G4double aweight)
{
masterWeight= aweight;
if(aweight<0.) masterWeight= 0.;
if(aweight>1.) masterWeight= 1.;
}
inline G4double G4MPImanager::GetMasterWeight() const
{
return masterWeight;
}
inline G4VMPIseedGenerator* G4MPImanager::GetSeedGenerator() const
{
return seedGenerator;
}
#endif
@@ -0,0 +1,69 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
/// @file G4MPImessenger.hh
/// @brief Define MPI commands
#ifndef G4MPI_MESSENGER_H
#define G4MPI_MESSENGER_H
#include "G4UImessenger.hh"
class G4MPImanager;
class G4UIdirectory;
class G4UIcmdWithoutParameter;
class G4UIcmdWithAnInteger;
class G4UIcmdWithAString;
class G4UIcmdWithADouble;
class G4UIcommand;
class G4MPImessenger : public G4UImessenger {
public:
G4MPImessenger(G4MPImanager* manager);
~G4MPImessenger();
virtual void SetNewValue(G4UIcommand* command, G4String newValue);
virtual G4String GetCurrentValue(G4UIcommand* command);
private:
G4MPImanager* g4MPI;
// /mpi
G4UIdirectory* dir;
G4UIcmdWithAnInteger* verbose;
G4UIcmdWithoutParameter* status;
G4UIcmdWithAString* execute;
G4UIcommand* beamOn;
G4UIcommand* dotbeamOn;
G4UIcmdWithADouble* masterWeight;
G4UIcmdWithoutParameter* showSeeds;
G4UIcmdWithAnInteger* setMasterSeed;
G4UIcommand* setSeed;
};
#endif
@@ -0,0 +1,43 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
/// @file G4MPIrandomSeedGenerator.hh
/// @brief An implementation of random number seed distribution
#ifndef G4MPI_RANDOM_SEED_GENERATOR_H
#define G4MPI_RANDOM_SEED_GENERATOR_H
#include "G4VMPIseedGenerator.hh"
class G4MPIrandomSeedGenerator : public G4VMPIseedGenerator {
public:
G4MPIrandomSeedGenerator();
~G4MPIrandomSeedGenerator();
protected:
G4bool CheckDoubleCount();
virtual void GenerateSeeds();
};
#endif
@@ -0,0 +1,52 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
/// @file G4MPIsession.hh
/// @brief A terminal session for MPI application
#ifndef G4MPI_SESSION_H
#define G4MPI_SESSION_H
#include "G4VMPIsession.hh"
class G4MPIsession : public G4VMPIsession {
public:
G4MPIsession(G4VUIshell* ashell = 0);
~G4MPIsession();
void SetPrompt(const G4String& prompt);
void SetShell(G4VUIshell* ashell);
virtual G4UIsession* SessionStart();
protected:
G4VUIshell* shell;
// get command from user prompt of the master node
G4String GetCommand(const char* msg = 0);
G4bool TryForcedTerminate();
};
#endif
@@ -0,0 +1,124 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
/// @file G4MPIstatus.hh
/// @brief status of MPI application
#ifndef G4MPI_STATUS_H
#define G4MPI_STATUS_H
#include "globals.hh"
#include "G4ApplicationState.hh"
#include "G4Timer.hh"
class G4Timer;
class G4MPIstatus {
public:
enum { NSIZE = 10 };
G4MPIstatus();
~G4MPIstatus();
// set/get functions
void SetStatus(G4int arank, G4int runid, G4int noe, G4int evtid,
G4ApplicationState state);
G4int GetRank() const;
G4int GetRunID() const;
G4int GetNEventToBeProcessed() const;
G4int GetEventID() const;
G4double GetCPUTime() const;
G4ApplicationState GetG4State() const;
// for pickling
G4int SizeOf() const;
void Pack(G4int* data) const;
void UnPack(G4int* data);
// for timer
void StartTimer();
void StopTimer();
void Print() const;
private:
G4int rank;
G4int runID;
G4int nEventToBeProcessed;
G4int eventID;
G4double cputime;
G4ApplicationState g4state;
G4Timer* timer;
G4String GetStateString(G4ApplicationState astate) const;
};
// ====================================================================
inline G4int G4MPIstatus::SizeOf() const
{
return NSIZE;
}
inline G4int G4MPIstatus::GetRank() const
{
return rank;
}
inline G4int G4MPIstatus::GetRunID() const
{
return runID;
}
inline G4int G4MPIstatus::GetNEventToBeProcessed() const
{
return nEventToBeProcessed;
}
inline G4int G4MPIstatus::GetEventID() const
{
return eventID;
}
inline G4double G4MPIstatus::GetCPUTime() const
{
return cputime;
}
inline G4ApplicationState G4MPIstatus::GetG4State() const
{
return g4state;
}
inline void G4MPIstatus::StartTimer()
{
timer-> Start();
}
inline void G4MPIstatus::StopTimer()
{
timer-> Stop();
}
#endif
@@ -0,0 +1,41 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
/// @file G4UImpish.hh
/// @brief A basic shell for MPI session
#ifndef G4UI_MPI_SH_H
#define G4UI_MPI_SH_H
#include "G4VUIshell.hh"
class G4UImpish : public G4VUIshell {
public:
G4UImpish();
~G4UImpish();
virtual G4String GetCommandLineString(const char* msg = 0);
};
#endif
@@ -0,0 +1,64 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
/// @file G4VMPIseedGenerator.hh
/// @brief A base class for random number seed distribution
#ifndef G4VMPI_SEED_GENERATOR_H
#define G4VMPI_SEED_GENERATOR_H
#include "globals.hh"
#include <vector>
class G4VMPIseedGenerator {
public:
G4VMPIseedGenerator();
virtual ~G4VMPIseedGenerator();
// set/get methods
void SetMasterSeed(G4long aseed); // trigger GenerateSeeds()
G4long GetMasterSeed() const;
const std::vector<G4long>& GetSeedList() const;
protected:
G4long masterSeed;
std::vector<G4long> seedList;
// generate seeds for MPI nodes
virtual void GenerateSeeds()=0;
};
// ====================================================================
inline G4long G4VMPIseedGenerator::GetMasterSeed() const
{
return masterSeed;
}
inline const std::vector<G4long>& G4VMPIseedGenerator::GetSeedList() const
{
return seedList;
}
#endif
@@ -0,0 +1,65 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
/// @file G4VMPIsession.hh
/// @brief A base class for MPI sessions
#ifndef G4VMPI_SESSION_H
#define G4VMPI_SESSION_H
#include "G4VBasicShell.hh"
typedef void* (*Func_t)(void *); // for thead function
class G4MPImanager;
class G4VUIshell;
class G4VMPIsession : public G4VBasicShell {
public:
G4VMPIsession();
~G4VMPIsession();
virtual void PauseSessionStart(const G4String& msg);
virtual G4int ReceiveG4cout(const G4String& coutString);
virtual G4int ReceiveG4cerr(const G4String& cerrString);
protected:
G4MPImanager* g4MPI;
// MPI node info (cache)
G4bool isMaster;
G4bool isSlave;
G4int rank;
G4int ExecCommand(G4String acommand);
G4String TruncateCommand(const G4String& command) const;
G4String BypassCommand(const G4String& command) const;
// for help operation
virtual G4bool GetHelpChoice(G4int& aval);
virtual void ExitHelp() const;
};
#endif