NAG Library Manual, Mark 30
Interfaces:  FL   CL   CPP   AD 

NAG FL Interface Introduction
Example description
    Program f04fefe

!     F04FEF Example Program Text

!     Mark 30.0 Release. NAG Copyright 2024.

!     .. Use Statements ..
      Use nag_library, Only: f04fef, nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: vlast
      Integer                          :: ifail, n
      Logical                          :: wantp, wantv
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: p(:), t(:), v(:), work(:), x(:)
!     .. Executable Statements ..
      Write (nout,*) 'F04FEF Example Program Results'
!     Skip heading in data file
      Read (nin,*)
      Read (nin,*) n
      Write (nout,*)

      Allocate (p(n),t(0:n),v(n),work(n-1),x(n))
      Read (nin,*) t(0:n)
      wantp = .True.
      wantv = .True.

!     ifail: behaviour on error exit
!             =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
      ifail = 1
      Call f04fef(n,t,x,wantp,p,wantv,v,vlast,work,ifail)

      If (ifail==0) Then
        Write (nout,*)
        Write (nout,*) 'Solution vector'
        Write (nout,99998) x(1:n)
        If (wantp) Then
          Write (nout,*)
          Write (nout,*) 'Reflection coefficients'
          Write (nout,99998) p(1:n)
        End If
        If (wantv) Then
          Write (nout,*)
          Write (nout,*) 'Mean square prediction errors'
          Write (nout,99998) v(1:n)
        End If
      Else If (ifail>0) Then
        Write (nout,*)
        Write (nout,99999) 'Solution for system of order', ifail
        Write (nout,99998) x(1:ifail)
        If (wantp) Then
          Write (nout,*)
          Write (nout,*) 'Reflection coefficients'
          Write (nout,99998) p(1:ifail)
        End If
        If (wantv) Then
          Write (nout,*)
          Write (nout,*) 'Mean square prediction errors'
          Write (nout,99998) v(1:ifail)
        End If
      Else
        Write (nout,99997) ifail
      End If

99999 Format (1X,A,I5)
99998 Format (1X,5F9.4)
99997 Format (1X,' ** F04FEF returned with IFAIL = ',I5)
    End Program f04fefe