    PROGRAM g07ddfe

!      G07DDF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : g07ddf, nag_wp
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: alpha, propn, tmean, tvar, wmean, wvar
       INTEGER                         :: ifail, k, n
!      .. Local Arrays ..
       REAL (KIND=nag_wp), ALLOCATABLE :: sx(:), x(:)
!      .. Intrinsic Functions ..
       INTRINSIC                          real
!      .. Executable Statements ..
       WRITE (nout,*) 'G07DDF Example Program Results'
       WRITE (nout,*)

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

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

       ALLOCATE (x(n),sx(n))

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

!      Trim data
       ifail = 0
       CALL g07ddf(n,x,alpha,tmean,wmean,tvar,wvar,k,sx,ifail)

!      Calculate proportion of data cut
       propn = real(k,kind=nag_wp)/real(n,kind=nag_wp)
       propn = 100.0E0_nag_wp - 200.0E0_nag_wp*propn

!      Display results
       WRITE (nout,99999) 'Statistics from middle ', propn, '% of data'
       WRITE (nout,*)
       WRITE (nout,99998) '               Trimmed-mean = ', tmean
       WRITE (nout,99998) '   Variance of Trimmed-mean = ', tvar
       WRITE (nout,*)
       WRITE (nout,99998) '            Winsorized-mean = ', wmean
       WRITE (nout,99998) 'Variance of Winsorized-mean = ', wvar

99999  FORMAT (1X,A,F6.2,A)
99998  FORMAT (1X,A,F11.4)
    END PROGRAM g07ddfe
