1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
program test_rand
integer,parameter :: seed = 86456
integer :: clockseed
! Avec une graine "figée":
print *, rand(seed), rand(), rand(), rand()
! On aura les mêmes valeurs que ci-dessus en reprenant la même graine:
print *, rand(seed), rand(), rand()
! initialisation de la graine avec l'horloge => résultats différent à chaque exécution du programme
call system_clock(count=clockseed)
write(*,*) "clockseed:",clockseed,
& " rand(clockseed)=",rand(clockseed),
& " rand()=",rand()
end program test_rand |
Partager