The routine may be called by the names m01daf or nagf_sort_realvec_rank.
m01daf uses a variant of list-merging, as described on pages 165–166 in Knuth (1973). The routine takes advantage of natural ordering in the data, and uses a simple list insertion in a preparatory pass to generate ordered lists of length at least . The ranking is stable: equal elements preserve their ordering in the input data.
Knuth D E (1973) The Art of Computer Programming (Volume 3) (2nd Edition) Addison–Wesley
1: – Real (Kind=nag_wp) arrayInput
On entry: elements
of rv must contain real values to be ranked.
2: – IntegerInput
On entry: the index of the first element of rv to be ranked.
3: – IntegerInput
On entry: the index of the last element of rv to be ranked.
4: – Character(1)Input
On entry: if , the values will be ranked in ascending (i.e., nondecreasing) order.
If , into descending order.
5: – Integer arrayOutput
On exit: elements
of irank contain the ranks of the corresponding elements of rv. Note that the ranks are in the range m1 to m2: thus, if is the first element in the rank order, is set to m1.
6: – IntegerInput/Output
On entry: ifail must be set to , or to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value or is recommended. If message printing is undesirable, then the value is recommended. Otherwise, the value is recommended. When the value or is used it is essential to test the value of ifail on exit.
On exit: unless the routine detects an error or a warning has been flagged (see Section 6).
6Error Indicators and Warnings
If on entry or , explanatory error messages are output on the current error message unit (as defined by x04aaf).