Program g05tkfe
! G05TKF Example Program Text
! Mark 26.1 Release. NAG Copyright 2016.
! .. Use Statements ..
Use nag_library, Only: g05kff, g05tkf, nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: lseed = 1, nin = 5, nout = 6
! .. Local Scalars ..
Integer :: genid, i, ifail, lstate, m, n, subid
! .. Local Arrays ..
Real (Kind=nag_wp), Allocatable :: lambda(:)
Integer :: seed(lseed)
Integer, Allocatable :: state(:), x(:)
! .. Executable Statements ..
Write (nout,*) 'G05TKF 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)
! Initial call to initializer to get size 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 sample size
Read (nin,*) n
! Read in the distribution parameters
Read (nin,*) m
Allocate (x(n),lambda(m))
! Read in rest of distribution parameters
Read (nin,*) lambda(1:m)
! Generate N sets of the M variates
Do i = 1, n
ifail = 0
Call g05tkf(m,lambda,state,x,ifail)
! Display the variates
Write (nout,99999) i, x(1:m)
End Do
99999 Format (1X,6(1X,I12))
End Program g05tkfe