    PROGRAM nag_spline_1d_ex03

      ! Example Program Text for nag_spline_1d
      ! NAG fl90, Release 4. NAG Copyright 2000.

      ! .. Use Statements ..
      USE nag_examples_io, ONLY : nag_std_in, nag_std_out
      USE nag_spline_1d, ONLY : nag_spline_1d_comm_wp => nag_spline_1d_comm_dp &
       , nag_spline_1d_interp, nag_spline_1d_eval, nag_deallocate
      ! .. Implicit None Statement ..
      IMPLICIT NONE
      ! .. Intrinsic Functions ..
      INTRINSIC EXP, KIND
      ! .. Parameters ..
      INTEGER, PARAMETER :: wp = KIND(1.0D0)
      ! .. Local Scalars ..
      INTEGER :: i, m, n
      TYPE (nag_spline_1d_comm_wp) :: spline
      ! .. Local Arrays ..
      REAL (wp), ALLOCATABLE :: f(:), s(:), u(:), x(:)
      ! .. Executable Statements ..
      WRITE (nag_std_out,*) 'Example Program Results for nag_spline_1d_ex03'

      READ (nag_std_in,*)          ! Skip heading in data file
      READ (nag_std_in,*) m
      n = 2*m - 1

      ALLOCATE (x(m),f(m),u(n),s(n)) ! Allocate storage

      READ (nag_std_in,*) x
      f = EXP(x)

      ! Construct interpolating spline.

      CALL nag_spline_1d_interp(x,f,spline)

      ! Calculate values of the spline at the x(i)
      ! and at points halfway between them.
      u(1:n:2) = x(1:m)
      u(2:n-1:2) = 0.5_wp*(x(1:m-1)+x(2:m))

      CALL nag_spline_1d_eval(spline,u,s)

      WRITE (nag_std_out,'(/,7X,''x'',11X,''s(x)'')')
      DO i = 1, n
        WRITE (nag_std_out,'(2(3X,E10.4))') u(i), s(i)
      END DO

      DEALLOCATE (x,f,u,s)         ! Deallocate storage

      CALL nag_deallocate(spline)  ! Free structure allocated by NAG fl90

    END PROGRAM nag_spline_1d_ex03
