Program g05kjfe
! G05KJF Example Program Text
! Mark 30.1 Release. NAG Copyright 2024.
! .. Use Statements ..
Use nag_library, Only: g05kff, g05kjf, g05saf, nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: lseed = 1, nin = 5, nout = 6
! .. Local Scalars ..
Integer :: genid, ifail, lstate, n, nv, subid
! .. Local Arrays ..
Real (Kind=nag_wp), Allocatable :: x(:)
Integer :: seed(lseed)
Integer, Allocatable :: state(:)
! .. Executable Statements ..
Write (nout,*) 'G05KJF Example Program Results'
Write (nout,*)
! Skip heading in data file
Read (nin,*)
! Read in the base generator information and seed
Read (nin,*) genid, subid, seed(1)
! Query G05KFF to get the require length of STATE array
lstate = 0
Allocate (state(lstate))
ifail = 0
Call g05kff(genid,subid,seed,lseed,state,lstate,ifail)
! Reallocate STATE
Deallocate (state)
Allocate (state(lstate))
! Initialize the generator to a repeatable sequence
ifail = 0
Call g05kff(genid,subid,seed,lseed,state,lstate,ifail)
! Read in the skip ahead and sample size
Read (nin,*) n, nv
Allocate (x(nv))
! Advance the sequence N places
ifail = 0
Call g05kjf(n,state,ifail)
! Generate a NV variates from a uniform distribution
ifail = 0
Call g05saf(nv,state,x,ifail)
! Display the variates
Write (nout,99999) x(1:nv)
99999 Format (1X,F10.4)
End Program g05kjfe