FNLMath : Utilities : RNGE32
RNGE32
Retrieves the current table used in the 32-bit Mersenne Twister generator.
Required Arguments
MTABLE — Integer array of length 625 containing the table used in the 32-bit Mersenne Twister generator. (Output)
FORTRAN 90 Interface
Generic: CALL RNGE32 (MTABLE)
Specific: The specific interface name is RNGE32
FORTRAN 77 Interface
Single: CALL RNGE32 (MTABLE)
Description
The values in the table contain the state of the 32-bit Mersenne Twister random number generator. The table can be used by RNSE32 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 RNIN32_INT
USE RNGE32_INT
USE RNSET_INT
USE UMACH_INT
USE RNUN_INT
IMPLICIT NONE
INTEGER I, ISEED, NOUT
INTEGER INIT(4)
DATA INIT/291,564,837,1110/
DATA ISEED/123457/
INTEGER NR
REAL R(5)
INTEGER MTABLE(625)
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(8)
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 RNIN32(INIT)
! SAVE THE STATE OF THE SERIES
CALL RNGE32(MTABLE)
CALL RNUN(R)
CALL WRRRL('SECOND STREAM OUTPUT',1,5,R,1,0, &
FMT, RLABEL, CLABEL)
! RESTORE THE STATE OF THE TABLE
CALL RNSE32(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 RNSE32(MTABLE)
CALL RNUN(R)
CALL WRRRL('FOURTH STREAM OUTPUT',1,5,R,1,0, &
FMT, RLABEL, CLABEL)
END
Output
 
First stream output
0.4347 0.3522 0.0139 0.2091 0.4956
Second stream output
0.2486 0.2226 0.1111 0.9563 0.9846
Third stream output
0.2486 0.2226 0.1111 0.9563 0.9846
Fourth stream output
0.4347 0.3522 0.0139 0.2091 0.4956
Published date: 03/19/2020
Last modified date: 03/19/2020