list_operations_m Module

Routines operating on lists, like sorting, removing duplicates etc...



Interfaces

public interface rank_list

  • private subroutine i_mrgref(XVALT, IRNGT)

    Ranks array XVALT into index array IRNGT, using merge-sort

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in), Dimension (:) :: XVALT
    integer, intent(out), Dimension (:) :: IRNGT
  • private subroutine fp_mrgref(xvalt, IRNGT)

    Ranks array XVALT into index array IRNGT, using merge-sort

    Arguments

    Type IntentOptional Attributes Name
    real(kind=FP), intent(in), Dimension (:) :: xvalt
    integer, intent(out), Dimension (:) :: IRNGT

Functions

public function findloc_i(arr, val)

Finds first index i where arr(i) = val. Returns 0 if val not found or size of array is 0

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in), dimension(:) :: arr

Array

integer, intent(in) :: val

Value to be searched for

Return Value integer

public function findloc_i(arr, val)

Finds first index i where arr(i) = val. Returns 0 if val not found or size of array is 0

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in), dimension(:) :: arr

Array

integer, intent(in) :: val

Value to be searched for

Return Value integer


Subroutines

public subroutine unique_tuples(ndim, nz, arr)

Removes duplicate entries from integer tuple arr

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ndim

Dimension of tuple

integer, intent(inout) :: nz

Number of tuples, on return number of unique tuples

integer, intent(inout), dimension(ndim, nz) :: arr

Tuples, on return unique tuples (nz adapted)

public subroutine insertion_sort(nz, ndim, decrow, arr)

Sorts integer tuple arr in ascending order according to row decr

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nz

Number of tuples

integer, intent(in) :: ndim

Dimension of tuples

integer, intent(in) :: decrow

Is sorted in ascending order according to row decrow

integer, intent(inout), dimension(ndim, nz) :: arr

Tuples, on return sorted

public subroutine sort_tuples(nz, ndim, precedence, arr)

Sorts integer tuples arr in ascending order, where pecedence of rows in sorting is prescribed

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nz

Number of tuples

integer, intent(in) :: ndim

Dimension of tuples

integer, intent(in), dimension(ndim) :: precedence

Precedence of sorting, i.e. for ndim=2 precedence=[2,1] sorts firstly according to second row

integer, intent(inout), dimension(ndim,nz) :: arr

Tuples, on return sorted

public subroutine findindex_2d(lpi, lpf, li, lj, i, j, lg)

Searches in grid lists (li, lj) if it contains point (i, j) and returns its index in lg. If index cannot be found, returns lg=0 Note: (li, lj) shall be uniqued tuple

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: lpi

Start index of lists li and lj

integer, intent(in) :: lpf

Final index of lists li and lj

integer, intent(in), dimension(lpi:lpf) :: li

Grid list li

integer, intent(in), dimension(lpi:lpf) :: lj

Grid list lj

integer, intent(in) :: i

Integer coordinate i that is looked for in li

integer, intent(in) :: j

Integer coordinate j that is looked for in lj

integer, intent(out) :: lg

If present (i,j)=(li(lg), lj(lg)), if not present lg=0 is returned

public subroutine sort_row(size, col_ind, values)

Simple bubble sort for small arrays. Different from the sort_and_sum function below as it does not include the summed-up part.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: size

Dimension of the arrays

integer, intent(inout) :: col_ind(size)

Column index of the input and the output sorted array

real(kind=FP), intent(inout) :: values(size)

Element value

public subroutine sort_and_sum(nz, j, val)

Uniques and sorts values according to j-ascending ordering Same j-values are summed up in val

Arguments

Type IntentOptional Attributes Name
integer, intent(inout) :: nz

On input: Dimension of j and val On output: Number of unique

integer, intent(inout), dimension(nz) :: j

Integer list, on output uniqued and sorted in ascending order

real(kind=FP), intent(inout), dimension(nz) :: val

Values, on output sorted and summed according to new j-ordering