    PROGRAM g10cafe

!      G10CAF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : g10caf, nag_wp
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       INTEGER                         :: i, ifail, itype, n
!      .. Local Arrays ..
       REAL (KIND=nag_wp), ALLOCATABLE :: rough0(:), rough1(:), smooth0(:),    &
                                          smooth1(:), y(:)
!      .. Executable Statements ..
       WRITE (nout,*) ' G10CAF Example Program Results'
       WRITE (nout,*)

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

!      Read in the problem size
       READ (nin,*) n

       ALLOCATE (y(n),rough0(n),smooth0(n),rough1(n),smooth1(n))

!      Read in data
       READ (nin,*) y(1:n)

!      Smooth sequence using 3RSSH,twice
       itype = 1
       ifail = 0
       CALL g10caf(itype,n,y,smooth1,rough1,ifail)

!      Smooth sequence using 4253H,twice
       itype = 0
       ifail = 0
       CALL g10caf(itype,n,y,smooth0,rough0,ifail)

!      Display results
       WRITE (nout,*) &
          '                      Using 3RSSH,twice         Using 4253H,twice'
       WRITE (nout,*) &
          ' Index     Data      Smooth        Rough       Smooth       Rough'
       WRITE (nout,99999) (i,y(i),smooth1(i),rough1(i),smooth0(i),rough0(i), &
          i=1,n)

99999  FORMAT (1X,I4,F11.1,4F13.1)
    END PROGRAM g10cafe
