Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Merge branch 'debug'
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Oct 22, 2021
2 parents a08add9 + 8a1d254 commit a36d7e0
Showing 1 changed file with 19 additions and 37 deletions.
56 changes: 19 additions & 37 deletions src/util/util_sort.f90
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,12 @@ module pure subroutine util_sort_dp(arr)
do i = 2, n
tmp = arr(i)
j = i - 1
do while ((j > 1) .and. (arr(j) > tmp))
do while (j >= 1)
if (arr(j) <= tmp) exit
arr(j + 1) = arr(j)
j = j - 1
end do
if ((j == 1) .and. (arr(j) > tmp)) then
arr(j + 1) = arr(j)
j = j - 1
end if
arr(j + 1) = tmp
arr(j + 1) = tmp
end do

return
Expand All @@ -102,7 +99,7 @@ module pure subroutine util_sort_index_dp(arr, ind)
real(DP), dimension(:), intent(in) :: arr
integer(I4B), dimension(:), allocatable, intent(inout) :: ind
! Internals
integer(I4B) :: n, i, j, itmp
integer(I4B) :: n, i, j, jp, itmp

n = size(arr)
if (.not.allocated(ind)) then
Expand All @@ -112,15 +109,12 @@ module pure subroutine util_sort_index_dp(arr, ind)
do i = 2, n
itmp = ind(i)
j = i - 1
do while ((j > 1) .and. (arr(ind(j)) > arr(itmp)))
do while (j >= 1)
if (arr(ind(j)) <= arr(itmp)) exit
ind(j + 1) = ind(j)
j = j - 1
end do
if ((j == 1) .and. (arr(ind(j)) > arr(itmp))) then
ind(j + 1) = ind(j)
j = j - 1
end if
ind(j + 1) = itmp
ind(j + 1) = itmp
end do

return
Expand All @@ -144,15 +138,12 @@ module pure subroutine util_sort_i4b(arr)
do i = 2, n
tmp = arr(i)
j = i - 1
do while ((j > 1) .and. (arr(j) > tmp))
do while (j >= 1)
if (arr(j) <= tmp) exit
arr(j + 1) = arr(j)
j = j - 1
end do
if ((j == 1) .and. (arr(j) > tmp)) then
arr(j + 1) = arr(j)
j = j - 1
end if
arr(j + 1) = tmp
arr(j + 1) = tmp
end do

return
Expand Down Expand Up @@ -182,15 +173,12 @@ module pure subroutine util_sort_index_i4b(arr, ind)
do i = 2, n
itmp = ind(i)
j = i - 1
do while ((j > 1) .and. (arr(ind(j)) > arr(itmp)))
do while (j >= 1)
if (arr(ind(j)) <= arr(itmp)) exit
ind(j + 1) = ind(j)
j = j - 1
end do
if ((j == 1) .and. (arr(ind(j)) > arr(itmp))) then
ind(j + 1) = ind(j)
j = j - 1
end if
ind(j + 1) = itmp
ind(j + 1) = itmp
end do

return
Expand All @@ -214,15 +202,12 @@ module pure subroutine util_sort_sp(arr)
do i = 2, n
tmp = arr(i)
j = i - 1
do while ((j > 1) .and. (arr(j) > tmp))
do while (j >= 1)
if (arr(j) <= tmp) exit
arr(j + 1) = arr(j)
j = j - 1
end do
if ((j == 1) .and. (arr(j) > tmp)) then
arr(j + 1) = arr(j)
j = j - 1
end if
arr(j + 1) = tmp
arr(j + 1) = tmp
end do

return
Expand Down Expand Up @@ -252,15 +237,12 @@ module pure subroutine util_sort_index_sp(arr, ind)
do i = 2, n
itmp = ind(i)
j = i - 1
do while ((j > 1) .and. (arr(ind(j)) > arr(itmp)))
do while (j >= 1)
if (arr(ind(j)) <= arr(itmp)) exit
ind(j + 1) = ind(j)
j = j - 1
end do
if ((j == 1) .and. (arr(ind(j)) > arr(itmp))) then
ind(j + 1) = ind(j)
j = j - 1
end if
ind(j + 1) = itmp
ind(j + 1) = itmp
end do

return
Expand Down

0 comments on commit a36d7e0

Please sign in to comment.