RANDOM_SEED(3) - [MATHEMATICS:RANDOM] Initialize a pseudo-random number sequence
call random_seed( [size] [,put] [,get] )
subroutine random_seed( size, put, get )integer,intent(out),optional :: size integer,intent(in),optional :: put(*) integer,intent(out),optional :: get(*)
o SIZE a scalar default integer o PUT a rank-one default integer array o GET a rank-one default integer array o the result
RANDOM_SEED(3) restarts or queries the state of the pseudorandom number generator used by random_number.
If random_seed is called without arguments, it is seeded with random data retrieved from the operating system.
o SIZE : specifies the minimum size of the arrays used with the PUT and GET arguments. o PUT : the size of the array must be larger than or equal to the number returned by the SIZE argument. o GET : It is INTENT(OUT) and the size of the array must be larger than or equal to the number returned by the SIZE argument.
Sample program:
program demo_random_seed implicit none integer, allocatable :: seed(:) integer :: nResults:call random_seed(size = n) allocate(seed(n)) call random_seed(get=seed) write (*, *) seed
end program demo_random_seed
> -674862499 -1750483360 -183136071 -317862567 682500039 > 349459 344020729 -1725483289
Fortran 95
RANDOM_NUMBER(3)
Fortran intrinsic descriptions
Nemo Release 3.1 | random_seed (3fortran) | November 02, 2024 |