Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program check_sum
- implicit none
- integer, parameter :: nmol = 2, ndp = 2, npt = 50000
- real, dimension(npt+ndp,nmol) :: rd
- real, dimension(npt) :: y
- real :: c
- integer :: i, j
- call init_random_seed()
- call random_number(c)
- call random_number(rd)
- do i=1, npt
- y(i) = c*sum(rd(i+ndp,1:nmol))
- end do
- print *, y(10:15)
- y = 0d0
- do j=1,nmol
- do i=1, npt
- y(i) = y(i) + c*rd(i+ndp,j)
- end do
- end do
- print *, y(10:15)
- contains
- subroutine init_random_seed()
- integer :: i, n, clock
- integer, dimension(:), allocatable :: seed
- call random_seed(size = n)
- allocate(seed(n))
- call system_clock(count=clock)
- seed = clock + 37 * (/ (i-1, i=1, n) /)
- call random_seed(put = seed)
- deallocate(seed)
- end subroutine init_random_seed
- end program check_sum
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement