    PROGRAM g05qafe

!      G05QAF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : g05kbf, g05qaf, nag_wp
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: lda = 10, m = 4, n = 4, nout = 6
!      .. Local Scalars ..
       INTEGER                         :: i, ifail, igen, j
!      .. Local Arrays ..
       REAL (KIND=nag_wp)              :: a(lda,n), wk(2*n)
       INTEGER                         :: iseed(4)
!      .. Executable Statements ..
       WRITE (nout,*) 'G05QAF Example Program Results'
       WRITE (nout,*)

!      IGEN identifies the stream.
       igen = 1
!      Initialize the seed to a repeatable sequence
       iseed(1) = 1762543
       iseed(2) = 9324783
       iseed(3) = 423446
       iseed(4) = 742355
       CALL g05kbf(igen,iseed)

       ifail = 1

       CALL g05qaf('Right','Initialize',m,n,a,lda,igen,iseed,wk,ifail)

       IF (ifail==0) THEN
          DO i = 1, m
             WRITE (nout,99999) (a(i,j),j=1,n)
          END DO
       ELSE
          WRITE (nout,99998) ifail
       END IF

99999  FORMAT (1X,4F9.3)
99998  FORMAT (1X,' ** G05QAF returned with IFAIL = ',I5)
    END PROGRAM g05qafe
