Program g05rkfe
! G05RKF Example Program Text
! Mark 29.2 Release. NAG Copyright 2023.
! .. Use Statements ..
Use nag_library, Only: g05kff, g05rkf, nag_wp, x04caf
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: lseed = 1, nin = 5, nout = 6
! .. Local Scalars ..
Real (Kind=nag_wp) :: theta
Integer :: genid, ifail, ldx, lstate, m, n, &
sdx, sorder, subid
! .. Local Arrays ..
Real (Kind=nag_wp), Allocatable :: x(:,:)
Integer :: seed(lseed)
Integer, Allocatable :: state(:)
! .. Executable Statements ..
Write (nout,*) 'G05RKF Example Program Results'
Write (nout,*)
Flush (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, number of dimensions and order
Read (nin,*) n, m, sorder
If (sorder==1) Then
! X(N,M)
ldx = n
sdx = m
Else
! X(M,N)
ldx = m
sdx = n
End If
Allocate (x(ldx,sdx))
! Read in parameter
Read (nin,*) theta
! Generate variates
ifail = 0
Call g05rkf(n,m,theta,sorder,state,x,ldx,sdx,ifail)
! Display the variates
If (sorder==1) Then
! X(N,M)
ifail = 0
Call x04caf('General',' ',n,m,x,ldx, &
'Uniform variates with copula joint distribution',ifail)
Else
! X(M,N)
ifail = 0
Call x04caf('General',' ',m,n,x,ldx, &
'Uniform variates with copula joint distribution',ifail)
End If
End Program g05rkfe