! C05AGF Example Program Text ! Mark 24 Release. NAG Copyright 2012. Module c05agfe_mod ! C05AGF Example Program Module: ! Parameters and User-defined Routines ! .. Use Statements .. Use nag_library, Only: nag_wp ! .. Implicit None Statement .. Implicit None ! .. Parameters .. Integer, Parameter :: nout = 6 Contains Function f(x) ! .. Function Return Value .. Real (Kind=nag_wp) :: f ! .. Scalar Arguments .. Real (Kind=nag_wp), Intent (In) :: x ! .. Intrinsic Procedures .. Intrinsic :: exp ! .. Executable Statements .. f = x - exp(-x) Return End Function f End Module c05agfe_mod Program c05agfe ! C05AGF Example Main Program ! .. Use Statements .. Use nag_library, Only: c05agf, nag_wp Use c05agfe_mod, Only: f, nout ! .. Implicit None Statement .. Implicit None ! .. Local Scalars .. Real (Kind=nag_wp) :: a, b, eps, eta, h, x Integer :: ifail ! .. Executable Statements .. Write (nout,*) 'C05AGF Example Program Results' x = 1.0E0_nag_wp h = 0.1E0_nag_wp eps = 1.0E-5_nag_wp eta = 0.0E0_nag_wp ifail = -1 Call c05agf(x,h,eps,eta,f,a,b,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 End Select 99999 Format (1X,A,F13.5) 99998 Format (1X,A,2(F8.5,A)) End Program c05agfe