    MODULE quad_1d_ex01_mod

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

    CONTAINS

      FUNCTION f(x)

        ! .. Implicit None Statement ..
        IMPLICIT NONE
        ! .. Intrinsic Functions ..
        INTRINSIC SIN, SIZE, SQRT
        ! .. Array Arguments ..
        REAL (wp), INTENT (IN) :: x(:)
        ! .. Function Return Value ..
        REAL (wp) :: f(SIZE(x))
        ! .. Executable Statements ..
        f = x*SIN(30.0_wp*x)/SQRT(1.0_wp-x*x/(4.0_wp*pi*pi))

      END FUNCTION f

    END MODULE quad_1d_ex01_mod

    PROGRAM nag_quad_1d_ex01

      ! 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_math_constants, ONLY : nag_pi
      USE nag_quad_1d, ONLY : nag_quad_1d_gen
      USE quad_1d_ex01_mod, ONLY : wp, f, pi
      ! .. Implicit None Statement ..
      IMPLICIT NONE
      ! .. Local Scalars ..
      REAL (wp) :: a, b, result
      ! .. Executable Statements ..
      WRITE (nag_std_out,*) 'Example Program Results for nag_quad_1d_ex01'

      pi = nag_pi(0.0_wp)
      a = 0.0_wp
      b = 2.0_wp*pi

      CALL nag_quad_1d_gen(f,a,b,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,F9.5)') &
       'result - approximation to the integral =', result

    END PROGRAM nag_quad_1d_ex01
