Quick launch:
Last version:
News:
--
Fluka Release
|
Functions, subroutines and Fortran programmingQ:
What is the correct way of generating random numbers to be used in a user-specific source routine?
A:
The FLUKA random number generator can be invoked using the FLRNDM(XDUMMY) function. It returns a 64-bit pseudo random number in the interval [0.D+00,1.D+00), 1 being not included. See also next question about the argument of FLRNDM argument. FLRNDM gurarantees an extremely low peridiocity (of the order of 10*44). Any other function, for instance the intrinsic random generator of fortran or other functions belonging to external libraries, must be absolutely avoided, since they follow a different seed history and break any possibility of a correct use of the last seed in progressive runs.
Q:
When using the FLRNDM random number generator function in user routines, what argument must be used?
A:
In general, any name is ok, provided it begins by A-H, O-Z. If possible, it is suggested to use the name of a variable which has been recently modified, otherwise it doesn't matter. The reason is that in the far past some compiler tried to be "clever" by extracting the function call when it was present inside a DO loop (in principle, a function with constant argument is supposed to give a constant result - but not a random number generator!). Therefore, it is safer to fool the compiler by letting it believe that the argument has changed, but fortunately such dumb compilers seem to have disappeared. With most compilers accepting f90 extensions, it is now allowed also to write FLRNDM( ) without any argument.
Q:
Are there in FLUKA other utilities for generation and manipulation of random numbers?
A:
Yes. In particular the use of the following subroutines is recommended whenever useful:
Q:
When programming code in the user routines, is there a recommended way of giving numerical constants?
A:
When the user has to insert a numerical constant in the user code, he must always give it explicitly either in INTEGER, if this is the case, or in DOUBLE PRECISION. This is fundamental especially when geometrical accuracy is involved (for example when using a routine like lattic.f). Therefore one should never write something like '4.2' but instead '4.2D+00'. Most compilers treat the two cases in different ways. In this respect, whenever possible, the user should make use of the constants defined as PARAMETER in the (DBLPRC) include file.
It is also important to know that all numerical values passed on the code by data cards are automatically interpreted in DOUBLE PRECISION. Last updated: 26th of April, 2016 |
© FLUKA Team 2000–2025