C+ C NAME: C Rank C PURPOSE: C Construct rank table from given index table. C CATEGORY: C Math: sorting C CALLING SEQUENCE: subroutine Rank(N1,N2,M1,M2,INDX,IRANK) C INPUTS: C N1,N2 integer physical dimensions of arrays INDX and IRANK C M1,M2 integer logical dimensions of arrays INDX and IRANK C (only the logical part of INDX is ranked) C INDX(M1:M2) C integer index table for a one-dimensional array C ARRIN(M1:M2) (obtained from subroutine Index??) C OUTPUTS: C IRANK(M1:M2) C integer rank table C SIDE EFFECTS: C The part of the rank array IRANK outside the logical range C (i.e. [M1:N1-1] and [N2+1,M2]) remains untouched C RESTRICTIONS: C The index range [N1,N2] must be a subset of [M1,M2] C SEE ALSO: C SortI4, Sort2I4, IndexI4 C PROCEDURE: C The index values [N1,N2] are arranged in IRANK(N1:N2) in such a way C that IRANK(J) gives the rank of the element ARRIN(J), i.e. N1 if C ARRIN(J) is the smallest element in the range [N1,N2]; and N2 if it is C the largest. C See Press et al., "Numerical Recipes", Cambridge UP (1989), Chapter 8, C p. 234 C MODIFICATION HISTORY: C 1990, Paul Hick (UCSD) C- integer N1 integer N2 integer M1 integer M2 integer INDX (M1:M2) integer IRANK(M1:M2) do J=N1,N2 IRANK(INDX(J)) = J end do return end