1c1
< MODULE module_cu_kfeta
---
> MODULE module_cu_kfeta_nmm
3a4,6
> !!!!!tlb
>       USE module_ext_internal
> !!!!!tlb
5a9,10
>       IMPLICIT NONE
> !--------------------------------------------------------------------
7a13
> 
14a21
>       integer :: mype,isee=26,jsee=107,ksee=32
25c32
<               CU_ACT_FLAG,warm_rain,                         &
---
>               CU_ACT_FLAG,warm_rain,KTOP,KBOT,               &
75a83,86
>    INTEGER,DIMENSION( ims:ime , jms:jme ),                   &
>           INTENT(OUT) ::                               KTOP, &
>                                                        KBOT
> 
105a117
>        call wrf_get_myproc(mype)
164a177,180
> !         if(I.ge.20 .and. I.le.22 .and. J.le.2)then
> ! write(98,*)'KTAU, I, J, U1D, V1D =',ktau,i,j,U1D(K),V1D(K)
> ! write(98,*)'T1D, QV1D, P1D, DZ1D =',T1D(K),QV1D(K),P1D(K),DZ1D(k)
> !         endif
166,167c182,184
<           CALL wrf_debug(100,'in kf_eta_para')
<             CALL KF_eta_PARA(I, J,                  &
---
> 
> !
>             CALL KF_eta_PARA(I, J,ktau,             &
174a192
>                  KTOP,KBOT,                         &
178d195
<           CALL wrf_debug(100,'after kf_eta_para')
223c240
<    SUBROUTINE KF_eta_PARA (I, J,                           &
---
>    SUBROUTINE KF_eta_PARA (I, J,ktau,                      &
230a248
>                       KTOP,KBOT,                           &
243c261
<                                 I,J,NTST,P_QI,P_QS,P_FIRST_SCALAR
---
>                                 I,J,NTST,P_QI,P_QS,P_FIRST_SCALAR,ktau
276a295,298
> 
>       INTEGER, DIMENSION( ims:ime , jms:jme ),             &
>             INTENT(OUT) ::                           KTOP, &
>                                                      KBOT
337d358
<    REAL    :: TVDIFF,DTTOT,ABSOMG,ABSOMGTC,FRDP
365a387,388
> 	
> !	write(0,*) 'DX= ', DX
587c610,612
<           IF(WKL.LT.0.0001)THEN
---
>           WABS=ABS(WKL)
>           IF(WABS.EQ.0.)THEN
>             WSIGNE=1.
590c615,617
<             DTLCL=4.64*WKL**0.33
---
>             WSIGNE=WKL/WABS
>             DTLCL=4.64*WSIGNE*WABS**0.33
>             DTLCL = AMAX1(DTLCL,0.)
627c654
<             CALL ENVIRTHT(PMIX,TMIX,QMIX,THETEU(K),ALIQ,BLIQ,CLIQ,DLIQ)
---
>             CALL ENVIRTHT(PMIX,TMIX,QMIX,THETEU(K),ALIQ,BLIQ,CLIQ,DLIQ,i,j,k,1)
630,638c657,664
< !
<             DTTOT = DTLCL+DTRH
<             IF(DTTOT.GT.1.E-4)THEN
<               GDT=2.*G*DTTOT*500./TVEN
<               WLCL=1.+0.5*SQRT(GDT)
<               WLCL = AMIN1(WLCL,3.)
<             ELSE
<               WLCL=1.
<             ENDIF
---
> !           GDT=G*DTLCL*(ZLCL-Z00(LC))/(TV0(LC)+TVEN)
> !              WLCL=1.+.5*WSIGNE*SQRT(ABS(GDT)+1.E-10)
>             GDT=2.*G*(DTLCL+DTRH)*500./TVEN
> !           WLCL=1.+0.5*WSIGNE*SQRT(ABS(GDT)+1.E-10)
>             WLCL=1.+0.5*SQRT(ABS(GDT)+1.E-10)
> !           WLCL = AMIN1(WLCL,5.)
> !           WLCL = AMIN1(WLCL,4.)
>             WLCL = AMIN1(WLCL,3.)
723c749
<                      qice(nk1),qnewlq,qnewic,XLV1,XLV0)
---
>                      qice(nk1),qnewlq,qnewic,XLV1,XLV0,i,j,0)
725d750
< !
751c776
<                           QICE(NK1),ALIQ,BLIQ,CLIQ,DLIQ)
---
>                           QICE(NK1),ALIQ,BLIQ,CLIQ,DLIQ,i,j,nk1)
759a785
> !               ENTERM=0.
763a790
> !               ENTERM=2.*UER(NK)*WTW/UPOLD
769a797,799
> 
>               WABS=SQRT(ABS(WTW))
>               WU(NK1)=WTW/WABS
774c804
<               IF(WTW.LT.1.E-3)THEN
---
>               IF(WU(NK1).LT.0.)THEN
776,777d805
<               ELSE
<                 WU(NK1)=SQRT(WTW)
778a807
> !
781c810
<               CALL ENVIRTHT(P0(NK1),T0(NK1),Q0(NK1),THETEE(NK1),ALIQ,BLIQ,CLIQ,DLIQ)
---
>               CALL ENVIRTHT(P0(NK1),T0(NK1),Q0(NK1),THETEE(NK1),ALIQ,BLIQ,CLIQ,DLIQ,i,j,nk1,0)
814c843
<                            qnewlq,qnewic,XLV1,XLV0)
---
>                            qnewlq,qnewic,XLV1,XLV0,i,j,1)
828c857
<                                qnewlq,qnewic,XLV1,XLV0)
---
>                                qnewlq,qnewic,XLV1,XLV0,i,j,0)
830,831c859
<                   TVDIFF = ABS(TU10-TVQU(NK1))
<                   IF(TVDIFF.LT.1.e-3)THEN
---
>                   IF(ABS(TU10-TVQU(NK1)) < .01)THEN
923d950
< !
927,928d953
< !
< !
1080c1105
<       CALL ENVIRTHT(P0(NK),T0(NK),Q0(NK),THETEE(NK),ALIQ,BLIQ,CLIQ,DLIQ)
---
>       CALL ENVIRTHT(P0(NK),T0(NK),Q0(NK),THETEE(NK),ALIQ,BLIQ,CLIQ,DLIQ,i,j,nk,0)
1264a1290,1291
> !         DTMELT = RLF*PPTMLT/(CP*DMFFRC*UMF(KLCL))
> !...
1273d1299
< !
1275d1300
< !
1337c1362
< !
---
> !     
1340c1365
< !
---
> !     
1342c1367
< !           WRITE(98,3004)I,J 
---
> !           WRITE(98,3004)I,J
1432,1435c1457,1458
<          IF((UER(NK)-DER(NK)).GT.1.e-3)THEN
<            AINCM1=EMS(NK)/((UER(NK)-DER(NK))*TIMEC)
<            AINCMX=AMIN1(AINCMX,AINCM1)
<          ENDIF
---
>          IF((UER(NK)-DER(NK)).GT.0.)AINCM1=EMS(NK)/((UER(NK)-DER(NK))*TIMEC)
>           AINCMX=AMIN1(AINCMX,AINCM1)
1516,1522c1539,1540
<                 ABSOMG = ABS(OMG(NK))
<                 ABSOMGTC = ABSOMG*TIMEC
<                 FRDP = 0.75*DP(NK-1)
<                 IF(ABSOMGTC.GT.FRDP)THEN
<                   DTT1 = FRDP/ABSOMG
<                   DTT=AMIN1(DTT,DTT1)
<                 ENDIF
---
>                 DTT1=0.75*DP(NK-1)/(ABS(OMG(NK))+1.E-10)
>                 DTT=AMIN1(DTT,DTT1)
1707d1724
< !
1709d1725
< !
1722c1738
<             CALL ENVIRTHT(P0(NK1),TG(NK1),QG(NK1),THTEEG(NK1),ALIQ,BLIQ,CLIQ,DLIQ)
---
>             CALL ENVIRTHT(P0(NK1),TG(NK1),QG(NK1),THTEEG(NK1),ALIQ,BLIQ,CLIQ,DLIQ,i,j,nk1,0)
1737c1753
<           FABE=ABEG/ABE
---
>           FABE=ABEG/(ABE+1.E-8)
1744,1748d1759
<             IF(ABS(AINC-AINCOLD).LT.0.0001)THEN
<               NOITR=1
<               AINC=AINCOLD
<               CYCLE iter
<             ENDIF
1782,1788c1793
<               IF(DABE.LT.1.e-4)THEN
<                 NOITR=1
<                 AINC=AINCOLD
<                 CYCLE iter
<               ELSE
<                 AINC=AINC*STAB*ABE/DABE
<               ENDIF
---
>               AINC=AINC*STAB*ABE/(DABE+1.E-8)
1823a1829,1831
> !       IF(I.EQ.95 .AND. J.EQ.82)THEN
> !        write(98,*)'PPTFLX, CPR, AINC =',PPTFLX,CPR,AINC
> !       ENDIF
1981c1989
<                        u0(k),v0(k),W0AVG1D(K),dp(k),tke(k)
---
>                        u0(k),v0(k),W0AVG1D(K),dp(k)
1990c1998
<   4455  format(8f11.3) 
---
>   4455  format(7f11.3) 
2041,2045c2049
<         IF(PPTFLX.GT.0.)THEN
<           RELERR=ERR2*QINIT/(PPTFLX*TIMEC)
<         ELSE
<           RELERR=0.
<         ENDIF
---
>         RELERR=ERR2*QINIT/(PPTFLX*TIMEC+1.E-10)
2169a2174,2181
> !-----------------------------------------------------------------------
> !--------------SAVE CLOUD TOP AND BOTTOM FOR RADIATION------------------
> !-----------------------------------------------------------------------
> !
>       KTOP(I,J)=LTOP
>       KBOT(I,J)=LCL
> !
> !-----------------------------------------------------------------------
2173c2185,2186
<    SUBROUTINE TPMIX2(p,thes,tu,qu,qliq,qice,qnewlq,qnewic,XLV1,XLV0)
---
>    SUBROUTINE TPMIX2(p,thes,tu,qu,qliq,qice,qnewlq,qnewic,XLV1,XLV0 &
>      &              ,i,j,iflag)
2190a2204
>       integer,intent(in) :: i,j,iflag
2207d2220
< 
2218,2221d2230
<        IF(IPTB.GE.220 .OR. IPTB.LE.1 .OR. ITHTB.GE.250 .OR. ITHTB.LE.1)THEN
<          write(98,*)'**** OUT OF BOUNDS *********'
< !        call flush(98)
<        ENDIF
2241,2242c2250
<       DQ=QS-QU
<       IF(DQ.LE.0.)THEN
---
>       IF(QS.LE.QU)THEN
2249a2258
> 
2250a2260
>         DQ=QS-QU
2266,2267c2276,2277
<           qliq=qliq-dq*qliq/(qtot+1.e-10)
<           qice=qice-dq*qice/(qtot+1.e-10)
---
>           qliq=qliq-dq*qliq/qtot
>           qice=qice-dq*qice/qtot
2295c2305
<       SUBROUTINE DTFRZNEW(TU,P,THTEU,QU,QFRZ,QICE,ALIQ,BLIQ,CLIQ,DLIQ)
---
>       SUBROUTINE DTFRZNEW(TU,P,THTEU,QU,QFRZ,QICE,ALIQ,BLIQ,CLIQ,DLIQ,i,j,k)
2301a2312
>       integer,intent(in) :: i,j,k
2382c2393
<       RATIO3=QNEWLQ/(QNEW+1.E-8)                                       
---
>       RATIO3=QNEWLQ/(QNEW+1.E-10)                                       
2386c2397
<       RATIO4=(0.6*QNEWLQ+QLIQ)/(QTOT+1.E-8)                            
---
>       RATIO4=(0.6*QNEWLQ+QLIQ)/(QTOT+1.E-10)                            
2401c2412
<       IF(ABS(WTW).LT.1.E-4)WTW=1.E-4
---
>       IF(ABS(WTW).LT.1.E-10)WTW=1.E-10
2524c2535
<   SUBROUTINE ENVIRTHT(P1,T1,Q1,THT1,ALIQ,BLIQ,CLIQ,DLIQ)                       
---
>   SUBROUTINE ENVIRTHT(P1,T1,Q1,THT1,ALIQ,BLIQ,CLIQ,DLIQ,i,j,k,iflag)                       
2533a2545
>       integer,intent(in) :: i,j,k,iflag
2592c2604
<    REAL, INTENT(IN)    :: SVP1,SVP2,SVP3,SVPT0
---
>    REAL    :: SVP1,SVP2,SVP3,SVPT0
2674,2676c2686
< !    REAL    :: ALIQ,BLIQ,CLIQ,DLIQ,SVP1,SVP2,SVP3,SVPT0
<      REAL    :: ALIQ,BLIQ,CLIQ,DLIQ
<      REAL, INTENT(IN)    :: SVP1,SVP2,SVP3,SVPT0
---
>      REAL    :: ALIQ,BLIQ,CLIQ,DLIQ,SVP1,SVP2,SVP3,SVPT0
2685c2695
<       plutop=5000.0
---
>       plutop=100.0
2782c2792
< END MODULE module_cu_kfeta
---
> END MODULE module_cu_kfeta_nmm