    PROGRAM nag_pch_interp_ex01

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

      ! .. Use Statements ..
      USE nag_examples_io, ONLY : nag_std_in, nag_std_out
      USE nag_pch_interp, ONLY : nag_pch_comm_wp => nag_pch_comm_dp, &
       nag_pch_monot_interp, nag_pch_extract, nag_pch_intg, nag_deallocate
      ! .. Implicit None Statement ..
      IMPLICIT NONE
      ! .. Intrinsic Functions ..
      INTRINSIC KIND
      ! .. Parameters ..
      INTEGER, PARAMETER :: wp = KIND(1.0D0)
      ! .. Local Scalars ..
      INTEGER :: i, m
      REAL (wp) :: integral
      TYPE (nag_pch_comm_wp) :: interp
      ! .. Local Arrays ..
      REAL (wp), POINTER :: comp_d(:), comp_f(:), comp_x(:)
      REAL (wp), ALLOCATABLE :: f(:), x(:)
      ! .. Executable Statements ..
      WRITE (nag_std_out,*) 'Example Program Results for nag_pch_interp_ex01'

      READ (nag_std_in,*)          ! Skip heading in data file
      READ (nag_std_in,*) m

      ALLOCATE (x(m),f(m))         ! Allocate storage

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

      ! Generate monotonicity preserving interpolant.

      CALL nag_pch_monot_interp(x,f,interp)

      ! Extract and output data points, data values and computed
      ! derivatives.

      CALL nag_pch_extract(interp,x=comp_x,f=comp_f,d=comp_d)

      WRITE (nag_std_out,'(/,'' Details of interpolant'',//, 7X,''i'',8X, &
       & ''x(i)'',11X,''f(i)'',11X,''d(i)'')')
      WRITE (nag_std_out,'(I8,3ES15.4)') (i,comp_x(i),comp_f(i),comp_d(i),i=1, &
       m)

      ! Compute integral over interval of definition.

      integral = nag_pch_intg(interp)

      WRITE (nag_std_out,'(/,'' Integral ='',ES15.4)') integral

      DEALLOCATE (x,f,comp_x,comp_f,comp_d) ! Deallocate storage

      NULLIFY (comp_x,comp_f,comp_d)

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

    END PROGRAM nag_pch_interp_ex01
