! C05AJF Example Program Text ! Mark 24 Release. NAG Copyright 2012. Module c05ajfe_mod ! C05AJF 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 = exp(-x) - x Return End Function f End Module c05ajfe_mod Program c05ajfe ! C05AJF Example Main Program ! .. Use Statements .. Use nag_library, Only: c05ajf, nag_wp Use c05ajfe_mod, Only: f, nout ! .. Implicit None Statement .. Implicit None ! .. Local Scalars .. Real (Kind=nag_wp) :: eps, eta, x Integer :: ifail, k, nfmax ! .. Executable Statements .. Write (nout,*) 'C05AJF Example Program Results' Write (nout,*) loop: Do k = 3, 4 eps = 10.0E0_nag_wp**(-k) x = 1.0E0_nag_wp eta = 0.0E0_nag_wp nfmax = 200 ifail = -1 Call c05ajf(x,eps,eta,f,nfmax,ifail) Select Case (ifail) Case (0) Write (nout,99999) 'With EPS = ', eps, ' root = ', x Case (:-1) Exit loop Case (3,4) Write (nout,99999) 'With EPS = ', eps, ' final value = ', x End Select End Do loop 99999 Format (1X,A,E10.2,A,F14.5) End Program c05ajfe