5 & ,
pplay,pplev,pphi,debut &
7 & ,pduadj,pdvadj,pdtadj,pdoadj &
8 & ,fm0,entr0,detr0,zqta,zqla,
lmax &
9 & ,ratqscth,ratqsdiff,zqsatth &
11 & ,ale_bl,alp_bl,lalim_conv,wght_th &
12 & ,zmax0, f0,zw2,fraca)
53 INTEGER ngrid,nlay,w2di
55 real ptimestep,l_mix,r_aspect
56 REAL pt(ngrid,nlay),pdtadj(ngrid,nlay)
57 REAL pu(ngrid,nlay),pduadj(ngrid,nlay)
58 REAL pv(ngrid,nlay),pdvadj(ngrid,nlay)
59 REAL po(ngrid,nlay),pdoadj(ngrid,nlay)
60 REAL pplay(ngrid,nlay),pplev(ngrid,nlay+1)
71 integer,
save :: igout=1
73 integer,
save :: lunout1=6
75 integer,
save :: lev_out=10
82 INTEGER lmix_bis(
klon)
142 real alim_star_tot(
klon),alim_star2(
klon)
167 integer lalim_conv(
klon)
174 character (len=20) :: modname=
'thermcellV0_main'
175 character (len=80) :: abort_message
192 fm=0. ; entr=0. ; detr=0.
204 if (
prt_level.ge.1) print*,
'thermcell_main V4'
207 IF(ngrid.NE.
klon)
THEN
209 print*,
'STOP dans convadj'
210 print*,
'ngrid =',ngrid
217 &
'WARNING thermcell_main f0=max(f0,1.e-2)'
219 f0(ig)=max(f0(ig),1.e-2)
227 & pplev,zo,zh,zl,ztv,zthl,zu,zv,zpspsk,zqsat,lev_out)
229 if (
prt_level.ge.1) print*,
'thermcell_main apres thermcell_env'
254 zlev(:,l)=0.5*(pphi(:,l)+pphi(:,l-1))/
rg
257 zlev(:,nlay+1)=(2.*pphi(:,
klev)-pphi(:,
klev-1))/
rg
259 zlay(:,l)=pphi(:,l)/
rg
263 deltaz(:,l)=zlev(:,l+1)-zlev(:,l)
272 rho(:,l)=pplay(:,l)/(zpspsk(:,l)*rd*ztv(:,l))
277 &
'WARNING thermcell_main rhobarz(:,1)=rho(:,1)'
278 rhobarz(:,1)=rho(:,1)
281 rhobarz(:,l)=0.5*(rho(:,l)+rho(:,l-1))
286 masse(:,l)=(pplev(:,l)-pplev(:,l+1))/
rg
289 if (
prt_level.ge.1) print*,
'thermcell_main apres initialisation'
349 entr_star=0. ; detr_star=0. ; alim_star=0. ; alim_star_tot=0.
351 & lalim,lmin,alim_star,alim_star_tot,lev_out)
357 if (
prt_level.ge.1) print*,
'thermcell_main apres thermcell_init'
359 write(lunout1,*)
'Dans thermcell_main 1'
360 write(lunout1,*)
'lmin ',lmin(igout)
361 write(lunout1,*)
'lalim ',lalim(igout)
362 write(lunout1,*)
' ig l alim_star thetav'
363 write(lunout1,
'(i6,i4,2e15.5)') (igout,l,alim_star(igout,l) &
364 & ,ztv(igout,l),l=1,lalim(igout)+4)
380 & lalim,lmin,zmax_sec,wmax_sec,lev_out)
385 if (
prt_level.ge.1) print*,
'thermcell_main apres thermcell_dry'
387 write(lunout1,*)
'Dans thermcell_main 1b'
388 write(lunout1,*)
'lmin ',lmin(igout)
389 write(lunout1,*)
'lalim ',lalim(igout)
390 write(lunout1,*)
' ig l alim_star entr_star detr_star f_star '
391 write(lunout1,
'(i6,i4,e15.5)') (igout,l,alim_star(igout,l) &
392 & ,l=1,lalim(igout)+4)
401 if (
prt_level.ge.1) print*,
'avant thermcell_plume ',lev_out
404 & zlev,pplev,pphi,zpspsk,l_mix,r_aspect,alim_star,alim_star_tot, &
405 & lalim,zmax_sec,f0,detr_star,entr_star,f_star,ztva, &
406 & ztla,zqla,zqta,zha,zw2,zw_est,zqsatth,lmix,lmix_bis,linter &
407 & ,lev_out,lunout1,igout)
408 if (
prt_level.ge.1) print*,
'apres thermcell_plume ',lev_out
410 call testv0_ltherm(ngrid,nlay,pplev,pplay,lalim,seuil,ztv,po,ztva,zqla,f_star,zw2,
'thermcell_plum lalim ')
411 call testv0_ltherm(ngrid,nlay,pplev,pplay,lmix ,seuil,ztv,po,ztva,zqla,f_star,zw2,
'thermcell_plum lmix ')
413 if (
prt_level.ge.1) print*,
'thermcell_main apres thermcell_plume'
415 write(lunout1,*)
'Dans thermcell_main 2'
416 write(lunout1,*)
'lmin ',lmin(igout)
417 write(lunout1,*)
'lalim ',lalim(igout)
418 write(lunout1,*)
' ig l alim_star entr_star detr_star f_star '
419 write(lunout1,
'(i6,i4,4e15.5)') (igout,l,alim_star(igout,l),entr_star(igout,l),detr_star(igout,l) &
420 & ,f_star(igout,l+1),l=1,nint(linter(igout))+5)
428 & zlev,lmax,zmax,zmax0,zmix,wmax,lev_out)
431 call testv0_ltherm(ngrid,nlay,pplev,pplay,lalim,seuil,ztv,po,ztva,zqla,f_star,zw2,
'thermcell_heig lalim ')
432 call testv0_ltherm(ngrid,nlay,pplev,pplay,lmin ,seuil,ztv,po,ztva,zqla,f_star,zw2,
'thermcell_heig lmin ')
433 call testv0_ltherm(ngrid,nlay,pplev,pplay,lmix ,seuil,ztv,po,ztva,zqla,f_star,zw2,
'thermcell_heig lmix ')
434 call testv0_ltherm(ngrid,nlay,pplev,pplay,lmax ,seuil,ztv,po,ztva,zqla,f_star,zw2,
'thermcell_heig lmax ')
436 if (
prt_level.ge.1) print*,
'thermcell_main apres thermcell_height'
451 & zlev,lalim,alim_star,alim_star_tot,zmax_sec,wmax_sec,zmax,wmax,f,lev_out)
453 if(
prt_level.ge.1)print*,
'thermcell_closure apres thermcell_closure'
455 if (tau_thermals>1.)
then
456 lambda=exp(-ptimestep/tau_thermals)
457 f0=(1.-lambda)*f+lambda*f0
463 if (.not. (f0(1).ge.0.) )
then
464 abort_message = .lt.
'Dans thermcell_main f0(1)0 '
473 & lalim,lmax,alim_star, &
474 & entr_star,detr_star,f,rhobarz,zlev,zw2,fm,entr, &
475 & detr,zqla,lev_out,lunout1,igout)
478 if (
prt_level.ge.1) print*,
'thermcell_main apres thermcell_flux'
479 call testv0_ltherm(ngrid,nlay,pplev,pplay,lalim,seuil,ztv,po,ztva,zqla,f_star,zw2,
'thermcell_flux lalim ')
480 call testv0_ltherm(ngrid,nlay,pplev,pplay,lmax ,seuil,ztv,po,ztva,zqla,f_star,zw2,
'thermcell_flux lmax ')
488 if (tau_thermals>1.)
then
489 lambda=exp(-ptimestep/tau_thermals)
490 fm0=(1.-lambda)*fm+lambda*fm0
491 entr0=(1.-lambda)*entr+lambda*entr0
503 call thermcell_dq(ngrid,nlay,1,ptimestep,fm0,entr0,masse, &
504 & zthl,zdthladj,zta,lev_out)
505 call thermcell_dq(ngrid,nlay,1,ptimestep,fm0,entr0,masse, &
506 & po,pdoadj,zoa,lev_out)
517 if (zw2(ig,l).gt.1.e-10)
then
518 fraca(ig,l)=fm(ig,l)/(rhobarz(ig,l)*zw2(ig,l))
540 & ,zu,zv,pduadj,pdvadj,zua,zva,lev_out)
545 call thermcell_dq(ngrid,nlay,1,ptimestep,fm0,entr0,masse &
546 & ,zu,pduadj,zua,lev_out)
547 call thermcell_dq(ngrid,nlay,1,ptimestep,fm0,entr0,masse &
548 & ,zv,pdvadj,zva,lev_out)
554 pdtadj(ig,l)=zdthladj(ig,l)*zpspsk(ig,l)
558 if (
prt_level.ge.1) print*,
'14 OK convect8'
565 if (
prt_level.ge.1) print*,
'14a OK convect8'
574 chi=zh(ig,1)/(1669.0-122.0*zo(ig,1)/zqsat(ig,1)-zh(ig,1))
575 pcon(ig)=pplay(ig,1)*(zo(ig,1)/zqsat(ig,1))**chi
580 if ((pcon(ig).le.pplay(ig,k)) &
581 & .and.(pcon(ig).gt.pplay(ig,k+1)))
then
582 zcon2(ig)=zlay(ig,k)-(pcon(ig)-pplay(ig,k))/(
rg*rho(ig,k))/100.
588 if (pcon(ig).le.pplay(ig,nlay))
then
589 zcon2(ig)=zlay(ig,nlay)-(pcon(ig)-pplay(ig,nlay))/(
rg*rho(ig,nlay))/100.
590 abort_message =
'thermcellV0_main: les thermiques vont trop haut '
594 if (
prt_level.ge.1) print*,
'14b OK convect8'
597 if (zqla(ig,k).gt.1e-10)
then
603 if (
prt_level.ge.1) print*,
'14c OK convect8'
615 if (
prt_level.ge.1) print*,
'14d OK convect8'
617 &
'WARNING thermcell_main wth2=0. si zw2 > 1.e-10'
623 thetath2(ig,l)=zf2*(zha(ig,l)-zh(ig,l)/zpspsk(ig,l))**2
624 if(zw2(ig,l).gt.1.e-10)
then
625 wth2(ig,l)=zf2*(zw2(ig,l))**2
630 wth3(ig,l)=zf2*(1-2.*fraca(ig,l))/(1-fraca(ig,l)) &
631 & *zw2(ig,l)*zw2(ig,l)*zw2(ig,l)
632 q2(ig,l)=zf2*(zqta(ig,l)*1000.-po(ig,l)*1000.)**2
634 ratqscth(ig,l)=sqrt(max(q2(ig,l),1.e-6)/(po(ig,l)*1000.))
639 print*,
'14e OK convect8 ig,l,zf,zf2',ig,l,zf,zf2
642 print*,
'14f OK convect8 ig,l,zha zh zpspsk ',ig,l,zha(ig,l),zh(ig,l),zpspsk(ig,l)
645 print*,
'14g OK convect8 ig,l,po',ig,l,po(ig,l)
657 if(l.LE.lmax(ig))
THEN
658 alp_int(ig)=alp_int(ig)+0.5*rhobarz(ig,l)*wth3(ig,l)
659 ale_int(ig)=ale_int(ig)+0.5*zw2(ig,l)**2
660 n_int(ig)=n_int(ig)+1
672 if (n_int(ig).gt.0)
then
673 alp_bl(ig)=0.5*alp_int(ig)/n_int(ig)
686 ale_bl(ig)=0.5*zw2(ig,lmix(ig))**2
713 lalim_conv(ig)=lalim(ig)
717 do k=1,lalim_conv(ig)
718 fm_tot(ig)=fm_tot(ig)+fm(ig,k)
722 do k=1,lalim_conv(ig)
723 if (fm_tot(ig).gt.1.e-10)
then
727 if (alim_star(ig,k).gt.1.e-10)
then
728 wght_th(ig,k)=alim_star(ig,k)
738 if ((alim_star(ig,1).lt.1.e-10))
then
746 if (
prt_level.ge.1) print*,
'14e OK convect8'
752 var=var+alim_star(ig,l)*zqta(ig,l)*1000.
755 if (
prt_level.ge.1) print*,
'14f OK convect8'
760 vardiff=vardiff+alim_star(ig,l) &
761 & *(zqta(ig,l)*1000.-var)**2
766 if (
prt_level.ge.1) print*,
'14g OK convect8'
769 ratqsdiff(ig,l)=sqrt(vardiff)/(po(ig,l)*1000.)
778 if (
prt_level.ge.1) print*,
'thermcell_main sorties 3D'
781 if (
prt_level.ge.1) print*,
'thermcell_main FIN OK'
789 subroutine testv0_ltherm(klon,klev,pplev,pplay,long,seuil,ztv,po,ztva,zqla,f_star,zw2,comment)
793 integer i, k, klon,klev
794 real pplev(klon,klev+1),pplay(klon,klev)
799 real f_star(klon,klev)
806 print*,
'WARNING !!! TEST ',comment
814 print*,
'WARNING ',comment,
' au point ',i,
' K= ',long(i)
815 print*,
' K P(MB) THV(K) Qenv(g/kg)THVA QLA(g/kg) F* W2'
817 write(6,
'(i3,7f10.3)') k,pplay(i,k),ztv(i,k),1000*po(i,k),ztva(i,k),1000*zqla(i,k),f_star(i,k),zw2(i,k)
828 & zlev,lalim,alim_star,alim_star_tot,zmax_sec,wmax_sec,zmax,wmax,f,lev_out)
836 include
"thermcell.h"
839 REAL r_aspect,ptimestep
843 REAL alim_star(ngrid,nlay)
844 REAL alim_star_tot(ngrid)
846 REAL zlev(ngrid,nlay)
847 REAL zmax(ngrid),zmax_sec(ngrid)
848 REAL wmax(ngrid),wmax_sec(ngrid)
851 REAL alim_star2(ngrid)
855 character (len=20) :: modname=
'thermcellV0_main'
856 character (len=80) :: abort_message
862 if (alim_star(ig,1).LT.1.e-10)
then
866 alim_star2(ig)=alim_star2(ig)+alim_star(ig,k)**2 &
867 & /(rho(ig,k)*(zlev(ig,k+1)-zlev(ig,k)))
869 zdenom=max(500.,zmax(ig))*r_aspect*alim_star2(ig)
870 if (zdenom<1.e-14)
then
872 print*,
'alim_star2',alim_star2(ig)
873 print*,
'zmax',zmax(ig)
874 print*,
'r_aspect',r_aspect
875 print*,
'zdenom',zdenom
876 print*,
'alim_star',alim_star(ig,:)
877 print*,
'zmax_sec',zmax_sec(ig)
878 print*,
'wmax_sec',wmax_sec(ig)
879 abort_message =
'zdenom<1.e-14'
883 f(ig)=wmax_sec(ig)*alim_star_tot(ig)/(max(500.,zmax_sec(ig))*r_aspect &
887 if(
prt_level.GE.10)
write(
lunout,*)
'closure dry',f(ig),wmax_sec(ig),alim_star_tot(ig),zmax_sec(ig)
889 f(ig)=wmax(ig)*alim_star_tot(ig)/zdenom
892 if(
prt_level.GE.10) print*,
'closure moist',f(ig),wmax(ig),alim_star_tot(ig),zmax(ig)
897 if (
prt_level.ge.1) print*,
'apres fermeture'
904 & zlev,pplev,pphi,zpspsk,l_mix,r_aspect,alim_star,alim_star_tot, &
905 & lalim,zmax_sec,f0,detr_star,entr_star,f_star,ztva, &
906 & ztla,zqla,zqta,zha,zw2,w_est,zqsatth,lmix,lmix_bis,linter &
907 & ,lev_out,lunout1,igout)
919 include
"thermcell.h"
922 INTEGER lunout1,igout
926 REAL zthl(ngrid,klev)
929 REAL rhobarz(ngrid,klev)
930 REAL zlev(ngrid,klev+1)
931 REAL pplev(ngrid,klev+1)
932 REAL pphi(ngrid,klev)
933 REAL zpspsk(ngrid,klev)
934 REAL alim_star(ngrid,klev)
943 real alim_star_tot(ngrid)
945 REAL ztva(ngrid,klev)
946 REAL ztla(ngrid,klev)
947 REAL zqla(ngrid,klev)
948 REAL zqla0(ngrid,klev)
949 REAL zqta(ngrid,klev)
952 REAL detr_star(ngrid,klev)
954 REAL detr_stara(ngrid,klev)
955 REAL detr_starb(ngrid,klev)
956 REAL detr_starc(ngrid,klev)
957 REAL detr_star0(ngrid,klev)
958 REAL detr_star1(ngrid,klev)
959 REAL detr_star2(ngrid,klev)
961 REAL entr_star(ngrid,klev)
962 REAL entr_star1(ngrid,klev)
963 REAL entr_star2(ngrid,klev)
964 REAL detr(ngrid,klev)
965 REAL entr(ngrid,klev)
967 REAL zw2(ngrid,klev+1)
968 REAL w_est(ngrid,klev+1)
969 REAL f_star(ngrid,klev+1)
970 REAL wa_moy(ngrid,klev+1)
972 REAL ztva_est(ngrid,klev)
973 REAL zqla_est(ngrid,klev)
974 REAL zqsatth(ngrid,klev)
975 REAL zta_est(ngrid,klev)
979 INTEGER lmix_bis(ngrid)
984 real zcor,zdelta,zcvm5,qlbef
986 real dqsat_dT,DT,num,denom
990 REAL fact_gamma,fact_epsilon
1011 ztva_est(ig,l)=ztva(ig,l)
1025 ztva(ig,k)=ztv(ig,k)
1026 ztla(ig,k)=zthl(ig,k)
1030 ztva(ig,k) = ztla(ig,k)*zpspsk(ig,k)+rlvcp*zqla(ig,k)
1031 ztva(ig,k) = ztva(ig,k)/zpspsk(ig,k)
1032 zha(ig,k) = ztva(ig,k)
1055 if (
prt_level.ge.1) print*,
'7 OK convect8'
1065 if (
prt_level.ge.1) print*,
'8 OK convect8'
1085 if (ztv(ig,l).gt.ztv(ig,l+1) &
1086 & .and.alim_star(ig,l).gt.1.e-10 &
1087 & .and.zw2(ig,l).lt.1e-10)
then
1092 ztla(ig,l)=zthl(ig,l)
1095 f_star(ig,l+1)=alim_star(ig,l)
1097 zw2(ig,l+1)=2.*
rg*(ztv(ig,l)-ztv(ig,l+1))/ztv(ig,l+1) &
1098 & *(zlev(ig,l+1)-zlev(ig,l)) &
1099 & *0.4*pphi(ig,l)/(pphi(ig,l+1)-pphi(ig,l))
1100 w_est(ig,l+1)=zw2(ig,l+1)
1104 else if ((zw2(ig,l).ge.1e-10).and. &
1105 & (f_star(ig,l)+alim_star(ig,l)).gt.1.e-10)
then
1137 w_est(ig,3)=zw2(ig,2)* &
1138 & ((f_star(ig,2))**2) &
1139 & /(f_star(ig,2)+alim_star(ig,2))**2+ &
1140 & 2.*
rg*(ztva(ig,2)-ztv(ig,2))/ztv(ig,2) &
1142 & *(zlev(ig,3)-zlev(ig,2))
1152 tbef=ztla(ig,l-1)*zpspsk(ig,l)
1153 zdelta=max(0.,sign(1.,rtt-tbef))
1154 qsatbef= r2es * foeew(tbef,zdelta)/pplev(ig,l)
1155 qsatbef=min(0.5,qsatbef)
1156 zcor=1./(1.-retv*qsatbef)
1157 qsatbef=qsatbef*zcor
1158 zsat = (max(0.,zqta(ig,l-1)-qsatbef) .gt. 1.e-10)
1160 qlbef=max(0.,zqta(ig,l-1)-qsatbef)
1161 dt = 0.5*rlvcp*qlbef
1162 do while (abs(dt).gt.ddt0)
1164 zdelta=max(0.,sign(1.,rtt-tbef))
1165 qsatbef= r2es * foeew(tbef,zdelta)/pplev(ig,l)
1166 qsatbef=min(0.5,qsatbef)
1167 zcor=1./(1.-retv*qsatbef)
1168 qsatbef=qsatbef*zcor
1169 qlbef=zqta(ig,l-1)-qsatbef
1171 zdelta=max(0.,sign(1.,rtt-tbef))
1172 zcvm5=r5les*(1.-zdelta) + r5ies*zdelta
1173 zcor=1./(1.-retv*qsatbef)
1174 dqsat_dt=foede(tbef,zdelta,zcvm5,qsatbef,zcor)
1175 num=-tbef+ztla(ig,l-1)*zpspsk(ig,l)+rlvcp*qlbef
1176 denom=1.+rlvcp*dqsat_dt
1179 zqla_est(ig,l) = max(0.,zqta(ig,l-1)-qsatbef)
1181 ztva_est(ig,l) = ztla(ig,l-1)*zpspsk(ig,l)+rlvcp*zqla_est(ig,l)
1182 ztva_est(ig,l) = ztva_est(ig,l)/zpspsk(ig,l)
1183 zta_est(ig,l)=ztva_est(ig,l)
1184 ztva_est(ig,l) = ztva_est(ig,l)*(1.+retv*(zqta(ig,l-1) &
1185 & -zqla_est(ig,l))-zqla_est(ig,l))
1187 w_est(ig,l+1)=zw2(ig,l)* &
1188 & ((f_star(ig,l))**2) &
1189 & /(f_star(ig,l)+alim_star(ig,l))**2+ &
1190 & 2.*
rg*(ztva_est(ig,l)-ztv(ig,l))/ztv(ig,l) &
1192 & *(zlev(ig,l+1)-zlev(ig,l))
1193 if (w_est(ig,l+1).lt.0.)
then
1194 w_est(ig,l+1)=zw2(ig,l)
1217 if ((w_est(ig,l+1).gt.w_est(ig,l)).and. &
1218 & (zlev(ig,l+1).lt.zmax_sec(ig)).and. &
1220 & (zqla_est(ig,l).lt.1.e-10))
then
1222 & (zqla(ig,l-1).lt.1.e-10))
then
1224 detr_star(ig,l)=max(0.,(rhobarz(ig,l+1) &
1225 & *sqrt(w_est(ig,l+1))*sqrt(l_mix*zlev(ig,l+1)) &
1226 & -rhobarz(ig,l)*sqrt(w_est(ig,l))*sqrt(l_mix*zlev(ig,l))) &
1227 & /(r_aspect*zmax_sec(ig)))
1228 detr_stara(ig,l)=detr_star(ig,l)
1230 if (
prt_level.ge.20) print*,
'coucou calcul detr 1: ig, l',ig,l
1233 else if ((zlev(ig,l+1).lt.zmax_sec(ig)).and. &
1235 & (zqla_est(ig,l).lt.1.e-10))
then
1237 & (zqla(ig,l-1).lt.1.e-10))
then
1239 detr_star(ig,l)=-f0(ig)*f_star(ig,lmix(ig)) &
1240 & /(rhobarz(ig,lmix(ig))*wmaxa(ig))* &
1241 & (rhobarz(ig,l+1)*sqrt(w_est(ig,l+1)) &
1242 & *((zmax_sec(ig)-zlev(ig,l+1))/ &
1243 & ((zmax_sec(ig)-zlev(ig,lmix(ig)))))**2. &
1244 & -rhobarz(ig,l)*sqrt(w_est(ig,l)) &
1245 & *((zmax_sec(ig)-zlev(ig,l))/ &
1246 & ((zmax_sec(ig)-zlev(ig,lmix(ig)))))**2.)
1247 detr_starb(ig,l)=detr_star(ig,l)
1249 if (
prt_level.ge.20) print*,
'coucou calcul detr 2: ig, l',ig,l
1254 detr_star(ig,l)=0.002*f0(ig)*f_star(ig,l) &
1255 & *(zlev(ig,l+1)-zlev(ig,l))
1256 detr_starc(ig,l)=detr_star(ig,l)
1258 if (
prt_level.ge.20) print*,
'coucou calcul detr 3 n: ig, l',ig, l
1265 if ((w_est(ig,l+1).gt.w_est(ig,l)).and. &
1266 & (zlev(ig,l+1).lt.zmax_sec(ig)) )
then
1267 detr_star(ig,l)=max(0.,(rhobarz(ig,l+1) &
1268 & *sqrt(w_est(ig,l+1))*sqrt(l_mix*zlev(ig,l+1)) &
1269 & -rhobarz(ig,l)*sqrt(w_est(ig,l))*sqrt(l_mix*zlev(ig,l))) &
1270 & /(r_aspect*zmax_sec(ig)))
1272 if (
prt_level.ge.20) print*,
'coucou calcul detr 1: ig, l', ig, l
1275 else if ((zlev(ig,l+1).lt.zmax_sec(ig)) )
then
1276 detr_star(ig,l)=-f0(ig)*f_star(ig,lmix(ig)) &
1277 & /(rhobarz(ig,lmix(ig))*wmaxa(ig))* &
1278 & (rhobarz(ig,l+1)*sqrt(w_est(ig,l+1)) &
1279 & *((zmax_sec(ig)-zlev(ig,l+1))/ &
1280 & ((zmax_sec(ig)-zlev(ig,lmix(ig)))))**2. &
1281 & -rhobarz(ig,l)*sqrt(w_est(ig,l)) &
1282 & *((zmax_sec(ig)-zlev(ig,l))/ &
1283 & ((zmax_sec(ig)-zlev(ig,lmix(ig)))))**2.)
1284 if (
prt_level.ge.20) print*,
'coucou calcul detr 1: ig, l', ig, l
1291 detr_starc(ig,l)=0.002*f0(ig)*f_star(ig,l) &
1292 & *(zlev(ig,l+1)-zlev(ig,l))
1294 coefc=min(zqla(ig,l-1)/1.e-3,1.)
1295 if (zlev(ig,l+1).ge.zmax_sec(ig)) coefc=1.
1299 detr_star(ig,l)=detr_starc(ig,l)*coefc+detr_star(ig,l)*(1.-coefc)
1301 if (
prt_level.ge.20) print*,
'coucou calcul detr 2: ig, l', ig, l
1306 if (
prt_level.ge.20) print*,
'coucou calcul detr 444: ig, l', ig, l
1313 zqla0(ig,l)=zqla_est(ig,l)
1314 detr_star0(ig,l)=detr_star(ig,l)
1323 detr_star(ig,l)=detr_star(ig,l)/f0(ig)
1336 if (
prt_level.ge.20) print*,
'coucou calcul detr 445: ig, l', ig, l
1357 if (
prt_level.ge.20) print*,
'coucou calcul detr 446: ig, l', ig, l
1368 detr_star(ig,l)=min(detr_star(ig,l),f_star(ig,l))
1370 detr_star(ig,l)=min(detr_star(ig,l),1.)
1373 entr_star(ig,l)=max(0.4*detr_star(ig,l)-alim_star(ig,l),0.)
1375 if (
prt_level.ge.20) print*,
'coucou calcul detr 447: ig, l', ig, l
1379 if (detr_star(ig,l)>f_star(ig,l)+entr_star(ig,l))
then
1380 detr_star(ig,l)=f_star(ig,l)+entr_star(ig,l)
1390 if (
prt_level.ge.20) print*,
'coucou calcul detr 448: ig, l', ig, l
1391 if(l.gt.lalim(ig))
then
1392 entr_star(ig,l)=0.4*detr_star(ig,l)
1404 if (
prt_level.ge.20) print*,
'coucou calcul detr 449: ig, l', ig, l
1407 entr_star(ig,l)=max(detr_star(ig,l)-alim_star(ig,l),0.)
1408 detr_star(ig,l)=entr_star(ig,l)
1417 if (
prt_level.ge.20) print*,
'coucou calcul detr 440: ig, l', ig, l
1418 entr_star1(ig,l)=entr_star(ig,l)
1419 detr_star1(ig,l)=detr_star(ig,l)
1424 if (detr_star(ig,l).gt.f_star(ig,l))
then
1430 detr_star(ig,l)=f_star(ig,l)
1432 if (l.gt.lalim(ig)+1)
then
1440 entr_star(ig,l)=0.4*detr_star(ig,l)
1443 entr_star(ig,l)=0.4*detr_star(ig,l)
1453 entr_star2(ig,l)=entr_star(ig,l)
1454 detr_star2(ig,l)=detr_star(ig,l)
1455 if (
prt_level.ge.20) print*,
'coucou calcul detr 450: ig, l', ig, l
1475 entr_star(ig,l)=max(0.*f_star(ig,l)*(zlev(ig,l+1)-zlev(ig,l)), &
1476 & f_star(ig,l)/(2.*w_est(ig,l+1)) &
1477 & *
rg*(ztva_est(ig,l)-ztv(ig,l))/ztv(ig,l) &
1478 & *(zlev(ig,l+1)-zlev(ig,l))) &
1479 & +0.0001*f_star(ig,l)*(zlev(ig,l+1)-zlev(ig,l))
1481 if (((ztva_est(ig,l)-ztv(ig,l)).gt.1.e-10).and.(l.le.lmix_bis(ig)))
then
1482 alim_star_tot(ig)=alim_star_tot(ig)+entr_star(ig,l)
1483 lalim(ig)=lmix_bis(ig)
1484 if(
prt_level.GE.10) print*,
'alim_star_tot',alim_star_tot(ig),entr_star(ig,l)
1487 if (((ztva_est(ig,l)-ztv(ig,l)).gt.1.e-10).and.(l.le.lmix_bis(ig)))
then
1490 detr_star(ig,l)=max(0.*f_star(ig,l)*(zlev(ig,l+1)-zlev(ig,l)), &
1491 & c2(ig,l)*f_star(ig,l)*(zlev(ig,l+1)-zlev(ig,l)) &
1492 & -f_star(ig,l)/(2.*w_est(ig,l+1)) &
1493 & *
rg*(ztva_est(ig,l)-ztv(ig,l))/ztv(ig,l) &
1494 & *(zlev(ig,l+1)-zlev(ig,l))) &
1495 & +0.0001*f_star(ig,l)*(zlev(ig,l+1)-zlev(ig,l))
1501 detr_star(ig,l)=max(0.*f_star(ig,l)*(zlev(ig,l+1)-zlev(ig,l)), &
1502 & c2(ig,l)*f_star(ig,l)*(zlev(ig,l+1)-zlev(ig,l)) &
1503 & -f_star(ig,l)/(2.*w_est(ig,l+1)) &
1504 & *
rg*(ztva_est(ig,l)-ztv(ig,l))/ztv(ig,l) &
1505 & *(zlev(ig,l+1)-zlev(ig,l))) &
1506 & +0.0002*f_star(ig,l)*(zlev(ig,l+1)-zlev(ig,l))
1550 f_star(ig,l+1)=f_star(ig,l)+alim_star(ig,l)+entr_star(ig,l) &
1554 if (
prt_level.ge.20) print*,
'coucou calcul detr 451: ig, l', ig, l
1555 if (f_star(ig,l+1).gt.1.e-10)
then
1561 ztla(ig,l)=(f_star(ig,l)*ztla(ig,l-1)+ &
1562 & (alim_star(ig,l)+entr_star(ig,l))*zthl(ig,l)) &
1563 & /(f_star(ig,l+1)+detr_star(ig,l))
1565 zqta(ig,l)=(f_star(ig,l)*zqta(ig,l-1)+ &
1566 & (alim_star(ig,l)+entr_star(ig,l))*po(ig,l)) &
1567 & /(f_star(ig,l+1)+detr_star(ig,l))
1569 tbef=ztla(ig,l)*zpspsk(ig,l)
1570 zdelta=max(0.,sign(1.,rtt-tbef))
1571 qsatbef= r2es * foeew(tbef,zdelta)/pplev(ig,l)
1572 qsatbef=min(0.5,qsatbef)
1573 zcor=1./(1.-retv*qsatbef)
1574 qsatbef=qsatbef*zcor
1575 zsat = (max(0.,zqta(ig,l)-qsatbef) .gt. 1.e-10)
1577 qlbef=max(0.,zqta(ig,l)-qsatbef)
1578 dt = 0.5*rlvcp*qlbef
1579 do while (abs(dt).gt.ddt0)
1581 zdelta=max(0.,sign(1.,rtt-tbef))
1582 qsatbef= r2es * foeew(tbef,zdelta)/pplev(ig,l)
1583 qsatbef=min(0.5,qsatbef)
1584 zcor=1./(1.-retv*qsatbef)
1585 qsatbef=qsatbef*zcor
1586 qlbef=zqta(ig,l)-qsatbef
1588 zdelta=max(0.,sign(1.,rtt-tbef))
1589 zcvm5=r5les*(1.-zdelta) + r5ies*zdelta
1590 zcor=1./(1.-retv*qsatbef)
1591 dqsat_dt=foede(tbef,zdelta,zcvm5,qsatbef,zcor)
1592 num=-tbef+ztla(ig,l)*zpspsk(ig,l)+rlvcp*qlbef
1593 denom=1.+rlvcp*dqsat_dt
1596 zqla(ig,l) = max(0.,qlbef)
1599 if (
prt_level.ge.20) print*,
'coucou calcul detr 4512: ig, l', ig, l
1602 ztva(ig,l) = ztla(ig,l)*zpspsk(ig,l)+rlvcp*zqla(ig,l)
1603 ztva(ig,l) = ztva(ig,l)/zpspsk(ig,l)
1605 zha(ig,l) = ztva(ig,l)
1606 ztva(ig,l) = ztva(ig,l)*(1.+retv*(zqta(ig,l) &
1607 & -zqla(ig,l))-zqla(ig,l))
1610 zqsatth(ig,l)=qsatbef
1612 zw2(ig,l+1)=zw2(ig,l)* &
1613 & ((f_star(ig,l))**2) &
1616 & /(f_star(ig,l+1)+detr_star(ig,l)-entr_star(ig,l)*(1.-fact_epsilon))**2+ &
1617 & 2.*
rg*(ztva(ig,l)-ztv(ig,l))/ztv(ig,l) &
1619 & *(zlev(ig,l+1)-zlev(ig,l))
1646 if (
prt_level.ge.20) print*,
'coucou calcul detr 460: ig, l',ig, l
1650 if (zw2(ig,l+1)>0. .and. zw2(ig,l+1).lt.1.e-10)
then
1651 print*,
'On tombe sur le cas particulier de thermcell_plume'
1657 if (zw2(ig,l+1).lt.0.)
then
1658 linter(ig)=(l*(zw2(ig,l+1)-zw2(ig,l)) &
1659 & -zw2(ig,l))/(zw2(ig,l+1)-zw2(ig,l))
1663 wa_moy(ig,l+1)=sqrt(zw2(ig,l+1))
1665 if (wa_moy(ig,l+1).gt.wmaxa(ig))
then
1668 if (zqla(ig,l).lt.1.e-10)
then
1672 wmaxa(ig)=wa_moy(ig,l+1)
1693 alim_star(ig,l)=entr_star(ig,l)
1698 if (
prt_level.ge.20) print*,
'coucou calcul detr 470: ig, l', ig, l
1706 & lalim,lmin,zmax,wmax,lev_out)
1717 REAL zlev(ngrid,nlay+1)
1718 REAL pphi(ngrid,nlay)
1719 REAl ztv(ngrid,nlay)
1720 REAL alim_star(ngrid,nlay)
1721 INTEGER lalim(ngrid)
1728 REAL zw2(ngrid,nlay+1)
1729 REAL f_star(ngrid,nlay+1)
1730 REAL ztva(ngrid,nlay+1)
1732 REAL wa_moy(ngrid,nlay+1)
1733 REAL linter(ngrid),zlevinter(ngrid)
1734 INTEGER lmix(ngrid),lmax(ngrid),lmin(ngrid)
1745 ztva(ig,l)=ztv(ig,l)
1770 f_star(:,l+1)=f_star(:,l)+alim_star(:,l)
1784 if (l.eq.lmin(ig).and.lalim(ig).gt.1)
then
1790 zw2(ig,l+1)=2.*
rg*(ztv(ig,l)-ztv(ig,l+1))/ztv(ig,l+1) &
1791 & *(zlev(ig,l+1)-zlev(ig,l)) &
1792 & *0.4*pphi(ig,l)/(pphi(ig,l+1)-pphi(ig,l))
1814 else if (zw2(ig,l).ge.1e-10)
then
1816 ztva(ig,l)=(f_star(ig,l)*ztva(ig,l-1)+alim_star(ig,l) &
1817 & *ztv(ig,l))/f_star(ig,l+1)
1818 zw2(ig,l+1)=zw2(ig,l)*(f_star(ig,l)/f_star(ig,l+1))**2+ &
1819 & 2.*
rg*(ztva(ig,l)-ztv(ig,l))/ztv(ig,l) &
1820 & *(zlev(ig,l+1)-zlev(ig,l))
1825 if (zw2(ig,l+1)>0. .and. zw2(ig,l+1).lt.1.e-10)
then
1832 if (zw2(ig,l+1).lt.0.)
then
1833 linter(ig)=(l*(zw2(ig,l+1)-zw2(ig,l)) &
1834 & -zw2(ig,l))/(zw2(ig,l+1)-zw2(ig,l))
1839 wa_moy(ig,l+1)=sqrt(zw2(ig,l+1))
1841 if (wa_moy(ig,l+1).gt.wmaxa(ig))
then
1844 wmaxa(ig)=wa_moy(ig,l+1)
1848 if (
prt_level.ge.1) print*,
'fin calcul zw2'
1874 if (l.le.lmax(ig))
then
1875 zw2(ig,l)=sqrt(zw2(ig,l))
1876 wmax(ig)=max(wmax(ig),zw2(ig,l))
1886 zlevinter(ig)=zlev(ig,1)
1899 zlevinter(ig)=zlev(ig,lmax(ig)) + &
1900 & (linter(ig)-lmax(ig))*(zlev(ig,lmax(ig)+1)-zlev(ig,lmax(ig)))
1901 zmax(ig)=max(zmax(ig),zlevinter(ig)-zlev(ig,lmin(ig)))
1906 if(lalim(ig)>lmax(ig))
then
1908 print*,
'WARNING thermcell_dry ig=',ig,
' lalim=',lalim(ig),
' lmax(ig)=',lmax(ig)
1918 & lalim,lmin,alim_star,alim_star_tot,lev_out)
1925 include
"thermcell.h"
1930 REAL ztv(ngrid,nlay)
1931 REAL zlay(ngrid,nlay)
1932 REAL zlev(ngrid,nlay+1)
1934 INTEGER lalim(ngrid)
1936 REAL alim_star(ngrid,nlay)
1937 REAL alim_star_tot(ngrid)
1957 if (ztv(ig,1).gt.ztv(ig,2))
then
1961 alim_star_tot(ig)=alim_star(ig,1)
1962 if(
prt_level.GE.10) print*,
'init',alim_star(ig,1),alim_star_tot(ig)
1967 alim_star_tot(ig)=0.
1977 if (ztv(ig,l).gt.ztv(ig,l+1).and. &
1978 & ztv(ig,l+1).le.ztv(ig,l+2))
then
1993 if (ztv(ig,l-1).gt.ztv(ig,l))
then
2002 if (l<lalim(ig))
then
2003 zzalim(ig)=zzalim(ig)+zlay(ig,l)*(ztv(ig,l)-ztv(ig,l+1))
2008 if (lalim(ig)>1)
then
2009 zzalim(ig)=zlay(ig,1)+zzalim(ig)/(ztv(ig,1)-ztv(ig,lalim(ig)))
2011 zzalim(ig)=zlay(ig,1)
2015 if(
prt_level.GE.10) print*,
'ZZALIM LALIM ',zzalim,lalim,zlay(1,lalim(1))
2021 if (ztv(ig,l).gt.ztv(ig,l+1).and. &
2022 & l.ge.lmin(ig).and.l.lt.lalim(ig))
then
2024 alim_star(ig,l)=max((ztv(ig,l)-ztv(ig,l+1)),0.) &
2025 & *sqrt(zlev(ig,l+1))
2032 if (ztv(ig,l).gt.ztv(ig,l+1).and. &
2033 & l.ge.lmin(ig).and.l.lt.lalim(ig))
then
2034 alim_star(ig,l)=max(3.*zzalim(ig)-zlay(ig,l),0.) &
2035 & *(zlev(ig,l+1)-zlev(ig,l))
2044 if (alim_star(ig,1).lt.1.e-10)
then
2053 alim_star_tot(ig)=0.
2057 alim_star_tot(ig)=alim_star_tot(ig)+alim_star(ig,l)
2064 if (alim_star_tot(ig).gt.1.e-10)
then
2065 alim_star(ig,l)=alim_star(ig,l)/alim_star_tot(ig)
2072 alim_star_tot(ig)=1.
subroutine thermcell_env(ngrid, nlay, po, pt, pu, pv, pplay, pplev, zo, zh, zl, ztv, zthl, zu, zv, zpspsk, pqsat, lev_out)
subroutine thermcell_height(ngrid, nlay, lalim, lmin, linter, lmix, zw2, zlev, lmax, zmax, zmax0, zmix, wmax, lev_out)
subroutine thermcellv0_dry(ngrid, nlay, zlev, pphi, ztv, alim_star, lalim, lmin, zmax, wmax, lev_out)
subroutine scopy(n, sx, incx, sy, incy)
subroutine thermcellv0_plume(itap, ngrid, klev, ptimestep, ztv, zthl, po, zl, rhobarz, zlev, pplev, pphi, zpspsk, l_mix, r_aspect, alim_star, alim_star_tot, lalim, zmax_sec, f0, detr_star, entr_star, f_star, ztva, ztla, zqla, zqta, zha, zw2, w_est, zqsatth, lmix, lmix_bis, linter, lev_out, lunout1, igout)
!$Id itapm1 ENDIF!IM on interpole les champs sur les niveaux STD de pression!IM a chaque pas de temps de la physique c!positionnement de l argument logique a false c!pour ne pas recalculer deux fois la meme chose!c!a cet effet un appel a plevel_new a ete deplace c!a la fin de la serie d appels c!la boucle DO nlevSTD a ete internalisee c!dans d ou la creation de cette routine c c!CALL false
subroutine thermcellv0_init(ngrid, nlay, ztv, zlay, zlev, lalim, lmin, alim_star, alim_star_tot, lev_out)
!$Id itapm1 ENDIF!IM on interpole les champs sur les niveaux STD de pression!IM a chaque pas de temps de la physique c!positionnement de l argument logique a false c!pour ne pas recalculer deux fois la meme chose!c!a cet effet un appel a plevel_new a ete deplace c!a la fin de la serie d appels c!la boucle DO nlevSTD a ete internalisee c!dans d ou la creation de cette routine c c!CALL pplay
!FH On elimine toutes les clefs physiques dans la dynamique prt_level
!$Header!integer nvarmx parameter(nfmx=10, imx=200, jmx=150, lmx=200, nvarmx=1000) real xd(imx
subroutine thermcellv0_main(itap, ngrid, nlay, ptimestep, pplay, pplev, pphi, debut, pu, pv, pt, po, pduadj, pdvadj, pdtadj, pdoadj, fm0, entr0, detr0, zqta, zqla, lmax, ratqscth, ratqsdiff, zqsatth, r_aspect, l_mix, tau_thermals, Ale_bl, Alp_bl, lalim_conv, wght_th, zmax0, f0, zw2, fraca)
!$Id itapm1 ENDIF!IM on interpole les champs sur les niveaux STD de pression!IM a chaque pas de temps de la physique c!positionnement de l argument logique a false c!pour ne pas recalculer deux fois la meme chose!c!a cet effet un appel a plevel_new a ete deplace c!a la fin de la serie d appels c!la boucle DO nlevSTD a ete internalisee c!dans d ou la creation de cette routine c c!CALL ulevSTD CALL &zphi philevSTD CALL &zx_rh rhlevSTD!DO klev DO klon klev DO klon klev DO klon klev DO klon klev DO klon klev DO klon klev DO klon klev DO klon klev DO klon klev DO klon du jour ou toutes les read_climoz CALL true
subroutine thermcell_flux2(ngrid, klev, ptimestep, masse, lalim, lmax, alim_star, entr_star, detr_star, f, rhobarz, zlev, zw2, fm, entr, detr, zqla, lev_out, lunout1, igout)
subroutine thermcell_dq(ngrid, nlay, impl, ptimestep, fm, entr, masse, q, dq, qa, lev_out)
nsplit_thermals!nrlmd le iflag_clos_bl tau_trig_deep real::s_trig!fin nrlmd le fact_thermals_ed_dz iflag_wake iflag_thermals_closure common ctherm1 iflag_thermals_closure common ctherm2 tau_thermals
subroutine thermcellv0_closure(ngrid, nlay, r_aspect, ptimestep, rho, zlev, lalim, alim_star, alim_star_tot, zmax_sec, wmax_sec, zmax, wmax, f, lev_out)
nsplit_thermals!nrlmd le iflag_clos_bl tau_trig_deep real::s_trig!fin nrlmd le fact_thermals_ed_dz iflag_wake iflag_thermals_closure common ctherm1 iflag_thermals_closure common ctherm2 fact_thermals_ed_dz common ctherm4 iflag_wake common ctherm5 iflag_thermals_ed
subroutine testv0_ltherm(klon, klev, pplev, pplay, long, seuil, ztv, po, ztva, zqla, f_star, zw2, comment)
subroutine abort_physic(modname, message, ierr)
INTERFACE SUBROUTINE RRTM_ECRT_140GP pt
subroutine thermcell_dv2(ngrid, nlay, ptimestep, fm, entr, masse, fraca, larga, u, v, du, dv, ua, va, lev_out)
!$Header!gestion des impressions de sorties et de débogage la sortie standard prt_level COMMON comprint lunout