mardi 24 mai 2016

Why is the Fortran RANDOM_SEED input an array?

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.

  1. Pg.12 of http://ift.tt/20uuass
  2. http://ift.tt/1NITr14
  3. http://ift.tt/20utJi1



Aucun commentaire:

Enregistrer un commentaire