libSUFR
a LIBrary of Some Useful Fortran Routines
All Classes Namespaces Files Functions Variables Pages
sufr_sorting Module Reference

Procedures for sorting. More...

Functions/Subroutines

subroutine sorted_index_list (array, index_list, mask, index_n)
 Return a list of indices index_list that sorts the members of array to ascending value, using a Quicksort algorithm.
 
subroutine sort_array (array)
 Sort an array to ascending value.
 
subroutine sort_array_sp (array)
 Sort an array to ascending value - single-precision wrapper for sort_array.
 
subroutine sort_string_array (narr, strlen, strarr, index_list)
 Sort strings alphabetically.
 

Detailed Description

Procedures for sorting.

Function/Subroutine Documentation

◆ sort_array()

subroutine sufr_sorting::sort_array ( real(double), dimension(:), intent(inout) array)

Sort an array to ascending value.

Parameters
arrayInput: array to be sorted, output: sorted array (double)
Note
Uses sorted_index_list()

Definition at line 203 of file sorting.f90.

References sufr_kinds::double, and sorted_index_list().

Here is the call graph for this function:

◆ sort_array_sp()

subroutine sufr_sorting::sort_array_sp ( real, dimension(:), intent(inout) array)

Sort an array to ascending value - single-precision wrapper for sort_array.

Parameters
arrayInput: array to be sorted, output: sorted array (double)
Todo
Check whether array = array(index_list) works

Definition at line 228 of file sorting.f90.

References sorted_index_list().

Here is the call graph for this function:

◆ sort_string_array()

subroutine sufr_sorting::sort_string_array ( integer, intent(in) narr,
integer, intent(in) strlen,
character, dimension(strlen), intent(in) strarr,
integer, dimension(narr), intent(out) index_list )

Sort strings alphabetically.

Parameters
narrNumber of strings in array str
strlenLength of the strings in array str
strarrArray of n strings with length len
index_listSorting index (output)

Definition at line 252 of file sorting.f90.

References sorted_index_list().

Here is the call graph for this function:

◆ sorted_index_list()

subroutine sufr_sorting::sorted_index_list ( real(double), dimension(:), intent(in) array,
integer, dimension(:), intent(out) index_list,
logical, dimension(:), intent(in), optional mask,
integer, intent(out), optional index_n )

Return a list of indices index_list that sorts the members of array to ascending value, using a Quicksort algorithm.

Parameters
arrayArray of size n with values that must be sorted - use dble(array) for other variable types
index_listList with indices of array values, sorted to ascending value, same dimension and size as array. (output) array(index_list) gives the sorted array.
maskMask to apply to array. If present, index_list will have zeroes after the last meaningful entry (optional)
index_nNumber of meaningful elements in index_list, after applying mask (output, optional)
Note
This routine does not need to be called directly, but is implicitly called by sort_array().
See also
Numerical Recipes in Fortran 77, Sect. 8.2, 8.4.

Definition at line 44 of file sorting.f90.

References sufr_kinds::double, and sufr_system::quit_program_error().

Referenced by sufr_statistics::median(), sufr_statistics::prob_range(), sufr_statistics::prob_range_sp(), sort_array(), sort_array_sp(), and sort_string_array().

Here is the call graph for this function: