dbcsr_array_sort Module

Routine for sorting an array

Note

CP2K: Please use the interface defined in util.F for calling sort(). DBCSR: Please use the interface defined in dbcsr_toollib.F for calling sort().



Variables

Type Visibility Attributes Name Initial
logical, private, parameter :: debug_this_module = .FALSE.
character(len=*), private, parameter :: moduleN = 'dbcsr_array_sort'

Subroutines

public subroutine dbcsr_1d_d_sort(arr, n, indices)

Sorts an array inplace using a combination of merge- and bubble-sort. It also returns the indices, which the elements had before the sort.

Arguments

Type IntentOptional Attributes Name
real(kind=real_8), intent(inout), dimension(1:n) :: arr

the array to sort

integer, intent(in) :: n

length of array

integer, intent(out), dimension(1:n) :: indices

returns elements-indices before the sort

private recursive subroutine dbcsr_1d_d_sort_low(arr, indices, tmp_arr, tmp_idx)

The actual sort routine. Only dbcsr_1d_d_sort and itself should call this.

Arguments

Type IntentOptional Attributes Name
real(kind=real_8), intent(inout), dimension(:) :: arr

the array to sort

integer, intent(inout), dimension(size(arr)) :: indices

elements-indices before the sort

real(kind=real_8), intent(inout), dimension((size(arr) + 1)/2) :: tmp_arr

scratch space

integer, intent(inout), dimension((size(arr) + 1)/2) :: tmp_idx

scratch space

public subroutine dbcsr_1d_s_sort(arr, n, indices)

Sorts an array inplace using a combination of merge- and bubble-sort. It also returns the indices, which the elements had before the sort.

Arguments

Type IntentOptional Attributes Name
real(kind=real_4), intent(inout), dimension(1:n) :: arr

the array to sort

integer, intent(in) :: n

length of array

integer, intent(out), dimension(1:n) :: indices

returns elements-indices before the sort

private recursive subroutine dbcsr_1d_s_sort_low(arr, indices, tmp_arr, tmp_idx)

The actual sort routine. Only dbcsr_1d_s_sort and itself should call this.

Arguments

Type IntentOptional Attributes Name
real(kind=real_4), intent(inout), dimension(:) :: arr

the array to sort

integer, intent(inout), dimension(size(arr)) :: indices

elements-indices before the sort

real(kind=real_4), intent(inout), dimension((size(arr) + 1)/2) :: tmp_arr

scratch space

integer, intent(inout), dimension((size(arr) + 1)/2) :: tmp_idx

scratch space

public subroutine dbcsr_1d_i4_sort(arr, n, indices)

Sorts an array inplace using a combination of merge- and bubble-sort. It also returns the indices, which the elements had before the sort.

Arguments

Type IntentOptional Attributes Name
integer(kind=int_4), intent(inout), dimension(1:n) :: arr

the array to sort

integer, intent(in) :: n

length of array

integer, intent(out), dimension(1:n) :: indices

returns elements-indices before the sort

private recursive subroutine dbcsr_1d_i4_sort_low(arr, indices, tmp_arr, tmp_idx)

The actual sort routine. Only dbcsr_1d_i4_sort and itself should call this.

Arguments

Type IntentOptional Attributes Name
integer(kind=int_4), intent(inout), dimension(:) :: arr

the array to sort

integer, intent(inout), dimension(size(arr)) :: indices

elements-indices before the sort

integer(kind=int_4), intent(inout), dimension((size(arr) + 1)/2) :: tmp_arr

scratch space

integer, intent(inout), dimension((size(arr) + 1)/2) :: tmp_idx

scratch space

public subroutine dbcsr_1d_i8_sort(arr, n, indices)

Sorts an array inplace using a combination of merge- and bubble-sort. It also returns the indices, which the elements had before the sort.

Arguments

Type IntentOptional Attributes Name
integer(kind=int_8), intent(inout), dimension(1:n) :: arr

the array to sort

integer, intent(in) :: n

length of array

integer, intent(out), dimension(1:n) :: indices

returns elements-indices before the sort

private recursive subroutine dbcsr_1d_i8_sort_low(arr, indices, tmp_arr, tmp_idx)

The actual sort routine. Only dbcsr_1d_i8_sort and itself should call this.

Arguments

Type IntentOptional Attributes Name
integer(kind=int_8), intent(inout), dimension(:) :: arr

the array to sort

integer, intent(inout), dimension(size(arr)) :: indices

elements-indices before the sort

integer(kind=int_8), intent(inout), dimension((size(arr) + 1)/2) :: tmp_arr

scratch space

integer, intent(inout), dimension((size(arr) + 1)/2) :: tmp_idx

scratch space