    MODULE quad_1d_ex04_mod

      ! .. Implicit None Statement ..
      IMPLICIT NONE
      ! .. Default Accessibility ..
      PUBLIC
      ! .. Intrinsic Functions ..
      INTRINSIC KIND
      ! .. Parameters ..
      INTEGER, PARAMETER :: wp = KIND(1.0D0)

    CONTAINS

      FUNCTION g(x)

        ! .. Implicit None Statement ..
        IMPLICIT NONE
        ! .. Intrinsic Functions ..
        INTRINSIC SIZE
        ! .. Array Arguments ..
        REAL (wp), INTENT (IN) :: x(:)
        ! .. Function Return Value ..
        REAL (wp) :: g(SIZE(x))
        ! .. Executable Statements ..
        g = 1.0_wp/(x*x+0.01_wp*0.01_wp)

      END FUNCTION g

    END MODULE quad_1d_ex04_mod

    PROGRAM nag_quad_1d_ex04

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

      ! .. Use Statements ..
      USE nag_examples_io, ONLY : nag_std_out
      USE nag_quad_1d, ONLY : nag_quad_1d_wt_hilb
      USE quad_1d_ex04_mod, ONLY : wp, g
      ! .. Implicit None Statement ..
      IMPLICIT NONE
      ! .. Local Scalars ..
      REAL (wp) :: a, b, c, result
      ! .. Executable Statements ..
      WRITE (nag_std_out,*) 'Example Program Results for nag_quad_1d_ex04'

      a = -1.0_wp
      b = 1.0_wp
      c = 0.5_wp

      CALL nag_quad_1d_wt_hilb(g,a,b,c,result)

      WRITE (nag_std_out,'(/,1X,A,F10.4)') &
       'a  - lower limit of integration = ', a
      WRITE (nag_std_out,'(1X,A,F10.4)') 'b  - upper limit of integration = ', b
      WRITE (nag_std_out,'(1X,A,F10.4)') &
       'c  - parameter in the weight function = ', c
      WRITE (nag_std_out,'(1X,A,F12.3)') &
       'result - approximation to the integral =', result

    END PROGRAM nag_quad_1d_ex04
