Clicky

Fortran Wiki
random_init (changes)

Skip the Navigation Links | Home Page | All Pages | Recently Revised | Authors | Feeds | Export |

Showing changes from revision #1 to #2: (追記) Added (追記ここまで) | (削除) Removed (削除ここまで) | (削除) Chan (削除ここまで)(追記) ged (追記ここまで)

Description

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

Standard

Fortran 2018

Class

Subroutine

Syntax

call random_init(repeatable, image_distinct)

Arguments

  • repeatable - Shall be a scalar with a logical type, and it is intent(in). 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 - Shall be a scalar with a logical type, and it is intent(in). 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_init in another image. If it is .false., the seed is set value that does depend which image called random_init.

Example

program test_random_seed
 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 are the same sequence
 if (any(x /= y)) (削除) call (削除ここまで)(追記) stop (追記ここまで) (削除) abort (削除ここまで)(追記) "x(:) (追記ここまで)(追記) and (追記ここまで)(追記) y(:) (追記ここまで)(追記) not (追記ここまで)(追記) all (追記ここまで)(追記) equal" (追記ここまで)
end program test_random_seed

See also

random_number, random_seed

Revised on April 2, 2021 10:04:01 by Beliavsky? (173.76.111.99) (1609 characters / 0.0 pages)
Edit | Back in time (1 revision) | Hide changes | History | Views: Print | TeX | Source | Linked from: random_number, random_seed

AltStyle によって変換されたページ (->オリジナル) /