Import Geant4 11.0.0 source tree
This commit is contained in:
committed by
Ben Morgan
parent
6399a014b6
commit
80e2389dd8
@@ -8,7 +8,7 @@ project(${_projname})
|
||||
#------------------------------------------------------------------------------
|
||||
#Manadatory dependencies
|
||||
|
||||
cmake_minimum_required(VERSION 3.12...3.20)
|
||||
cmake_minimum_required(VERSION 3.16...3.21)
|
||||
find_package(MPI REQUIRED)
|
||||
find_package(Geant4 10.2.0 REQUIRED)
|
||||
include(${Geant4_USE_FILE})
|
||||
|
||||
@@ -47,6 +47,9 @@ class G4RootMpiAnalysisManager : public G4RootAnalysisManager
|
||||
explicit G4RootMpiAnalysisManager(G4bool isMaster = true);
|
||||
virtual ~G4RootMpiAnalysisManager();
|
||||
|
||||
// Static methods
|
||||
static G4RootMpiAnalysisManager* Instance();
|
||||
|
||||
// MPI
|
||||
void SetMpiNtupleMerging(tools::impi* impi,
|
||||
G4int mpiRank, G4int mpiSize,
|
||||
@@ -57,6 +60,10 @@ class G4RootMpiAnalysisManager : public G4RootAnalysisManager
|
||||
virtual G4bool OpenFileImpl(const G4String& fileName) final;
|
||||
virtual G4bool WriteImpl() final;
|
||||
virtual G4bool CloseFileImpl(G4bool reset) final;
|
||||
|
||||
private:
|
||||
// Static data members
|
||||
inline static G4RootMpiAnalysisManager* fgInstance { nullptr };
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -45,6 +45,8 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
using std::to_string;
|
||||
|
||||
class G4RootFileManager;
|
||||
|
||||
namespace tools {
|
||||
@@ -93,6 +95,9 @@ class G4RootMpiPNtupleManager : public G4BaseNtupleManager
|
||||
virtual G4bool AddNtupleRow(G4int ntupleId) final;
|
||||
virtual G4bool Merge() final;
|
||||
|
||||
// Clear all data
|
||||
virtual void Clear() final;
|
||||
|
||||
// Reset
|
||||
virtual G4bool Reset(G4bool deleteNtuple) final;
|
||||
|
||||
@@ -140,14 +145,11 @@ inline G4bool G4RootMpiPNtupleManager::FillNtupleTColumn(
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId
|
||||
<< " columnId " << columnId << " value " << value;
|
||||
fState.GetVerboseL4()->Message("fill", "pntuple T column", description);
|
||||
}
|
||||
#endif
|
||||
if ( IsVerbose(G4Analysis::kVL4) ) {
|
||||
Message(G4Analysis::kVL4, "fill", "pntuple T column",
|
||||
" ntupleId " + to_string(ntupleId) + " columnId " + to_string(columnId) +
|
||||
" value " + G4Analysis::ToString(value));
|
||||
}
|
||||
|
||||
auto ntuple = GetNtupleInFunction(ntupleId, "FillNtupleTColumn");
|
||||
if ( ! ntuple ) return false;
|
||||
@@ -176,14 +178,13 @@ inline G4bool G4RootMpiPNtupleManager::FillNtupleTColumn(
|
||||
|
||||
column->fill(value);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId
|
||||
<< " columnId " << columnId << " value " << value;
|
||||
fState.GetVerboseL4()->Message("done fill", "pntuple T column", description);
|
||||
}
|
||||
#endif
|
||||
if ( IsVerbose(G4Analysis::kVL4) ) {
|
||||
Message(G4Analysis::kVL4, "done fill", "pntuple T column",
|
||||
" ntupleId " + to_string(ntupleId) +
|
||||
" columnId " + to_string(columnId) +
|
||||
" value " + value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -197,14 +198,12 @@ G4bool G4RootMpiPNtupleManager::FillNtupleTColumn(
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId
|
||||
<< " columnId " << columnId << " value " << value;
|
||||
fState.GetVerboseL4()->Message("fill", "pntuple T column", description);
|
||||
}
|
||||
#endif
|
||||
if ( IsVerbose(G4Analysis::kVL4) ) {
|
||||
Message(G4Analysis::kVL4, "fill", "pntuple T column",
|
||||
" ntupleId " + to_string(ntupleId) +
|
||||
" columnId " + to_string(columnId) +
|
||||
" value " + G4Analysis::ToString(value));
|
||||
}
|
||||
|
||||
// get ntuple
|
||||
auto ntuple = GetNtupleInFunction(ntupleId, "FillNtupleTColumn");
|
||||
@@ -236,14 +235,13 @@ G4bool G4RootMpiPNtupleManager::FillNtupleTColumn(
|
||||
|
||||
column->fill(value);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId
|
||||
<< " columnId " << columnId << " value " << value;
|
||||
fState.GetVerboseL4()->Message("done fill", "pntuple T column", description);
|
||||
}
|
||||
#endif
|
||||
if ( IsVerbose(G4Analysis::kVL4) ) {
|
||||
Message(G4Analysis::kVL4, "done fill", "pntuple T column",
|
||||
" ntupleId " + to_string(ntupleId) +
|
||||
" columnId " + to_string(columnId) +
|
||||
" value " + G4Analysis::ToString(value));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,13 +30,24 @@
|
||||
#include "G4RootMpiNtupleFileManager.hh"
|
||||
#include "G4RootMpiNtupleManager.hh"
|
||||
#include "G4RootMpiPNtupleManager.hh"
|
||||
#include "G4AnalysisUtilities.hh"
|
||||
|
||||
#include <tools/impi>
|
||||
|
||||
using namespace G4Analysis;
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4RootMpiAnalysisManager::G4RootMpiAnalysisManager(G4bool isMaster)
|
||||
: G4RootAnalysisManager(isMaster)
|
||||
G4RootMpiAnalysisManager* G4RootMpiAnalysisManager::Instance()
|
||||
{
|
||||
return fgInstance;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4RootMpiAnalysisManager::G4RootMpiAnalysisManager(G4bool /*isMaster*/)
|
||||
: G4RootAnalysisManager()
|
||||
{
|
||||
fgInstance = this;
|
||||
|
||||
// Reset the ntuple file manager
|
||||
fNtupleFileManager.reset();
|
||||
|
||||
@@ -48,7 +59,9 @@ G4RootMpiAnalysisManager::G4RootMpiAnalysisManager(G4bool isMaster)
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4RootMpiAnalysisManager::~G4RootMpiAnalysisManager()
|
||||
{}
|
||||
{
|
||||
fgInstance = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// public methods
|
||||
@@ -118,11 +131,7 @@ G4bool G4RootMpiAnalysisManager::WriteImpl()
|
||||
finalResult = finalResult && result;
|
||||
}
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
fState.GetVerboseL2()->Message("write", "slave files", "", finalResult);
|
||||
}
|
||||
#endif
|
||||
Message(kVL2, "write", "slave files", "", finalResult);
|
||||
|
||||
return finalResult;
|
||||
}
|
||||
@@ -144,11 +153,7 @@ G4bool G4RootMpiAnalysisManager::CloseFileImpl(G4bool reset)
|
||||
finalResult = finalResult && result;
|
||||
}
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
fState.GetVerboseL2()->Message("close", "slave files", "", finalResult);
|
||||
}
|
||||
#endif
|
||||
Message(kVL2, "close", "slave files", "", finalResult);
|
||||
|
||||
return finalResult;
|
||||
|
||||
|
||||
@@ -29,9 +29,11 @@
|
||||
#include "G4RootMpiNtupleFileManager.hh"
|
||||
#include "G4RootMpiNtupleManager.hh"
|
||||
#include "G4RootMpiPNtupleManager.hh"
|
||||
#include "G4AnalysisUtilities.hh"
|
||||
|
||||
#include <tools/impi>
|
||||
|
||||
using namespace G4Analysis;
|
||||
using std::make_shared;
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -56,11 +58,7 @@ G4RootMpiNtupleFileManager::~G4RootMpiNtupleFileManager()
|
||||
void G4RootMpiNtupleFileManager::SetMpiNtupleMergingMode(
|
||||
G4int nofNtupleFiles)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
fState.GetVerboseL2()->Message("set", "mpi ntuple merging mode", "");
|
||||
}
|
||||
#endif
|
||||
Message(kVL2, "set", "mpi ntuple merging mode");
|
||||
|
||||
auto canMerge = true;
|
||||
|
||||
@@ -98,11 +96,7 @@ void G4RootMpiNtupleFileManager::SetMpiNtupleMergingMode(
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL1() ) {
|
||||
fState.GetVerboseL1()->Message("set", "ntuple merging mode", mergingMode);
|
||||
}
|
||||
#endif
|
||||
Message(kVL1, "set", "mpi ntuple merging mode", mergingMode);
|
||||
}
|
||||
|
||||
|
||||
@@ -137,11 +131,7 @@ void G4RootMpiNtupleFileManager::SetMpiNtupleMerging(tools::impi* impi,
|
||||
//_____________________________________________________________________________
|
||||
std::shared_ptr<G4VNtupleManager> G4RootMpiNtupleFileManager::CreateNtupleManager()
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
fState.GetVerboseL4()->Message("create", "mpi ntuple managers", "");
|
||||
}
|
||||
#endif
|
||||
Message(kVL4, "create", "mpi ntuple manager");
|
||||
|
||||
std::shared_ptr<G4VNtupleManager> activeNtupleManager = nullptr;
|
||||
switch ( fNtupleMergeMode )
|
||||
@@ -172,23 +162,19 @@ std::shared_ptr<G4VNtupleManager> G4RootMpiNtupleFileManager::CreateNtupleManage
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL3() ) {
|
||||
G4String mergeMode;
|
||||
switch ( fNtupleMergeMode ) {
|
||||
case G4NtupleMergeMode::kNone:
|
||||
mergeMode = "";
|
||||
break;
|
||||
case G4NtupleMergeMode::kMain:
|
||||
mergeMode = "main ";
|
||||
break;
|
||||
case G4NtupleMergeMode::kSlave:
|
||||
mergeMode = "slave ";
|
||||
break;
|
||||
}
|
||||
fState.GetVerboseL3()->Message("create", mergeMode + "mpi ntuple managers", "");
|
||||
G4String mergeMode;
|
||||
switch ( fNtupleMergeMode ) {
|
||||
case G4NtupleMergeMode::kNone:
|
||||
mergeMode = "";
|
||||
break;
|
||||
case G4NtupleMergeMode::kMain:
|
||||
mergeMode = "main ";
|
||||
break;
|
||||
case G4NtupleMergeMode::kSlave:
|
||||
mergeMode = "slave ";
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
Message(kVL3, "create", mergeMode + "mpi ntuple manager");
|
||||
|
||||
fIsInitialized = true;
|
||||
|
||||
@@ -207,15 +193,12 @@ G4bool G4RootMpiNtupleFileManager::ActionAtOpenFile(const G4String& fileName)
|
||||
|
||||
if ( ! fNtupleBooked ) {
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
G4String objectType = "analysis file";
|
||||
if ( fNtupleMergeMode == G4NtupleMergeMode::kMain ) {
|
||||
objectType = "main analysis file";
|
||||
}
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
fState.GetVerboseL4()->Message("open", objectType, fileName);
|
||||
}
|
||||
#endif
|
||||
Message(kVL4, "open", objectType, fileName);
|
||||
|
||||
|
||||
if ( fNtupleMergeMode == G4NtupleMergeMode::kMain ) {
|
||||
// Creating files is triggered from CreateNtuple
|
||||
@@ -230,11 +213,7 @@ G4bool G4RootMpiNtupleFileManager::ActionAtOpenFile(const G4String& fileName)
|
||||
fBookingManager->GetNtupleBookingVector());
|
||||
}
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL1() ) {
|
||||
fState.GetVerboseL1()->Message("open", objectType, fileName, finalResult);
|
||||
}
|
||||
#endif
|
||||
Message(kVL1, "open", objectType, fileName);
|
||||
|
||||
fNtupleBooked = true;
|
||||
}
|
||||
@@ -256,11 +235,7 @@ G4bool G4RootMpiNtupleFileManager::ActionAtWrite()
|
||||
if ( fNtupleMergeMode == G4NtupleMergeMode::kMain ) ntupleType = "main ntuples";
|
||||
if ( fNtupleMergeMode == G4NtupleMergeMode::kSlave ) ntupleType = "slave ntuples";
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
fState.GetVerboseL4()->Message("merge", ntupleType, "");
|
||||
}
|
||||
#endif
|
||||
Message(kVL4, "merge", ntupleType);
|
||||
|
||||
if ( fNtupleMergeMode == G4NtupleMergeMode::kMain ) {
|
||||
auto result = fNtupleManager->Merge();
|
||||
@@ -272,11 +247,7 @@ G4bool G4RootMpiNtupleFileManager::ActionAtWrite()
|
||||
finalResult = result && finalResult;
|
||||
}
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL1() ) {
|
||||
fState.GetVerboseL1()->Message("merge", ntupleType, "");
|
||||
}
|
||||
#endif
|
||||
Message(kVL1, "merge", ntupleType, "", finalResult);
|
||||
|
||||
return finalResult;
|
||||
}
|
||||
@@ -326,7 +297,7 @@ G4bool G4RootMpiNtupleFileManager::Reset()
|
||||
auto finalResult = true;
|
||||
|
||||
if ( fNtupleMergeMode == G4NtupleMergeMode::kMain ) {
|
||||
auto result = fNtupleManager->Reset(false);
|
||||
auto result = fNtupleManager->Reset();
|
||||
finalResult = result && finalResult;
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ G4bool G4RootMpiNtupleManager::WaitBuffer()
|
||||
|
||||
unsigned long numberOfEndFill = 0;
|
||||
|
||||
G4bool verbose = ( fState.GetVerboseL2() );
|
||||
G4bool verbose = IsVerbose(kVL2);
|
||||
|
||||
while ( true ) {
|
||||
fImpi->pack_reset();
|
||||
|
||||
@@ -34,9 +34,10 @@
|
||||
#include "tools/wroot/mpi_ntuple_row_wise"
|
||||
#include "tools/wroot/mpi_ntuple_column_wise"
|
||||
|
||||
using namespace G4Analysis;
|
||||
|
||||
const int kTAG_NTUPLE = 1004; // This constant is defined in G4MPImanager
|
||||
// (should be passed from the application)
|
||||
|
||||
namespace {
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -114,17 +115,12 @@ tools::wroot::base_pntuple* G4RootMpiPNtupleManager::GetNtupleInFunction(
|
||||
//_____________________________________________________________________________
|
||||
void G4RootMpiPNtupleManager::CreateNtuple(G4RootMpiPNtupleDescription* ntupleDescription)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
fState.GetVerboseL4()
|
||||
->Message("create from booking", "mpi pntuple",
|
||||
ntupleDescription->fDescription.fNtupleBooking.name());
|
||||
}
|
||||
#endif
|
||||
Message(kVL4, "create from booking", "mpi pntuple",
|
||||
ntupleDescription->fDescription.fNtupleBooking.name());
|
||||
|
||||
// Wait for the ntuple data from main
|
||||
|
||||
G4bool verbose = ( fState.GetVerboseL2() );
|
||||
G4bool verbose = IsVerbose(kVL2);
|
||||
|
||||
G4cout << "Go to wait_buffer from " << fDestinationRank << G4endl;
|
||||
fImpi->pack_reset();
|
||||
@@ -229,13 +225,8 @@ void G4RootMpiPNtupleManager::CreateNtuple(G4RootMpiPNtupleDescription* ntupleDe
|
||||
// pntuple object is not deleted automatically
|
||||
fNtupleVector.push_back(ntupleDescription->fNtuple);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL3() ) {
|
||||
fState.GetVerboseL3()
|
||||
->Message("create from booking", "mpi pntuple",
|
||||
ntupleDescription->fDescription.fNtupleBooking.name());
|
||||
}
|
||||
#endif
|
||||
Message(kVL3, "create from booking", "mpi pntuple",
|
||||
ntupleDescription->fDescription.fNtupleBooking.name());
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -266,13 +257,8 @@ void G4RootMpiPNtupleManager::CreateNtuplesFromBooking(
|
||||
// Do not create ntuple if it already exists
|
||||
if ( ntupleDescription->fNtuple ) continue;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
fState.GetVerboseL4()
|
||||
->Message("create from booking", "mpi pntuple",
|
||||
ntupleDescription->fDescription.fNtupleBooking.name());
|
||||
}
|
||||
#endif
|
||||
Message(kVL4, "create from booking", "mpi pntuple",
|
||||
ntupleDescription->fDescription.fNtupleBooking.name());
|
||||
|
||||
// create ntuple
|
||||
CreateNtuple(ntupleDescription);
|
||||
@@ -281,13 +267,8 @@ void G4RootMpiPNtupleManager::CreateNtuplesFromBooking(
|
||||
// (nothing to be done ?)
|
||||
// FinishTNtuple(ntupleDescription);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL3() ) {
|
||||
fState.GetVerboseL3()
|
||||
->Message("create from booking", "mpi pntuple",
|
||||
ntupleDescription->fDescription.fNtupleBooking.name());
|
||||
}
|
||||
#endif
|
||||
Message(kVL3, "create from booking", "mpi pntuple",
|
||||
ntupleDescription->fDescription.fNtupleBooking.name());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -338,13 +319,7 @@ G4bool G4RootMpiPNtupleManager::AddNtupleRow(G4int ntupleId)
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL4()->Message("add", "pntuple row", description);
|
||||
}
|
||||
#endif
|
||||
Message(kVL4, "add", "pntuple row", " ntupleId " + to_string(ntupleId));
|
||||
|
||||
auto ntupleDescription = GetNtupleDescriptionInFunction(ntupleId, "AddNtupleRow");
|
||||
if ( ! ntupleDescription ) return false;
|
||||
@@ -362,13 +337,7 @@ G4bool G4RootMpiPNtupleManager::AddNtupleRow(G4int ntupleId)
|
||||
"Analysis_W002", JustWarning, description);
|
||||
}
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL3() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL3()->Message("add", "pntuple row", description);
|
||||
}
|
||||
#endif
|
||||
Message(kVL3, "add", "pntuple row", " ntupleId " + to_string(ntupleId));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -390,13 +359,8 @@ G4bool G4RootMpiPNtupleManager::Merge()
|
||||
// (this happend when the main rank re-opens a new file for merged data)
|
||||
if ( ! ntupleDescription->fNtuple ) continue;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
fState.GetVerboseL4()
|
||||
->Message("end_fill", "pntuple", ntupleDescription->fDescription.fNtupleBooking.name());
|
||||
}
|
||||
#endif
|
||||
|
||||
Message(kVL4, "merge", "pntuple", ntupleDescription->fDescription.fNtupleBooking.name());
|
||||
|
||||
// G4cout << "call end_fill " << fImpi
|
||||
// << " to rank " << ntupleDescription->fMainNtupleRank
|
||||
// << " pntuple: " << ntupleDescription->fNtuple << G4endl;
|
||||
@@ -415,17 +379,26 @@ G4bool G4RootMpiPNtupleManager::Merge()
|
||||
delete ntupleDescription->fNtuple;
|
||||
ntupleDescription->fNtuple = nullptr;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL3() ) {
|
||||
fState.GetVerboseL3()
|
||||
->Message("end_fill", "pntuple", ntupleDescription->fDescription.fNtupleBooking.name());
|
||||
}
|
||||
#endif
|
||||
Message(kVL3, "merge", "pntuple", ntupleDescription->fDescription.fNtupleBooking.name());
|
||||
}
|
||||
|
||||
return finalResult;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4RootMpiPNtupleManager::Clear()
|
||||
{
|
||||
for ( auto ntupleDescription : fNtupleDescriptionVector ) {
|
||||
delete ntupleDescription->fNtuple;
|
||||
}
|
||||
|
||||
fNtupleDescriptionVector.clear();
|
||||
fNtupleVector.clear();
|
||||
|
||||
Message(kVL2, "clear", "pntuples");
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootMpiPNtupleManager::Reset(G4bool deleteNtuple)
|
||||
{
|
||||
|
||||
@@ -39,8 +39,8 @@ void Tokenize(const G4String& str, std::vector<G4String>& tokens)
|
||||
{
|
||||
const char* delimiter = " ";
|
||||
|
||||
str_size pos0 = str.find_first_not_of(delimiter);
|
||||
str_size pos = str.find_first_of(delimiter, pos0);
|
||||
auto pos0 = str.find_first_not_of(delimiter);
|
||||
auto pos = str.find_first_of(delimiter, pos0);
|
||||
|
||||
while (pos != G4String::npos || pos0 != G4String::npos) {
|
||||
if (str[pos0] == '\"') {
|
||||
@@ -95,19 +95,19 @@ G4String G4MPIbatch::ReadCommand()
|
||||
G4String cmdline(linebuf);
|
||||
|
||||
// TAB-> ' ' conversion
|
||||
str_size nb = 0;
|
||||
G4String::size_type nb = 0;
|
||||
while ((nb= cmdline.find('\t',nb)) != G4String::npos) {
|
||||
cmdline.replace(nb, 1, " ");
|
||||
}
|
||||
|
||||
// strip
|
||||
cmdline = cmdline.strip(G4String::both);
|
||||
G4StrUtil::strip(cmdline);
|
||||
|
||||
// skip null line if single line
|
||||
if( !qcontinued && cmdline.size() == 0 ) continue;
|
||||
|
||||
// '#' is treated as echoing something
|
||||
if( cmdline(0) == '#' ) return cmdline;
|
||||
if( cmdline[0] == '#' ) return cmdline;
|
||||
|
||||
// tokenize...
|
||||
std::vector<G4String> tokens;
|
||||
@@ -115,9 +115,9 @@ G4String G4MPIbatch::ReadCommand()
|
||||
qcontinued = false;
|
||||
for( G4int i = 0; i < G4int(tokens.size()); i++ ) {
|
||||
// string after '#" is ignored
|
||||
if( tokens[i](0) == '#' ) break;
|
||||
if( tokens[i][0] == '#' ) break;
|
||||
// '\' or '_' is treated as continued line.
|
||||
if( tokens[i] == '\\' || tokens[i] == '_' ) {
|
||||
if( tokens[i] == "\\" || tokens[i] == "_" ) {
|
||||
qcontinued = true;
|
||||
// check nothing after line continuation character
|
||||
if( i != G4int(tokens.size())-1 ) {
|
||||
@@ -137,7 +137,7 @@ G4String G4MPIbatch::ReadCommand()
|
||||
}
|
||||
|
||||
// strip again
|
||||
cmdtotal = cmdtotal.strip(G4String::both);
|
||||
G4StrUtil::strip(cmdtotal);
|
||||
|
||||
// bypass some commands
|
||||
cmdtotal = BypassCommand(cmdtotal);
|
||||
@@ -170,7 +170,7 @@ G4UIsession* G4MPIbatch::SessionStart()
|
||||
}
|
||||
|
||||
// just echo something
|
||||
if( scommand(0) == '#' ) {
|
||||
if( scommand[0] == '#' ) {
|
||||
if( G4UImanager::GetUIpointer()-> GetVerboseLevel() == 2 ) {
|
||||
G4cout << scommand << G4endl;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ G4MPIntupleMerger::G4MPIntupleMerger(G4int nofReducedNtupleFiles,
|
||||
G4bool isMaster = true;
|
||||
auto analysisManager
|
||||
= new G4RootMpiAnalysisManager(isMaster);
|
||||
analysisManager->SetVerboseLevel(1);
|
||||
// G4cout << "Start configure ntuple MPI merging" << G4endl;
|
||||
|
||||
// Get communicator
|
||||
|
||||
@@ -100,20 +100,20 @@ G4String G4MPIsession::GetCommand(const char* msg)
|
||||
// get command from shell...
|
||||
newCommand = shell_-> GetCommandLineString(msg);
|
||||
|
||||
G4String nC= newCommand.strip(G4String::leading);
|
||||
G4String nC= G4StrUtil::lstrip_copy(newCommand);
|
||||
if( nC.length() == 0 ) {
|
||||
newCommand = nullString;
|
||||
|
||||
} else if( nC(0) == '#' ) {
|
||||
} else if( nC[0] == '#' ) {
|
||||
G4cout << nC << G4endl;
|
||||
newCommand = nullString;
|
||||
|
||||
} else if( nC == "ls" || nC(0,3) == "ls " ) { // list commands
|
||||
} else if( nC == "ls" || nC.substr(0,3) == "ls " ) { // list commands
|
||||
ListDirectory(nC);
|
||||
newCommand = nullString;
|
||||
|
||||
} else if( nC == "lc" || nC(0,3) == "lc " ) { // ... by shell
|
||||
shell_-> ListCommand(nC.remove(0,2));
|
||||
} else if( nC == "lc" || nC.substr(0,3) == "lc " ) { // ... by shell
|
||||
shell_-> ListCommand(nC.erase(0,2));
|
||||
newCommand = nullString;
|
||||
|
||||
} else if( nC == "pwd" ) { // show current directory
|
||||
@@ -125,16 +125,16 @@ G4String G4MPIsession::GetCommand(const char* msg)
|
||||
shell_-> ShowCurrentDirectory();
|
||||
newCommand = nullString;
|
||||
|
||||
} else if(nC == "cd" || nC(0,3) == "cd " ) { // "cd"
|
||||
} else if(nC == "cd" || nC.substr(0,3) == "cd " ) { // "cd"
|
||||
ChangeDirectoryCommand(nC);
|
||||
shell_-> SetCurrentDirectory(GetCurrentWorkingDirectory());
|
||||
newCommand = nullString;
|
||||
|
||||
} else if( nC == "help" || nC(0,5) == "help " ) { // "help"
|
||||
} else if( nC == "help" || nC.substr(0,5) == "help " ) { // "help"
|
||||
TerminalHelp(nC);
|
||||
newCommand = nullString;
|
||||
|
||||
} else if( nC(0) == '?' ) { // "show current value of a parameter"
|
||||
} else if( nC[0] == '?' ) { // "show current value of a parameter"
|
||||
ShowCurrent(nC);
|
||||
newCommand = nullString;
|
||||
|
||||
@@ -145,8 +145,8 @@ G4String G4MPIsession::GetCommand(const char* msg)
|
||||
}
|
||||
newCommand = nullString;
|
||||
|
||||
} else if( nC(0) == '!' ) { // "!"
|
||||
G4String ss = nC(1, nC.length()-1);
|
||||
} else if( nC[0] == '!' ) { // "!"
|
||||
G4String ss = nC.substr(1, nC.length()-1);
|
||||
G4int vl;
|
||||
const char* tt = ss;
|
||||
std::istringstream is(tt);
|
||||
|
||||
@@ -83,10 +83,10 @@ G4int G4VMPIsession::ExecCommand(const G4String& acommand)
|
||||
G4String command = BypassCommand(acommand);
|
||||
|
||||
// "/mpi/beamOn is threaded out.
|
||||
if( command(0,11) == "/mpi/beamOn" ) {
|
||||
if( command.substr(0,11) == "/mpi/beamOn" ) {
|
||||
g4mpi_-> ExecuteBeamOnThread(command);
|
||||
returnVal = fCommandSucceeded;
|
||||
} else if( command(0,12) == "/mpi/.beamOn" ) { // care for beamOn
|
||||
} else if( command.substr(0,12) == "/mpi/.beamOn" ) { // care for beamOn
|
||||
G4bool threadStatus = g4mpi_-> CheckThreadStatus();
|
||||
if ( threadStatus ) { // still /run/beamOn is active
|
||||
if( is_master_ ) {
|
||||
@@ -151,16 +151,16 @@ G4String G4VMPIsession::TruncateCommand(const G4String& command) const
|
||||
G4String acommand = command;
|
||||
G4String strarg;
|
||||
|
||||
str_size iarg = acommand.find(' ');
|
||||
G4String::size_type iarg = acommand.find(' ');
|
||||
if( iarg != G4String::npos ) {
|
||||
strarg = acommand(iarg, acommand.size()-iarg);
|
||||
acommand = acommand(0,iarg);
|
||||
strarg = acommand.substr(iarg, acommand.size()-iarg);
|
||||
acommand = acommand.substr(0,iarg);
|
||||
}
|
||||
|
||||
str_size idx;
|
||||
G4String::size_type idx;
|
||||
while( (idx = acommand.find("//")) != G4String::npos) {
|
||||
G4String command1 = acommand(0,idx+1);
|
||||
G4String command2 = acommand(idx+2, acommand.size()-idx-2);
|
||||
G4String command1 = acommand.substr(0,idx+1);
|
||||
G4String command2 = acommand.substr(idx+2, acommand.size()-idx-2);
|
||||
acommand = command1 + command2;
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ G4String G4VMPIsession::BypassCommand(const G4String& command) const
|
||||
G4String acommand = command;
|
||||
|
||||
// /mpi/beamOn
|
||||
if( acommand(0,11) == "/mpi/beamOn" ) {
|
||||
if( acommand.substr(0,11) == "/mpi/beamOn" ) {
|
||||
#ifdef G4MULTITHREADED
|
||||
acommand = "/mpi/.beamOn";
|
||||
if(command.length() > 11) {
|
||||
@@ -204,12 +204,12 @@ G4String G4VMPIsession::BypassCommand(const G4String& command) const
|
||||
}
|
||||
|
||||
// /run/beamOn
|
||||
if( acommand(0,11) == "/run/beamOn" ) {
|
||||
if( acommand.substr(0,11) == "/run/beamOn" ) {
|
||||
G4String strarg = "";
|
||||
G4bool qget = false;
|
||||
G4bool qdone = false;
|
||||
|
||||
for ( str_size idx = 10; idx < command.size(); idx++ ) {
|
||||
for ( G4String::size_type idx = 10; idx < command.size(); idx++ ) {
|
||||
if( command[idx] == ' ' || command[idx] == '\011' ) {
|
||||
qget = true;
|
||||
if(qdone) break;
|
||||
@@ -242,7 +242,7 @@ G4String G4VMPIsession::BypassCommand(const G4String& command) const
|
||||
}
|
||||
|
||||
// /control/execute
|
||||
if( acommand(0,16) == "/control/execute" ) {
|
||||
if( acommand.substr(0,16) == "/control/execute" ) {
|
||||
if( g4mpi_-> GetVerbose()>0 && is_master_ ) {
|
||||
G4cout << "/control/execute is overridden by /mpi/execute"
|
||||
<< G4endl;
|
||||
|
||||
Reference in New Issue
Block a user