SUBROUTINE SORTY(X,Y,Z,AX,AY,AZ,K,KODE,JCODE,GRIO) 

 C Y=INPUT VARIABLE TO BE SORTED, X,Z=VALUES ASSOCIATED WITH Y 



C K=LENGTH OF Y,IF K00E=1, VALUES OF Y WHICH ARE WITHIN 1 GRID INT OF 



C PREVIOUS VALUE ARE REMOVED, IF KODE=0 ALL VALUES OF Y ARE 



C RETAINED, IF JC0DE=+1,Y IS SORTED IN INCREASING ORDER, IF JC0DE=-1, 



C Y IS SORTED IN DECREASING ORDER, OUTPUT IS SORTED VALUES OF 



C Y WITH ASSOCIATED X AND Z 



DIMENSION Y(20),X(20),Z(20),AX(20),AY(20),AZ(20) 



KB = K 



C0DE=JC0DE 



J = 1 

 129 1=1 



JCT=0 



AY(J) = Yd) 

 132 TEMP= C0DE*(AY(J)-Y(I+1)) 



IF((ABS(TEMP))-GRID+0.0001) 122,120,120 

 120 IF (TEMP) 121,136,123 



121 



1 = 1 + 1 





IF((I + 1) - KB) 132,132,125 



123 



JCT = 1 





AY(J) = Yd + 1) 





AX(J) = Xd + 1) 





AZ(J) = Z(I + 1) 





KT = I + 2 





GO TO 121 



122 



IF(KOOE) 120,120,136 



136 



KD=I+2 





IF (KD-KB) 124,124,139 



139 



K=K-1 





KB=KB-1 





GO TO 125 



124 



DO 126 JO=KD,KB 





JF = JD - 1 





Y(JF) = Y(JD) 





X(JF) = X(JD) 



126 



Z(JF) = Z(JD) 





KB = KB - 1 





K = K - 1 





GO TO 132 



125 



IF(JCT) 127,127,128 



127 



AY(J) = Yd) 





AX(J) = Xd) 





AZ(J) = Zd) 





KT = 2 



128 



J = J + 1 





IF(J - K) 131,133,133 



131 



00 134 KA = KT.KB 





JT = KA - 1 





Y(JT) = Y(KA) 





X(JT) = X(KA) 



134 



Z(JT) = Z(KA) 





KB = KB - 1 





60 TO 129 



163 



