Example description
    Program f04amfe

!     F04AMF Example Program Text

!     Mark 26.2 Release. NAG Copyright 2017.

!     .. Use Statements ..
      Use nag_library, Only: f04amf, nag_wp, x02ajf
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: eps
      Integer                          :: i, ifail, ir, lda, ldb, ldqr, ldx,   &
                                          m, n
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: a(:,:), alpha(:), b(:,:), e(:),      &
                                          qr(:,:), r(:), x(:,:), y(:), z(:)
      Integer, Allocatable             :: ipiv(:)
!     .. Executable Statements ..
      Write (nout,*) 'F04AMF Example Program Results'
      Write (nout,*)
!     Skip heading in data file
      Read (nin,*)
      Read (nin,*) m, n
      ir = 1
      lda = m
      ldb = m
      ldqr = m
      ldx = n
      Allocate (a(lda,n),alpha(n),b(ldb,ir),e(n),qr(ldqr,n),r(m),x(ldx,ir),    &
        y(n),z(n),ipiv(n))
      Read (nin,*)(a(i,1:n),b(i,1:ir),i=1,m)
      eps = x02ajf()

!     ifail: behaviour on error exit
!             =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
      ifail = 0
      Call f04amf(a,lda,x,ldx,b,ldb,m,n,ir,eps,qr,ldqr,alpha,e,y,z,r,ipiv,     &
        ifail)

      Write (nout,*) ' Solution'
      Do i = 1, n
        Write (nout,99999) x(i,1:ir)
      End Do

99999 Format (1X,8F9.4)
    End Program f04amfe