    Program g01kafe

!     G01KAF Example Program Text

!     Mark 24 Release. NAG Copyright 2012.

!     .. Use Statements ..
      Use nag_library, Only: g01kaf, nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: f, x, xmean, xstd
      Integer                          :: ifail
!     .. Executable Statements ..
      Write (nout,*) 'G01KAF Example Program Results'
      Write (nout,*)

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

!     Display titles
      Write (nout,*) '   X             MEAN          STANDARD      RESULT '
      Write (nout,*) '                               DEVIATION'
      Write (nout,*)

d_lp: Do
        Read (nin,*,Iostat=ifail) x, xmean, xstd
        If (ifail/=0) Then
          Exit d_lp
        End If

        ifail = 0
        f = g01kaf(x,xmean,xstd,ifail)

!       Display results
        Write (nout,99999) x, xmean, xstd, f
      End Do d_lp

99999 Format (1X,1P,4(1X,E13.5))
    End Program g01kafe
