NAG Library Manual, Mark 30.1
Interfaces:  FL   CL   CPP   AD 

NAG FL Interface Introduction
Example description
    Program e02dffe

!     E02DFF Example Program Text

!     Mark 30.1 Release. NAG Copyright 2024.

!     .. Use Statements ..
      Use nag_library, Only: e02dff, nag_wp, x04cbf
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: indent = 0, ncols = 80, nin = 5,     &
                                          nout = 6
      Character (1), Parameter         :: chlabel = 'C', diag = 'N',           &
                                          matrix = 'G'
      Character (4), Parameter         :: form = 'F8.3'
!     .. Local Scalars ..
      Integer                          :: ifail, liwrk, lwrk, mx, my, px, py
      Character (48)                   :: title
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: c(:), ff(:), lamda(:), mu(:),        &
                                          wrk(:), x(:), y(:)
      Integer, Allocatable             :: iwrk(:)
      Character (10), Allocatable      :: clabs(:), rlabs(:)
!     .. Intrinsic Procedures ..
      Intrinsic                        :: min
!     .. Executable Statements ..
      Write (nout,*) 'E02DFF Example Program Results'
      Flush (nout)

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

!     Read PX and PY, the number of knots in the X and Y directions.

      Read (nin,*) px, py
      Allocate (lamda(px),mu(py),c((px-4)*(py-4)))

!     Read the knots LAMDA(1) .. LAMDA(PX) and MU(1) .. MU(PY).

      Read (nin,*) lamda(1:px)
      Read (nin,*) mu(1:py)

!     Read C, the bicubic spline coefficients.

      Read (nin,*) c(1:(px-4)*(py-4))

!     Read MX and MY, the number of grid points in the X and Y
!     directions respectively.

      Read (nin,*) mx, my
      lwrk = min(4*mx+px,4*my+py)
      liwrk = mx + px - 4
      Allocate (clabs(mx),rlabs(my),x(mx),y(my),ff(mx*my),wrk(lwrk),           &
        iwrk(liwrk))

!     Read the X and Y co-ordinates defining the evaluation grid.

      Read (nin,*) x(1:mx)
      Read (nin,*) y(1:my)

!     Evaluate the spline at the MX by MY points.

      ifail = 0
      Call e02dff(mx,my,px,py,x,y,lamda,mu,c,ff,wrk,lwrk,iwrk,liwrk,ifail)

!     Generate column and row labels to print the results with.

      Write (clabs(1:mx),99999) x(1:mx)
      Write (rlabs(1:my),99999) y(1:my)

      Write (nout,*)
      Flush (nout)

!     Print the result array.
      title = 'Spline evaluated on X-Y grid (X across, Y down):'
      Call x04cbf(matrix,diag,my,mx,ff,my,form,title,chlabel,rlabs,chlabel,    &
        clabs,ncols,indent,ifail)

99999 Format ((F5.1))
    End Program e02dffe