Lahey/Fujitsu Fortran

RANDOM_SEED Subroutine

Description

The RANDOM_SEED subroutine initializes or queries the pseudorandom number generator used by RANDOM_NUMBER.

Syntax

RANDOM_SEED ( {[SIZE=size]|[PUT=put]|[GET=get]} )

Optional Arguments

size is an INTENT(OUT) scalar of type default INTEGER. It is set to the number of default INTEGERs the processor uses to hold the seed. For LF95 this value is one.

put is an INTENT(IN) default INTEGER array of rank one and size greater than or equal to size. It is used by the processor to set the seed value.

get is an INTENT(OUT) default INTEGER array of rank one and size greater than or equal to size. It is set to the current value of the seed.

Remarks

The RANDOM_SEED subroutine can only be called with one or zero arguments.

If an argument is present, the argument's keyword must be used.

If no argument is present, the system generates a seed value and initializes the random number generator.

Example

integer :: seed_size integer,allocatable :: seed(:) call random_seed() ! initialize with system generated seed call random_seed(size=seed_size) ! find out size of seed allocate(seed(seed_size)) call random_seed(get=seed) ! get system generated seed write(*,*) seed ! writes system generated seed seed=314159265 call random_seed(put=seed) ! set current seed call random_seed(get=seed) ! get current seed write(*,*) seed ! writes 314159265 deallocate(seed) ! safe

See Also

RANDOM_NUMBER Subroutine