Program g01asfe

!     G01ASF Example Program Text

!     Mark 26.1 Release. NAG Copyright 2016.

!     .. Use Statements ..
      Use nag_library, Only: g01asf, nag_wp, x04abf
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: iset = 1, nin = 5, nout = 6
!     .. Local Scalars ..
      Integer                          :: ifail, j, ldplot, ldx, m, nstepx,    &
                                          nstepy, outchn
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: fivept(:), x(:,:)
      Integer, Allocatable             :: iwork(:), n(:)
      Character (1), Allocatable       :: plot(:,:)
!     .. Intrinsic Procedures ..
      Intrinsic                        :: maxval
!     .. Executable Statements ..
      Write (nout,*) 'G01ASF Example Program Results'
      Write (nout,*)
      Flush (nout)

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

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

      ldplot = nstepy
      Allocate (n(m))

!     Read in number of observations in each batch
      Read (nin,*) n(1:m)

      ldx = maxval(n(1:m))
      Allocate (iwork(ldx),x(ldx,m),fivept(5*m),plot(ldplot,nstepx))

!     Read in data
      Read (nin,*)(x(1:n(j),j),j=1,m)

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

!     Produce the plot
      ifail = 0
      Call g01asf('Print',m,n,x,ldx,nstepx,nstepy,plot,ldplot,fivept,iwork,    &
        ifail)

    End Program g01asfe