[1403] | 1 | ! $Id: calwake.F90 5160 2024-08-03 12:56:58Z abarral $ |
---|
[879] | 2 | |
---|
[2635] | 3 | SUBROUTINE calwake(iflag_wake_tend, paprs, pplay, dtime, & |
---|
[5144] | 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) |
---|
[1992] | 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 | ! ************************************************************** |
---|
[974] | 25 | |
---|
[1992] | 26 | USE dimphy |
---|
[2761] | 27 | USE phys_state_var_mod, ONLY: pctsrf |
---|
| 28 | USE indice_sol_mod, ONLY: is_oce |
---|
[5144] | 29 | USE lmdz_print_control, ONLY: mydebug => debug, lunout, prt_level |
---|
[5101] | 30 | USE lmdz_wake, ONLY: wake |
---|
[5144] | 31 | USE lmdz_yomcst |
---|
| 32 | |
---|
[1992] | 33 | IMPLICIT NONE |
---|
[974] | 34 | |
---|
[1992] | 35 | ! Arguments |
---|
| 36 | ! ---------- |
---|
[2635] | 37 | ! Input |
---|
| 38 | ! ---- |
---|
[5144] | 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 |
---|
[2635] | 50 | ! Input/Output |
---|
| 51 | ! ------------ |
---|
[5144] | 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 |
---|
[2635] | 55 | ! Output |
---|
| 56 | ! ------ |
---|
[5144] | 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 |
---|
[974] | 72 | |
---|
| 73 | |
---|
[1992] | 74 | ! Variable internes |
---|
| 75 | ! ----------------- |
---|
[5144] | 76 | LOGICAL, SAVE :: first = .TRUE. |
---|
[3000] | 77 | !$OMP THREADPRIVATE(first) |
---|
[5144] | 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 |
---|
[974] | 104 | |
---|
[5144] | 105 | REAL :: rdcp |
---|
[974] | 106 | |
---|
[2761] | 107 | IF (prt_level >= 10) THEN |
---|
[5160] | 108 | PRINT *, '-> calwake, wake_s, awake_s, wgen input ', wake_s(1), awake_s(1), wgen(1) |
---|
[2761] | 109 | ENDIF |
---|
[990] | 110 | |
---|
[5144] | 111 | rdcp = 1. / 3.5 |
---|
[974] | 112 | |
---|
[2761] | 113 | znatsurf(:) = 0 |
---|
[5144] | 114 | DO i = 1, klon |
---|
| 115 | IF (pctsrf(i, is_oce) < 0.1) znatsurf(i) = 1 |
---|
[2761] | 116 | ENDDO |
---|
[974] | 117 | |
---|
[2761] | 118 | |
---|
[1992] | 119 | ! ----------------------------------------------------------- |
---|
| 120 | ! IM 290108 DO 999 i=1,klon ! a vectoriser |
---|
| 121 | ! ---------------------------------------------------------- |
---|
[974] | 122 | |
---|
[1992] | 123 | DO l = 1, klev |
---|
| 124 | DO i = 1, klon |
---|
| 125 | p(i, l) = pplay(i, l) |
---|
| 126 | ph(i, l) = paprs(i, l) |
---|
[5144] | 127 | pi(i, l) = (pplay(i, l) / 100000.)**rdcp |
---|
[990] | 128 | |
---|
[1992] | 129 | te(i, l) = t(i, l) |
---|
| 130 | qe(i, l) = q(i, l) |
---|
| 131 | omgbe(i, l) = omgb(i, l) |
---|
[974] | 132 | |
---|
[1992] | 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 |
---|
[974] | 139 | |
---|
[5144] | 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. |
---|
[2761] | 152 | |
---|
[1992] | 153 | DO i = 1, klon |
---|
| 154 | sigd0(i) = sigd(i) |
---|
| 155 | END DO |
---|
[5103] | 156 | ! PRINT*, 'sigd0,sigd', sigd0, sigd(i) |
---|
[1992] | 157 | DO i = 1, klon |
---|
[5144] | 158 | ph(i, klev + 1) = 0. |
---|
[1992] | 159 | END DO |
---|
[974] | 160 | |
---|
[5144] | 161 | !!jyg! DO i = 1, klon |
---|
| 162 | !!jyg! ktopw(i) = NINT(wake_k(i)) |
---|
| 163 | !!jyg! END DO |
---|
[974] | 164 | |
---|
[2635] | 165 | DO i = 1, klon |
---|
| 166 | hw(i) = wake_h(i) |
---|
| 167 | END DO |
---|
[5099] | 168 | |
---|
[5144] | 169 | ! Make a copy of state variables |
---|
[1992] | 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 |
---|
[974] | 176 | |
---|
[2635] | 177 | DO i = 1, klon |
---|
[5144] | 178 | sigmaw(i) = wake_s(i) |
---|
[4744] | 179 | asigmaw(i) = awake_s(i) |
---|
[1992] | 180 | END DO |
---|
[974] | 181 | |
---|
[1992] | 182 | DO i = 1, klon |
---|
[4744] | 183 | wdens(i) = max(0., wake_dens(i)) |
---|
[3208] | 184 | awdens(i) = max(0., awake_dens(i)) |
---|
[1992] | 185 | END DO |
---|
[974] | 186 | |
---|
[1992] | 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 |
---|
[974] | 189 | |
---|
[1992] | 190 | DO l = 1, klev - 1 |
---|
| 191 | DO i = 1, klon |
---|
[5144] | 192 | amdwn(i, l) = 0.5 * (m_dwn(i, l) + m_dwn(i, l + 1)) |
---|
| 193 | amdwn(i, l) = (m_dwn(i, l + 1)) |
---|
[1992] | 194 | END DO |
---|
| 195 | END DO |
---|
[1403] | 196 | |
---|
[1992] | 197 | ! au sommet le flux de masse est nul |
---|
[974] | 198 | |
---|
[1992] | 199 | DO i = 1, klon |
---|
[5144] | 200 | amdwn(i, klev) = 0.5 * m_dwn(i, klev) |
---|
[1992] | 201 | END DO |
---|
[879] | 202 | |
---|
[1992] | 203 | DO l = 1, klev |
---|
| 204 | DO i = 1, klon |
---|
| 205 | amup(i, l) = m_up(i, l) |
---|
| 206 | END DO |
---|
| 207 | END DO |
---|
[879] | 208 | |
---|
[5144] | 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 |
---|
[4085] | 219 | |
---|
[1992] | 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) |
---|
[5144] | 232 | dt_wake(i, l) = dtls(i, l) * dtime ! derivative -> tendency |
---|
| 233 | dq_wake(i, l) = dqls(i, l) * dtime ! derivative -> tendency |
---|
[2635] | 234 | t_x(i, l) = tx(i, l) |
---|
| 235 | q_x(i, l) = qx(i, l) |
---|
[1992] | 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. |
---|
[2635] | 248 | t_x(i, l) = te(i, l) |
---|
| 249 | q_x(i, l) = qe(i, l) |
---|
[1992] | 250 | END IF |
---|
| 251 | END DO |
---|
| 252 | END DO |
---|
[879] | 253 | |
---|
[1992] | 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 |
---|
[879] | 262 | |
---|
[5144] | 263 | ! Tendencies of state variables |
---|
[2635] | 264 | DO l = 1, klev |
---|
| 265 | DO i = 1, klon |
---|
| 266 | IF (ktopw(i)>0) THEN |
---|
[5144] | 267 | wake_ddeltat(i, l) = d_deltatw(i, l) * dtime |
---|
| 268 | wake_ddeltaq(i, l) = d_deltaqw(i, l) * dtime |
---|
[2635] | 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 |
---|
[5144] | 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 |
---|
[2635] | 281 | ELSE |
---|
[5144] | 282 | wake_ds(i) = -wake_s(i) |
---|
| 283 | awake_ds(i) = -awake_s(i) |
---|
[4744] | 284 | wake_ddens(i) = -wake_dens(i) |
---|
[5144] | 285 | awake_ddens(i) = -awake_dens(i) |
---|
[2635] | 286 | END IF |
---|
| 287 | END DO |
---|
| 288 | |
---|
[5144] | 289 | !jyg< |
---|
[5082] | 290 | IF (iflag_wake_tend == 0) THEN |
---|
[5144] | 291 | ! Update State variables |
---|
[2635] | 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) |
---|
[4744] | 305 | awake_s(i) = asigmaw(i) |
---|
[3208] | 306 | awake_dens(i) = awdens(i) |
---|
[2635] | 307 | wake_dens(i) = wdens(i) |
---|
| 308 | END DO |
---|
[3000] | 309 | ENDIF ! (iflag_wake_tend .EQ. 0) |
---|
[5099] | 310 | |
---|
[3000] | 311 | IF (first) THEN |
---|
[5144] | 312 | DO i = 1, klon |
---|
[3000] | 313 | IF (wake_dens(i) < -1.) THEN |
---|
| 314 | wake_dens(i) = wdens(i) |
---|
| 315 | ENDIF |
---|
| 316 | ENDDO |
---|
[5144] | 317 | first = .FALSE. |
---|
[3000] | 318 | ENDIF ! (first) |
---|
[5144] | 319 | !>jyg |
---|
[4744] | 320 | IF (prt_level >= 10) THEN |
---|
[5160] | 321 | PRINT *, 'calwake ->, wake_s, awake_s ', wake_s(1), awake_s(1) |
---|
[4744] | 322 | ENDIF |
---|
[2635] | 323 | |
---|
[1992] | 324 | END SUBROUTINE calwake |
---|
[2635] | 325 | |
---|
[4744] | 326 | |
---|