    PROGRAM g05ykfe

!      G05YKF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : g05ykf, g05ylf, nag_wp
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       INTEGER                         :: genid, i, idim, ifail, iskip,        &
                                          ldquas, liref, n
!      .. Local Arrays ..
       REAL (KIND=nag_wp), ALLOCATABLE :: quas(:,:), std(:), xmean(:)
       INTEGER, ALLOCATABLE            :: iref(:)
!      .. Executable Statements ..
       WRITE (nout,*) 'G05YKF Example Program Results'
       WRITE (nout,*)

!      Skip heading in data file
       READ (nin,*)

!      Readin the generator to use
       READ (nin,*) genid

!      Read in problem size
       READ (nin,*) n, idim, iskip

       IF (genid==4) THEN
          liref = 407
       ELSE
          liref = 32*idim + 7
       END IF
       ldquas = n
       ALLOCATE (quas(ldquas,idim),iref(liref),xmean(idim),std(idim))

!      Read in the parameters for the distribution
       READ (nin,*) xmean(1:idim)
       READ (nin,*) std(1:idim)

!      Initialize the generator
       ifail = 0
       CALL g05ylf(genid,idim,iref,liref,iskip,ifail)

!      Generate N values for the normal distribution
       ifail = 0
       CALL g05ykf(xmean,std,n,quas,iref,ifail)

!      Display results
       WRITE (nout,99999) (quas(i,1:idim),i=1,n)

99999  FORMAT (1X,4F10.4)
    END PROGRAM g05ykfe
