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