Initializes the state of the pseudorandom number generator used by random_number
.
Subroutine
call random_init(repeatable, image_distinct)
repeatable
- Shall be a scalar with a logical
type, and it is intent(in)
. 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
- Shall be a scalar with a logical
type, and it is intent(in)
. 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_init
in another image. If it is .false.
, the seed is set value that does depend which image called random_init
.program test_random_seed
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 are the same sequence
if (any(x /= y)) stop "x(:) and y(:) not all equal"
end program test_random_seed