    PROGRAM g07dafe

!      G07DAF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : g07daf, nag_wp
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: xmd, xme, xsd
       INTEGER                         :: ifail, n
!      .. Local Arrays ..
       REAL (KIND=nag_wp), ALLOCATABLE :: x(:), y(:)
!      .. Executable Statements ..
       WRITE (nout,*) 'G07DAF Example Program Results'
       WRITE (nout,*)

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

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

       ALLOCATE (x(n),y(n))

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

!      Calculate robust summaries
       ifail = 0
       CALL g07daf(n,x,y,xme,xmd,xsd,ifail)

!      Display results
       WRITE (nout,*) 'Original Data'
       WRITE (nout,99999) x(1:n)
       WRITE (nout,*)
       WRITE (nout,*) 'Sorted Data'
       WRITE (nout,99999) y(1:n)
       WRITE (nout,*)
       WRITE (nout,99998) 'Median                             = ', xme
       WRITE (nout,99998) 'Median absolute deviation          = ', xmd
       WRITE (nout,99998) 'Robust estimate standard deviation = ', xsd

99999  FORMAT (1X,11F7.3)
99998  FORMAT (1X,A,F6.3)
    END PROGRAM g07dafe
