RANDOM_INIT(3) - [MATHEMATICS:RANDOM] Initializes the state of the pseudorandom number generator
call random_init(repeatable, image_distinct)
logical,intent(in) :: repeatable logical,intent(in) :: image_distinct
Description
o HARVEST and IMAGE_DISTINCT are logical scalars Initializes the state of the pseudorandom number generator used by RANDOM_NUMBER.
REPEATABLE : If it is .TRUE., the seed is set to a processor-dependent value that is the same each time RANDOM_INIT is called from the same image. The term "same image" means a single instance of program execution. The sequence of random numbers is different for repeated execution of the program.
If it is .FALSE., the seed is set to a processor-dependent value.
IMAGE_DISTINCT : If it is .true., the seed is set to a processor-dependent value that is distinct from the seed set by a call to RANDOM_INITin another image. If it is .FALSE., the seed is set to a value that does depend on which image called RANDOM_INIT.
Sample program:
program demo_random_init implicit none real x(3), y(3) call random_init(.true., .true.) call random_number(x) call random_init(.true., .true.) call random_number(y) ! x and y should be the same sequence if ( any(x /= y) ) stop "x(:) and y(:) are not all equal" write(*,*)x write(*,*)y end program demo_random_initResults:
RUN 1:
> 0.825262189 0.191325366 0.155503273 > 0.825262189 0.191325366 0.155503273RUN 2:
> 0.825262189 0.191325366 0.155503273 > 0.825262189 0.191325366 0.155503273
Fortran 2018
random_number, random_seed
_Fortran intrinsic descriptions
Nemo Release 3.1 | random_init (3fortran) | November 02, 2024 |