Given two points with two function evaluations, choose the best one (the one closest to the root).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x1 | |||
real(kind=wp), | intent(in) | :: | x2 | |||
real(kind=wp), | intent(in) | :: | f1 | |||
real(kind=wp), | intent(in) | :: | f2 | |||
real(kind=wp), | intent(out) | :: | xbest | |||
real(kind=wp), | intent(out) | :: | fbest |
pure subroutine choose_best(x1,x2,f1,f2,xbest,fbest) implicit none real(wp),intent(in) :: x1,x2 real(wp),intent(in) :: f1,f2 real(wp),intent(out) :: xbest real(wp),intent(out) :: fbest if (abs(f1)<abs(f2)) then xbest = x1 fbest = f1 else xbest = x2 fbest = f2 end if end subroutine choose_best