Source_newgen.f- "sampling from different files"

FLUKA:4.4.0
Flair:3.3.1
Operating system:FEDORA 35
Compiler:gcc 11.3.1

Dear All
I have a simple question. The source_newgen.f says that

" ! 3.4.4. Sampling from histogram
! ------
! Possible [unit]s: “TeV”, “GeV”, “MeV”, “keV” “eV”
! “TeV/c”, “GeV/c”, “MeV/c”, “keV/c”, “eV/c”
! “J”
! Histogram file has to have 3 columns:
! - Emin (of the bin)
! - Emax (of the bin)
! - dN/dE (bin height; NOTE: doesn’t need to be normalized)
! Sampling from different files treated separately, up to 100 files.

  •  momentum_energy = sample_histogram_momentum_energy( [filename], [unit] )
    

it seems one can sample from 100 different files. so, how to do that? Do i have to include multiple source_newgen.f and compile? Or I can do that in a single source_newgen.f file? Can someone give a sample code please?
thanks & regards
saurabh

Dear Saurabh,

Only one source_newgen.f routine is needed.
To sample from multiple files, you only need to change the filename argument of the function.

E.g.:

if (l_electron == true) then
   particle_ code = 3
   momentum_energy = sample_histogram_momentum_energy("electron.txt", "GeV")
else
   particle_code = 7
   momentum_energy = sample_histogram_momentum_energy("photon.txt", "GeV")
endif

Cheers,
David

P.S.:
Please update your FLUKA, Flair, and Linux OS to the latest version.

Dear David
thanks for the quick reply. One question please. This " l_electron == true" , is this an argument that I can pass through FLAIR? Say, i loop my run over some parameter that I introduce through ‘define’ card.
regards
saurabh

Dear Saurabh,

no, the l_electron variable is just a dummy logical flag used in the example. You need to program your logic selecting particles, etc. in the source routine.

You may pass variables via the SOURCE card to the source routine, and use them with WHASOU(1) .. WHASOU(18).

See: 7.22.70. SOURCE — FLUKA Manual

Cheers,
David

thank you very much!
-saurabh