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