    Program c05bbfe

!     C05BBF Example Program Text

!     Mark 24 Release. NAG Copyright 2012.

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

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

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

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

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

      Write (nout,*)
      Write (nout,99999)
      Write (nout,*)

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

        If (ioerr<0) Then
          Exit data
        End If

        ifail = -1
        Call c05bbf(branch,offset,z,w,resid,ifail)

        If (ifail<0) Then
          Exit data
        End If

        Write (nout,99998) z, w, resid, ifail
      End Do data

99999 Format (1X,14X,'Z',28X,'W(Z)',18X,'RESID',4X,'IFAIL')
99998 Format (1X,1P,2('(',E13.5,',',E13.5,')',1X),E13.5,1X,I5)
99997 Format (1X,A,I3)
99996 Format (1X,A)
    End Program c05bbfe
