Procedure to initialize a random number generator with a seed. If seed is negative then random seed is used
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(rng_type), | intent(inout) | :: | self | Random Number Generator |
||
integer(kind=Int32), | intent(in) | :: | seed | Initial Seed Value |
subroutine rng_init(self, seed)
#ifdef _MPI
use mpi_utils
#endif
!+ Procedure to initialize a random number generator with a seed.
!+ If seed is negative then random seed is used
type(rng_type), intent(inout) :: self
!+ Random Number Generator
integer(Int32), intent(in) :: seed
!+ Initial Seed Value
integer(Int32) :: s
if(seed.lt.0) then
s = rng_seed()
else
#ifdef _MPI
s = seed + my_rank()
#else
s = seed
#endif
endif
self%seed = s
self%state(1) = ieor(777755555,abs(s))
self%state(2) = ior(ieor(888889999,abs(s)),1)
end subroutine rng_init