    PROGRAM g01agfe

!      G01AGF Example Program Text

!      Mark 23 Release. NAG Copyright 2011.

!      .. Use Statements ..
       USE nag_library, ONLY : g01agf, nag_wp, x04abf
!      .. Implicit None Statement ..
       IMPLICIT NONE
!      .. Parameters ..
       INTEGER, PARAMETER              :: iset = 1, nin = 5, nout = 6
!      .. Local Scalars ..
       INTEGER                         :: i, ifail, nobs, nstepx, nstepy, outchn
       CHARACTER (80)                  :: title
!      .. Local Arrays ..
       REAL (KIND=nag_wp), ALLOCATABLE :: x(:), y(:)
       INTEGER, ALLOCATABLE            :: isort(:)
!      .. Intrinsic Functions ..
       INTRINSIC                          len_trim
!      .. Executable Statements ..
       WRITE (nout,*) 'G01AGF Example Program Results'
       WRITE (nout,*)

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

!      Read in the problem size
       READ (nin,*) nobs, nstepx, nstepy

       ALLOCATE (x(nobs),y(nobs),isort(nobs))

!      Read in data
       READ (nin,*) (x(i),y(i),i=1,nobs)

!      Read in the title
       READ (nin,99999) title

!      Set advisory channel
       outchn = nout
       CALL x04abf(iset,outchn)

!      Display title
       WRITE (nout,*) title(1:len_trim(title))
       WRITE (nout,*)
       FLUSH (nout)

!      Produce the plot
       ifail = 0
       CALL g01agf(x,y,nobs,isort,nstepx,nstepy,ifail)

99999  FORMAT (A80)
    END PROGRAM g01agfe
