NAG Library Manual, Mark 28.5
```    Program e01safe

!     E01SAF Example Program Text

!     Mark 28.5 Release. NAG Copyright 2022.

!     .. Use Statements ..
Use nag_library, Only: e01saf, e01sbf, nag_wp
!     .. Implicit None Statement ..
Implicit None
!     .. Parameters ..
Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
Real (Kind=nag_wp)               :: hx, hy, xhi, xlo, yhi, ylo
Integer                          :: i, ifail, j, m, nx, ny
!     .. Local Arrays ..
Real (Kind=nag_wp), Allocatable  :: f(:), grads(:,:), pf(:), px(:),      &
py(:), x(:), y(:)
Integer, Allocatable             :: triang(:)
!     .. Intrinsic Procedures ..
Intrinsic                        :: real
!     .. Executable Statements ..
Write (nout,*) 'E01SAF Example Program Results'

!     Skip heading in data file

Do i = 1, m
End Do

!     Generate the triangulation and gradients.

ifail = 0

!     Evaluate the interpolant on a rectangular grid at NX*NY
!     points over the domain (XLO to XHI) x (YLO to YHI).

Allocate (px(nx),py(ny),pf(nx))

hx = (xhi-xlo)/real(nx-1,kind=nag_wp)
px(1) = xlo

Do i = 2, nx
px(i) = px(i-1) + hx
End Do

hy = (yhi-ylo)/real(ny-1,kind=nag_wp)
py(1) = ylo

Do i = 2, ny
py(i) = py(i-1) + hy
End Do

Write (nout,*)
Write (nout,99999) '          X', (px(i),i=1,nx)
Write (nout,*) '     Y'

Do i = ny, 1, -1

Do j = 1, nx

ifail = 0