      SUBROUTINE CONKUO(DT,SATCRI,ACUMT,NKUO,PS,DEL,SL,QN,QN1,TN1,
     1 ACUM,DQ,GESHEM,RELKUO,MSTA)
      DIMENSION GESHEM( 50 )
      DIMENSION PS( 50 ),DEL( 7 ),SL( 7 ),
     1QN( 50 , 6 ),QN1( 50 , 6 ),DQ( 50 , 6 ),
     2TN1( 50 , 7 )
      DIMENSION ACUM( 50 ),PRESS( 6 ),TIN( 6 ),QIN( 6 ),
     1TMST( 6 ),QMST( 6 ),DTKUO( 6 ),DQKUO( 6 ),ESAT( 6 )
      IF(DT.EQ.0.) RETURN
C***
C*** DEL=DEL SIGMA (DEL P OVR PSFC)
C*** PS=SFC PRES (CB),  RELKUO(=.80) IS THE SATURATION CRITERION
C*** ACMT = TEN TO MINUS SEVEN PER SEC
      RDT=1./DT
      CPOVL= 1005. /2.5E+6
      RELEPS=RELKUO*0.622
      DO 5 K=1, 6
      DO 5 I=1, 50
5     DQ(I,K)=QN1(I,K)-QN(I,K)
C*** NET TIME RATE MOISTURE INFLOW ..LWST KACUM.. LYRS
      KACUM=4
      DO  10 I=1, 50
10    ACUM(I)=ACUMT*0.1
      DO 15 K=1,KACUM
      DO 15 I=1, 50
15    ACUM(I)=ACUM(I)+RDT*DQ(I,K)*DEL(K)
C***
C*** ENTER LON LOOP........
      DO 125 I=1, 50
C***
C*** TEST 1....SUFFICIENT WATER ACCUM? NET INFLO INTO LWST LYR?
      IF(ACUM(I).LT.0.) GO TO 125
      IF(DQ(I,1) .LE. .0) GO TO 125
      DO 12345 K=1, 6
12345 PRESS(K)=SL(K)*PS(I)
C*** TIN, QIN ARE PRELIM TMP AND Q AT N+1, ZERO NEGATIVE Q
      DO 103 K=1, 6
      TIN(K)=TN1(I,K)
      QIN(K)=QN1(I,K)
      IF(QN1(I,K) .LT. .0) QIN(K) = .0
103   CONTINUE
       IF(TIN(1) .LT. 278.16) GO TO 125
       IF(TIN(2) .GT. TIN(1)) GO TO 125
       CALL SATVAP(TIN,ESAT,2)
       QSATK = .65*.622*ESAT(1)/(PRESS(1)-0.378*ESAT(1))
       QDEF = QIN(1) - QSATK
C*** LWST LYR MIN  TMP AND RH CONDS PLUS NO TMP INVERSION EXISTS
       IF(QDEF .LT. .0) GO TO 125
C*** MODIFY TMP FOR MSTADB (SUBR PERMITS AN INTERVENING STBL LYR)
      TIN(1) =  TIN(1) + .25* (TIN(2) - TIN(1))
      HNEW=PS(I)/100.
      CALL MSTADB(HNEW, SL  ,TIN,1, 6 ,THE,TMST,QMST,KTOP,IER)
C***  TMST AND QMST,K=1...KTOP CONTAIN CLOUD TEMPS AND SPECIFIC HUMID.
C**** -------------------------------
      IF(IER)105,106,105
105   MSTA=MSTA+1
      GO TO 125
106   CONTINUE
C**** -------------------------------
C***
C*** TEST 2...INSTABILITY.  KTOP .GE. 4,  NO STBL LYRS PERMITTED
       IF(KTOP.LT.4) GO TO 125
       DO 150 K = 2,KTOP
       X = TMST(K) - TIN(K)
       IF(X .LT. 0.) GO TO 125
150    CONTINUE
C*** HERE  KUO REQUIREMENTS ARE MET, FIRST COMPUTE WATER=TONS WATER
C*** SUBSTANCE  ACCUMULATED IN ONE TIME STEP PER SQ M IN LAYERS 2-KTOP
      NKUO=NKUO+1
C*** AVL  WATER  (WATER=WATER*G/PS) .GT. .0, COMES FM TWO LWST LYRS
      WATER=0.
      DO 107 K=1,2
      WATER=WATER+   DQ(I,K)*DEL(K)
107   CONTINUE
      IF(WATER .LE. .0) GO TO 125
C***
      Q1=0.
      Q2=0.
        DO 111 K=2,KTOP
        X=QMST(K)-QIN(K)
        IF(X)109,109,108
108     Q1=Q1+X*DEL(K)
109     X=TMST(K)-TIN(K)
        IF(X)111,111,110
110     Q2=Q2+X*DEL(K)
111     CONTINUE
C*** CONTRIB. FACTOR (FRAC CVRG?) .GE. MIN, NOT .GT. 1.0
      Q2=Q2*CPOVL
      QEFF=WATER/(Q1+Q2)
      IF(QEFF .LT. .001) GO TO 125
      IF(QEFF .GT. 1.00) QEFF = 1.00
C***
C*** CONVECTIVE  CONTRIBUTION TO HEATING AND MOISTENING
        DO 304 K=2,KTOP
        X=QEFF*(TMST(K)-TIN(K))
C***  CHANGE T ONLY IF X GT.0
        IF(X)300,300,301
300     X=0.
301     DTKUO(K)=X
        X=QEFF*(QMST(K)-QIN(K))
C***  CHANGE Q ONLY IF X GT.0
        IF(X)302,302,303
302     X=0.
303     DQKUO(K)=X
304     CONTINUE
      DTKUO(1)=0.
      DQKUO(1)=0.
      CEVAP=0.
        DO 305 K=2,KTOP
        TIN(K)=TIN(K)+DTKUO(K)
        QIN(K)=DQKUO(K)   + QIN(K)
        CEVAP=CEVAP+DQKUO(K)*DEL(K)
305     CONTINUE
C***
C*** CONVECTIVE PCPN  = AVL WATER, REMOVE WATER FM TWO LWST LYRS
      FALL = WATER - CEVAP
      GESHEM(I)=GESHEM(I)+PS(I)*FALL/9.8
       QIN(1) = QIN(1) - DQ(I,1)
       IF(DQ(I,2) .GT. 0.) QIN(2) = QIN(2)-DQ(I,2)
C***  RESTORE BASIC FIELDS
      TIN(1) = TN1(I,1)
      DO 310 K=1,KTOP
      QN1(I,K)=QIN(K)
      TN1(I,K)=TIN(K)
310   CONTINUE
125   CONTINUE
C***  END LON LOOP
C***
C(DEBUGLINE) VERSION CREATED JULY 8 1982 BY J.SELA,NMC.
      RETURN
      END
