Example description
!   C05AU_P0W_F Example Program Text
!   Mark 27 Release. NAG Copyright 2019.
    Module c05au_p0w_fe_mod

!     C05AU_P0W_F Example Program Module:
!            Parameters and User-defined Routines

!     .. Use Statements ..
      Use iso_c_binding, Only: c_ptr
      Use nag_library, Only: nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Accessibility Statements ..
      Private
      Public                           :: f
!     .. Parameters ..
      Integer, Parameter, Public       :: nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp), Public, Save :: t
    Contains
      Subroutine f(ad_handle,x,z,iuser,ruser)

!       .. Scalar Arguments ..
        Type (c_ptr), Intent (Inout)   :: ad_handle
        Real (Kind=nag_wp), Intent (In) :: x
        Real (Kind=nag_wp), Intent (Out) :: z
!       .. Array Arguments ..
        Real (Kind=nag_wp), Intent (Inout) :: ruser(*)
        Integer, Intent (Inout)        :: iuser(*)
!       .. Executable Statements ..
        z = x - exp(-t*x)

        Return

      End Subroutine f
    End Module c05au_p0w_fe_mod

    Program c05au_p0w_fe

!     C05AU_P0W_F Example Main Program

!     .. Use Statements ..
      Use c05au_p0w_fe_mod, Only: f, nout, t
      Use iso_c_binding, Only: c_ptr
      Use nagad_library, Only: c05au_p0w_f
      Use nag_library, Only: nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: a, b, eps, eta, h, x
      Type (c_ptr)                     :: ad_handle
      Integer                          :: ifail
!     .. Local Arrays ..
      Real (Kind=nag_wp)               :: ruser(1)
      Integer                          :: iuser(1)
!     .. Executable Statements ..
      Write (nout,*) 'C05AU_P0W_F Example Program Results'

      t = 1.0E0_nag_wp
      x = 1.0E0_nag_wp
      h = 0.1E0_nag_wp
      eps = 1.0E-5_nag_wp
      eta = 0.0E0_nag_wp

      ifail = -1
      Call c05au_p0w_f(ad_handle,x,h,eps,eta,f,a,b,iuser,ruser,ifail)

      Write (nout,*)
      Select Case (ifail)
      Case (0)
        Write (nout,99999) 'Root is ', x
        Write (nout,99998) 'Interval searched is [', a, ',', b,    &
          ']'
      Case (3,4)
        Write (nout,99999) 'Final value = ', x
      Case Default
        Write (nout,99996) 'The routine has failed with ifail = ', ifail
        Go To 100
      End Select

100   Continue


99999 Format (1X,A,F13.5)
99998 Format (1X,A,2(F8.5,A))
99997 Format (1X,A,F26.16)
99996 Format (1X,A,I0)

    End Program c05au_p0w_fe