mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Added check for too many iterations in binary_search.
This commit is contained in:
parent
f4111ec63c
commit
44012b9b9d
1 changed files with 11 additions and 0 deletions
|
|
@ -4,6 +4,8 @@ module search
|
|||
use error, only: fatal_error
|
||||
use global, only: message
|
||||
|
||||
integer, parameter :: MAX_ITERATION = 64
|
||||
|
||||
contains
|
||||
|
||||
!===============================================================================
|
||||
|
|
@ -20,6 +22,7 @@ contains
|
|||
|
||||
integer :: L
|
||||
integer :: R
|
||||
integer :: n_iteration
|
||||
real(8) :: testval
|
||||
|
||||
L = 1
|
||||
|
|
@ -30,6 +33,7 @@ contains
|
|||
call fatal_error()
|
||||
end if
|
||||
|
||||
n_iteration = 0
|
||||
do while (R - L > 1)
|
||||
|
||||
! Check boundaries
|
||||
|
|
@ -49,6 +53,13 @@ contains
|
|||
elseif (val < testval) then
|
||||
R = array_index
|
||||
end if
|
||||
|
||||
! check for large number of iterations
|
||||
n_iteration = n_iteration + 1
|
||||
if (n_iteration == MAX_ITERATION) then
|
||||
message = "Reached maximum number of iterations on binary search."
|
||||
call fatal_error()
|
||||
end if
|
||||
end do
|
||||
|
||||
array_index = L
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue