Message: the problem of SetRandomNumberStoreDir function in G4RunManager.hh Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None the problem of SetRandomNumberStoreDir function in G4RunManager.hh 

Forum: Run Management
Date: 11 Oct, 2010
From: Fada Guan <Fada Guan>

To dear developers:

In Geant4.9.3p02 and later version 4.9.4.b01, the content of SetRandomNumberStoreDir function in G4RunManager.hh is:

    inline void SetRandomNumberStoreDir(const G4String& dir)
    { 
      G4String dirStr = dir;
      if( dirStr(dirStr.length()-1) != '/' ) dirStr += "/";
#ifndef WIN32
      G4String shellCmd = "mkdir -p ";
#else
      std::replace(dirStr.begin(), dirStr.end(),'/','\\');
      G4String shellCmd = "mkdir ";
#endif
      shellCmd += dirStr;
      randomNumberStatusDir = dirStr;
      system(shellCmd); 
    }

I have some doubts about this function:

1)std::replace(dirStr.begin(), dirStr.end(),'/','\\');

I guess it should be std::replace(dirStr.begin(), dirStr.end(),'/','\');

because in the release notes of Geant4.9.3p02 at

http://geant4.cern.ch/support/Patch4.9.3-2.txt

shows that:
  o Run:
    ---
    + Corrected printing of number of events processed on run abortion.
    + Fixed definition of path for Windows in G4RunManager for random seeds
      directory: use '\' instead of '/' and suitable system command.

I'm working on a Linux system, so I don't know the influence of it.

2)system(shellCmd);

shellCmd is a string, but not a const char*, which is the type of the argument in the system function shown below:

int system ( const char * command ); the reference is: http://www.cplusplus.com/reference/clibrary/cstdlib/system/

In some problems, this will result in a warning message shown below:

/geant4/geant4.9.3.p02/source/run/include/G4RunManager.hh: In member function ‘void G4RunManager::SetRandomNumberStoreDir(const G4String&)’: geant4/geant4.9.3.p02/source/run/include/G4RunManager.hh:357: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result

I guess if we can change system(shellCmd);

to

system(shellCmd.c_str());

or assign a temporary int for it, i.e.

int i;

i = system(shellCmd.c_str());

to avoid this warning message.

Thanks a lot. Regards.

Fada

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 None: Re: the problem of SetRandomNumberStoreDir function in G4RunManager.hh   (Michael H. Kelsey - 11 Oct, 2010)
(_ None: Re: the problem of SetRandomNumberStoreDir function in G4RunManager.hh   (Fada Guan - 12 Oct, 2010)
(_ More: Re: the problem of SetRandomNumberStoreDir function in G4RunManager.hh   (Michael H. Kelsey - 14 Oct, 2010)
(_ None: Re: the problem of SetRandomNumberStoreDir function in G4RunManager.hh   (Fada Guan - 14 Oct, 2010)
 Add Message Add Message
to: "the problem of SetRandomNumberStoreDir function in G4RunManager.hh"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]