    PROGRAM f01qjfe

!      F01QJF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : f01qjf, nag_wp, x04cbf
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       INTEGER                         :: i, ifail, lda, m, n
!      .. Local Arrays ..
       REAL (KIND=nag_wp), ALLOCATABLE :: a(:,:), zeta(:)
       CHARACTER (1)                   :: dummy(1)
!      .. Executable Statements ..
       WRITE (nout,*) 'F01QJF Example Program Results'
       WRITE (nout,*)
!      Skip heading in data file
       READ (nin,*)
       READ (nin,*) m, n
       lda = n
       ALLOCATE (a(lda,n),zeta(m))
       READ (nin,*) (a(i,1:n),i=1,m)

!      ifail: behaviour on error exit
!             =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
       ifail = 0
!      Find the RQ factorization of A
       CALL f01qjf(m,n,a,lda,zeta,ifail)

       WRITE (nout,*) 'RQ factorization of A'
       WRITE (nout,*)
       WRITE (nout,*) 'Vector ZETA'
       WRITE (nout,99999) zeta(1:m)
       WRITE (nout,*)
       FLUSH (nout)
       CALL x04cbf('G',' ',m,n,a,lda,'F8.4', &
          'Matrix A after factorization (R is in left-hand upper triangle)', &
          'N',dummy,'N',dummy,80,0,ifail)

99999  FORMAT (5(1X,F8.4))
    END PROGRAM f01qjfe
