Program g01agfe

!     G01AGF Example Program Text

!     Mark 26.1 Release. NAG Copyright 2017.

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