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