zm_conv.f90

来自「CCSM Research Tools: Community Atmospher」· F90 代码 · 共 1,872 行 · 第 1/5 页

F90
1,872
字号
! Reset max moist static energy level when relative difference exceeds 1.e-4!         rhd = (hmn(i) - hmax(i))/(hmn(i) + hmax(i))         if (k >= nint(pblt(i)) .and. k <= lon(i) .and. rhd > -1.e-4) then            hmax(i) = hmn(i)            mx(i) = k         end if      end do   end do#else   do k = pver,msg + 1,-1      do i = 1,ncol         hmn(i) = cp*t(i,k) + grav*z(i,k) + rl*q(i,k)         if (k >= nint(pblt(i)) .and. k <= lon(i) .and. hmn(i) > hmax(i)) then            hmax(i) = hmn(i)            mx(i) = k         end if      end do   end do#endif!   do i = 1,ncol      lcl(i) = mx(i)      e = p(i,mx(i))*q(i,mx(i))/ (eps1+q(i,mx(i)))      tl(i) = 2840./ (3.5*log(t(i,mx(i)))-log(e)-4.805) + 55.      if (tl(i) < t(i,mx(i))) then         plexp(i) = (1./ (0.2854* (1.-0.28*q(i,mx(i)))))         pl(i) = p(i,mx(i))* (tl(i)/t(i,mx(i)))**plexp(i)      else         tl(i) = t(i,mx(i))         pl(i) = p(i,mx(i))      end if   end do!! calculate lifting condensation level (lcl).!   do k = pver,msg + 2,-1      do i = 1,ncol         if (k <= mx(i) .and. (p(i,k) > pl(i) .and. p(i,k-1) <= pl(i))) then            lcl(i) = k - 1         end if      end do   end do!! if lcl is above the nominal level of non-divergence (600 mbs),! no deep convection is permitted (ensuing calculations! skipped and cape retains initialized value of zero).!   do i = 1,ncol      plge600(i) = pl(i).ge.600.   end do!! initialize parcel properties in sub-cloud layer below lcl.!   do k = pver,msg + 1,-1      do i=1,ncol         if (k > lcl(i) .and. k <= mx(i) .and. plge600(i)) then            tv(i,k) = t(i,k)* (1.+1.608*q(i,k))/ (1.+q(i,k))            qstp(i,k) = q(i,mx(i))            tp(i,k) = t(i,mx(i))* (p(i,k)/p(i,mx(i)))**(0.2854* (1.-0.28*q(i,mx(i))))!! buoyancy is increased by 0.5 k as in tiedtke!!-jjh          tpv (i,k)=tp(i,k)*(1.+1.608*q(i,mx(i)))/!-jjh     1                     (1.+q(i,mx(i)))            tpv(i,k) = (tp(i,k)+tpert(i))*(1.+1.608*q(i,mx(i)))/ (1.+q(i,mx(i)))            buoy(i,k) = tpv(i,k) - tv(i,k) + 0.5         end if      end do   end do!! define parcel properties at lcl (i.e. level immediately above pl).!   do k = pver,msg + 1,-1      do i=1,ncol         if (k == lcl(i) .and. plge600(i)) then            tv(i,k) = t(i,k)* (1.+1.608*q(i,k))/ (1.+q(i,k))            qstp(i,k) = q(i,mx(i))            tp(i,k) = tl(i)* (p(i,k)/pl(i))**(0.2854* (1.-0.28*qstp(i,k)))!              estp(i)  =exp(a-b/tp(i,k))! use of different formulas for est has about 1 g/kg difference! in qs at t= 300k, and 0.02 g/kg at t=263k, with the formula! above giving larger qs.!            estp(i) = c1*exp((c2* (tp(i,k)-tfreez))/((tp(i,k)-tfreez)+c3))            qstp(i,k) = eps1*estp(i)/ (p(i,k)-estp(i))            a1(i) = cp / rl + qstp(i,k) * (1.+ qstp(i,k) / eps1) * rl * eps1 / &                    (rd * tp(i,k) ** 2)            a2(i) = .5* (qstp(i,k)* (1.+2./eps1*qstp(i,k))* &                    (1.+qstp(i,k)/eps1)*eps1**2*rl*rl/ &                    (rd**2*tp(i,k)**4)-qstp(i,k)* &                    (1.+qstp(i,k)/eps1)*2.*eps1*rl/ &                    (rd*tp(i,k)**3))            a1(i) = 1./a1(i)            a2(i) = -a2(i)*a1(i)**3            y(i) = q(i,mx(i)) - qstp(i,k)            tp(i,k) = tp(i,k) + a1(i)*y(i) + a2(i)*y(i)**2!          estp(i)  =exp(a-b/tp(i,k))            estp(i) = c1*exp((c2* (tp(i,k)-tfreez))/ ((tp(i,k)-tfreez)+c3))            qstp(i,k) = eps1*estp(i) / (p(i,k)-estp(i))!! buoyancy is increased by 0.5 k in cape calculation.! dec. 9, 1994!-jjh          tpv(i,k) =tp(i,k)*(1.+1.608*qstp(i,k))/(1.+q(i,mx(i)))!            tpv(i,k) = (tp(i,k)+tpert(i))* (1.+1.608*qstp(i,k)) / (1.+q(i,mx(i)))            buoy(i,k) = tpv(i,k) - tv(i,k) + 0.5         end if      end do   end do!! main buoyancy calculation.!   do k = pver - 1,msg + 1,-1      do i=1,ncol         if (k < lcl(i) .and. plge600(i)) then            tv(i,k) = t(i,k)* (1.+1.608*q(i,k))/ (1.+q(i,k))            qstp(i,k) = qstp(i,k+1)            tp(i,k) = tp(i,k+1)* (p(i,k)/p(i,k+1))**(0.2854* (1.-0.28*qstp(i,k)))!          estp(i) = exp(a-b/tp(i,k))            estp(i) = c1*exp((c2* (tp(i,k)-tfreez))/((tp(i,k)-tfreez)+c3))            qstp(i,k) = eps1*estp(i)/ (p(i,k)-estp(i))            a1(i) = cp/rl + qstp(i,k)* (1.+qstp(i,k)/eps1)*rl*eps1/ (rd*tp(i,k)**2)            a2(i) = .5* (qstp(i,k)* (1.+2./eps1*qstp(i,k))* &                    (1.+qstp(i,k)/eps1)*eps1**2*rl*rl/ &                    (rd**2*tp(i,k)**4)-qstp(i,k)* &                    (1.+qstp(i,k)/eps1)*2.*eps1*rl/ &                    (rd*tp(i,k)**3))            a1(i) = 1./a1(i)            a2(i) = -a2(i)*a1(i)**3            y(i) = qstp(i,k+1) - qstp(i,k)            tp(i,k) = tp(i,k) + a1(i)*y(i) + a2(i)*y(i)**2!          estp(i)  =exp(a-b/tp(i,k))            estp(i) = c1*exp((c2* (tp(i,k)-tfreez))/ ((tp(i,k)-tfreez)+c3))            qstp(i,k) = eps1*estp(i)/ (p(i,k)-estp(i))!-jjh          tpv(i,k) =tp(i,k)*(1.+1.608*qstp(i,k))/!jt            (1.+q(i,mx(i)))            tpv(i,k) = (tp(i,k)+tpert(i))* (1.+1.608*qstp(i,k))/(1.+q(i,mx(i)))            buoy(i,k) = tpv(i,k) - tv(i,k) + 0.5         end if      end do   end do!   do k = msg + 2,pver      do i = 1,ncol         if (k < lcl(i) .and. plge600(i)) then            if (buoy(i,k+1) > 0. .and. buoy(i,k) <= 0.) then               knt(i) = min(5,knt(i) + 1)               lelten(i,knt(i)) = k            end if         end if      end do   end do!! calculate convective available potential energy (cape).!   do n = 1,5      do k = msg + 1,pver         do i = 1,ncol            if (plge600(i) .and. k <= mx(i) .and. k > lelten(i,n)) then               capeten(i,n) = capeten(i,n) + rd*buoy(i,k)*log(pf(i,k+1)/pf(i,k))            end if         end do      end do   end do!! find maximum cape from all possible tentative capes from! one sounding,! and use it as the final cape, april 26, 1995!   do n = 1,5      do i = 1,ncol         if (capeten(i,n) > cape(i)) then            cape(i) = capeten(i,n)            lel(i) = lelten(i,n)         end if      end do   end do!! put lower bound on cape for diagnostic purposes.!   do i = 1,ncol      cape(i) = max(cape(i), 0._r8)   end do!   returnend subroutine buoyansubroutine cldprp(lchnk   , &                  q       ,t       ,u       ,v       ,p       , &                  z       ,s       ,mu      ,eu      ,du      , &                  md      ,ed      ,sd      ,qd      ,mc      , &                  qu      ,su      ,zf      ,qst     ,hmn     , &                  hsat    ,shat    ,ql      ,totpcp  ,totevp  , &                  cmeg    ,jb      ,lel     ,jt      ,jlcl    , &                  mx      ,j0      ,jd      ,rl      ,il2g    , &                  rd      ,grav    ,cp      ,msg     ,nstep   , &                           pflx    ,evp     ,cu      ,mu2     , &                  eu2     ,du2     ,md2     ,ed2     ,cmfdqr  , &                  limcnv  )!----------------------------------------------------------------------- ! ! Purpose: ! <Say what the routine does> ! ! Method: ! may 09/91 - guang jun zhang, m.lazare, n.mcfarlane.!             original version cldprop.! ! Author: P. Rasch! This is contributed code not fully standardized by the CCM core group.!! this code is very much rougher than virtually anything else in the CCM! there are debug statements left strewn about and code segments disabled! these are to facilitate future development. We expect to release a! cleaner code in a future release!! the documentation has been enhanced to the degree that we are able!!**** PLEASE NOTE ****!! we are aware of a specific problem in this code! (identified by the string ---> PROBLEM ONE)! during the calculation of the updraft cloud properties,! rather than adding a perturbation to the updraft temperature of! half a degree, (there was an inadvertant addition of cp*0.5) degrees! or about 500 degrees. (This problem was in the code prior to its! contribution to the NCAR effort)! Fortunately, the erroneous values! are overwritten later in the code. The problem is quite subtle.! The erroneous values would persist between cloud base and the lifting! condensation level. The addition of the very high perturbation to the updraft! temperature causes the saturation mixing ratio to be set to zero,! and later the lcl to be set to one level above cloud base.! There are therefore no levels between cloud base and the lcl. Therefore! all erroneous values are overwritten.! The only manifestation we are aware of with respect to this problem! is that the lifting condensation level is constrained to be one level above! cloud base.! We discovered the problem after too much had been invested in! very long integrations (in terms of computer time)! to allow for a modification and model retuning. It is our expectation that! this problem will be fixed in the next release of the model.!!-----------------------------------------------------------------------   implicit none#include <guang.h>!------------------------------------------------------------------------------!! Input arguments!   integer, intent(in) :: lchnk                  ! chunk identifier   real(r8), intent(in) :: q(pcols,pver)         ! spec. humidity of env   real(r8), intent(in) :: t(pcols,pver)         ! temp of env   real(r8), intent(in) :: p(pcols,pver)         ! pressure of env   real(r8), intent(in) :: z(pcols,pver)         ! height of env   real(r8), intent(in) :: s(pcols,pver)         ! normalized dry static energy of env   real(r8), intent(in) :: zf(pcols,pverp)       ! height of interfaces   real(r8), intent(in) :: u(pcols,pver)         ! zonal velocity of env   real(r8), intent(in) :: v(pcols,pver)         ! merid. velocity of env   integer, intent(in) :: jb(pcols)              ! updraft base level   integer, intent(in) :: lel(pcols)             ! updraft launch level   integer, intent(out) :: jt(pcols)              ! updraft plume top   integer, intent(out) :: jlcl(pcols)            ! updraft lifting cond level   integer, intent(in) :: mx(pcols)              ! updraft base level (same is jb)   integer, intent(out) :: j0(pcols)              ! level where updraft begins detraining   integer, intent(out) :: jd(pcols)              ! level of downdraft   integer, intent(in) :: limcnv                 ! convection limiting level   integer, intent(in) :: il2g                   !CORE GROUP REMOVE   integer, intent(in) :: msg                    ! missing moisture vals (always 0)   integer, intent(in) :: nstep                  ! time step index   real(r8), intent(in) :: rl                    ! latent heat of vap   real(r8), intent(in) :: shat(pcols,pver)      ! interface values of dry stat energy!! output!   real(r8), intent(out) :: cmfdqr(pcols,pver)   ! rate of production of precip at that layer   real(r8), intent(out) :: du(pcols,pver)       ! detrainement rate of updraft   real(r8), intent(out) :: ed(pcols,pver)       ! entrainment rate of downdraft   real(r8), intent(out) :: eu(pcols,pver)       ! entrainment rate of updraft   real(r8), intent(out) :: hmn(pcols,pver)      ! moist stat energy of env   real(r8), intent(out) :: hsat(pcols,pver)     ! sat moist stat energy of env   real(r8), intent(out) :: mc(pcols,pver)       ! net mass flux   real(r8), intent(out) :: md(pcols,pver)       ! downdraft mass flux   real(r8), intent(out) :: mu(pcols,pver)       ! updraft mass flux   real(r8), intent(out) :: pflx(pcols,pverp)    ! precipitation flux thru layer   real(r8), intent(out) :: qd(pcols,pver)       ! spec humidity of downdraft   real(r8), intent(out) :: ql(pcols,pver)       ! liq water of updraft   real(r8), intent(out) :: qst(pcols,pver)      ! saturation spec humidity of env.   real(r8), intent(out) :: qu(pcols,pver)       ! spec hum of updraft   real(r8), intent(out) :: sd(pcols,pver)       ! normalized dry stat energy of downdraft   real(r8), intent(out) :: su(pcols,pver)       ! normalized dry stat energy of updraft!!     these version of the mass fluxes conserve mass (used in tracer transport)!   real(r8), intent(out) :: mu2(pcols,pver)      ! updraft mass flux   real(r8), intent(out) :: eu2(pcols,pver)      ! updraft entrainment   real(r8), intent(out) :: du2(pcols,pver)      ! updraft detrainment   real(r8), intent(out) :: md2(pcols,pver)      ! downdraft mass flux   real(r8), intent(out) :: ed2(pcols,pver)      ! downdraft entrainment   real(r8) rd                   ! gas constant for dry air   real(r8) grav                 ! gravity   real(r8) cp                   ! heat capacity of dry air!! Local workspace!   real(r8) gamma(pcols,pver)   real(r8) dz(pcols,pver)   real(r8) iprm(pcols,pver)   real(r8) hu(pcols,pver)   real(r8) hd(pcols,pver)   real(r8) eps(pcols,pver)   real(r8) f(pcols,pver)   real(r8) k1(pcols,pver)   real(r8) i2(pcols,pver)   real(r8) ihat(pcols,pver)   real(r8) i3(pcols,pver)   real(r8) idag(pcols,pver)   real(r8) i4(pcols,pver)   real(r8) qsthat(pcols,pver)   real(r8) hsthat(pcols,pver)   real(r8) gamhat(pcols,pver)   real(r8) cu(pcols,pver)   real(r8) evp(pcols,pver)   real(r8) cmeg(pcols,pver)   real(r8) qds(pcols,pver)   real(r8) hmin(pcols)   real(r8) expdif(pcols)   real(r8) expnum(pcols)   real(r8) ftemp(pcols)   real(r8) eps0(pcols)   real(r8) rmue(pcols)   real(r8) zuef(pcols)   real(r8) zdef(pcols)   real(r8) epsm(pcols)   real(r8) ratmjb(pcols)   real(r8) est(pcols)   real(r8) totpcp(pcols)   real(r8) totevp(pcols)   real(r8) alfa(pcols)   real(r8) beta   real(r8) c0   real(r8) ql1   real(r8) weight   real(r8) tu   real(r8) estu   real(r8) qstu   real(r8) small   real(r8) mdt!      real(r8) cu2   integer khighest   integer klowest   integer kount   integer i,k   logical doit(pcols)   logical done(pcols)!

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?