    PROGRAM c06ekfe

!      C06EKF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : c06ekf, 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 :: xa(:), xb(:), ya(:), yb(:)
!      .. Executable Statements ..
       WRITE (nout,*) 'C06EKF Example Program Results'
!      Skip heading in data file
       READ (nin,*)
LOOP:  DO
          READ (nin,*,IOSTAT=ieof) n
          IF (ieof<0) EXIT LOOP
          ALLOCATE (xa(0:n-1),xb(0:n-1),ya(0:n-1),yb(0:n-1))
          READ (nin,*) (xa(j),ya(j),j=0,n-1)
          xb(0:n-1) = xa(0:n-1)
          yb(0:n-1) = ya(0:n-1)

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

          CALL c06ekf(2,xb,yb,n,ifail)

          WRITE (nout,*)
          WRITE (nout,*) '        Convolution  Correlation'
          WRITE (nout,*)
          WRITE (nout,99999) (j,xa(j),xb(j),j=0,n-1)
          DEALLOCATE (xa,xb,ya,yb)
       END DO LOOP

99999  FORMAT (1X,I5,2F13.5)
    END PROGRAM c06ekfe
