!----------------------------------------------------------------------- ! ! diehard_multi_data.f90 ! ! Utility to generate data file from random_pl package to be ! tested by Marsaglia's 'diehard' package; output is to ! 'diehard.dat'. Note that diehard expects 32-bit numbers, but ! random_pl only produces 30- or 31-bit numbers; therefore we pick ! twice as many numbers, and use half the numbers to replace the ! two ls bits. ! ! This version uses multiple, identical generators with different ! initial seeds, and interleaves the results to test their ! independence. ! !----------------------------------------------------------------------- program diehard_multi_data use globals use random_pl implicit none integer, parameter :: ngen = 2 ! number of generators to use integer(rpk), parameter :: m = 2147483647 integer(rpk) :: ai, aa integer :: iol, curgen integer(rpk) :: j integer(rpk), parameter :: num=100000000 real(wp) :: a integer :: timer_init, ntime, time_unit ai = 0 inquire(iolength=iol) ai open(unit=30,file='diehard.dat',action='write',status='replace',& form='unformatted',access='direct',recl=iol) call allocate_rand_pl_multi(ngen) do j = 1, 3*1000**2 curgen = mod(j-1, ngen) + 1 ai = rand_pl_multi(curgen) * m ai = ishft(ai, -1) ai = ishft(ai, 2) aa = rand_pl_multi(curgen) * m ai = ai + iand(aa, 3_rpk) write(30, rec=j) ai end do close(30) call system_clock(count=timer_init, count_rate=time_unit) do j = 1, num curgen = mod(j-1, ngen) + 1 a = rand_pl_multi(curgen) end do call system_clock(count=ntime, count_rate=time_unit) write(0,*) 'time to fetch ', num, ' random numbers:' write(0,*) real(ntime - timer_init) / real(time_unit), ' seconds' write(0,*) 'final deviate: ', a end program diehard_multi_data