1 | |
---|
2 | ! $Id: calwake.F90 4744 2023-11-02 09:09:59Z evignon $ |
---|
3 | |
---|
4 | SUBROUTINE calwake(iflag_wake_tend, paprs, pplay, dtime, & |
---|
5 | t, q, omgb, & |
---|
6 | dt_dwn, dq_dwn, m_dwn, m_up, dt_a, dq_a, wgen, & |
---|
7 | sigd, Cin, & |
---|
8 | wake_deltat, wake_deltaq, wake_s, awake_s, wake_dens, awake_dens, & |
---|
9 | wake_dth, wake_h, & |
---|
10 | wake_pe, wake_fip, wake_gfl, & |
---|
11 | dt_wake, dq_wake, wake_k, t_x, q_x, wake_omgbdth, & |
---|
12 | wake_dp_omgb, & |
---|
13 | wake_dtke, wake_dqke, & |
---|
14 | wake_omg, wake_dp_deltomg, & |
---|
15 | wake_spread, wake_cstar, wake_d_deltat_gw, & |
---|
16 | wake_ddeltat, wake_ddeltaq, wake_ds, awake_ds, wake_ddens, awake_ddens) |
---|
17 | ! ************************************************************** |
---|
18 | ! * |
---|
19 | ! CALWAKE * |
---|
20 | ! interface avec le schema de calcul de la poche * |
---|
21 | ! froide * |
---|
22 | ! * |
---|
23 | ! written by : CHERUY Frederique, 13/03/2000, 10.31.05 * |
---|
24 | ! modified by : ROEHRIG Romain, 01/30/2007 * |
---|
25 | ! ************************************************************** |
---|
26 | |
---|
27 | USE dimphy |
---|
28 | USE phys_state_var_mod, ONLY: pctsrf |
---|
29 | USE indice_sol_mod, ONLY: is_oce |
---|
30 | USE print_control_mod, ONLY: mydebug=>debug , lunout, prt_level |
---|
31 | USE lmdz_wake, ONLY : wake |
---|
32 | IMPLICIT NONE |
---|
33 | ! ====================================================================== |
---|
34 | include "YOMCST.h" |
---|
35 | |
---|
36 | ! Arguments |
---|
37 | ! ---------- |
---|
38 | ! Input |
---|
39 | ! ---- |
---|
40 | INTEGER, INTENT (IN) :: iflag_wake_tend |
---|
41 | REAL, INTENT (IN) :: dtime |
---|
42 | REAL, DIMENSION(klon, klev), INTENT (IN) :: pplay |
---|
43 | REAL, DIMENSION(klon, klev+1), INTENT (IN) :: paprs |
---|
44 | REAL, DIMENSION(klon, klev), INTENT (IN) :: t, q, omgb |
---|
45 | REAL, DIMENSION(klon, klev), INTENT (IN) :: dt_dwn, dq_dwn |
---|
46 | REAL, DIMENSION(klon, klev), INTENT (IN) :: m_up, m_dwn |
---|
47 | REAL, DIMENSION(klon, klev), INTENT (IN) :: dt_a, dq_a |
---|
48 | REAL, DIMENSION(klon), INTENT (IN) :: wgen |
---|
49 | REAL, DIMENSION(klon), INTENT (IN) :: sigd |
---|
50 | REAL, DIMENSION(klon), INTENT (IN) :: Cin |
---|
51 | ! Input/Output |
---|
52 | ! ------------ |
---|
53 | REAL, DIMENSION(klon, klev), INTENT (INOUT) :: wake_deltat, wake_deltaq |
---|
54 | REAL, DIMENSION(klon), INTENT (INOUT) :: wake_s, awake_s |
---|
55 | REAL, DIMENSION(klon), INTENT (INOUT) :: wake_dens, awake_dens |
---|
56 | ! Output |
---|
57 | ! ------ |
---|
58 | REAL, DIMENSION(klon, klev), INTENT (OUT) :: dt_wake, dq_wake |
---|
59 | !!jyg REAL, DIMENSION(klon), INTENT (OUT) :: wake_k |
---|
60 | INTEGER, DIMENSION(klon), INTENT (OUT) :: wake_k |
---|
61 | REAL, DIMENSION(klon, klev), INTENT (OUT) :: wake_d_deltat_gw |
---|
62 | REAL, DIMENSION(klon), INTENT (OUT) :: wake_h |
---|
63 | REAL, DIMENSION(klon, klev), INTENT (OUT) :: wake_dth |
---|
64 | REAL, DIMENSION(klon), INTENT (OUT) :: wake_pe, wake_fip, wake_gfl |
---|
65 | REAL, DIMENSION(klon, klev), INTENT (OUT) :: t_x, q_x |
---|
66 | REAL, DIMENSION(klon, klev), INTENT (OUT) :: wake_omgbdth, wake_dp_omgb |
---|
67 | REAL, DIMENSION(klon, klev), INTENT (OUT) :: wake_dtke, wake_dqke |
---|
68 | REAL, DIMENSION(klon, klev), INTENT (OUT) :: wake_omg, wake_dp_deltomg |
---|
69 | REAL, DIMENSION(klon, klev), INTENT (OUT) :: wake_spread |
---|
70 | REAL, DIMENSION(klon), INTENT (OUT) :: wake_cstar |
---|
71 | REAL, DIMENSION(klon, klev), INTENT (OUT) :: wake_ddeltat, wake_ddeltaq |
---|
72 | REAL, DIMENSION(klon), INTENT (OUT) :: wake_ds, awake_ds, wake_ddens, awake_ddens |
---|
73 | |
---|
74 | |
---|
75 | ! Variable internes |
---|
76 | ! ----------------- |
---|
77 | LOGICAL, SAVE :: first = .TRUE. |
---|
78 | !$OMP THREADPRIVATE(first) |
---|
79 | INTEGER :: i, l |
---|
80 | INTEGER, DIMENSION(klon) :: znatsurf ! 0 if pctsrf(is_oce)>0.1; 1 else. |
---|
81 | REAL :: aire |
---|
82 | REAL, DIMENSION(klon, klev) :: p, pi |
---|
83 | REAL, DIMENSION(klon, klev+1) :: ph |
---|
84 | REAL, DIMENSION(klon, klev) :: omgbe |
---|
85 | REAL, DIMENSION(klon, klev) :: te, qe |
---|
86 | REAL, DIMENSION(klon, klev) :: dtdwn, dqdwn |
---|
87 | REAL, DIMENSION(klon, klev) :: dta, dqa |
---|
88 | REAL, DIMENSION(klon, klev) :: amdwn, amup |
---|
89 | REAL, DIMENSION(klon, klev) :: dtw, dqw, dth |
---|
90 | REAL, DIMENSION(klon, klev) :: dtls, dqls |
---|
91 | REAL, DIMENSION(klon, klev) :: tx, qx |
---|
92 | REAL, DIMENSION(klon) :: hw, wape, fip, gfl |
---|
93 | REAL, DIMENSION(klon) :: sigmaw, asigmaw, wdens, awdens |
---|
94 | REAL, DIMENSION(klon, klev) :: omgbdth |
---|
95 | REAL, DIMENSION(klon, klev) :: dp_omgb |
---|
96 | REAL, DIMENSION(klon, klev) :: dtke, dqke |
---|
97 | REAL, DIMENSION(klon, klev) :: omg |
---|
98 | REAL, DIMENSION(klon, klev) :: dp_deltomg, spread |
---|
99 | REAL, DIMENSION(klon) :: cstar |
---|
100 | REAL, DIMENSION(klon) :: sigd0 |
---|
101 | INTEGER, DIMENSION(klon) :: ktopw |
---|
102 | REAL, DIMENSION(klon, klev) :: d_deltat_gw |
---|
103 | REAL, DIMENSION(klon, klev) :: d_deltatw, d_deltaqw |
---|
104 | REAL, DIMENSION(klon) :: d_sigmaw, d_asigmaw, d_wdens, d_awdens |
---|
105 | |
---|
106 | REAL :: rdcp |
---|
107 | |
---|
108 | |
---|
109 | IF (prt_level >= 10) THEN |
---|
110 | print *, '-> calwake, wake_s, awake_s, wgen input ', wake_s(1), awake_s(1), wgen(1) |
---|
111 | ENDIF |
---|
112 | |
---|
113 | rdcp = 1./3.5 |
---|
114 | |
---|
115 | znatsurf(:) = 0 |
---|
116 | DO i = 1,klon |
---|
117 | IF (pctsrf(i,is_oce) < 0.1) znatsurf(i) = 1 |
---|
118 | ENDDO |
---|
119 | |
---|
120 | |
---|
121 | ! ----------------------------------------------------------- |
---|
122 | ! IM 290108 DO 999 i=1,klon ! a vectoriser |
---|
123 | ! ---------------------------------------------------------- |
---|
124 | |
---|
125 | |
---|
126 | DO l = 1, klev |
---|
127 | DO i = 1, klon |
---|
128 | p(i, l) = pplay(i, l) |
---|
129 | ph(i, l) = paprs(i, l) |
---|
130 | pi(i, l) = (pplay(i,l)/100000.)**rdcp |
---|
131 | |
---|
132 | te(i, l) = t(i, l) |
---|
133 | qe(i, l) = q(i, l) |
---|
134 | omgbe(i, l) = omgb(i, l) |
---|
135 | |
---|
136 | dtdwn(i, l) = dt_dwn(i, l) |
---|
137 | dqdwn(i, l) = dq_dwn(i, l) |
---|
138 | dta(i, l) = dt_a(i, l) |
---|
139 | dqa(i, l) = dq_a(i, l) |
---|
140 | END DO |
---|
141 | END DO |
---|
142 | |
---|
143 | !---------------------------------------------------------------- |
---|
144 | ! Initialize tendencies to zero |
---|
145 | !---------------------------------------------------------------- |
---|
146 | dtls(:,:) = 0. |
---|
147 | dqls(:,:) = 0. |
---|
148 | d_deltat_gw(:,:) = 0. |
---|
149 | d_deltatw(:,:) = 0. |
---|
150 | d_deltaqw(:,:) = 0. |
---|
151 | d_sigmaw(:) = 0. |
---|
152 | d_asigmaw(:) = 0. |
---|
153 | d_wdens(:) = 0. |
---|
154 | d_awdens(:) = 0. |
---|
155 | ! |
---|
156 | |
---|
157 | DO i = 1, klon |
---|
158 | sigd0(i) = sigd(i) |
---|
159 | END DO |
---|
160 | ! print*, 'sigd0,sigd', sigd0, sigd(i) |
---|
161 | DO i = 1, klon |
---|
162 | ph(i, klev+1) = 0. |
---|
163 | END DO |
---|
164 | |
---|
165 | !!jyg! DO i = 1, klon |
---|
166 | !!jyg! ktopw(i) = NINT(wake_k(i)) |
---|
167 | !!jyg! END DO |
---|
168 | |
---|
169 | DO i = 1, klon |
---|
170 | hw(i) = wake_h(i) |
---|
171 | END DO |
---|
172 | ! |
---|
173 | ! Make a copy of state variables |
---|
174 | DO l = 1, klev |
---|
175 | DO i = 1, klon |
---|
176 | dtw(i, l) = wake_deltat(i, l) |
---|
177 | dqw(i, l) = wake_deltaq(i, l) |
---|
178 | END DO |
---|
179 | END DO |
---|
180 | |
---|
181 | DO i = 1, klon |
---|
182 | sigmaw(i) = wake_s(i) |
---|
183 | asigmaw(i) = awake_s(i) |
---|
184 | END DO |
---|
185 | |
---|
186 | DO i = 1, klon |
---|
187 | wdens(i) = max(0., wake_dens(i)) |
---|
188 | awdens(i) = max(0., awake_dens(i)) |
---|
189 | END DO |
---|
190 | |
---|
191 | ! fkc les flux de masses sont evalues aux niveaux et valent 0 a la surface |
---|
192 | ! fkc on veut le flux de masse au milieu des couches |
---|
193 | |
---|
194 | DO l = 1, klev - 1 |
---|
195 | DO i = 1, klon |
---|
196 | amdwn(i, l) = 0.5*(m_dwn(i,l)+m_dwn(i,l+1)) |
---|
197 | amdwn(i, l) = (m_dwn(i,l+1)) |
---|
198 | END DO |
---|
199 | END DO |
---|
200 | |
---|
201 | ! au sommet le flux de masse est nul |
---|
202 | |
---|
203 | DO i = 1, klon |
---|
204 | amdwn(i, klev) = 0.5*m_dwn(i, klev) |
---|
205 | END DO |
---|
206 | |
---|
207 | DO l = 1, klev |
---|
208 | DO i = 1, klon |
---|
209 | amup(i, l) = m_up(i, l) |
---|
210 | END DO |
---|
211 | END DO |
---|
212 | |
---|
213 | |
---|
214 | |
---|
215 | CALL wake(klon,klev,znatsurf, p, ph, pi, dtime, & |
---|
216 | te, qe, omgbe, & |
---|
217 | dtdwn, dqdwn, amdwn, amup, dta, dqa, wgen, & |
---|
218 | sigd0, Cin, & |
---|
219 | dtw, dqw, sigmaw, asigmaw, wdens, awdens, & ! state variables |
---|
220 | dth, hw, wape, fip, gfl, & |
---|
221 | dtls, dqls, ktopw, omgbdth, dp_omgb, tx, qx, & |
---|
222 | dtke, dqke, omg, dp_deltomg, spread, cstar, & |
---|
223 | d_deltat_gw, & |
---|
224 | d_deltatw, d_deltaqw, d_sigmaw, d_asigmaw, d_wdens, d_awdens) ! tendencies |
---|
225 | |
---|
226 | ! |
---|
227 | DO l = 1, klev |
---|
228 | DO i = 1, klon |
---|
229 | IF (ktopw(i)>0) THEN |
---|
230 | wake_d_deltat_gw(i, l) = d_deltat_gw(i, l) |
---|
231 | wake_omgbdth(i, l) = omgbdth(i, l) |
---|
232 | wake_dp_omgb(i, l) = dp_omgb(i, l) |
---|
233 | wake_dtke(i, l) = dtke(i, l) |
---|
234 | wake_dqke(i, l) = dqke(i, l) |
---|
235 | wake_omg(i, l) = omg(i, l) |
---|
236 | wake_dp_deltomg(i, l) = dp_deltomg(i, l) |
---|
237 | wake_spread(i, l) = spread(i, l) |
---|
238 | wake_dth(i, l) = dth(i, l) |
---|
239 | dt_wake(i, l) = dtls(i, l)*dtime ! derivative -> tendency |
---|
240 | dq_wake(i, l) = dqls(i, l)*dtime ! derivative -> tendency |
---|
241 | t_x(i, l) = tx(i, l) |
---|
242 | q_x(i, l) = qx(i, l) |
---|
243 | ELSE |
---|
244 | wake_d_deltat_gw(i, l) = 0. |
---|
245 | wake_omgbdth(i, l) = 0. |
---|
246 | wake_dp_omgb(i, l) = 0. |
---|
247 | wake_dtke(i, l) = 0. |
---|
248 | wake_dqke(i, l) = 0. |
---|
249 | wake_omg(i, l) = 0. |
---|
250 | wake_dp_deltomg(i, l) = 0. |
---|
251 | wake_spread(i, l) = 0. |
---|
252 | wake_dth(i, l) = 0. |
---|
253 | dt_wake(i, l) = 0. |
---|
254 | dq_wake(i, l) = 0. |
---|
255 | t_x(i, l) = te(i, l) |
---|
256 | q_x(i, l) = qe(i, l) |
---|
257 | END IF |
---|
258 | END DO |
---|
259 | END DO |
---|
260 | |
---|
261 | DO i = 1, klon |
---|
262 | wake_h(i) = hw(i) |
---|
263 | wake_pe(i) = wape(i) |
---|
264 | wake_fip(i) = fip(i) |
---|
265 | wake_gfl(i) = gfl(i) |
---|
266 | wake_k(i) = ktopw(i) |
---|
267 | wake_cstar(i) = cstar(i) |
---|
268 | END DO |
---|
269 | |
---|
270 | ! Tendencies of state variables |
---|
271 | DO l = 1, klev |
---|
272 | DO i = 1, klon |
---|
273 | IF (ktopw(i)>0) THEN |
---|
274 | wake_ddeltat(i, l) = d_deltatw(i, l)*dtime |
---|
275 | wake_ddeltaq(i, l) = d_deltaqw(i, l)*dtime |
---|
276 | ELSE |
---|
277 | wake_ddeltat(i, l) = -wake_deltat(i, l) |
---|
278 | wake_ddeltaq(i, l) = -wake_deltaq(i, l) |
---|
279 | END IF |
---|
280 | END DO |
---|
281 | END DO |
---|
282 | DO i = 1, klon |
---|
283 | IF (ktopw(i)>0) THEN |
---|
284 | wake_ds(i) = d_sigmaw(i)*dtime |
---|
285 | awake_ds(i) = d_asigmaw(i)*dtime |
---|
286 | awake_ddens(i) = d_awdens(i)*dtime |
---|
287 | wake_ddens(i) = d_wdens(i)*dtime |
---|
288 | ELSE |
---|
289 | wake_ds(i) = -wake_s(i) |
---|
290 | awake_ds(i) = -awake_s(i) |
---|
291 | wake_ddens(i) = -wake_dens(i) |
---|
292 | awake_ddens(i)= -awake_dens(i) |
---|
293 | END IF |
---|
294 | END DO |
---|
295 | ! |
---|
296 | |
---|
297 | !jyg< |
---|
298 | IF (iflag_wake_tend .EQ. 0) THEN |
---|
299 | ! Update State variables |
---|
300 | DO l = 1, klev |
---|
301 | DO i = 1, klon |
---|
302 | IF (ktopw(i)>0) THEN |
---|
303 | wake_deltat(i, l) = dtw(i, l) |
---|
304 | wake_deltaq(i, l) = dqw(i, l) |
---|
305 | ELSE |
---|
306 | wake_deltat(i, l) = 0. |
---|
307 | wake_deltaq(i, l) = 0. |
---|
308 | END IF |
---|
309 | END DO |
---|
310 | END DO |
---|
311 | DO i = 1, klon |
---|
312 | wake_s(i) = sigmaw(i) |
---|
313 | awake_s(i) = asigmaw(i) |
---|
314 | awake_dens(i) = awdens(i) |
---|
315 | wake_dens(i) = wdens(i) |
---|
316 | END DO |
---|
317 | ENDIF ! (iflag_wake_tend .EQ. 0) |
---|
318 | ! |
---|
319 | IF (first) THEN |
---|
320 | DO i = 1,klon |
---|
321 | IF (wake_dens(i) < -1.) THEN |
---|
322 | wake_dens(i) = wdens(i) |
---|
323 | ENDIF |
---|
324 | ENDDO |
---|
325 | first=.false. |
---|
326 | ENDIF ! (first) |
---|
327 | !>jyg |
---|
328 | IF (prt_level >= 10) THEN |
---|
329 | print *, 'calwake ->, wake_s, awake_s ', wake_s(1), awake_s(1) |
---|
330 | ENDIF |
---|
331 | |
---|
332 | RETURN |
---|
333 | END SUBROUTINE calwake |
---|
334 | |
---|
335 | |
---|