Example description
    Program c05bafe

!     C05BAF Example Program Text

!     Mark 26.2 Release. NAG Copyright 2017.

!     .. Use Statements ..
      Use nag_library, Only: c05baf, nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: w, x
      Integer                          :: branch, ifail, ioerr
      Logical                          :: offset
!     .. Executable Statements ..
      Write (nout,*) 'C05BAF Example Program Results'

!     Skip heading in data file
      Read (nin,*)

      Read (nin,*) branch
      Read (nin,*) offset

      Write (nout,*)
      Write (nout,99998) 'BRANCH = ', branch

      If (offset) Then
        Write (nout,99997) 'OFFSET = .TRUE.'
      Else
        Write (nout,99997) 'OFFSET = .FALSE.'
      End If

      Write (nout,*)
      Write (nout,*) '        X           W(X)     IFAIL'
      Write (nout,*)

data: Do
        Read (nin,*,Iostat=ioerr) x

        If (ioerr<0) Then
          Exit data
        End If

        ifail = -1
        w = c05baf(x,branch,offset,ifail)

        If (ifail<0) Then
          Exit data
        End If

        Write (nout,99999) x, w, ifail
      End Do data

99999 Format (1X,1P,2(1X,E13.5),1X,I5)
99998 Format (1X,A,I3)
99997 Format (1X,A)
    End Program c05bafe