Module mrgrnk_mod


Uses:
    module kinds_mod
Variables:
    integer, private, Parameter :: kdp = r8k
Interfaces:
    public interface mrgrnk
Subroutines and functions:
    private subroutine D_mrgrnk (XDONT, IRNGT)
    private subroutine R_mrgrnk (XDONT, IRNGT)
    private subroutine I_mrgrnk (XDONT, IRNGT)
    public subroutine I8_mrgrnk (XDONT, IRNGT)

Ranking of integer and real arrays by merge sort.

In some instances, one is not actually interested in modifying the order of the elements in a set, but only in knowing how to access them in increasing -- or decreasing -- order. Ranking, as it is called, provides the index array I(:) such as the set S(I(:)) is ordered. One of the advantages of carrying out ranking rather than sorting is that the index array can be computed without the performance penalty of moving the elements around when they are of large sizes. A similar point is that the index array can be used to index other data.

This module is taken from ORDERPACK 2.0 -- Unconditional, Unique, and Partial Ranking, Sorting, and Permutation. Michel Olagnon, http://www.fortran-2000.com with small modifications for FD4.


Description of Interfaces

mrgrnk

public interface mrgrnk
    module procedure D_mrgrnk
    module procedure R_mrgrnk
    module procedure I_mrgrnk
    module procedure I8_mrgrnk
end interface mrgrnk
Interfave to the double precision, real, and integer version.

Description of Subroutines and Functions

D_mrgrnk

private subroutine D_mrgrnk (XDONT, IRNGT)
    real (kind=kdp), Dimension (:), Intent (In) :: XDONT
    integer, Dimension (:), Intent (Out) :: IRNGT
end subroutine D_mrgrnk
Parameters:
XDONT input array
IRNGT rank array
Ranking of double precision array.

R_mrgrnk

private subroutine R_mrgrnk (XDONT, IRNGT)
    real, Dimension (:), Intent (In) :: XDONT
    integer, Dimension (:), Intent (Out) :: IRNGT
end subroutine R_mrgrnk
Parameters:
XDONT input array
IRNGT rank array
Ranking of real array.

I_mrgrnk

private subroutine I_mrgrnk (XDONT, IRNGT)
    integer, Dimension (:), Intent (In) :: XDONT
    integer, Dimension (:), Intent (Out) :: IRNGT
end subroutine I_mrgrnk
Parameters:
XDONT input array
IRNGT rank array
Ranking of integer array.

I8_mrgrnk

public subroutine I8_mrgrnk (XDONT, IRNGT)
    integer (kind=i8k), Dimension (:), Intent (In) :: XDONT
    integer, Dimension (:), Intent (Out) :: IRNGT
end subroutine I8_mrgrnk
Parameters:
XDONT input array
IRNGT rank array
Ranking of 8 byte integer array.