Running on single thread with multi-threading G4

Dear Geant4 gurus,

I am using a LCG-centrally-compiled version of G4 on lxplus, which is multi-threading.
I would like to force it to use one single thread, is there a way to do it?


In your main, instantiate G4RunManager instead of G4MTRunManager. Then it runs in sequential mode.

thank you very much!

Actually, I was unhappy at hardwiring this option. MT mode is annoying when debugging since the screen output will then mix info from different events running on different threads.

Indeed, G4MULTITHREADED is defined when compiling geant4 and there is nothing you can do about it. So G4MTRunManager will always be instantiated however if you put

/run/numberOfThreads 1

in your macro (before /run/initialize) the code will run single thread even if G4MTRunManager is used

since version 11.0 (may be earlier) you can start explicitly the SERIAL mode in a MT compiled geant4.

env G4RUN_MANAGER_TYPE=Serial ./exampleB1 run.mac

But be aware SERIAL mode and MT mode with /run/numberOfThreads 1 are not excatly the same. See here: