    PROGRAM g08bafe

!      G08BAF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : g08baf, nag_wp
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: pv, pw, v, w
       INTEGER                         :: ifail, itest, n, n1
!      .. Local Arrays ..
       REAL (KIND=nag_wp), ALLOCATABLE :: r(:), x(:)
!      .. Executable Statements ..
       WRITE (nout,*) 'G08BAF Example Program Results'
       WRITE (nout,*)

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

!      Read in problem size and type of test
       READ (nin,*) n, n1, itest

       ALLOCATE (x(n),r(n))

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

!      Display title
       WRITE (nout,*) 'Mood''s test and David''s test'
       WRITE (nout,*)

!      Display input data
       WRITE (nout,*) 'Data values'
       WRITE (nout,*)
       WRITE (nout,*) 'Group 1  '
       WRITE (nout,99999) x(1:n1)
       WRITE (nout,*)
       WRITE (nout,*) 'Group 2  '
       WRITE (nout,99999) x((n1+1):n)

!      Perform test
       ifail = 0
       CALL g08baf(x,n,n1,r,itest,w,v,pw,pv,ifail)

!      Display results
       WRITE (nout,*)
       WRITE (nout,99998) '    Mood''s measure  = ', w, '   Significance = ', &
          pw
       WRITE (nout,99998) '    David''s measure = ', v, '   Significance = ', &
          pv

99999  FORMAT (1X,8F4.0)
99998  FORMAT (1X,A,F8.3,A,F8.4)
    END PROGRAM g08bafe
