![]() |
Module mergesort_module for merging arrays of rates. More...
Functions/Subroutines | |
subroutine, public | mergesort_init () |
Initialize the mergesort module and open files for debugging. More... | |
subroutine, public | nurate_ms (x, xs, y, ys, r) |
Merges two tables of neutrino rates (of type global_class::nurate_type). More... | |
subroutine, public | rrate_ms (x, xs, y, ys, r, ptz, rate_out) |
Merges two tables of rates (of type global_class::reactionrate_type). More... | |
subroutine, public | rrate_qs_replace (x, xs, y, ys, r, out_array, ptz) |
Wrapper around the quicksort subroutine. More... | |
recursive subroutine, private | qsort (A, nA) |
Modified quicksort algorithm. More... | |
subroutine, public | mergesort_finalize () |
Close files and finalize this module. More... | |
subroutine, public | rrate_sort (num, rate_array) |
Sorts chapter one of the rate array. More... | |
subroutine, public | bubblesort (mode, length, arr1, arr2) |
Bubblesort of array. More... | |
recursive subroutine, public | quicksort (mode, length, arr1, arr2, is_recursion) |
Quicksort of array. More... | |
subroutine, public | reorder (arr1, arr2, length) |
Takes an array and an array with indices to reorder the first array. More... | |
subroutine, public | reorder_int (arr1, arr2, length) |
Takes an array and an array with indices to reorder the first array. More... | |
Variables | |
integer, private | debug_tabl |
File ID for debugging tabulated rate class. More... | |
Module mergesort_module for merging arrays of rates.
A mergesort is a recursive algorithm to sort arrays. It works as illustrated in these two figures (Source: en.wikipedia)
subroutine, public mergesort_module::bubblesort | ( | integer, intent(in) | mode, |
integer, intent(in) | length, | ||
real(r_kind), dimension(:), intent(inout) | arr1, | ||
integer, dimension(:), intent(out), optional | arr2 | ||
) |
Bubblesort of array.
This subroutine performs a bubblesort of an array. See the following illustration (from wikipedia):
The subroutine is able to run in 2 modes,
Furthermore, a second array can be given which will return the indices of the changes within the first array.
[in,out] | arr1 | Array to get sorted |
[out] | arr2 | Indices of the sort |
[in] | length | Length of the arrays |
[in] | mode | 0 descending; 1 ascending |
Definition at line 723 of file mergesort_module.f90.
subroutine, public mergesort_module::mergesort_finalize |
Close files and finalize this module.
This subroutine closes the debug file "debug_tabln.dat"
Edited:
Definition at line 636 of file mergesort_module.f90.
subroutine, public mergesort_module::mergesort_init |
Initialize the mergesort module and open files for debugging.
The file debug_tabln.dat is created in case of verbose_level>2.
Edited:
Definition at line 47 of file mergesort_module.f90.
subroutine, public mergesort_module::nurate_ms | ( | type(nurate_type), dimension(xs), intent(in) | x, |
integer, intent(in) | xs, | ||
type(nurate_type), dimension(ys), intent(in) | y, | ||
integer, intent(in) | ys, | ||
integer, intent(in) | r | ||
) |
Merges two tables of neutrino rates (of type global_class::nurate_type).
Parameter r is a flag with the following meaning:
r mode | Behavior |
---|---|
1 | Values of y replace corresponding values of x |
2 | Values of x replace corresponding values of y |
other | Both values are stored one after the other\ |
Edited:
[in] | xs | Length of x |
[in] | ys | Length of y |
[in] | x | the first nurates table |
[in] | y | the second nurates table |
[in] | r | flag |
Definition at line 87 of file mergesort_module.f90.
|
private |
Modified quicksort algorithm.
A quicksort is a recursive sorting algorithm. An illustration of it is shown in the following (Source en.wikipedia):
In this gif, the red indicated number is the so called pivot-element.
Edited:
[in,out] | a | Reaction rate array |
[in] | na | Length of the investigated reaction rate array. The recursion anchor of the routine is given for nA \(\le =1 \). |
Definition at line 555 of file mergesort_module.f90.
recursive subroutine, public mergesort_module::quicksort | ( | integer, intent(in) | mode, |
integer, intent(in) | length, | ||
real(r_kind), dimension(:), intent(inout) | arr1, | ||
integer, dimension(:), intent(out), optional | arr2, | ||
logical, intent(in), optional | is_recursion | ||
) |
Quicksort of array.
This subroutine performs a quicksort of an array. A quicksort is a recursive sorting algorithm. An illustration of it is shown in the following (Source en.wikipedia):
In this gif, the red indicated number is the so called pivot-element. In contrast to QSort, this subroutine is able to sort an array that is not a derived type and comes in form of an array of doubles. The subroutine is able to run in 2 modes,
Furthermore, a second array can be given which will return the indices of the changes within the first array.
[in,out] | arr1 | Array to get sorted |
[out] | arr2 | Indices of the sort |
[in] | length | Length of the arrays |
[in] | mode | 0 descending; 1 ascending |
[in] | is_recursion | Flag to indicate if the subroutine is called recursively |
Definition at line 809 of file mergesort_module.f90.
subroutine, public mergesort_module::reorder | ( | real(r_kind), dimension(:), intent(inout) | arr1, |
integer, dimension(:), intent(in) | arr2, | ||
integer, intent(in) | length | ||
) |
Takes an array and an array with indices to reorder the first array.
[in,out] | arr1 | Array to reorder |
[in] | arr2 | Array containing the indices |
[in] | length | Length of the arrays |
Definition at line 900 of file mergesort_module.f90.
subroutine, public mergesort_module::reorder_int | ( | integer, dimension(:), intent(inout) | arr1, |
integer, dimension(:), intent(in) | arr2, | ||
integer, intent(in) | length | ||
) |
Takes an array and an array with indices to reorder the first array.
Same as reorder, but for integer arrays.
[in,out] | arr1 | Array to reorder |
[in] | arr2 | Array containing the indices |
[in] | length | Length of the arrays |
Definition at line 931 of file mergesort_module.f90.
subroutine, public mergesort_module::rrate_ms | ( | type(reactionrate_type), dimension(xs), intent(in) | x, |
integer, intent(in) | xs, | ||
type(reactionrate_type), dimension(ys), intent(in) | y, | ||
integer, intent(in) | ys, | ||
integer, intent(in) | r, | ||
integer, intent(out) | ptz, | ||
type(reactionrate_type), dimension(:), intent(out), optional, allocatable | rate_out | ||
) |
Merges two tables of rates (of type global_class::reactionrate_type).
Parameter r is a flag with the following meaning:
r mode | Behavior |
---|---|
1 | Values of y replace corresponding values of x |
2 | Values of x replace corresponding values of y |
other | Both values are stored one after the other\ |
In case of theoretical weak rates that get merged, this function counts the amount of rates that get replaced.
Edited:
[in] | xs | Length of x |
[in] | ys | Length of y |
[in] | x | the first nurates table |
[in] | y | the second nurates table |
[in] | r | flag |
[out] | ptz | length of new (merged) array |
[out] | rate_out | returns the merged |
[out] | rate_out | reactions in this array, if present |
Definition at line 226 of file mergesort_module.f90.
subroutine, public mergesort_module::rrate_qs_replace | ( | type(reactionrate_type), dimension(xs), intent(in) | x, |
integer, intent(in) | xs, | ||
type(reactionrate_type), dimension(ys), intent(in) | y, | ||
integer, intent(in) | ys, | ||
integer, intent(in) | r, | ||
type(reactionrate_type), dimension(:), intent(out), allocatable | out_array, | ||
integer, intent(out) | ptz | ||
) |
Wrapper around the quicksort subroutine.
This subroutine is able to replace rates that appear with multiple entries in the REACLIB (e.g., because it has a resonance) with a tabulated rate. In debug mode, the file debug_tabln.dat is written to debug this subroutine.
Edited:
[in] | ys | replacement rule, lenghts of arrays |
[in] | x | array 1 (rrate) |
[in] | y | array 2 (tabl) |
[out] | out_array | new merged array |
Definition at line 424 of file mergesort_module.f90.
subroutine, public mergesort_module::rrate_sort | ( | integer, intent(in) | num, |
type(reactionrate_type), dimension(num), intent(inout) | rate_array | ||
) |
Sorts chapter one of the rate array.
The sorting is based on the second nucleus in the rate array.
Rate 1: cl34 (Z=17) -> s34 (Z=16) Rate 2: cl36 (Z=17) -> ar36 (Z=18) Rate 3: cl36 (Z=17) -> s36 (Z=16) Rate 4: cl38 (Z=17) -> ar38 (Z=18)
will switch the order of the rates to:
Rate 1: cl34 (Z=17) -> s34 (Z=16) Rate 3: cl36 (Z=17) -> s36 (Z=16) Rate 2: cl36 (Z=17) -> ar36 (Z=18) Rate 4: cl38 (Z=17) -> ar38 (Z=18)
In case the sunet is ordered by proton number.
[in] | num | Number of rates in chapter 1 |
[in,out] | rate_array | Rate array that will get sorted |
Definition at line 675 of file mergesort_module.f90.
|
private |
File ID for debugging tabulated rate class.
Definition at line 20 of file mergesort_module.f90.