Program g08aafe

!     G08AAF Example Program Text

!     Mark 26.1 Release. NAG Copyright 2016.

!     .. 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