MODULE convection #include "use_logging.h" IMPLICIT NONE CONTAINS PURE SUBROUTINE sigma_levels(ngrid, nlay, i, pplev, ppopsk, sig, dsig, sdsig) INTEGER, INTENT(IN) :: ngrid, nlay, i REAL, INTENT(IN) :: pplev(ngrid,nlay+1), ppopsk(ngrid,nlay) REAL, INTENT(OUT) :: sig(nlay+1), dsig(nlay), sdsig(nlay) ! Calcul des niveaux sigma sur cette colonne INTEGER :: l DO l=1,nlay+1 sig(l)=pplev(i,l)/pplev(i,1) ENDDO DO l=1,nlay dsig(l)=sig(l)-sig(l+1) sdsig(l)=ppopsk(i,l)*dsig(l) ENDDO END SUBROUTINE sigma_levels SUBROUTINE adjust_onecolumn(ngrid, nlay, i, sig, dsig, sdsig, zu2, zv2, zh2) INTEGER, INTENT(IN) :: ngrid, nlay, i REAL, INTENT(OUT) :: sig(nlay+1), sdsig(nlay), dsig(nlay) REAL, INTENT(INOUT) :: zu2(ngrid,nlay), zv2(ngrid,nlay), zh2(ngrid,nlay) INTEGER :: l,l1,l2 LOGICAL :: extend REAL :: zhm,zsm,zum,zvm,zalpha l2=1 DO WHILE( l21 and zhm is lower than layer l1-1 extend = .FALSE. IF (l1 > 1) THEN IF (zhm < zh2(i, l1-1)) extend = .TRUE. END IF IF(extend) THEN l1 = l1-1 zsm = zsm + sdsig(l1) zhm = zhm + sdsig(l1) * (zh2(i, l1) - zhm) / zsm CYCLE END IF ! extend upwards if l21. zalpha=0. zum=0. zvm=0. DO l = l1, l2 zalpha=zalpha+ABS(zh2(i,l)-zhm)*dsig(l) zh2(i, l) = zhm ! we must use compute zum, zvm from zu2, zv2 to conserve momentum (see below) zum=zum+dsig(l)*zu2(i,l) zvm=zvm+dsig(l)*zv2(i,l) END DO zalpha=zalpha/(zhm*(sig(l1)-sig(l2+1))) zum=zum/(sig(l1)-sig(l2+1)) zvm=zvm/(sig(l1)-sig(l2+1)) IF(zalpha.GT.1.) THEN WRITELOG(*,*) 'zalpha=',zalpha CALL log_gridpoint(i) LOG_WARN('convadj') STOP END IF IF(zalpha.LT.1.e-5) zalpha=1.e-5 ! zum, zvm are mass-weighted averages of zu2, zv2 => mixing preserves total momentum DO l=l1,l2 zu2(i,l)=zu2(i,l)+zalpha*(zum-zu2(i,l)) zv2(i,l)=zv2(i,l)+zalpha*(zvm-zv2(i,l)) ENDDO END IF END DO END SUBROUTINE adjust_onecolumn SUBROUTINE convadj(ngrid,nlay,ptimestep, & & pplay,pplev,ppopsk, & & pu,pv,ph, & & pdufi,pdvfi,pdhfi, & & pduadj,pdvadj,pdhadj) !======================================================================= ! ! dry convective adjustment ! h = pot. temp. , static instability if ph(above)