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

    CONTAINS

      SUBROUTINE fun(x,f,g)
        ! .. Implicit None Statement ..
        IMPLICIT NONE
        ! .. Intrinsic Functions ..
        INTRINSIC SIN
        ! .. Scalar Arguments ..
        REAL (wp), INTENT (OUT) :: f
        REAL (wp), OPTIONAL, INTENT (OUT) :: g
        REAL (wp), INTENT (IN) :: x
        ! .. Executable Statements ..

        f = SIN(x)/x
      END SUBROUTINE fun
    END MODULE uv_min_ex03_mod

    PROGRAM nag_uv_min_ex03

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

      ! .. Use Statements ..
      USE nag_examples_io, ONLY : nag_std_out
      USE nag_uv_min, ONLY : nag_uv_min_sol
      USE uv_min_ex03_mod, ONLY : fun, wp
      ! .. Implicit None Statement ..
      IMPLICIT NONE
      ! .. Local Scalars ..
      INTEGER :: num_fun_eval
      REAL (wp) :: a, b, f, fa, fb, x
      ! .. Executable Statements ..
      WRITE (nag_std_out,*) 'Example Program Results for nag_uv_min_ex03'

      ! Find the minimum of fun in the interval [a,b], without derivatives

      a = 3.5_wp
      b = 5.0_wp

      CALL fun(a,fa)
      CALL fun(b,fb)
      WRITE (nag_std_out,'(/,A,''['',F8.5,'','',F8.5,'']'')') &
       ' Original interval is ', a, b
      WRITE (nag_std_out,'(''  f('',F4.2,'') = '',1PE12.5)') a, fa
      WRITE (nag_std_out,'(''  f('',F4.2,'') = '',1PE12.5)') b, fb

      CALL nag_uv_min_sol(fun,a,b,x,f,use_deriv=.FALSE., &
       num_fun_eval=num_fun_eval)

      WRITE (nag_std_out,'(/,A)') ' Minimization without derivatives:'
      WRITE (nag_std_out,'(A,1PE12.5)') &
       '  Estimated minimum located at x  . . = ', x
      WRITE (nag_std_out,'(A,1PE12.5)') &
       '  The function value at the above x . = ', f
      WRITE (nag_std_out,'(A,1PE12.5)') &
       '  Length of the final interval  (b-a) = ', b - a
      WRITE (nag_std_out,'(A,I3)') '  No of function calls  . . . . . . . = ', &
       num_fun_eval
    END PROGRAM nag_uv_min_ex03
