1 | |
---|
2 | ! $Id: calwake.F90 4094 2022-03-14 00:45:50Z aborella $ |
---|
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_dens, wake_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_ddens, wake_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 | IMPLICIT NONE |
---|
32 | ! ====================================================================== |
---|
33 | include "YOMCST.h" |
---|
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 |
---|
54 | REAL, DIMENSION(klon), INTENT (INOUT) :: awake_dens, wake_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_ddens, wake_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, awdens, wdens |
---|
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_awdens, d_wdens |
---|
104 | |
---|
105 | REAL :: rdcp |
---|
106 | |
---|
107 | |
---|
108 | IF (prt_level >= 10) THEN |
---|
109 | print *, '-> calwake, wake_s, wgen input ', wake_s(1), wgen(1) |
---|
110 | ENDIF |
---|
111 | |
---|
112 | rdcp = 1./3.5 |
---|
113 | |
---|
114 | znatsurf(:) = 0 |
---|
115 | DO i = 1,klon |
---|
116 | IF (pctsrf(i,is_oce) < 0.1) znatsurf(i) = 1 |
---|
117 | ENDDO |
---|
118 | |
---|
119 | |
---|
120 | ! ----------------------------------------------------------- |
---|
121 | ! IM 290108 DO 999 i=1,klon ! a vectoriser |
---|
122 | ! ---------------------------------------------------------- |
---|
123 | |
---|
124 | |
---|
125 | DO l = 1, klev |
---|
126 | DO i = 1, klon |
---|
127 | p(i, l) = pplay(i, l) |
---|
128 | ph(i, l) = paprs(i, l) |
---|
129 | pi(i, l) = (pplay(i,l)/100000.)**rdcp |
---|
130 | |
---|
131 | te(i, l) = t(i, l) |
---|
132 | qe(i, l) = q(i, l) |
---|
133 | omgbe(i, l) = omgb(i, l) |
---|
134 | |
---|
135 | dtdwn(i, l) = dt_dwn(i, l) |
---|
136 | dqdwn(i, l) = dq_dwn(i, l) |
---|
137 | dta(i, l) = dt_a(i, l) |
---|
138 | dqa(i, l) = dq_a(i, l) |
---|
139 | END DO |
---|
140 | END DO |
---|
141 | |
---|
142 | !---------------------------------------------------------------- |
---|
143 | ! Initialize tendencies to zero |
---|
144 | !---------------------------------------------------------------- |
---|
145 | dtls(:,:) = 0. |
---|
146 | dqls(:,:) = 0. |
---|
147 | d_deltat_gw(:,:) = 0. |
---|
148 | d_deltatw(:,:) = 0. |
---|
149 | d_deltaqw(:,:) = 0. |
---|
150 | d_sigmaw(:) = 0. |
---|
151 | d_awdens(:) = 0. |
---|
152 | d_wdens(:) = 0. |
---|
153 | ! |
---|
154 | |
---|
155 | DO i = 1, klon |
---|
156 | sigd0(i) = sigd(i) |
---|
157 | END DO |
---|
158 | ! print*, 'sigd0,sigd', sigd0, sigd(i) |
---|
159 | DO i = 1, klon |
---|
160 | ph(i, klev+1) = 0. |
---|
161 | END DO |
---|
162 | |
---|
163 | !!jyg! DO i = 1, klon |
---|
164 | !!jyg! ktopw(i) = NINT(wake_k(i)) |
---|
165 | !!jyg! END DO |
---|
166 | |
---|
167 | DO i = 1, klon |
---|
168 | hw(i) = wake_h(i) |
---|
169 | END DO |
---|
170 | ! |
---|
171 | ! Make a copy of state variables |
---|
172 | DO l = 1, klev |
---|
173 | DO i = 1, klon |
---|
174 | dtw(i, l) = wake_deltat(i, l) |
---|
175 | dqw(i, l) = wake_deltaq(i, l) |
---|
176 | END DO |
---|
177 | END DO |
---|
178 | |
---|
179 | DO i = 1, klon |
---|
180 | sigmaw(i) = wake_s(i) |
---|
181 | END DO |
---|
182 | |
---|
183 | DO i = 1, klon |
---|
184 | awdens(i) = max(0., awake_dens(i)) |
---|
185 | wdens(i) = max(0., wake_dens(i)) |
---|
186 | END DO |
---|
187 | |
---|
188 | ! fkc les flux de masses sont evalues aux niveaux et valent 0 a la surface |
---|
189 | ! fkc on veut le flux de masse au milieu des couches |
---|
190 | |
---|
191 | DO l = 1, klev - 1 |
---|
192 | DO i = 1, klon |
---|
193 | amdwn(i, l) = 0.5*(m_dwn(i,l)+m_dwn(i,l+1)) |
---|
194 | amdwn(i, l) = (m_dwn(i,l+1)) |
---|
195 | END DO |
---|
196 | END DO |
---|
197 | |
---|
198 | ! au sommet le flux de masse est nul |
---|
199 | |
---|
200 | DO i = 1, klon |
---|
201 | amdwn(i, klev) = 0.5*m_dwn(i, klev) |
---|
202 | END DO |
---|
203 | |
---|
204 | DO l = 1, klev |
---|
205 | DO i = 1, klon |
---|
206 | amup(i, l) = m_up(i, l) |
---|
207 | END DO |
---|
208 | END DO |
---|
209 | |
---|
210 | |
---|
211 | |
---|
212 | CALL wake(klon,klev,znatsurf, p, ph, pi, dtime, & |
---|
213 | te, qe, omgbe, & |
---|
214 | dtdwn, dqdwn, amdwn, amup, dta, dqa, wgen, & |
---|
215 | sigd0, Cin, & |
---|
216 | dtw, dqw, sigmaw, awdens, wdens, & ! state variables |
---|
217 | dth, hw, wape, fip, gfl, & |
---|
218 | dtls, dqls, ktopw, omgbdth, dp_omgb, tx, qx, & |
---|
219 | dtke, dqke, omg, dp_deltomg, spread, cstar, & |
---|
220 | d_deltat_gw, & |
---|
221 | d_deltatw, d_deltaqw, d_sigmaw, d_awdens, d_wdens) ! tendencies |
---|
222 | |
---|
223 | ! |
---|
224 | DO l = 1, klev |
---|
225 | DO i = 1, klon |
---|
226 | IF (ktopw(i)>0) THEN |
---|
227 | wake_d_deltat_gw(i, l) = d_deltat_gw(i, l) |
---|
228 | wake_omgbdth(i, l) = omgbdth(i, l) |
---|
229 | wake_dp_omgb(i, l) = dp_omgb(i, l) |
---|
230 | wake_dtke(i, l) = dtke(i, l) |
---|
231 | wake_dqke(i, l) = dqke(i, l) |
---|
232 | wake_omg(i, l) = omg(i, l) |
---|
233 | wake_dp_deltomg(i, l) = dp_deltomg(i, l) |
---|
234 | wake_spread(i, l) = spread(i, l) |
---|
235 | wake_dth(i, l) = dth(i, l) |
---|
236 | dt_wake(i, l) = dtls(i, l)*dtime ! derivative -> tendency |
---|
237 | dq_wake(i, l) = dqls(i, l)*dtime ! derivative -> tendency |
---|
238 | t_x(i, l) = tx(i, l) |
---|
239 | q_x(i, l) = qx(i, l) |
---|
240 | ELSE |
---|
241 | wake_d_deltat_gw(i, l) = 0. |
---|
242 | wake_omgbdth(i, l) = 0. |
---|
243 | wake_dp_omgb(i, l) = 0. |
---|
244 | wake_dtke(i, l) = 0. |
---|
245 | wake_dqke(i, l) = 0. |
---|
246 | wake_omg(i, l) = 0. |
---|
247 | wake_dp_deltomg(i, l) = 0. |
---|
248 | wake_spread(i, l) = 0. |
---|
249 | wake_dth(i, l) = 0. |
---|
250 | dt_wake(i, l) = 0. |
---|
251 | dq_wake(i, l) = 0. |
---|
252 | t_x(i, l) = te(i, l) |
---|
253 | q_x(i, l) = qe(i, l) |
---|
254 | END IF |
---|
255 | END DO |
---|
256 | END DO |
---|
257 | |
---|
258 | DO i = 1, klon |
---|
259 | wake_h(i) = hw(i) |
---|
260 | wake_pe(i) = wape(i) |
---|
261 | wake_fip(i) = fip(i) |
---|
262 | wake_gfl(i) = gfl(i) |
---|
263 | wake_k(i) = ktopw(i) |
---|
264 | wake_cstar(i) = cstar(i) |
---|
265 | END DO |
---|
266 | |
---|
267 | ! Tendencies of state variables |
---|
268 | DO l = 1, klev |
---|
269 | DO i = 1, klon |
---|
270 | IF (ktopw(i)>0) THEN |
---|
271 | wake_ddeltat(i, l) = d_deltatw(i, l)*dtime |
---|
272 | wake_ddeltaq(i, l) = d_deltaqw(i, l)*dtime |
---|
273 | ELSE |
---|
274 | wake_ddeltat(i, l) = -wake_deltat(i, l) |
---|
275 | wake_ddeltaq(i, l) = -wake_deltaq(i, l) |
---|
276 | END IF |
---|
277 | END DO |
---|
278 | END DO |
---|
279 | DO i = 1, klon |
---|
280 | IF (ktopw(i)>0) THEN |
---|
281 | wake_ds(i) = d_sigmaw(i)*dtime |
---|
282 | awake_ddens(i) = d_awdens(i)*dtime |
---|
283 | wake_ddens(i) = d_wdens(i)*dtime |
---|
284 | ELSE |
---|
285 | wake_ds(i) = -wake_s(i) |
---|
286 | wake_ddens(i)= -wake_dens(i) |
---|
287 | END IF |
---|
288 | END DO |
---|
289 | ! |
---|
290 | |
---|
291 | !jyg< |
---|
292 | IF (iflag_wake_tend .EQ. 0) THEN |
---|
293 | ! Update State variables |
---|
294 | DO l = 1, klev |
---|
295 | DO i = 1, klon |
---|
296 | IF (ktopw(i)>0) THEN |
---|
297 | wake_deltat(i, l) = dtw(i, l) |
---|
298 | wake_deltaq(i, l) = dqw(i, l) |
---|
299 | ELSE |
---|
300 | wake_deltat(i, l) = 0. |
---|
301 | wake_deltaq(i, l) = 0. |
---|
302 | END IF |
---|
303 | END DO |
---|
304 | END DO |
---|
305 | DO i = 1, klon |
---|
306 | wake_s(i) = sigmaw(i) |
---|
307 | awake_dens(i) = awdens(i) |
---|
308 | wake_dens(i) = wdens(i) |
---|
309 | END DO |
---|
310 | ENDIF ! (iflag_wake_tend .EQ. 0) |
---|
311 | ! |
---|
312 | IF (first) THEN |
---|
313 | DO i = 1,klon |
---|
314 | IF (wake_dens(i) < -1.) THEN |
---|
315 | wake_dens(i) = wdens(i) |
---|
316 | ENDIF |
---|
317 | ENDDO |
---|
318 | first=.false. |
---|
319 | ENDIF ! (first) |
---|
320 | !>jyg |
---|
321 | |
---|
322 | RETURN |
---|
323 | END SUBROUTINE calwake |
---|
324 | |
---|