The routine may be called by the names m01dcf or nagf_sort_charvec_rank.
m01dcf 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.
Only the substring (l1:l2) of each element of the array ch is used to determine the rank order.
Knuth D E (1973) The Art of Computer Programming (Volume 3) (2nd Edition) Addison–Wesley
1: – Character(*) arrayInput
On entry: elements
of ch must contain character data to be ranked.
the length of each element of ch must not exceed .
2: – IntegerInput
On entry: the index of the first element of ch to be ranked.
3: – IntegerInput
On entry: the index of the last element of ch to be ranked.
4: – IntegerInput
5: – IntegerInput
On entry: only the substring (l1:l2) of each element of ch is to be used in determining the rank order.
6: – Character(1)Input
On entry: if , the values will be ranked in ASCII order.
If , in reverse ASCII order.
7: – Integer arrayOutput
On exit: elements
of irank contain the ranks of the corresponding elements of ch. 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.
8: – 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).