<Example Program>
Program random_seed_example Implicit None Real x(6), y(6) Integer, Allocatable :: state(:) Integer n Call Random_Seed (Size=n) Allocate (state(n)) Call Random_Seed (Get=state) Call Random_Number (x) Call display (x, 'x') Print *, 'Resetting...' Call Random_Seed (Put=state) Call Random_Number (y) Call display (y, 'y') Contains Subroutine display (a, name) Real, Intent(In) :: a(:) Character(*), Intent(In) :: name Integer i Do i=1, Size (a) Print 1, name, i, a(i) 1 Format(1X, A, '(', I0, ') = ', F6.4) End Do End Subroutine End Program |
|
![]() x(1) = 0.8824 x(2) = 0.6333 x(3) = 0.7272 x(4) = 0.2610 x(5) = 0.5427 x(6) = 0.4555 Resetting... y(1) = 0.8824 y(2) = 0.6333 y(3) = 0.7272 y(4) = 0.2610 y(5) = 0.5427 y(6) = 0.4555 |