Clicky

Fortran Wiki
random_init (Rev #1, changes)

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

Showing changes from revision #0 to #1: (追記) 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 abort
end program test_random_seed

See also

random_number, random_seed

Revision from July 6, 2018 13:17:56 by Jason Blevins
Forward in time (to current) | See current | History | Rollback | View: Source | Linked from: random_number, random_seed

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