SUBROUTINE PRVFIX(K1,K2,K3,MIN,KST) 



DIMENSION K1(1000),K2(1000),K3(1000),T1(200),T2(200),T3(200) 

 C SUBROUTINE FOR USE WITH THE PROVINCE PICKER PROGRAM 



C SEARCHES PROVINCE BOUNDARIES FOR SEGMENTS LESS THAN MIN 



C SEGMENTS ARE INCORPORATED INTO ADJACENT PROVINCES IF THEY 



C ARE EQUAL-SETS BOUNDARY TO INCLUDE SEGMENT IN ROUGHEST 



C PROVINCE IF ADJACENT PROVINCES ARE UNEQUAL-DELETES 



C SEGMENTS AT ENDS OF TRACKLINE 



C C.G.FOX-LDGO-JULY 6,1982 



C 



MINSAV=MIN 

 MIN=0 

 10 ISKIP=0 

 ICYCLE=0 

 MIN=MIN+5 



IF(MIN.GT.MINSAV)MIN=MINSAV 

 00 100 I=1,KST 

 IF(ICYCLE.GE.l) GO TO 95 

 IX=I-ISKIP 

 11=1+1 

 C TEST FOR ADJACENT PROVINCES OF SAME NUMBER 



IF(K3(I).NE.K3(II)) GO TO 30 

 T1(IX)=K1(I) 

 T2(IX)=K2(II) 

 T3(IX)=K3(I) 

 ICYCLE=1 

 ISKIP=ISKIP+1 

 GO TO 100 

 C TEST FOR MINIMUM PROVINCE SIZE 



30 IDIFF=K2(I)-K1(I) 



IF(IDIFF.LT.MIN)GO TO 40 

 C NORMAL PROVINCE - STORE IN T ARRAY AND CONTINUE 



T1(IX)=K1(I) 

 T2(IX)=K2(I) 

 T3(IX)=K3(I) 

 GO TO 100 

 C LESS THAN MINIMUM SIZE -TEST NUMBER OF ADJACENT PROVINCES 

 C IF FIRST OR LAST PROVINCE OF LINE, DELETE 



40 IF(I.NE.KST.OR.IX.NE.l) GO TO 50 

 ISKIP=ISKIP+1 

 GO TO 100 

 C TEST IF SURROUNDING PROVINCES ARE EQUAL 



50 IF(T3(IX-1).NE.K3(II)) GO TO 70 

 C IF EQUAL, EXTEND SECOND BOUNDARY OF PREVIOUS PROVINCE 



C TO END OF FOLLOWING PROVINCE 



T2(IX-1)=K2(II) 

 ICYCLE=1 

 ISKIP=ISKIP+2 

 GO TO 100 

 C ADJACENT PROVINCES ARE DIFFERENT-SET BOUNDARY CLOSER TO 

 C LOWER VALUED PROVINCE 



C 70 IF(T3(IX-1).LT.K3(II)) GO TO 75 

 C T1(IX)=K1(I) 



175 



