OLD vs New format of source.f

Versions

Please provide the used software versions.

FLUKA:4-5.1
Flair:3.4-3
Operating system: Ubuntu 20.04 LTS
Compiler:

Description

Dear Experts,

I want to sample a spherical source using source.f routine.

My sampling is as below:

CALL RACO(TXX, TYY, TZZ)
R = 2.5D0
XFLK(NPFLKA) = RTXX
YFLK(NPFLKA) = R
TYY
ZFLK(NPFLKA) = R*TZZ

when I used the “Ru106_beta_old_format_source.f”, it is compiling correctly. However, when I used this CALL RACO with “source_newgen_annular.f“ it is not compiling and following error message is coming:

- Compiling: /usr/local/fluka/bin/fff source_newgen_annular.f
gfortran -c -I/usr/local/fluka/include -g -cpp -O3 -fd-lines-as-comments -Wall -Waggregate-return -Wcast-align -Wline-truncation -Wno-conversion -Wno-integer-division -Wno-tabs -Wno-unused-dummy-argument -Wno-unused-function -Wno-unused-parameter -Wno-unused-variable -Wsystem-headers -Wuninitialized -Wunused-label -mtune=generic -msse2 -mfpmath=sse -fPIC -fexpensive-optimizations -funroll-loops -fstrength-reduce -fno-automatic -finit-local-zero -ffixed-line-length-132 -fbackslash -funderscoring -frecord-marker=4 -falign-commons -fbacktrace -frange-check -fbounds-check -fdump-core -ftrapping-math -ffpe-trap=invalid,zero,overflow -o source_newgen_annular.o source_newgen_annular.f
source_newgen_annular.f:383:7:

383 | R = 2.5D0
| 1
Error: Symbol ‘r’ at (1) has no IMPLICIT type
source_newgen_annular.f:382:19:

382 | CALL RACO(TXX, TYY, TZZ)
| 1
Error: Symbol ‘txx’ at (1) has no IMPLICIT type
source_newgen_annular.f:382:24:

382 | CALL RACO(TXX, TYY, TZZ)
| 1
Error: Symbol ‘tyy’ at (1) has no IMPLICIT type
source_newgen_annular.f:382:29:

382 | CALL RACO(TXX, TYY, TZZ)
| 1
Error: Symbol ‘tzz’ at (1) has no IMPLICIT type
Ended: 2026.02.23 20:55:57

Error compiling
Error: compiling file: source_newgen_annular.f
No object generated

see the attached .f files and .dat file

Can you please give me some suggestion on how to use the RACO function with new_gen_source.f ?

Thanking you in advance.

microsphere.inp (813 Bytes)

pure_thermal_neutron.dat (1.9 KB)

Ru106_beta_old_format_source.f (11.5 KB)

source_newgen_annular.f (19.1 KB)

Input files

Please upload all relevant files. (FLUKA input file, Flair project file, user routines, and data files)

Dear @ArghyaC,

Thank you for your question.

The compilation errors you encountered are due to how Fortran handles variables in the new-generation compared to the legacy source user routine.

Specifically, the new-generation source routine uses IMPLICIT NONE, which requires every variable to be explicitly declared before use, which is good practice. The legacy source routine relies on “Implicit Typing”, where the variable type is assumed based on its starting letter (variables starting with I-N are integers and the others are reals).

To fix this, you must declare R, TXX, TYY, and TZZ in the dedicated block for user variables, as shown below:

In the new-generation source routine, it is best practice to use the internal variables (coordinate_{x,y,z}) instead of {X,Y,Z}FLK(NPFLKA). The routine handles stack assignment automatically at the end.

Currently, because you fixed R = 2.5, only the surface (shell) of the sphere is sampled. If you intend to simulate a solid microsphere, you also have to sample the radius as R = R_max ⋅ ξ^(1/3), where ξ is a random number uniformly sampled between 0 and 1 (using the FLRNDM function).

A final remark: if you set the spatial coordinates, but do not define the direction, every particle will propagate parallel to the z-axis. To ensure particles are emitted isotropically, you must uncomment the call to sample_isotropic_direction(direction_cosx, direction_cosy, direction_cosz).

For more details, please consult the FLUKA manual and the Source routine lecture from the 2025 FLUKA beginner’s course. For a deeper dive into the differences between the legacy and the new generation source routines have a look at this lecture.

P.S.: Ensure you uncomment the SOURCE card in the input file so that your custom source routine is used.

Best regards,

Alexandra