p_testrandom.F90 817 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. program testrandom
  2. ! checks random numbers
  3. ! For parallelization
  4. use m_set_random_seed2
  5. implicit none
  6. integer seedsze, i, maxnb
  7. real, allocatable :: putseed(:)
  8. real rand, frac
  9. integer histo(10)
  10. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  11. !Set a variable random seed
  12. call set_random_seed2
  13. maxnb=1000000
  14. ! Remove any randomness in the results for Parallab
  15. ! call random_seed(size=seedsze)
  16. ! allocate(putseed(seedsze))
  17. ! putseed(:)=13
  18. ! call random_seed(put=putseed)
  19. ! deallocate(putseed)
  20. histo=0
  21. do i=1,maxnb
  22. call random_number(rand)
  23. do i=1,10
  24. frac=1./float(i)
  25. if (rand>frac-0.1 .and. rand<frac) histo(i)=histo(i)+1
  26. enddo
  27. ! if (mod(i,100)==0) then
  28. ! print *, rand
  29. ! endif
  30. enddo
  31. print *,histo(:)/float(maxnb)
  32. end program