    PROGRAM c06gcfe

!      C06GCF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : c06ecf, c06gcf, nag_wp
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       INTEGER                         :: ieof, ifail, j, n
!      .. Local Arrays ..
       REAL (KIND=nag_wp), ALLOCATABLE :: x(:), y(:)
!      .. Executable Statements ..
       WRITE (nout,*) 'C06GCF Example Program Results'
!      Skip heading in data file
       READ (nin,*)
LOOP:  DO
          READ (nin,*,IOSTAT=ieof) n
          IF (ieof<0) EXIT LOOP

          ALLOCATE (x(0:n-1),y(0:n-1))
          READ (nin,*) (x(j),y(j),j=0,n-1)

!         ifail: behaviour on error exit   
!                =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
          ifail = 0
          CALL c06gcf(y,n,ifail)

          CALL c06ecf(x,y,n,ifail)
          CALL c06gcf(y,n,ifail)

          WRITE (nout,*)
          WRITE (nout,*) 'Components of inverse discrete Fourier transform'
          WRITE (nout,*)
          WRITE (nout,*) '           Real      Imag'
          WRITE (nout,*)
          WRITE (nout,99999) (j,x(j),y(j),j=0,n-1)
          DEALLOCATE (x,y)
       END DO LOOP

99999  FORMAT (1X,I6,2F10.5)
    END PROGRAM c06gcfe
