Program f04mefe

!     F04MEF Example Program Text

!     Mark 25 Release. NAG Copyright 2014.

!     .. Use Statements ..
      Use nag_library, Only: f04mef, nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: v
      Integer                          :: ifail, k, n
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: t(:), work(:), x(:)
!     .. Executable Statements ..
      Write (nout,*) 'F04MEF Example Program Results'
      Write (nout,*)
!     Skip heading in data file
      Read (nin,*)
      Read (nin,*) n
      Allocate (t(0:n),work(n-1),x(n))
      Read (nin,*) t(0: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 f04mef(k,t,x,v,work,ifail)

        Write (nout,*)
        Write (nout,99999) 'Solution for system of order', k
        Write (nout,99998) x(1:k)
        Write (nout,*) 'Mean square prediction error'
        Write (nout,99998) v
      End Do

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