    PROGRAM g08cjfe

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : g08cjf, nag_wp
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: a2, mu, p
       INTEGER                         :: i, ifail, n
       LOGICAL                         :: issort
!      .. Local Arrays ..
       REAL (KIND=nag_wp), ALLOCATABLE :: x(:), y(:)
!      .. Intrinsic Functions ..
       INTRINSIC                          exp
!      .. Executable Statements ..
       WRITE (nout,*) 'G08CJF Example Program Results'
       WRITE (nout,*)

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

!      Read number of observations and parameter value
       READ (nin,*) n, mu

!      Memory allocation
       ALLOCATE (x(n),y(n))

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

!      PIT
       DO i = 1, n
          y(i) = 1.0E0_nag_wp - exp(-x(i)/mu)
       END DO

!      Let g08cjf sort the uniform variates
       issort = .FALSE.

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

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

    END PROGRAM g08cjfe
