random seed should contain some entropy
setting all elements to the same value does not make sense. Moreover, negative values are allowed
This commit is contained in:
parent
a545baebbf
commit
c5fd6a3677
2
PRIVATE
2
PRIVATE
|
@ -1 +1 @@
|
||||||
Subproject commit b898a8b5552bd9d1c555edc3d8134564dd32fe53
|
Subproject commit d570b4a1fac5b9b99d026d3ff9bf593615e22ce5
|
30
src/math.f90
30
src/math.f90
|
@ -84,38 +84,34 @@ contains
|
||||||
subroutine math_init
|
subroutine math_init
|
||||||
|
|
||||||
real(pReal), dimension(4) :: randTest
|
real(pReal), dimension(4) :: randTest
|
||||||
integer :: &
|
integer :: randSize
|
||||||
randSize, &
|
integer, dimension(:), allocatable :: seed
|
||||||
randomSeed !< fixed seeding for pseudo-random number generator, Default 0: use random seed
|
|
||||||
integer, dimension(:), allocatable :: randInit
|
|
||||||
class(tNode), pointer :: &
|
class(tNode), pointer :: &
|
||||||
num_generic
|
num_generic
|
||||||
|
|
||||||
|
|
||||||
print'(/,1x,a)', '<<<+- math init -+>>>'; flush(IO_STDOUT)
|
print'(/,1x,a)', '<<<+- math init -+>>>'; flush(IO_STDOUT)
|
||||||
|
|
||||||
num_generic => config_numerics%get('generic',defaultVal=emptyDict)
|
num_generic => config_numerics%get('generic',defaultVal=emptyDict)
|
||||||
randomSeed = num_generic%get_asInt('random_seed', defaultVal = 0)
|
|
||||||
|
|
||||||
call random_seed(size=randSize)
|
call random_seed(size=randSize)
|
||||||
allocate(randInit(randSize))
|
allocate(seed(randSize))
|
||||||
if (randomSeed > 0) then
|
|
||||||
randInit = randomSeed
|
if (num_generic%contains('random_seed')) then
|
||||||
|
seed = num_generic%get_as1dInt('random_seed',requiredSize=randSize)
|
||||||
else
|
else
|
||||||
call random_seed()
|
call random_seed()
|
||||||
call random_seed(get = randInit)
|
call random_seed(get = seed)
|
||||||
randInit(2:randSize) = randInit(1)
|
end if
|
||||||
endif
|
|
||||||
|
|
||||||
call random_seed(put = randInit)
|
call random_seed(put = seed)
|
||||||
call random_number(randTest)
|
call random_number(randTest)
|
||||||
|
|
||||||
print'(/,a,i2)', ' size of random seed: ', randSize
|
print'(/,a,i2)', ' size of random seed: ', randSize
|
||||||
print'( a,i0)', ' value of random seed: ', randInit(1)
|
print*, 'value of random seed: ', seed
|
||||||
print'( a,4(/,26x,f17.14),/)', ' start of random sequence: ', randTest
|
print'( a,4(/,26x,f17.14))', ' start of random sequence: ', randTest
|
||||||
|
|
||||||
call random_seed(put = randInit)
|
call selfTest()
|
||||||
|
|
||||||
call selfTest
|
|
||||||
|
|
||||||
end subroutine math_init
|
end subroutine math_init
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue