    PROGRAM g08ckfe

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : g08ckf, nag_wp
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: a2, aa2, p, ybar, yvar
       INTEGER                         :: i, ifail, n
       LOGICAL                         :: issort
!      .. Local Arrays ..
       REAL (KIND=nag_wp), ALLOCATABLE :: y(:)
!      .. Executable Statements ..
       WRITE (nout,*) 'G08CKF 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 g08ckf sort the data
       issort = .FALSE.

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

!      Results
       WRITE (nout,'(1X,A,E11.4,1X,A,E11.4)') &
          'H0: data from Normal distribution with mean', ybar, 'and variance', &
          yvar
       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 g08ckfe
