Initialize the intrinsic random number generator.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | seed1 |
the first seed for the random number generator. |
||
integer, | intent(in) | :: | seed2 |
the second seed for the random number generator. |
subroutine rand_init(seed1,seed2) implicit none integer,intent(in) :: seed1 !! the first seed for the random number generator. integer,intent(in) :: seed2 !! the second seed for the random number generator. integer,dimension(:),allocatable :: s integer :: n integer :: i if (seed1==0 .and. seed2==0) then call random_seed() else call random_seed(size = n) allocate(s(n)) s(1) = seed1 if (n>1) then s(2) = seed2 do i = 3, n ! just in case s(i) = seed1 + seed2 + i end do end if call random_seed(put=s) end if end subroutine rand_init