[問題] 亂數不隨機(已爬文)
不好意思我是fortran新手
爬了文還是搞不太懂QAQ
我照 http://latinboy.pixnet.net/blog/post/23342072
這篇文章的程式碼打
program random_test
implicit none
real*8 :: x(10)
call random_seed()
! call init_random_seed() !<- this line is for GFortran
call random_number(x)
write(*,'(F21.18)') x
end program
SUBROUTINE init_random_seed()
INTEGER :: i, n, clock
INTEGER, ALLOCATABLE :: seed(:)
call RANDOM_SEED(SIZE = n)
ALLOCATE(seed(n))
call SYSTEM_CLOCK(COUNT=clock)
seed = clock - 2047 * (/ (i - 1, i = 1, n) /)
seed = seed * 1103515245 + 2531011
call RANDOM_SEED(PUT = seed)
DEALLOCATE(seed)
END SUBROUTINE
每次執行的亂數還是都一樣
到底要改哪裡呢
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.218.188
→
10/04 12:10, , 1F
10/04 12:10, 1F
→
10/04 12:21, , 2F
10/04 12:21, 2F
→
10/04 12:27, , 3F
10/04 12:27, 3F
→
10/04 12:29, , 4F
10/04 12:29, 4F
→
10/04 13:55, , 5F
10/04 13:55, 5F
→
10/04 13:57, , 6F
10/04 13:57, 6F
→
10/04 14:24, , 7F
10/04 14:24, 7F
→
10/04 14:38, , 8F
10/04 14:38, 8F
→
10/04 14:57, , 9F
10/04 14:57, 9F
→
10/04 14:57, , 10F
10/04 14:57, 10F
→
10/04 15:24, , 11F
10/04 15:24, 11F
→
10/07 18:26, , 12F
10/07 18:26, 12F
Fortran 近期熱門文章
PTT數位生活區 即時熱門文章