    PROGRAM f04mffe

!      F04MFF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

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