Program f04mffe

!     F04MFF Example Program Text

!     Mark 26.1 Release. NAG Copyright 2016.

!     .. Use Statements ..
      Use nag_library, Only: f04mff, nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: p
      Integer                          :: ifail, k, n
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: b(:), t(:), work(:), x(:)
!     .. Executable Statements ..
      Write (nout,*) 'F04MFF Example Program Results'
      Write (nout,*)
!     Skip heading in data file
      Read (nin,*)
      Read (nin,*) n
      Allocate (b(n),t(0:n-1),work(2*n-1),x(n))
      Read (nin,*) t(0:n-1)
      Read (nin,*) b(1:n)
      Do k = 1, n
!       ifail: behaviour on error exit
!              =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
        ifail = 0
        Call f04mff(k,t,b,x,p,work,ifail)

        Write (nout,*)
        Write (nout,99999) 'Solution for system of order', k
        Write (nout,99998) x(1:k)
        If (k>1) Then
          Write (nout,*) 'Reflection coefficient'
          Write (nout,99998) p
        End If
      End Do

99999 Format (1X,A,I5)
99998 Format (1X,5F9.4)
    End Program f04mffe