You can use the same seed: it depends on the processor. The reason for this is because your random_seed call random_seed not set the seed.
With reference
CALL random_seed(i)
argument i not a ( intent(in) ) seed, but ( intent(out) ) is the size of the seed used by the processor. This call is like
CALL random_seed(SIZE=i) ! SIZE is the first dummy argument
To set a seed, you need to explicitly associate a dummy argument with the PUT argument: call random_seed(put=seed) . Here the seed is an array of rank 1 of size at least n , where n - again depends on the processor - this is the size specified by call random_seed(size=n) . From your call i , this value is executed.
Detailed information is given in 13.7.136 F2008.
A general way to generate a generator is:
integer, allocatable :: seed(:) integer size call random_seed(size=size) allocate(seed(size)) ! set seed(:) somehow call random_seed(put=seed)
Setting seed not a simple process. I am not considering how to do this, but the details can be found in the answers to this other question .
The use of srand() mentioned in the comments is non-standard.
francescalus
source share