SUBROUTINE I OSORT ( N.CH AR* I NOI 

 SHELL SORTING ALGORITHM PROGRAMMED BY ROBERT M, RUSSELL 

 INTEGER*2 INDCN) 

 DIMENSION CHAR(N) 

 IF ( N .LE. ) GO TO 100 



00 2 J = ItN 

 2 INDCJI = J 



IF I N .EQ. 1 ) GO TO 100 



M = I 

 20 M = M *• M 



IF ( M .LT. N » GO TO 20 



M = MAXC(l,M/2 - I ) 

 30 I = 1 



IM = I ♦ M 

 40 J » I 



JM = IM 



IHOLD = INO(IM) 

 50 JR » INOCJ) 



IF( CHARIJRI .GT.CHARI IKOLDI ) GO TO 60 



INO(JM) = IND(J) 



JM = J 



J = J - M 



IF ( J .GT. ) GO TO 50 

 60 INOIJM) « IHOLD 



1 = I ♦ 1 

 IM = I ♦ M 



IF I IM .LE. N ) GO TO 40 

 M = M/2 



IF ( M .GT. ) GO TO 30 

 130 RETURN 

 END 



SUBROUTINf PCTILE ( N, I ND, C HAR, PCT , TOT ) 



COMPUTES PERCENTILE WITHIN THE DISTRIBUTION OF CHAR SUCH THAT 

 THE LARGEST INDIVIDUAL HAS PCT(I) = 100. 



IND = INDEX TO SORTED ORDER OF CHAR FROM SUBROUTINE IDSORT. 

 INTEGER*2 IND 



DIMENSION IND(N) ,CHAR( NJ ♦ PCT(N) 

 NMl = N - I 



PCT(INO(N)) = CHAR(IND(N)) 

 DO 10 I = 1,NM1 

 J = N-I 



PCTtlNDtJ)) = PCT ( IND( J4-I) ) ♦ CHAR(INDlJ)) 

 10 CONTINUE 



TOT = PCTdNDIDI 



PCTI IND( 1) ) = TOT/IOO. 



IF { TOT .LE. 0.0 ) RETURN 



00 20 I = 2,N 



PCT(IND(I)) = PCT ( IND( I) ) /PCT ( IND I I ) ) 

 20 CONTINUE 



PCTdNOd)) = 100. 



RE TURN 



END 



Figure 4. —FORTEAN IV coding of IDSORT and PCTILE. 



26 



