RNGE64
Retrieves the current table used in the 64‑bit Mersenne Twister generator.
Required Arguments
MTABLE — Integer (kind=8) array of length 313 containing the table used in the 64‑bit Mersenne Twister generator. (Output)
FORTRAN 90 Interface
Generic: CALL RNGE64 (MTABLE)
Specific: The specific interface name is RNGE64
FORTRAN 77 Interface
Single: CALL RNGE64 (MTABLE)
Description
The values in the table contain the state of the 64‑bit Mersenne Twister random number generator. The table can be used by RNSE64 to set the generator back to this state.
Example
In this example, four simulation streams are generated. The first series is generated with the seed used for initialization. The second series is generated using an array for initialization. The third series is obtained by resetting the generator back to the state it had at the beginning of the second stream. Therefore, the second and third streams are identical. The fourth stream is obtained by resetting the generator back to its original, uninitialized state, and having it reinitialize using the seed. The first and fourth streams are therefore the same.
USE RNIN64_INT
USE RNGE64_INT
USE RNSET_INT
USE UMACH_INT
USE RNUN_INT
IMPLICIT NONE
INTEGER I, ISEED, NOUT
INTEGER(KIND=8) INIT(4)
DATA INIT/291,564,837,1110/
DATA ISEED/123457/
INTEGER NR
REAL R(5)
INTEGER(KIND=8) MTABLE(313)
CHARACTER CLABEL(5)*5, FMT*8, RLABEL(3)*5
RLABEL(1)='NONE'
CLABEL(1)='NONE'
DATA FMT/'(W10.4)'/
NR=5
CALL UMACH (2, NOUT)
ISEED = 123457
CALL RNOPT(9)
CALL RNSET(ISEED)
CALL RNUN(R)
CALL WRRRL('FIRST STREAM OUTPUT',1,5,R,1,0, &
FMT, RLABEL, CLABEL)
! REINITIALIZE MERSENNE TWISTER SERIES WITH AN ARRAY
CALL RNIN64(INIT)
! SAVE THE STATE OF THE SERIES
CALL RNGE64(MTABLE)
CALL RNUN(R)
CALL WRRRL('SECOND STREAM OUTPUT',1,5,R,1,0, &
FMT, RLABEL, CLABEL)
! RESTORE THE STATE OF THE TABLE
CALL RNSE64(MTABLE)
CALL RNUN(R)
CALL WRRRL('THIRD STREAM OUTPUT',1,5,R,1,0, &
FMT, RLABEL, CLABEL)
! RESET THE SERIES - IT WILL REINITIALIZE FROM THE SEED
MTABLE(1)=1000
CALL RNSE64(MTABLE)
CALL RNUN(R)
CALL WRRRL('FOURTH STREAM OUTPUT',1,5,R,1,0, &
FMT, RLABEL, CLABEL)
END
Output
First stream output
0.5799 0.9401 0.7102 0.1640 0.5457
Second stream output
0.4894 0.7397 0.5725 0.0863 0.7588
Third stream output
0.4894 0.7397 0.5725 0.0863 0.7588
Fourth stream output
0.5799 0.9401 0.7102 0.1640 0.5457