    PROGRAM g08clfe

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : g08clf, nag_wp
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: a2, aa2, p, ybar
       INTEGER                         :: i, ifail, n
       LOGICAL                         :: issort
!      .. Local Arrays ..
       REAL (KIND=nag_wp), ALLOCATABLE :: y(:)
!      .. Executable Statements ..
       WRITE (nout,*) 'G08CLF Example Program Results'
       WRITE (nout,*)

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

!      Read number of observations
       READ (nin,*) n

!      Memory allocation
       ALLOCATE (y(n))

!      Read observations
       READ (nin,*) (y(i),i=1,n)

!      Let g08clf sort the data
       issort = .FALSE.

!      Calculate A-squared and probability
       ifail = 0
       CALL g08clf(n,issort,y,ybar,a2,aa2,p,ifail)

!      Results
       WRITE (nout,'(1X,A,E11.4)') &
          'H0: data from exponential distribution with mean', ybar
       WRITE (nout,'(1X,A,1X,F8.4)') 'Test statistic, A-squared: ', a2
       WRITE (nout,'(1X,A,1X,F8.4)') 'Adjusted A-squared:        ', aa2
       WRITE (nout,'(1X,A,1X,F8.4)') 'Upper tail probability:    ', p

    END PROGRAM g08clfe
