    Program s22bafe

!     S22BAF Example Program Text

!     Mark 24 Release. NAG Copyright 2012.

!     .. Use Statements ..
      Use nag_library, Only: nag_wp, s22baf
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: a, b, m, x
      Integer                          :: ifail, istat_read
!     .. Executable Statements ..
      Write (nout,*) 'S22BAF Example Program Results'

      Read (nin,*)
      Read (nin,*) a, b

      Write (nout,99999) 'a    ', 'b    '
      Write (nout,99998)
      Write (nout,99997) a, b
      Write (nout,99998)
      Write (nout,99994) 'x    ', 'M(a,b,x)  ', 'IFAIL    '
      Write (nout,99995)

readx: Do
        Read (nin,*,Iostat=istat_read) x
        If (istat_read/=0) Exit readx
        ifail = -1
        Call s22baf(a,b,x,m,ifail)
        Write (nout,99996) x, m, ifail
      End Do readx

99999 Format (/2(1X,A14))
99998 Format (2('+--------------'),'+')
99997 Format (2(1X,E13.5,1X))
99996 Format (1X,F10.2,'    ',1X,E13.5,1X,I9)
99995 Format (3('+--------------'),'+')
99994 Format (/3(1X,A14))
    End Program s22bafe
