    Program f01qjfe

!     F01QJF Example Program Text

!     Mark 24 Release. NAG Copyright 2012.

!     .. 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
