C                                                                       
      SUBROUTINE CAT1(NTYP,FCST,FCST2,LOC,NSF,THRESH,INFLAT,
     *                M,MM,ND3,ND4,ND5,*)
C        NOVEMBER 1980   GLAHN, BETHEM, MARSHALL   MDL   IBM 360/195    
C        JUNE     1991   GILBERT        MDL      FORTRAN 77             
C        PURPOSE                                                        
C            TO MAKE CATEGORICAL QPF FORECASTS FROM PROBABILITIES.  IT  
C            IS ASSUMED THERE ARE NSF CUMULITIVE PROBABILITIES FOR      
C            NSF+1 CATEGORIES.                                          
C        DATA SET USE                                                   
C            NONE                                                       
C        VARIABLES                                                      
C                NTYP = TYPE OF FORECAST.  ONLY CERTAIN VALUES,         
C                       IDENTICAL TO THE NCODES USED IN M900 FOR        
C                       MAKING CATEGORICAL FORECASTS, ARE PROVIDED      
C                       FOR.                                            
C           FCST(N,M) = FORECASTS FROM EQUATIONS (N=1,NSTA)             
C                       (M=1,NSF OR M=1,NSF-1 DEPENDING ON NTYP).       
C                       THESE ARE UNINFLATED IF INFLAT=0 OR INFLATED    
C                       IF INFLAT=1.                                    
C              LOC(N) = LOCATION OF THE FORECAST IN FCST(K, ) COR-      
C                       RESPONDING TO STATION N(N=M,MM).  FOR M901,     
C                       THESE WILL BE SEQUENTIAL AND ARE INDICATED      
C                       ONLY TO MAKE CATGOR COMPLETELY COMPATIBLE       
C                       WITH M900.                                      
C            FCST2(N) = CATEGORICAL FORECASTS (N=M,MM). (OUTPUT)        
C                 NSF = NUMBER OF FORECASTS IN FCST( , ).  THIS MAY     
C                       COVER ALL MUTUALLY EXCLUSIVE AND EXHAUSTIVE     
C                       CATEGORIES OR MAY REFER TO CUMULATIVE           
C                       CATEGORIES.                                     
C           THRESH(K) = THRESHOLDS OR SPECIAL INFLATION FACTORS FOR     
C                       THE REGION WHOSE STATIONS ARE M TO MM IN        
C                       FCST( , ).  (K=MAX OF ND3)                      
C           INFLAT( ) = 1 IF INFLATED FORECASTS ARE IN FCST( , )        
C                       0 OTHERWISE. INFLAT MAY OR MAY NOT BE NEEDED    
C                      BY CATGOR.                                       
C                   M = INDEX OF 1ST STATION IN FCST( , ) BEING DEALT   
C                       WITH IN THIS CALL.                              
C                  MM = INDEX OF LAST STATION IN FCST( , ) BEING        
C                       DEALT WITH IN THIS CALL.                        
C                 ND3 = MAXIMUM NUMBER OF PREDICTANDS.                  
C                 ND4 = THE MAXIMUM NUMBER OF STATIONS FOR WHICH        
C                       FORECASTS CAN EXIST IN FCST( , ).               
C                 ND5 = THE SECOND DIMENSION OF FCST( , ).              
      DIMENSION FCST(ND4,ND5)
      DIMENSION FCST2(ND4),LOC(ND4)
      DIMENSION THRESH(ND3)
      DO 130 N=M,MM
      K=LOC(N)
      IF(FCST(K,1).EQ.9999.) GO TO 130
C        IF ONE CATEGORY HAS A MISSING PROBABILITY, ALL WILL.           
      IF(FCST2(K).NE.9999.) GO TO 130
C        CATEGORICAL FORCASTS ARE MADE ONLY FOR THOSE STATIONS          
C        HAVING PROBABILITIES AND NOT ALREADY HAVING A                  
C        CATEGORICAL FORECAST. (THIS PROCEDURE FOR M900.)               
      FCST2(K)=1.
      DO 120 J=1,NSF
      IF(FCST(K,J).EQ.9997.)GO TO 120
C        A 9997. IMPLIES THIS PARTICULAR CATEGORY HAS ZERO              
C        PROBABILITY AND DOES NOT ENTER COMPUTATIONS.                   
      IF(FCST(K,J).LE.THRESH(J)) GO TO 130
C        THRESHOLD FOR CATEGORY J+1 EXCEEDED.                           
      FCST2(K)=J+1
 120  CONTINUE
 130  CONTINUE
      RETURN 1
      END
