sort_mod Module


Uses


Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: int_size = 8
integer, public, parameter :: max_merge_stack = int(ceiling(log(real(2., kind=dp)**64)/log(real(1.6180339887, kind=dp))))

Derived Types

type, public ::  run_type

Used to pass state around in a stack among helper functions for the ORD_SORT and SORT_INDEX algorithms

Components

Type Visibility Attributes Name Initial
integer(kind=int_size), public :: base = 0
integer(kind=int_size), public :: len = 0

Functions

public pure elemental function optval(x, default) result(y)

Arguments

Type IntentOptional Attributes Name
logical, intent(in), optional :: x
logical, intent(in) :: default

Return Value logical

public pure function calc_min_run(n) result(min_run)

Returns the minimum length of a run from 32-63 so that N/MIN_RUN is less than or equal to a power of two. See https://svn.python.org/projects/python/trunk/Objects/listsort.txt

Arguments

Type IntentOptional Attributes Name
integer(kind=int_size), intent(in) :: n

Return Value integer(kind=int_size)

public pure function collapse(runs) result(r)

Arguments

Type IntentOptional Attributes Name
type(run_type), intent(in), target :: runs(0:)

Return Value integer(kind=int_size)


Subroutines

public subroutine sort2(n, arr, brr)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n
integer, intent(inout) :: arr(n)
integer, intent(inout) :: brr(n)

public subroutine sort_index(array, index, work, iwork, reverse)

Arguments

Type IntentOptional Attributes Name
integer, intent(inout) :: array(0:)
integer(kind=int_size), intent(out) :: index(0:)
integer, intent(out), optional :: work(0:)
integer(kind=int_size), intent(out), optional :: iwork(0:)
logical, intent(in), optional :: reverse

public pure subroutine insertion_sort(array, index)

Arguments

Type IntentOptional Attributes Name
integer, intent(inout) :: array(0:)
integer(kind=int_size), intent(inout) :: index(0:)

public pure subroutine insert_head(array, index)

Arguments

Type IntentOptional Attributes Name
integer, intent(inout) :: array(0:)
integer(kind=int_size), intent(inout) :: index(0:)

public subroutine merge_sort(array, index, buf, ibuf)

Arguments

Type IntentOptional Attributes Name
integer, intent(inout) :: array(0:)
integer(kind=int_size), intent(inout) :: index(0:)
integer, intent(inout) :: buf(0:)
integer(kind=int_size), intent(inout) :: ibuf(0:)

public pure subroutine merge(array, mid, buf, index, ibuf)

Arguments

Type IntentOptional Attributes Name
integer, intent(inout) :: array(0:)
integer(kind=int_size), intent(in) :: mid
integer, intent(inout) :: buf(0:)
integer(kind=int_size), intent(inout) :: index(0:)
integer(kind=int_size), intent(inout) :: ibuf(0:)

public pure subroutine reverse_segment(array, index)

Arguments

Type IntentOptional Attributes Name
integer, intent(inout) :: array(0:)
integer(kind=int_size), intent(inout) :: index(0:)