Dear Lihua,
the FLUKA subroutine RACO
returns a random (isotropically sampled) direction in 3 dimensions.
To implement it, you need to replace:
TXFLK (NPFLKA) = UBEAM
TYFLK (NPFLKA) = VBEAM
TZFLK (NPFLKA) = WBEAM
With:
CALL RACO (TXFLK (NPFLKA), TYFLK (NPFLKA), TZFLK (NPFLKA))
Cheers,
David