    MODULE nlin_eqn_ex01_mod

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

    CONTAINS

      FUNCTION f(x)

        ! .. Implicit None Statement ..
        IMPLICIT NONE
        ! .. Intrinsic Functions ..
        INTRINSIC EXP
        ! .. Scalar Arguments ..
        REAL (wp), INTENT (IN) :: x
        ! .. Function Return Value ..
        REAL (wp) :: f
        ! .. Executable Statements ..
        f = EXP(-x) - x

      END FUNCTION f

    END MODULE nlin_eqn_ex01_mod

    PROGRAM nag_nlin_eqn_ex01

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

      ! .. Use Statements ..
      USE nag_examples_io, ONLY : nag_std_out
      USE nag_nlin_eqn, ONLY : nag_nlin_eqn_sol
      USE nlin_eqn_ex01_mod, ONLY : f, wp
      ! .. Implicit None Statement ..
      IMPLICIT NONE
      ! .. Local Scalars ..
      REAL (wp) :: a, b, x
      ! .. Executable Statements ..
      WRITE (nag_std_out,*) 'Example Program Results for nag_nlin_eqn_ex01'

      a = 0.0_wp
      b = 1.0_wp

      ! Find a zero of the function in the interval [a,b]

      CALL nag_nlin_eqn_sol(f,x,a,b)

      WRITE (nag_std_out,'(/,1X,A,F12.5)') 'Zero = ', x

    END PROGRAM nag_nlin_eqn_ex01
