PROGRAM g08aafe

!      G08AAF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : g08aaf, nag_wp
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: nin = 5, nout = 6
!      .. Local Scalars ..
       REAL (KIND=nag_wp)              :: p
       INTEGER                         :: ifail, isgn, n, n1
!      .. Local Arrays ..
       REAL (KIND=nag_wp), ALLOCATABLE :: x(:), y(:)
!      .. Executable Statements ..
       WRITE (nout,*) 'G08AAF 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)
       READ (nin,*) y(1:n)

!      Display title
       WRITE (nout,*) 'Sign test'
       WRITE (nout,*)

!      Display input data
       WRITE (nout,*) 'Data values'
       WRITE (nout,*)
       WRITE (nout,99999) x(1:n)
       WRITE (nout,99999) y(1:n)

!      Perform the sign test
       ifail = 0
       CALL g08aaf(x,y,n,isgn,n1,p,ifail)

!      Display results
       WRITE (nout,*)
       WRITE (nout,99998) 'Test statistic   ', isgn
       WRITE (nout,99998) 'Observations     ', n1
       WRITE (nout,99997) 'Lower tail prob.', p

99999  FORMAT (4X,20F3.0)
99998  FORMAT (1X,A,I5)
99997  FORMAT (1X,A,F6.3)
    END PROGRAM g08aafe