1 |
|
|
MODULE lmdz_thermcell_height |
2 |
|
|
CONTAINS |
3 |
|
|
|
4 |
|
288 |
SUBROUTINE thermcell_height(ngrid,nlay,lalim,lmin,linter,lmix, & |
5 |
|
288 |
& zw2,zlev,lmax,zmax,zmax0,zmix,wmax) |
6 |
|
|
IMPLICIT NONE |
7 |
|
|
|
8 |
|
|
!----------------------------------------------------------------------------- |
9 |
|
|
!thermcell_height: calcul des caracteristiques du thermique: zmax,wmax,zmix |
10 |
|
|
!----------------------------------------------------------------------------- |
11 |
|
|
|
12 |
|
|
! arguments |
13 |
|
|
|
14 |
|
|
! Entree |
15 |
|
|
integer, intent(in) :: ngrid,nlay |
16 |
|
|
real, intent(in), dimension(ngrid) :: linter |
17 |
|
|
real, intent(in), dimension(ngrid,nlay+1) :: zlev |
18 |
|
|
! Sortie |
19 |
|
|
real, intent(out), dimension(ngrid) :: wmax,zmax,zmax0,zmix |
20 |
|
|
integer, intent(out), dimension(ngrid) :: lmax |
21 |
|
|
! Les deux |
22 |
|
|
integer, intent(inout), dimension(ngrid) :: lmix,lalim,lmin |
23 |
|
|
real, intent(inout), dimension(ngrid,nlay+1) :: zw2 |
24 |
|
|
|
25 |
|
|
! local |
26 |
|
288 |
real, dimension(ngrid) :: num,denom,zlevinter |
27 |
|
|
integer ig,l |
28 |
|
|
|
29 |
|
|
!calcul de la hauteur max du thermique |
30 |
✓✓ |
286560 |
do ig=1,ngrid |
31 |
|
286560 |
lmax(ig)=lalim(ig) |
32 |
|
|
enddo |
33 |
✓✓ |
286560 |
do ig=1,ngrid |
34 |
✓✓ |
10823426 |
do l=nlay,lalim(ig)+1,-1 |
35 |
✓✓ |
10823138 |
if (zw2(ig,l).le.1.e-10) then |
36 |
|
10136149 |
lmax(ig)=l-1 |
37 |
|
|
endif |
38 |
|
|
enddo |
39 |
|
|
enddo |
40 |
|
|
|
41 |
|
|
! On traite le cas particulier qu'il faudrait �viter ou le thermique |
42 |
|
|
! atteind le haut du modele ... |
43 |
✓✓ |
286560 |
do ig=1,ngrid |
44 |
✗✓ |
286560 |
if ( zw2(ig,nlay) > 1.e-10 ) then |
45 |
|
|
print*,'WARNING !!!!! W2 thermiques non nul derniere couche ' |
46 |
|
|
lmax(ig)=nlay |
47 |
|
|
endif |
48 |
|
|
enddo |
49 |
|
|
|
50 |
|
|
! pas de thermique si couche 1 stable |
51 |
✓✓ |
286560 |
do ig=1,ngrid |
52 |
✗✓ |
286560 |
if (lmin(ig).gt.1) then |
53 |
|
|
lmax(ig)=1 |
54 |
|
|
lmin(ig)=1 |
55 |
|
|
lalim(ig)=1 |
56 |
|
|
endif |
57 |
|
|
enddo |
58 |
|
|
! |
59 |
|
|
! Determination de zw2 max |
60 |
✓✓ |
286560 |
do ig=1,ngrid |
61 |
|
286560 |
wmax(ig)=0. |
62 |
|
|
enddo |
63 |
|
|
|
64 |
✓✓ |
11520 |
do l=1,nlay |
65 |
✓✓ |
11176128 |
do ig=1,ngrid |
66 |
✓✓ |
11175840 |
if (l.le.lmax(ig)) then |
67 |
✗✓ |
1028459 |
if (zw2(ig,l).lt.0.)then |
68 |
|
|
print*,'pb2 zw2<0' |
69 |
|
|
endif |
70 |
|
1028459 |
zw2(ig,l)=sqrt(zw2(ig,l)) |
71 |
|
1028459 |
wmax(ig)=max(wmax(ig),zw2(ig,l)) |
72 |
|
|
else |
73 |
|
10136149 |
zw2(ig,l)=0. |
74 |
|
|
endif |
75 |
|
|
enddo |
76 |
|
|
enddo |
77 |
|
|
|
78 |
|
|
! Longueur caracteristique correspondant a la hauteur des thermiques. |
79 |
✓✓ |
286560 |
do ig=1,ngrid |
80 |
|
286272 |
zmax(ig)=0. |
81 |
|
286560 |
zlevinter(ig)=zlev(ig,1) |
82 |
|
|
enddo |
83 |
|
|
|
84 |
|
|
! if (iflag_thermals_ed.ge.1) then |
85 |
|
|
if (1==0) then |
86 |
|
|
!CR:date de quand le calcul du zmax continu etait buggue |
87 |
|
|
num(:)=0. |
88 |
|
|
denom(:)=0. |
89 |
|
|
do ig=1,ngrid |
90 |
|
|
do l=1,nlay |
91 |
|
|
num(ig)=num(ig)+zw2(ig,l)*zlev(ig,l)*(zlev(ig,l+1)-zlev(ig,l)) |
92 |
|
|
denom(ig)=denom(ig)+zw2(ig,l)*(zlev(ig,l+1)-zlev(ig,l)) |
93 |
|
|
enddo |
94 |
|
|
enddo |
95 |
|
|
do ig=1,ngrid |
96 |
|
|
if (denom(ig).gt.1.e-10) then |
97 |
|
|
zmax(ig)=2.*num(ig)/denom(ig) |
98 |
|
|
zmax0(ig)=zmax(ig) |
99 |
|
|
endif |
100 |
|
|
enddo |
101 |
|
|
|
102 |
|
|
else |
103 |
|
|
!CR:Calcul de zmax continu via le linter |
104 |
✓✓ |
286560 |
do ig=1,ngrid |
105 |
|
|
! calcul de zlevinter |
106 |
|
|
zlevinter(ig)=(zlev(ig,lmax(ig)+1)-zlev(ig,lmax(ig)))* & |
107 |
|
|
& linter(ig)+zlev(ig,lmax(ig))-lmax(ig)*(zlev(ig,lmax(ig)+1) & |
108 |
|
286272 |
& -zlev(ig,lmax(ig))) |
109 |
|
|
!pour le cas ou on prend tjs lmin=1 |
110 |
|
|
! zmax(ig)=max(zmax(ig),zlevinter(ig)-zlev(ig,lmin(ig))) |
111 |
|
286272 |
zmax(ig)=max(zmax(ig),zlevinter(ig)-zlev(ig,1)) |
112 |
|
286560 |
zmax0(ig)=zmax(ig) |
113 |
|
|
enddo |
114 |
|
|
|
115 |
|
|
|
116 |
|
|
endif |
117 |
|
|
!endif iflag_thermals_ed |
118 |
|
|
! |
119 |
|
|
! def de zmix continu (profil parabolique des vitesses) |
120 |
✓✓ |
286560 |
do ig=1,ngrid |
121 |
✓✓ |
286272 |
if (lmix(ig).gt.1) then |
122 |
|
|
! test |
123 |
✓✗ |
134389 |
if (((zw2(ig,lmix(ig)-1)-zw2(ig,lmix(ig))) & |
124 |
|
|
& *((zlev(ig,lmix(ig)))-(zlev(ig,lmix(ig)+1))) & |
125 |
|
|
& -(zw2(ig,lmix(ig))-zw2(ig,lmix(ig)+1)) & |
126 |
|
|
& *((zlev(ig,lmix(ig)-1))-(zlev(ig,lmix(ig))))).gt.1e-10) & |
127 |
|
|
& then |
128 |
|
|
! |
129 |
|
|
zmix(ig)=((zw2(ig,lmix(ig)-1)-zw2(ig,lmix(ig))) & |
130 |
|
|
& *((zlev(ig,lmix(ig)))**2-(zlev(ig,lmix(ig)+1))**2) & |
131 |
|
|
& -(zw2(ig,lmix(ig))-zw2(ig,lmix(ig)+1)) & |
132 |
|
|
& *((zlev(ig,lmix(ig)-1))**2-(zlev(ig,lmix(ig)))**2)) & |
133 |
|
|
& /(2.*((zw2(ig,lmix(ig)-1)-zw2(ig,lmix(ig))) & |
134 |
|
|
& *((zlev(ig,lmix(ig)))-(zlev(ig,lmix(ig)+1))) & |
135 |
|
|
& -(zw2(ig,lmix(ig))-zw2(ig,lmix(ig)+1)) & |
136 |
|
134389 |
& *((zlev(ig,lmix(ig)-1))-(zlev(ig,lmix(ig)))))) |
137 |
|
|
else |
138 |
|
|
zmix(ig)=zlev(ig,lmix(ig)) |
139 |
|
|
print*,'pb zmix' |
140 |
|
|
endif |
141 |
|
|
else |
142 |
|
151883 |
zmix(ig)=0. |
143 |
|
|
endif |
144 |
|
|
!test |
145 |
✓✓ |
286560 |
if ((zmax(ig)-zmix(ig)).le.0.) then |
146 |
|
154063 |
zmix(ig)=0.9*zmax(ig) |
147 |
|
|
! print*,'pb zmix>zmax' |
148 |
|
|
endif |
149 |
|
|
enddo |
150 |
|
|
! |
151 |
|
|
! calcul du nouveau lmix correspondant |
152 |
✓✓ |
286560 |
do ig=1,ngrid |
153 |
✓✓ |
11451168 |
do l=1,nlay |
154 |
✓✓✓✓
|
11164608 |
if (zmix(ig).ge.zlev(ig,l).and. & |
155 |
|
286272 |
& zmix(ig).lt.zlev(ig,l+1)) then |
156 |
|
286272 |
lmix(ig)=l |
157 |
|
|
endif |
158 |
|
|
enddo |
159 |
|
|
enddo |
160 |
|
|
! |
161 |
|
288 |
RETURN |
162 |
|
|
end |
163 |
|
|
END MODULE lmdz_thermcell_height |