Before any random numbers can be selected, a seed must be set using PDA_RNSED. The integer seed should satisfy the relationship
where
is a non-negative integer. A fixed seed gives rise to a
reproducible sequence of pseudo-random numbers.
For a non-repeatable sequence, there is no equivalent to NAG routine G05CCF because the system clock used to create the seed is not accessible portably in Fortran, and PDA is independent of other libraries. However, the following code has the desired effect.
INTEGER SEED, STATUS, TICKS, PID
INCLUDE 'PRM_PAR'
CALL PSX_TIME( TICKS, STATUS )
CALL PSX_GETPID( PID, STATUS )
SEED = TICKS + PID
SEED = MOD( SEED, VAL__MAXI / 4 ) * 4 + 1
SEED = MOD( SEED, 2**28 )
CALL PDA_RNSED( SEED )
PSX_TIME returns the time in units of clock ticks since some
arbitrary time. See SUN/121 for more details and
linking instructions. The above code also permits storage of
the chosen seed.
PDA [1ex