| 1 |
C Copyright(C) 1999-2020 National Technology & Engineering Solutions |
| 2 |
C of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with |
| 3 |
C NTESS, the U.S. Government retains certain rights in this software. |
| 4 |
C |
| 5 |
C See packages/seacas/LICENSE for details |
| 6 |
|
| 7 |
subroutine hunt(a,n,x,jlo) |
| 8 |
|
| 9 |
C ... find jlo such that a(jlo) .le. x .and. a(jlo+1) .gt. x |
| 10 |
C (if jlo .ne. n) |
| 11 |
|
| 12 |
C Start search at passed in 'jlo' position |
| 13 |
|
| 14 |
DIMENSION a(n) |
| 15 |
|
| 16 |
integer jlo, low, high |
| 17 |
|
| 18 |
if (jlo .lt. 1 .or. jlo .gt. n) jlo = 1 |
| 19 |
|
| 20 |
if (a(jlo) .eq. x) then |
| 21 |
return |
| 22 |
else if (a(1) .ge. x) then |
| 23 |
jlo = 1 |
| 24 |
return |
| 25 |
else if (a(n) .lt. x) then |
| 26 |
jlo = n |
| 27 |
return |
| 28 |
end if |
| 29 |
|
| 30 |
if (a(jlo) .le. x) then |
| 31 |
low = jlo |
| 32 |
high = n-1 |
| 33 |
else |
| 34 |
low = 1 |
| 35 |
high = jlo |
| 36 |
end if |
| 37 |
|
| 38 |
do jlo = low, high |
| 39 |
if (a(jlo) .le. x .and. a(jlo+1) .ge. x) then |
| 40 |
return |
| 41 |
end if |
| 42 |
end do |
| 43 |
C ... should not get here since extremes checked above... |
| 44 |
|
| 45 |
end |