Manual Reference Pages  - random_init (3fortran)

NAME

RANDOM_INIT(3) - [MATHEMATICS:RANDOM] Initializes the state of the pseudorandom number generator

SYNOPSIS

call random_init(repeatable, image_distinct)

         logical,intent(in) :: repeatable
         logical,intent(in) :: image_distinct

CHARACTERISTICS

o HARVEST and IMAGE_DISTINCT are logical scalars
Description

Initializes the state of the pseudorandom number generator used by RANDOM_NUMBER.

OPTIONS

REPEATABLE : If it is .TRUE., the seed is set to a processor-dependent value that is the same each time RANDOM_INIT is called from the same image. The term "same image" means a single instance of program execution. The sequence of random numbers is different for repeated execution of the program.

If it is .FALSE., the seed is set to a processor-dependent value.

IMAGE_DISTINCT : If it is .true., the seed is set to a processor-dependent value that is distinct from the seed set by a call to RANDOM_INITin another image. If it is .FALSE., the seed is set to a value that does depend on which image called RANDOM_INIT.

EXAMPLES

Sample program:

        program demo_random_init
        implicit none
        real x(3), y(3)
           call random_init(.true., .true.)
           call random_number(x)
           call random_init(.true., .true.)
           call random_number(y)
           ! x and y should be the same sequence
           if ( any(x /= y) ) stop "x(:) and y(:) are not all equal"
           write(*,*)x
           write(*,*)y
        end program demo_random_init

Results:

RUN 1:

     >   0.825262189      0.191325366      0.155503273   
     >   0.825262189      0.191325366      0.155503273   

RUN 2:

     >   0.825262189      0.191325366      0.155503273   
     >   0.825262189      0.191325366      0.155503273   

STANDARD

Fortran 2018

SEE ALSO

random_number, random_seed

_Fortran intrinsic descriptions


Nemo Release 3.1 random_init (3fortran) November 02, 2024
Generated by manServer 1.08 from 9763cbb1-51c0-4d8b-815f-54215e788414 using man macros.