Program g05kgfe
! G05KGF Example Program Text
! Mark 25 Release. NAG Copyright 2014.
! .. Use Statements ..
Use nag_library, Only: g05kgf, g05saf, nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Integer :: genid, ifail, lstate, n, subid
! .. Local Arrays ..
Real (Kind=nag_wp), Allocatable :: x(:)
Integer, Allocatable :: state(:)
! .. Executable Statements ..
Write (nout,*) 'G05KGF Example Program Results'
Write (nout,*)
! Skip heading in data file
Read (nin,*)
! Read in the base generator information
Read (nin,*) genid, subid
! Initial call to initialiser to get size of STATE array
lstate = 0
Allocate (state(lstate))
ifail = 0
Call g05kgf(genid,subid,state,lstate,ifail)
! Reallocate STATE
Deallocate (state)
Allocate (state(lstate))
! Initialize the generator to a repeatable sequence
ifail = 0
Call g05kgf(genid,subid,state,lstate,ifail)
! Read in sample size
Read (nin,*) n
Allocate (x(n))
! Generate the variates
ifail = 0
Call g05saf(n,state,x,ifail)
! Display the variates
Write (nout,99999) x(1:n)
99999 Format (1X,F10.4)
End Program g05kgfe