I use the following code to initialise me seed (I don't know where I found it, but everyone, absolutely everyone seems to have exactly this! Why? Why 37?)
SUBROUTINE init_random_seed()
IMPLICIT NONE
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
Now why is the argument of PUT an array (of size .ge. n)? I can only find sources that say that that is how it should be, not why.
Aucun commentaire:
Enregistrer un commentaire