    Program c06gbfe

!     C06GBF Example Program Text

!     Mark 24 Release. NAG Copyright 2012.

!     .. Use Statements ..
      Use nag_library, Only: c06eaf, c06gbf, c06gsf, nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Integer                          :: ieof, ifail, j, m, n
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: a(:), b(:), x(:)
!     .. Executable Statements ..
      Write (nout,*) 'C06GBF Example Program Results'
!     Skip heading in data file
      Read (nin,*)
loop: Do
        Read (nin,*,Iostat=ieof) n
        If (ieof<0) Exit loop

        Allocate (a(0:n-1),b(0:n-1),x(0:n-1))
        Read (nin,*) x(0:n-1)

!       ifail: behaviour on error exit   
!              =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
        ifail = 0
        Call c06eaf(x,n,ifail)

        Call c06gbf(x,n,ifail)

        Write (nout,*)
        Write (nout,*) 'Components of inverse discrete Fourier transform'
        Write (nout,*)
        Write (nout,*) '           Real      Imag'
        Write (nout,*)

!       Convert x to separated real and imaginary parts for printing.
        ifail = 0
        m = 1
        Call c06gsf(m,n,x,a,b,ifail)
        Write (nout,99999)(j,a(j),b(j),j=0,n-1)
        Deallocate (a,b,x)
      End Do loop

99999 Format (1X,I6,2F10.5)
    End Program c06gbfe
