1 | SUBROUTINE cv3_enthalpmix(len, nd, iflag, plim1, plim2, p, ph, & |
---|
2 | t, q, u, v, w, & |
---|
3 | wi, nk, tmix, thmix, qmix, qsmix, umix, vmix, plcl & |
---|
4 | #ifdef ISO |
---|
5 | ,xt,xtmix & |
---|
6 | #endif |
---|
7 | ) |
---|
8 | #ifdef ISO |
---|
9 | USE infotrac_phy, ONLY: ntiso |
---|
10 | #endif |
---|
11 | ! ************************************************************** |
---|
12 | ! * |
---|
13 | ! CV3_ENTHALPMIX Brassage adiabatique d'une couche d'epaisseur * |
---|
14 | ! arbitraire. * |
---|
15 | ! * |
---|
16 | ! written by : Grandpeix Jean-Yves, 28/12/2001, 13.14.24 * |
---|
17 | ! modified by : Filiberti M-A 06/2005 vectorisation * |
---|
18 | ! ************************************************************** |
---|
19 | USE lmdz_cvthermo |
---|
20 | USE lmdz_yoethf |
---|
21 | |
---|
22 | USE lmdz_yomcst |
---|
23 | |
---|
24 | IMPLICIT NONE |
---|
25 | INCLUDE "FCTTRE.h" |
---|
26 | ! ============================================================== |
---|
27 | |
---|
28 | ! vertmix : determines theta, t, q, qs, u and v of the mixture generated by |
---|
29 | ! adiabatic mixing of air between plim1 and plim2 with weighting w. |
---|
30 | ! If plim1 and plim2 fall within the same model layer, then theta, ... v |
---|
31 | ! are those of that layer. |
---|
32 | ! A minimum value (dpmin) is imposed upon plim1-plim2 |
---|
33 | |
---|
34 | ! =============================================================== |
---|
35 | |
---|
36 | !inputs: |
---|
37 | INTEGER, INTENT (IN) :: nd, len |
---|
38 | INTEGER, DIMENSION (len), INTENT (IN) :: nk |
---|
39 | REAL, DIMENSION (len), INTENT (IN) :: plim1, plim2 |
---|
40 | REAL, DIMENSION (len,nd), INTENT (IN) :: t, q |
---|
41 | REAL, DIMENSION (len,nd), INTENT (IN) :: u, v |
---|
42 | REAL, DIMENSION (nd), INTENT (IN) :: w |
---|
43 | REAL, DIMENSION (len,nd), INTENT (IN) :: p |
---|
44 | REAL, DIMENSION (len,nd+1), INTENT (IN) :: ph |
---|
45 | #ifdef ISO |
---|
46 | REAL, DIMENSION (ntiso,len,nd), INTENT (IN) :: xt |
---|
47 | #endif |
---|
48 | !input/output: |
---|
49 | INTEGER, DIMENSION (len), INTENT (INOUT) :: iflag |
---|
50 | !outputs: |
---|
51 | REAL, DIMENSION (len), INTENT (OUT) :: tmix, thmix, qmix |
---|
52 | REAL, DIMENSION (len), INTENT (OUT) :: umix, vmix |
---|
53 | REAL, DIMENSION (len), INTENT (OUT) :: qsmix |
---|
54 | REAL, DIMENSION (len), INTENT (OUT) :: plcl |
---|
55 | REAL, DIMENSION (len,nd), INTENT (OUT) :: wi |
---|
56 | #ifdef ISO |
---|
57 | REAL, DIMENSION (ntiso,len), INTENT (OUT) :: xtmix |
---|
58 | #endif |
---|
59 | !internal variables : |
---|
60 | INTEGER i, j |
---|
61 | INTEGER niflag7 |
---|
62 | INTEGER, DIMENSION(len) :: j1, j2 |
---|
63 | REAL :: a, b |
---|
64 | REAL :: cpn |
---|
65 | REAL :: x, y, p0, p0m1, zdelta, zcor |
---|
66 | REAL, SAVE :: dpmin=1. |
---|
67 | !$OMP THREADPRIVATE(dpmin) |
---|
68 | REAL, DIMENSION(len) :: plim2p ! = min(plim2(:),plim1(:)-dpmin) |
---|
69 | REAL, DIMENSION(len) :: akm ! mixture enthalpy |
---|
70 | REAL, DIMENSION(len) :: dpw, coef |
---|
71 | REAL, DIMENSION(len) :: rdcp, a2, b2, pnk |
---|
72 | REAL, DIMENSION(len) :: rh, chi |
---|
73 | REAL, DIMENSION(len) :: eqwght |
---|
74 | REAL, DIMENSION(len,nd) :: p1, p2 |
---|
75 | #ifdef ISO |
---|
76 | INTEGER ixt |
---|
77 | #endif |
---|
78 | |
---|
79 | |
---|
80 | !! PRINT *,' ->cv3_vertmix, plim1,plim2 ', plim1,plim2 !jyg |
---|
81 | plim2p(:) = min(plim2(:),plim1(:)-dpmin) |
---|
82 | j1(:)=nd |
---|
83 | j2(:) = 0 |
---|
84 | DO j = 1, nd |
---|
85 | DO i = 1, len |
---|
86 | IF (plim1(i)<=ph(i,j)) j1(i) = j |
---|
87 | !!! IF (plim2p(i)>=ph(i,j+1) .AND. plim2p(i)<ph(i,j)) j2(i) = j |
---|
88 | IF (plim2p(i)< ph(i,j)) j2(i) = j |
---|
89 | END DO |
---|
90 | END DO |
---|
91 | |
---|
92 | DO j = 1, nd |
---|
93 | DO i = 1, len |
---|
94 | wi(i, j) = 0. |
---|
95 | END DO |
---|
96 | END DO |
---|
97 | DO i = 1, len |
---|
98 | akm(i) = 0. |
---|
99 | qmix(i) = 0. |
---|
100 | umix(i) = 0. |
---|
101 | vmix(i) = 0. |
---|
102 | dpw(i) = 0. |
---|
103 | a2(i) = 0.0 |
---|
104 | b2(i) = 0. |
---|
105 | pnk(i) = p(i, nk(i)) |
---|
106 | #ifdef ISO |
---|
107 | xtmix(:,i) = 0. |
---|
108 | #endif |
---|
109 | END DO |
---|
110 | eqwght(:) = 0. |
---|
111 | |
---|
112 | p0 = 1000. |
---|
113 | p0m1 = 1./p0 |
---|
114 | |
---|
115 | DO i = 1, len |
---|
116 | IF (j2(i) < j1(i)) THEN |
---|
117 | coef(i) = 1. |
---|
118 | eqwght(i) = 1. |
---|
119 | ELSE |
---|
120 | coef(i) = 1./(plim1(i)-plim2p(i)) |
---|
121 | ENDIF |
---|
122 | END DO |
---|
123 | |
---|
124 | !! PRINT *,'cv3_vertmix, j1,j2,coef ', j1,j2,coef !jyg |
---|
125 | |
---|
126 | DO j = 1, nd |
---|
127 | DO i = 1, len |
---|
128 | IF (j>=j1(i) .AND. j<=j2(i)) THEN |
---|
129 | p1(i, j) = min(ph(i,j), plim1(i)) |
---|
130 | p2(i, j) = max(ph(i,j+1), plim2p(i)) |
---|
131 | ! CRtest:couplage thermiques: deja normalise |
---|
132 | ! wi(i,j) = w(j) |
---|
133 | ! PRINT*,'wi',wi(i,j) |
---|
134 | wi(i, j) = w(j)*(p1(i,j)-p2(i,j))*coef(i)+eqwght(i) |
---|
135 | dpw(i) = dpw(i) + wi(i, j) |
---|
136 | |
---|
137 | !! PRINT *,'cv3_vertmix, j, wi(1,j),dpw ', j, wi(1,j),dpw !jyg |
---|
138 | |
---|
139 | END IF |
---|
140 | END DO |
---|
141 | END DO |
---|
142 | |
---|
143 | ! CR:print |
---|
144 | ! do i=1,len |
---|
145 | ! PRINT*,'plim',plim1(i),plim2p(i) |
---|
146 | ! enddo |
---|
147 | DO j = 1, nd |
---|
148 | DO i = 1, len |
---|
149 | IF (j>=j1(i) .AND. j<=j2(i)) THEN |
---|
150 | wi(i, j) = wi(i, j)/dpw(i) |
---|
151 | akm(i) = akm(i) + (cpd*(1.-q(i,j))+q(i,j)*cpv)*t(i, j)*wi(i, j) |
---|
152 | qmix(i) = qmix(i) + q(i, j)*wi(i, j) |
---|
153 | umix(i) = umix(i) + u(i, j)*wi(i, j) |
---|
154 | vmix(i) = vmix(i) + v(i, j)*wi(i, j) |
---|
155 | #ifdef ISO |
---|
156 | DO ixt=1,ntiso |
---|
157 | xtmix(ixt,i) = xtmix(ixt,i) + xt(ixt,i, j)*wi(i, j) |
---|
158 | enddo |
---|
159 | #endif |
---|
160 | END IF |
---|
161 | END DO |
---|
162 | END DO |
---|
163 | |
---|
164 | DO i = 1, len |
---|
165 | rdcp(i) = (rrd*(1.-qmix(i))+qmix(i)*rrv)/(cpd*(1.-qmix(i))+qmix(i)*cpv) |
---|
166 | END DO |
---|
167 | |
---|
168 | |
---|
169 | !! PRINT *,'cv3_vertmix, rdcp ', rdcp !jyg |
---|
170 | |
---|
171 | |
---|
172 | |
---|
173 | DO j = 1, nd |
---|
174 | DO i = 1, len |
---|
175 | IF (j>=j1(i) .AND. j<=j2(i)) THEN |
---|
176 | ! c x=(.5*(p1(i,j)+p2(i,j))*p0m1)**rdcp(i) |
---|
177 | y = (.5*(p1(i,j)+p2(i,j))/pnk(i))**rdcp(i) |
---|
178 | ! c a2(i)=a2(i)+(cpd*(1.-qmix(i))+qmix(i)*cpv)*x*wi(i,j) |
---|
179 | b2(i) = b2(i) + (cpd*(1.-qmix(i))+qmix(i)*cpv)*y*wi(i, j) |
---|
180 | END IF |
---|
181 | END DO |
---|
182 | END DO |
---|
183 | |
---|
184 | DO i = 1, len |
---|
185 | tmix(i) = akm(i)/b2(i) |
---|
186 | thmix(i) = tmix(i)*(p0/pnk(i))**rdcp(i) |
---|
187 | ! PRINT*,'thmix akm',akm(i),b2(i) |
---|
188 | ! PRINT*,'thmix t',tmix(i),p0 |
---|
189 | ! PRINT*,'thmix p',pnk(i),rdcp(i) |
---|
190 | ! PRINT*,'thmix',thmix(i) |
---|
191 | ! c thmix(i) = akm(i)/a2(i) |
---|
192 | ! c tmix(i)= thmix(i)*(pnk(i)*p0m1)**rdcp(i) |
---|
193 | zdelta = max(0., sign(1.,rtt-tmix(i))) |
---|
194 | qsmix(i) = r2es*foeew(tmix(i), zdelta)/(pnk(i)*100.) |
---|
195 | qsmix(i) = min(0.5, qsmix(i)) |
---|
196 | zcor = 1./(1.-retv*qsmix(i)) |
---|
197 | qsmix(i) = qsmix(i)*zcor |
---|
198 | END DO |
---|
199 | |
---|
200 | ! ------------------------------------------------------------------- |
---|
201 | ! --- Calculate lifted condensation level of air at parcel origin level |
---|
202 | ! --- (Within 0.2% of formula of Bolton, MON. WEA. REV.,1980) |
---|
203 | ! ------------------------------------------------------------------- |
---|
204 | |
---|
205 | a = 1669.0 ! convect3 |
---|
206 | b = 122.0 ! convect3 |
---|
207 | |
---|
208 | |
---|
209 | niflag7 = 0 |
---|
210 | DO i = 1, len |
---|
211 | |
---|
212 | IF (iflag(i)/=7) THEN ! modif sb Jun7th 2002 |
---|
213 | |
---|
214 | rh(i) = qmix(i)/qsmix(i) |
---|
215 | chi(i) = tmix(i)/(a-b*rh(i)-tmix(i)) ! convect3 |
---|
216 | ! ATTENTION, la LIGNE DESSOUS A ETE RAJOUTEE ARBITRAIREMENT ET |
---|
217 | ! MASQUE UN PB POTENTIEL |
---|
218 | chi(i) = max(chi(i), 0.) |
---|
219 | rh(i) = max(rh(i), 0.) |
---|
220 | plcl(i) = pnk(i)*(rh(i)**chi(i)) |
---|
221 | IF (((plcl(i)<200.0) .OR. (plcl(i)>=2000.0)) .AND. (iflag(i)==0)) & |
---|
222 | iflag(i) = 8 |
---|
223 | |
---|
224 | ELSE |
---|
225 | |
---|
226 | niflag7 = niflag7 + 1 |
---|
227 | plcl(i) = plim2p(i) |
---|
228 | |
---|
229 | END IF ! iflag=7 |
---|
230 | |
---|
231 | ! PRINT*,'NIFLAG7 =',niflag7 |
---|
232 | |
---|
233 | END DO |
---|
234 | |
---|
235 | !! PRINT *,' cv3_vertmix->' !jyg |
---|
236 | |
---|
237 | |
---|
238 | |
---|
239 | END SUBROUTINE cv3_enthalpmix |
---|
240 | |
---|