M_orderpack(3f) - general and specialized ranking and sorting routines
This repository is a derivative of ORDERPACK 2.0 from Michel Olagnon that additionally
M_ORDERPACK 2.1 performs both conventional sorting and ranking as well as the rarer specialized ordering tasks such as partial sorting, partial ranking, unique sorting, unique ranking, inverse unique ranking, and more. These partial sort and ranking routines can greatly accelerate many computations when users need only the M largest or smallest elements out of a N-element vector.
All the specialized procedures have a range over which they far outperform a basic sort, and most have a range where they dramatically underperform. If you are not limited by memory requirements or have no issues with runtimes the simplest solution may be just to use SORT(3f) and RANK(3f).
Otherwise, your solution method may very well depend on the size of the input arrays, whether the data is already close to the required order, or how costly it is to create work arrays or an index array.
So, if you want the smallest value in an array call the intrinsic MINVAL(3f), not ORDERVAL(3f).
Authors:
LICENSE:
CC0-1.0
This will compile the Fortran module and basic example programs that exercise the routines:
git clone https://github.com/urbanjost/M_orderpack.git
cd M_orderpack/src
# change Makefile if not using one of the listed compilers
# for gfortran
make clean
make gfortran
# for ifort
make clean
make ifort
# for nvfortran
make clean
make nvfortran
Note that to specifically get release 2.0.0 you would use
git clone --branch 2.0.0 https://github.com/urbanjost/M_orderpack.git
Download the github repository and build it with fpm ( as described at Fortran Package Manager )
git clone https://github.com/urbanjost/M_orderpack.git
cd M_orderpack
fpm build
or just list it as a dependency in your fpm.toml project file.
[dependencies]
M_orderpack = { git = "https://github.com/urbanjost/M_orderpack.git" }
There are man-pages in the repository download in the docs/ directory that may be installed on ULS (Unix-Like Systems).
fpm plugin fpm-m_orderpack(1). If you build the optional program source in app/fpm-m_orderpack.f90.plugin and place it in your search-path then commands like
fpm m_orderpack manual|more
will display the help-text manual for the procedures. For more
information enter
fpm m_orderpack --help