From 42ca8df692ba005dc7fee6030f9fae14fea1ac4c Mon Sep 17 00:00:00 2001 From: Colin Josey Date: Thu, 1 Oct 2015 14:01:52 -0400 Subject: [PATCH] Removed redundancy in binary search --- src/search.F90 | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/search.F90 b/src/search.F90 index db099946ee..ea11498663 100644 --- a/src/search.F90 +++ b/src/search.F90 @@ -41,10 +41,9 @@ contains do while (R - L > 1) ! Find values at midpoint array_index = L + (R - L)/2 - testval = array(array_index) - if (val >= testval) then + if (val >= array(array_index)) then L = array_index - elseif (val < testval) then + else R = array_index end if @@ -83,10 +82,9 @@ contains do while (R - L > 1) ! Find values at midpoint array_index = L + (R - L)/2 - testval = array(array_index) - if (val >= testval) then + if (val >= array(array_index)) then L = array_index - elseif (val < testval) then + else R = array_index end if @@ -125,10 +123,9 @@ contains do while (R - L > 1) ! Find values at midpoint array_index = L + (R - L)/2 - testval = array(array_index) - if (val >= testval) then + if (val >= array(array_index)) then L = array_index - elseif (val < testval) then + else R = array_index end if