[1850] | 1 | !> @file surface_layer_fluxes_mod.f90 |
---|
[2000] | 2 | !------------------------------------------------------------------------------! |
---|
[1691] | 3 | ! This file is part of PALM. |
---|
| 4 | ! |
---|
[2000] | 5 | ! PALM is free software: you can redistribute it and/or modify it under the |
---|
| 6 | ! terms of the GNU General Public License as published by the Free Software |
---|
| 7 | ! Foundation, either version 3 of the License, or (at your option) any later |
---|
| 8 | ! version. |
---|
[1691] | 9 | ! |
---|
| 10 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
| 11 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
| 12 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
| 13 | ! |
---|
| 14 | ! You should have received a copy of the GNU General Public License along with |
---|
| 15 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
| 16 | ! |
---|
[2101] | 17 | ! Copyright 1997-2017 Leibniz Universitaet Hannover |
---|
[1691] | 18 | ! |
---|
[2000] | 19 | !------------------------------------------------------------------------------! |
---|
[1691] | 20 | ! Current revisions: |
---|
[1747] | 21 | ! ------------------ |
---|
[1758] | 22 | ! |
---|
[2233] | 23 | ! |
---|
[1692] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: surface_layer_fluxes_mod.f90 2547 2017-10-16 12:41:56Z scharf $ |
---|
[2547] | 27 | ! extended by cloud_droplets option |
---|
| 28 | ! |
---|
| 29 | ! 2321 2017-07-24 15:57:07Z schwenkel |
---|
[2321] | 30 | ! Bugfix: Correct index in lookup table for Obukhov length |
---|
| 31 | ! |
---|
| 32 | ! 2299 2017-06-29 10:14:38Z suehring |
---|
[2299] | 33 | ! Adjusted for allow separate spinups of LSM and atmosphere code |
---|
| 34 | ! |
---|
| 35 | ! 2292 2017-06-20 09:51:42Z schwenkel |
---|
[2292] | 36 | ! Implementation of new microphysic scheme: cloud_scheme = 'morrison' |
---|
| 37 | ! includes two more prognostic equations for cloud drop concentration (nc) |
---|
| 38 | ! and cloud water content (qc). |
---|
| 39 | ! |
---|
| 40 | ! 2281 2017-06-13 11:34:50Z suehring |
---|
[2281] | 41 | ! Clean-up unnecessary index access to surface type |
---|
| 42 | ! |
---|
| 43 | ! 2233 2017-05-30 18:08:54Z suehring |
---|
[1692] | 44 | ! |
---|
[2233] | 45 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
| 46 | ! Adjustments to new surface concept |
---|
| 47 | ! OpenMP bugfix |
---|
| 48 | ! |
---|
[2119] | 49 | ! 2118 2017-01-17 16:38:49Z raasch |
---|
| 50 | ! OpenACC directives and related code removed |
---|
| 51 | ! |
---|
[2092] | 52 | ! 2091 2016-12-21 16:38:18Z suehring |
---|
| 53 | ! Bugfix in calculation of vsws ( incorrect linear interpolation of us ) |
---|
| 54 | ! |
---|
[2077] | 55 | ! 2076 2016-12-02 13:54:20Z raasch |
---|
| 56 | ! further openmp bugfix for lookup method |
---|
| 57 | ! |
---|
[2074] | 58 | ! 2073 2016-11-30 14:34:05Z raasch |
---|
| 59 | ! openmp bugfix for lookup method |
---|
| 60 | ! |
---|
[2038] | 61 | ! 2037 2016-10-26 11:15:40Z knoop |
---|
| 62 | ! Anelastic approximation implemented |
---|
| 63 | ! |
---|
[2012] | 64 | ! 2011 2016-09-19 17:29:57Z kanani |
---|
| 65 | ! Flag urban_surface is now defined in module control_parameters. |
---|
| 66 | ! |
---|
[2008] | 67 | ! 2007 2016-08-24 15:47:17Z kanani |
---|
| 68 | ! Account for urban surface model in computation of vertical kinematic heatflux |
---|
| 69 | ! |
---|
[2001] | 70 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
| 71 | ! Forced header and separation lines into 80 columns |
---|
| 72 | ! |
---|
[1993] | 73 | ! 1992 2016-08-12 15:14:59Z suehring |
---|
| 74 | ! Minor bug, declaration of look-up index as INTEGER |
---|
| 75 | ! |
---|
[1961] | 76 | ! 1960 2016-07-12 16:34:24Z suehring |
---|
| 77 | ! Treat humidity and passive scalar separately |
---|
| 78 | ! |
---|
[1930] | 79 | ! 1929 2016-06-09 16:25:25Z suehring |
---|
| 80 | ! Bugfix: avoid segmentation fault in case one grid point is horizontally |
---|
| 81 | ! completely surrounded by topography |
---|
| 82 | ! |
---|
[1921] | 83 | ! 1920 2016-05-30 10:50:15Z suehring |
---|
| 84 | ! Avoid segmentation fault (see change in 1915) by different initialization of |
---|
| 85 | ! us instead of adding a very small number in the denominator |
---|
| 86 | ! |
---|
[1916] | 87 | ! 1915 2016-05-27 11:05:02Z suehring |
---|
| 88 | ! Bugfix: avoid segmentation fault in case of most_method = 'circular' at first |
---|
| 89 | ! timestep |
---|
| 90 | ! |
---|
[1851] | 91 | ! 1850 2016-04-08 13:29:27Z maronga |
---|
| 92 | ! Module renamed |
---|
| 93 | ! |
---|
| 94 | ! |
---|
[1823] | 95 | ! 1822 2016-04-07 07:49:42Z hoffmann |
---|
| 96 | ! icloud_scheme replaced by microphysics_* |
---|
| 97 | ! |
---|
[1789] | 98 | ! 1788 2016-03-10 11:01:04Z maronga |
---|
| 99 | ! Added parameter z0q which replaces z0h in the similarity functions for |
---|
| 100 | ! humidity. |
---|
| 101 | ! Syntax layout improved. |
---|
| 102 | ! |
---|
[1758] | 103 | ! 1757 2016-02-22 15:49:32Z maronga |
---|
| 104 | ! Minor fixes. |
---|
| 105 | ! |
---|
[1750] | 106 | ! 1749 2016-02-09 12:19:56Z raasch |
---|
| 107 | ! further OpenACC adjustments |
---|
| 108 | ! |
---|
[1748] | 109 | ! 1747 2016-02-08 12:25:53Z raasch |
---|
| 110 | ! adjustments for OpenACC usage |
---|
| 111 | ! |
---|
[1710] | 112 | ! 1709 2015-11-04 14:47:01Z maronga |
---|
| 113 | ! Bugfix: division by zero could occur when calculating rib at low wind speeds |
---|
| 114 | ! Bugfix: calculation of uv_total for neutral = .T., initial value for ol for |
---|
| 115 | ! neutral = .T. |
---|
| 116 | ! |
---|
[1706] | 117 | ! 1705 2015-11-02 14:28:56Z maronga |
---|
| 118 | ! Typo removed |
---|
| 119 | ! |
---|
[1698] | 120 | ! 1697 2015-10-28 17:14:10Z raasch |
---|
| 121 | ! FORTRAN and OpenMP errors removed |
---|
| 122 | ! |
---|
[1697] | 123 | ! 1696 2015-10-27 10:03:34Z maronga |
---|
[1691] | 124 | ! Modularized and completely re-written version of prandtl_fluxes.f90. In the |
---|
| 125 | ! course of the re-writing two additional methods have been implemented. See |
---|
| 126 | ! updated description. |
---|
| 127 | ! |
---|
| 128 | ! 1551 2015-03-03 14:18:16Z maronga |
---|
| 129 | ! Removed land surface model part. The surface fluxes are now always calculated |
---|
| 130 | ! within prandtl_fluxes, based on the given surface temperature/humidity (which |
---|
| 131 | ! is either provided by the land surface model, by large scale forcing data, or |
---|
| 132 | ! directly prescribed by the user. |
---|
| 133 | ! |
---|
| 134 | ! 1496 2014-12-02 17:25:50Z maronga |
---|
| 135 | ! Adapted for land surface model |
---|
| 136 | ! |
---|
| 137 | ! 1494 2014-11-21 17:14:03Z maronga |
---|
| 138 | ! Bugfixes: qs is now calculated before calculation of Rif. calculation of |
---|
| 139 | ! buoyancy flux in Rif corrected (added missing humidity term), allow use of |
---|
| 140 | ! topography for coupled runs (not tested) |
---|
| 141 | ! |
---|
| 142 | ! 1361 2014-04-16 15:17:48Z hoffmann |
---|
| 143 | ! Bugfix: calculation of turbulent fluxes of rain water content (qrsws) and rain |
---|
| 144 | ! drop concentration (nrsws) added |
---|
| 145 | ! |
---|
| 146 | ! 1340 2014-03-25 19:45:13Z kanani |
---|
| 147 | ! REAL constants defined as wp-kind |
---|
| 148 | ! |
---|
| 149 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
| 150 | ! ONLY-attribute added to USE-statements, |
---|
| 151 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 152 | ! kinds are defined in new module kinds, |
---|
| 153 | ! old module precision_kind is removed, |
---|
| 154 | ! revision history before 2012 removed, |
---|
| 155 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 156 | ! all variable declaration statements |
---|
| 157 | ! |
---|
| 158 | ! 1276 2014-01-15 13:40:41Z heinze |
---|
| 159 | ! Use LSF_DATA also in case of Dirichlet bottom boundary condition for scalars |
---|
| 160 | ! |
---|
| 161 | ! 1257 2013-11-08 15:18:40Z raasch |
---|
| 162 | ! openACC "kernels do" replaced by "kernels loop", "loop independent" added |
---|
| 163 | ! |
---|
| 164 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 165 | ! code put under GPL (PALM 3.9) |
---|
| 166 | ! |
---|
| 167 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
| 168 | ! OpenACC statements added |
---|
| 169 | ! |
---|
| 170 | ! 978 2012-08-09 08:28:32Z fricke |
---|
| 171 | ! roughness length for scalar quantities z0h added |
---|
| 172 | ! |
---|
| 173 | ! Revision 1.1 1998/01/23 10:06:06 raasch |
---|
| 174 | ! Initial revision |
---|
| 175 | ! |
---|
| 176 | ! |
---|
| 177 | ! Description: |
---|
| 178 | ! ------------ |
---|
| 179 | !> Diagnostic computation of vertical fluxes in the constant flux layer from the |
---|
| 180 | !> values of the variables at grid point k=1. Three different methods are |
---|
| 181 | !> available: |
---|
| 182 | !> 1) the "old" version (most_method = 'circular') which is fast, but inaccurate |
---|
| 183 | !> 2) a Newton iteration method (most_method = 'newton'), which is accurate, but |
---|
| 184 | !> slower |
---|
| 185 | !> 3) a method using a lookup table which is fast and accurate. Note, however, |
---|
| 186 | !> that this method cannot be used in case of roughness heterogeneity |
---|
| 187 | !> |
---|
| 188 | !> @todo (re)move large_scale_forcing actions |
---|
[2118] | 189 | !> @todo check/optimize OpenMP directives |
---|
[1691] | 190 | !------------------------------------------------------------------------------! |
---|
| 191 | MODULE surface_layer_fluxes_mod |
---|
| 192 | |
---|
| 193 | USE arrays_3d, & |
---|
[2292] | 194 | ONLY: e, kh, nc, nr, pt, q, ql, qc, qr, s, u, v, vpt, w, zu, zw, & |
---|
| 195 | drho_air_zw, rho_air_zw |
---|
[1691] | 196 | |
---|
| 197 | USE cloud_parameters, & |
---|
| 198 | ONLY: l_d_cp, pt_d_t |
---|
| 199 | |
---|
| 200 | USE constants, & |
---|
| 201 | ONLY: pi |
---|
| 202 | |
---|
| 203 | USE cpulog |
---|
| 204 | |
---|
| 205 | USE control_parameters, & |
---|
[2547] | 206 | ONLY: cloud_droplets, cloud_physics, constant_heatflux, & |
---|
| 207 | constant_scalarflux, constant_waterflux, coupling_mode, g, & |
---|
| 208 | humidity, ibc_e_b, ibc_pt_b, initializing_actions, kappa, & |
---|
[2232] | 209 | intermediate_timestep_count, intermediate_timestep_count_max, & |
---|
| 210 | land_surface, large_scale_forcing, lsf_surf, & |
---|
[2292] | 211 | message_string, microphysics_morrison, microphysics_seifert, & |
---|
| 212 | most_method, neutral, passive_scalar, pt_surface, q_surface, & |
---|
| 213 | run_coupled, surface_pressure, simulated_time, terminate_run, & |
---|
[2299] | 214 | time_since_reference_point, urban_surface, zeta_max, zeta_min |
---|
[1691] | 215 | |
---|
[2232] | 216 | USE grid_variables, & |
---|
| 217 | ONLY: dx, dy |
---|
| 218 | |
---|
[1691] | 219 | USE indices, & |
---|
[2232] | 220 | ONLY: nxl, nxr, nys, nyn, nzb |
---|
[1691] | 221 | |
---|
| 222 | USE kinds |
---|
| 223 | |
---|
| 224 | USE pegrid |
---|
| 225 | |
---|
| 226 | USE land_surface_model_mod, & |
---|
[2232] | 227 | ONLY: aero_resist_kray, skip_time_do_lsm |
---|
[2011] | 228 | |
---|
[2232] | 229 | USE surface_mod, & |
---|
| 230 | ONLY : surf_def_h, surf_def_v, surf_lsm_h, surf_lsm_v, surf_type, & |
---|
| 231 | surf_usm_h, surf_usm_v |
---|
[2007] | 232 | |
---|
[1691] | 233 | |
---|
| 234 | IMPLICIT NONE |
---|
| 235 | |
---|
[1992] | 236 | INTEGER(iwp) :: i !< loop index x direction |
---|
| 237 | INTEGER(iwp) :: j !< loop index y direction |
---|
| 238 | INTEGER(iwp) :: k !< loop index z direction |
---|
[2232] | 239 | INTEGER(iwp) :: l !< loop index for surf type |
---|
| 240 | INTEGER(iwp) :: li_bnd = 7500 !< Lookup table index of the last time step |
---|
[1691] | 241 | |
---|
[2232] | 242 | INTEGER(iwp), PARAMETER :: num_steps = 15000 !< number of steps in the lookup table |
---|
[1691] | 243 | |
---|
[2232] | 244 | LOGICAL :: coupled_run !< Flag for coupled atmosphere-ocean runs |
---|
| 245 | LOGICAL :: downward = .FALSE.!< Flag indicating downward-facing horizontal surface |
---|
| 246 | LOGICAL :: mom_uv = .FALSE. !< Flag indicating calculation of usvs and vsus at vertical surfaces |
---|
| 247 | LOGICAL :: mom_w = .FALSE. !< Flag indicating calculation of wsus and wsvs at vertical surfaces |
---|
| 248 | LOGICAL :: mom_tke = .FALSE. !< Flag indicating calculation of momentum fluxes at vertical surfaces used for TKE production |
---|
| 249 | LOGICAL :: surf_vertical !< Flag indicating vertical surfaces |
---|
[1691] | 250 | |
---|
| 251 | REAL(wp), DIMENSION(0:num_steps-1) :: rib_tab, & !< Lookup table bulk Richardson number |
---|
| 252 | ol_tab !< Lookup table values of L |
---|
| 253 | |
---|
| 254 | REAL(wp) :: e_s, & !< Saturation water vapor pressure |
---|
| 255 | ol_max = 1.0E6_wp, & !< Maximum Obukhov length |
---|
| 256 | rib_max, & !< Maximum Richardson number in lookup table |
---|
| 257 | rib_min, & !< Minimum Richardson number in lookup table |
---|
| 258 | z_mo !< Height of the constant flux layer where MOST is assumed |
---|
| 259 | |
---|
[2232] | 260 | TYPE(surf_type), POINTER :: surf !< surf-type array, used to generalize subroutines |
---|
[1691] | 261 | |
---|
[2232] | 262 | |
---|
[1691] | 263 | SAVE |
---|
| 264 | |
---|
| 265 | PRIVATE |
---|
| 266 | |
---|
[2232] | 267 | PUBLIC init_surface_layer_fluxes, surface_layer_fluxes |
---|
[1691] | 268 | |
---|
| 269 | INTERFACE init_surface_layer_fluxes |
---|
| 270 | MODULE PROCEDURE init_surface_layer_fluxes |
---|
| 271 | END INTERFACE init_surface_layer_fluxes |
---|
| 272 | |
---|
| 273 | INTERFACE surface_layer_fluxes |
---|
| 274 | MODULE PROCEDURE surface_layer_fluxes |
---|
| 275 | END INTERFACE surface_layer_fluxes |
---|
| 276 | |
---|
| 277 | |
---|
| 278 | CONTAINS |
---|
| 279 | |
---|
| 280 | |
---|
| 281 | !------------------------------------------------------------------------------! |
---|
| 282 | ! Description: |
---|
| 283 | ! ------------ |
---|
| 284 | !> Main routine to compute the surface fluxes |
---|
| 285 | !------------------------------------------------------------------------------! |
---|
| 286 | SUBROUTINE surface_layer_fluxes |
---|
| 287 | |
---|
| 288 | IMPLICIT NONE |
---|
| 289 | |
---|
[2232] | 290 | surf_vertical = .FALSE. |
---|
| 291 | downward = .FALSE. |
---|
[1691] | 292 | ! |
---|
| 293 | !-- In case cloud physics is used, it is required to derive potential |
---|
| 294 | !-- temperature and specific humidity at first grid level from the fields pt |
---|
| 295 | !-- and q |
---|
[2547] | 296 | IF ( cloud_physics .OR. cloud_droplets ) THEN |
---|
[2232] | 297 | ! |
---|
| 298 | !-- First call for horizontal default-type surfaces (l=0 - upward facing, |
---|
| 299 | !-- l=1 - downward facing) |
---|
| 300 | DO l = 0, 1 |
---|
| 301 | IF ( surf_def_h(l)%ns >= 1 ) THEN |
---|
| 302 | surf => surf_def_h(l) |
---|
| 303 | CALL calc_pt_q |
---|
| 304 | ENDIF |
---|
| 305 | ENDDO |
---|
| 306 | ! |
---|
| 307 | !-- Call for natural-type surfaces |
---|
| 308 | IF ( surf_lsm_h%ns >= 1 ) THEN |
---|
| 309 | surf => surf_lsm_h |
---|
| 310 | CALL calc_pt_q |
---|
| 311 | ENDIF |
---|
| 312 | ! |
---|
| 313 | !-- Call for urban-type surfaces |
---|
| 314 | IF ( surf_usm_h%ns >= 1 ) THEN |
---|
| 315 | surf => surf_usm_h |
---|
| 316 | CALL calc_pt_q |
---|
| 317 | ENDIF |
---|
[1691] | 318 | ENDIF |
---|
| 319 | |
---|
| 320 | ! |
---|
| 321 | !-- First, calculate the new Obukhov length, then new friction velocity, |
---|
| 322 | !-- followed by the new scaling parameters (th*, q*, etc.), and the new |
---|
| 323 | !-- surface fluxes if required. The old routine ("circular") requires a |
---|
| 324 | !-- different order of calls as the scaling parameters from the previous time |
---|
| 325 | !-- steps are used to calculate the Obukhov length |
---|
| 326 | |
---|
| 327 | ! |
---|
| 328 | !-- Depending on setting of most_method use the "old" routine |
---|
[2232] | 329 | !-- Note, each routine is called for different surface types. |
---|
| 330 | !-- First call for default-type horizontal surfaces, for natural- and |
---|
| 331 | !-- urban-type surfaces. Note, at this place only upward-facing horizontal |
---|
| 332 | !-- surfaces are treted. |
---|
[1691] | 333 | IF ( most_method == 'circular' ) THEN |
---|
[2232] | 334 | ! |
---|
| 335 | !-- Default-type upward-facing horizontal surfaces |
---|
| 336 | IF ( surf_def_h(0)%ns >= 1 ) THEN |
---|
| 337 | surf => surf_def_h(0) |
---|
| 338 | CALL calc_scaling_parameters |
---|
| 339 | CALL calc_uvw_abs |
---|
| 340 | IF ( .NOT. neutral ) CALL calc_ol |
---|
| 341 | CALL calc_us |
---|
| 342 | CALL calc_surface_fluxes |
---|
[1691] | 343 | ENDIF |
---|
| 344 | ! |
---|
[2232] | 345 | !-- Natural-type horizontal surfaces |
---|
| 346 | IF ( surf_lsm_h%ns >= 1 ) THEN |
---|
| 347 | surf => surf_lsm_h |
---|
| 348 | CALL calc_scaling_parameters |
---|
| 349 | CALL calc_uvw_abs |
---|
| 350 | IF ( .NOT. neutral ) CALL calc_ol |
---|
| 351 | CALL calc_us |
---|
| 352 | CALL calc_surface_fluxes |
---|
| 353 | ENDIF |
---|
| 354 | ! |
---|
| 355 | !-- Urban-type horizontal surfaces |
---|
| 356 | IF ( surf_usm_h%ns >= 1 ) THEN |
---|
| 357 | surf => surf_usm_h |
---|
| 358 | CALL calc_scaling_parameters |
---|
| 359 | CALL calc_uvw_abs |
---|
| 360 | IF ( .NOT. neutral ) CALL calc_ol |
---|
| 361 | CALL calc_us |
---|
| 362 | CALL calc_surface_fluxes |
---|
| 363 | ENDIF |
---|
| 364 | ! |
---|
[1691] | 365 | !-- Use either Newton iteration or a lookup table for the bulk Richardson |
---|
| 366 | !-- number to calculate the Obukhov length |
---|
[1788] | 367 | ELSEIF ( most_method == 'newton' .OR. most_method == 'lookup' ) THEN |
---|
[2232] | 368 | ! |
---|
| 369 | !-- Default-type upward-facing horizontal surfaces |
---|
| 370 | IF ( surf_def_h(0)%ns >= 1 ) THEN |
---|
| 371 | surf => surf_def_h(0) |
---|
| 372 | CALL calc_uvw_abs |
---|
| 373 | IF ( .NOT. neutral ) CALL calc_ol |
---|
| 374 | CALL calc_us |
---|
| 375 | CALL calc_scaling_parameters |
---|
| 376 | CALL calc_surface_fluxes |
---|
[1691] | 377 | ENDIF |
---|
[2232] | 378 | ! |
---|
| 379 | !-- Natural-type horizontal surfaces |
---|
| 380 | IF ( surf_lsm_h%ns >= 1 ) THEN |
---|
| 381 | surf => surf_lsm_h |
---|
| 382 | CALL calc_uvw_abs |
---|
| 383 | IF ( .NOT. neutral ) CALL calc_ol |
---|
| 384 | CALL calc_us |
---|
| 385 | CALL calc_scaling_parameters |
---|
| 386 | CALL calc_surface_fluxes |
---|
| 387 | ENDIF |
---|
| 388 | ! |
---|
| 389 | !-- Urban-type horizontal surfaces |
---|
| 390 | IF ( surf_usm_h%ns >= 1 ) THEN |
---|
| 391 | surf => surf_usm_h |
---|
| 392 | CALL calc_uvw_abs |
---|
| 393 | IF ( .NOT. neutral ) CALL calc_ol |
---|
| 394 | CALL calc_us |
---|
| 395 | CALL calc_scaling_parameters |
---|
| 396 | CALL calc_surface_fluxes |
---|
| 397 | ENDIF |
---|
[1691] | 398 | |
---|
[2232] | 399 | ENDIF |
---|
| 400 | ! |
---|
| 401 | !-- Treat downward-facing horizontal surfaces. Note, so far, these are |
---|
| 402 | !-- always default type. Stratification is not considered |
---|
| 403 | !-- in this case, hence, no further distinction between different |
---|
| 404 | !-- most_method is required. |
---|
| 405 | IF ( surf_def_h(1)%ns >= 1 ) THEN |
---|
| 406 | downward = .TRUE. |
---|
| 407 | surf => surf_def_h(1) |
---|
| 408 | CALL calc_uvw_abs |
---|
[1691] | 409 | CALL calc_us |
---|
| 410 | CALL calc_surface_fluxes |
---|
[2232] | 411 | downward = .FALSE. |
---|
[1691] | 412 | ENDIF |
---|
[2232] | 413 | ! |
---|
| 414 | !-- Calculate surfaces fluxes at vertical surfaces for momentum |
---|
| 415 | !-- and subgrid-scale TKE. |
---|
| 416 | !-- No stability is considered. Therefore, scaling parameters and Obukhov- |
---|
| 417 | !-- length do not need to be calculated and no distinction in 'circular', |
---|
| 418 | !-- 'Newton' or 'lookup' is necessary so far. |
---|
| 419 | !-- Note, this will change if stability is once considered. |
---|
| 420 | surf_vertical = .TRUE. |
---|
| 421 | ! |
---|
| 422 | !-- Calculate horizontal momentum fluxes at north- and south-facing |
---|
| 423 | !-- surfaces(usvs). |
---|
| 424 | !-- For default-type surfaces |
---|
| 425 | mom_uv = .TRUE. |
---|
| 426 | DO l = 0, 1 |
---|
| 427 | IF ( surf_def_v(l)%ns >= 1 ) THEN |
---|
| 428 | surf => surf_def_v(l) |
---|
| 429 | ! |
---|
| 430 | !-- Compute surface-parallel velocity |
---|
| 431 | CALL calc_uvw_abs_v_ugrid |
---|
| 432 | ! |
---|
| 433 | !-- Compute respective friction velocity on staggered grid |
---|
| 434 | CALL calc_us |
---|
| 435 | ! |
---|
| 436 | !-- Compute respective surface fluxes for momentum and TKE |
---|
| 437 | CALL calc_surface_fluxes |
---|
| 438 | ENDIF |
---|
| 439 | ENDDO |
---|
| 440 | ! |
---|
| 441 | !-- For natural-type surfaces. Please note, even though stability is not |
---|
| 442 | !-- considered for the calculation of momentum fluxes at vertical surfaces, |
---|
| 443 | !-- scaling parameters and Obukov length are calculated nevertheless in this |
---|
| 444 | !-- case. This is due to the requirement of ts in parameterization of heat |
---|
| 445 | !-- flux in land-surface model in case of aero_resist_kray is not true. |
---|
| 446 | IF ( .NOT. aero_resist_kray ) THEN |
---|
| 447 | IF ( most_method == 'circular' ) THEN |
---|
| 448 | DO l = 0, 1 |
---|
| 449 | IF ( surf_lsm_v(l)%ns >= 1 ) THEN |
---|
| 450 | surf => surf_lsm_v(l) |
---|
| 451 | ! |
---|
| 452 | !-- Compute scaling parameters |
---|
| 453 | CALL calc_scaling_parameters |
---|
| 454 | ! |
---|
| 455 | !-- Compute surface-parallel velocity |
---|
| 456 | CALL calc_uvw_abs_v_ugrid |
---|
| 457 | ! |
---|
| 458 | !-- Compute Obukhov length |
---|
| 459 | IF ( .NOT. neutral ) CALL calc_ol |
---|
| 460 | ! |
---|
| 461 | !-- Compute respective friction velocity on staggered grid |
---|
| 462 | CALL calc_us |
---|
| 463 | ! |
---|
| 464 | !-- Compute respective surface fluxes for momentum and TKE |
---|
| 465 | CALL calc_surface_fluxes |
---|
| 466 | ENDIF |
---|
| 467 | ENDDO |
---|
| 468 | ELSE |
---|
| 469 | DO l = 0, 1 |
---|
| 470 | IF ( surf_lsm_v(l)%ns >= 1 ) THEN |
---|
| 471 | surf => surf_lsm_v(l) |
---|
| 472 | ! |
---|
| 473 | !-- Compute surface-parallel velocity |
---|
| 474 | CALL calc_uvw_abs_v_ugrid |
---|
| 475 | ! |
---|
| 476 | !-- Compute Obukhov length |
---|
| 477 | IF ( .NOT. neutral ) CALL calc_ol |
---|
| 478 | ! |
---|
| 479 | !-- Compute respective friction velocity on staggered grid |
---|
| 480 | CALL calc_us |
---|
| 481 | ! |
---|
| 482 | !-- Compute scaling parameters |
---|
| 483 | CALL calc_scaling_parameters |
---|
| 484 | ! |
---|
| 485 | !-- Compute respective surface fluxes for momentum and TKE |
---|
| 486 | CALL calc_surface_fluxes |
---|
| 487 | ENDIF |
---|
| 488 | ENDDO |
---|
| 489 | ENDIF |
---|
| 490 | ! |
---|
| 491 | !-- No ts is required, so scaling parameters and Obukhov length do not need |
---|
| 492 | !-- to be computed. |
---|
| 493 | ELSE |
---|
| 494 | DO l = 0, 1 |
---|
| 495 | IF ( surf_lsm_v(l)%ns >= 1 ) THEN |
---|
| 496 | surf => surf_lsm_v(l) |
---|
| 497 | ! |
---|
| 498 | !-- Compute surface-parallel velocity |
---|
| 499 | CALL calc_uvw_abs_v_ugrid |
---|
| 500 | ! |
---|
| 501 | !-- Compute respective friction velocity on staggered grid |
---|
| 502 | CALL calc_us |
---|
| 503 | ! |
---|
| 504 | !-- Compute respective surface fluxes for momentum and TKE |
---|
| 505 | CALL calc_surface_fluxes |
---|
| 506 | ENDIF |
---|
| 507 | ENDDO |
---|
| 508 | ENDIF |
---|
| 509 | ! |
---|
| 510 | !-- For urban-type surfaces |
---|
| 511 | DO l = 0, 1 |
---|
| 512 | IF ( surf_usm_v(l)%ns >= 1 ) THEN |
---|
| 513 | surf => surf_usm_v(l) |
---|
| 514 | ! |
---|
| 515 | !-- Compute surface-parallel velocity |
---|
| 516 | CALL calc_uvw_abs_v_ugrid |
---|
| 517 | ! |
---|
| 518 | !-- Compute respective friction velocity on staggered grid |
---|
| 519 | CALL calc_us |
---|
| 520 | ! |
---|
| 521 | !-- Compute respective surface fluxes for momentum and TKE |
---|
| 522 | CALL calc_surface_fluxes |
---|
| 523 | ENDIF |
---|
| 524 | ENDDO |
---|
| 525 | ! |
---|
| 526 | !-- Calculate horizontal momentum fluxes at east- and west-facing |
---|
| 527 | !-- surfaces (vsus). |
---|
| 528 | !-- For default-type surfaces |
---|
| 529 | DO l = 2, 3 |
---|
| 530 | IF ( surf_def_v(l)%ns >= 1 ) THEN |
---|
| 531 | surf => surf_def_v(l) |
---|
| 532 | ! |
---|
| 533 | !-- Compute surface-parallel velocity |
---|
| 534 | CALL calc_uvw_abs_v_vgrid |
---|
| 535 | ! |
---|
| 536 | !-- Compute respective friction velocity on staggered grid |
---|
| 537 | CALL calc_us |
---|
| 538 | ! |
---|
| 539 | !-- Compute respective surface fluxes for momentum and TKE |
---|
| 540 | CALL calc_surface_fluxes |
---|
| 541 | ENDIF |
---|
| 542 | ENDDO |
---|
| 543 | ! |
---|
| 544 | !-- For natural-type surfaces. Please note, even though stability is not |
---|
| 545 | !-- considered for the calculation of momentum fluxes at vertical surfaces, |
---|
| 546 | !-- scaling parameters and Obukov length are calculated nevertheless in this |
---|
| 547 | !-- case. This is due to the requirement of ts in parameterization of heat |
---|
| 548 | !-- flux in land-surface model in case of aero_resist_kray is not true. |
---|
| 549 | IF ( .NOT. aero_resist_kray ) THEN |
---|
| 550 | IF ( most_method == 'circular' ) THEN |
---|
| 551 | DO l = 2, 3 |
---|
| 552 | IF ( surf_lsm_v(l)%ns >= 1 ) THEN |
---|
| 553 | surf => surf_lsm_v(l) |
---|
| 554 | ! |
---|
| 555 | !-- Compute scaling parameters |
---|
| 556 | CALL calc_scaling_parameters |
---|
| 557 | ! |
---|
| 558 | !-- Compute surface-parallel velocity |
---|
| 559 | CALL calc_uvw_abs_v_vgrid |
---|
| 560 | ! |
---|
| 561 | !-- Compute Obukhov length |
---|
| 562 | IF ( .NOT. neutral ) CALL calc_ol |
---|
| 563 | ! |
---|
| 564 | !-- Compute respective friction velocity on staggered grid |
---|
| 565 | CALL calc_us |
---|
| 566 | ! |
---|
| 567 | !-- Compute respective surface fluxes for momentum and TKE |
---|
| 568 | CALL calc_surface_fluxes |
---|
| 569 | ENDIF |
---|
| 570 | ENDDO |
---|
| 571 | ELSE |
---|
| 572 | DO l = 2, 3 |
---|
| 573 | IF ( surf_lsm_v(l)%ns >= 1 ) THEN |
---|
| 574 | surf => surf_lsm_v(l) |
---|
| 575 | ! |
---|
| 576 | !-- Compute surface-parallel velocity |
---|
| 577 | CALL calc_uvw_abs_v_vgrid |
---|
| 578 | ! |
---|
| 579 | !-- Compute Obukhov length |
---|
| 580 | IF ( .NOT. neutral ) CALL calc_ol |
---|
| 581 | ! |
---|
| 582 | !-- Compute respective friction velocity on staggered grid |
---|
| 583 | CALL calc_us |
---|
| 584 | ! |
---|
| 585 | !-- Compute scaling parameters |
---|
| 586 | CALL calc_scaling_parameters |
---|
| 587 | ! |
---|
| 588 | !-- Compute respective surface fluxes for momentum and TKE |
---|
| 589 | CALL calc_surface_fluxes |
---|
| 590 | ENDIF |
---|
| 591 | ENDDO |
---|
| 592 | ENDIF |
---|
| 593 | ELSE |
---|
| 594 | DO l = 2, 3 |
---|
| 595 | IF ( surf_lsm_v(l)%ns >= 1 ) THEN |
---|
| 596 | surf => surf_lsm_v(l) |
---|
| 597 | ! |
---|
| 598 | !-- Compute surface-parallel velocity |
---|
| 599 | CALL calc_uvw_abs_v_vgrid |
---|
| 600 | ! |
---|
| 601 | !-- Compute respective friction velocity on staggered grid |
---|
| 602 | CALL calc_us |
---|
| 603 | ! |
---|
| 604 | !-- Compute respective surface fluxes for momentum and TKE |
---|
| 605 | CALL calc_surface_fluxes |
---|
| 606 | ENDIF |
---|
| 607 | ENDDO |
---|
| 608 | ENDIF |
---|
| 609 | ! |
---|
| 610 | !-- For urban-type surfaces |
---|
| 611 | DO l = 2, 3 |
---|
| 612 | IF ( surf_usm_v(l)%ns >= 1 ) THEN |
---|
| 613 | surf => surf_usm_v(l) |
---|
| 614 | ! |
---|
| 615 | !-- Compute surface-parallel velocity |
---|
| 616 | CALL calc_uvw_abs_v_vgrid |
---|
| 617 | ! |
---|
| 618 | !-- Compute respective friction velocity on staggered grid |
---|
| 619 | CALL calc_us |
---|
| 620 | ! |
---|
| 621 | !-- Compute respective surface fluxes for momentum and TKE |
---|
| 622 | CALL calc_surface_fluxes |
---|
| 623 | ENDIF |
---|
| 624 | ENDDO |
---|
| 625 | mom_uv = .FALSE. |
---|
| 626 | ! |
---|
| 627 | !-- Calculate horizontal momentum fluxes of w (wsus and wsvs) at vertial |
---|
| 628 | !-- surfaces. |
---|
| 629 | mom_w = .TRUE. |
---|
| 630 | ! |
---|
| 631 | !-- Default-type surfaces |
---|
| 632 | DO l = 0, 3 |
---|
| 633 | IF ( surf_def_v(l)%ns >= 1 ) THEN |
---|
| 634 | surf => surf_def_v(l) |
---|
| 635 | CALL calc_uvw_abs_v_wgrid |
---|
| 636 | CALL calc_us |
---|
| 637 | CALL calc_surface_fluxes |
---|
| 638 | ENDIF |
---|
| 639 | ENDDO |
---|
| 640 | ! |
---|
| 641 | !-- Natural-type surfaces |
---|
| 642 | DO l = 0, 3 |
---|
| 643 | IF ( surf_lsm_v(l)%ns >= 1 ) THEN |
---|
| 644 | surf => surf_lsm_v(l) |
---|
| 645 | CALL calc_uvw_abs_v_wgrid |
---|
| 646 | CALL calc_us |
---|
| 647 | CALL calc_surface_fluxes |
---|
| 648 | ENDIF |
---|
| 649 | ENDDO |
---|
| 650 | ! |
---|
| 651 | !-- Urban-type surfaces |
---|
| 652 | DO l = 0, 3 |
---|
| 653 | IF ( surf_usm_v(l)%ns >= 1 ) THEN |
---|
| 654 | surf => surf_usm_v(l) |
---|
| 655 | CALL calc_uvw_abs_v_wgrid |
---|
| 656 | CALL calc_us |
---|
| 657 | CALL calc_surface_fluxes |
---|
| 658 | ENDIF |
---|
| 659 | ENDDO |
---|
| 660 | mom_w = .FALSE. |
---|
| 661 | ! |
---|
| 662 | !-- Calculate momentum fluxes usvs, vsus, wsus and wsvs at vertical |
---|
| 663 | !-- surfaces for TKE production. Note, here, momentum fluxes are defined |
---|
| 664 | !-- at grid center and are not staggered as before. |
---|
| 665 | mom_tke = .TRUE. |
---|
| 666 | ! |
---|
| 667 | !-- Default-type surfaces |
---|
| 668 | DO l = 0, 3 |
---|
| 669 | IF ( surf_def_v(l)%ns >= 1 ) THEN |
---|
| 670 | surf => surf_def_v(l) |
---|
| 671 | CALL calc_uvw_abs_v_sgrid |
---|
| 672 | CALL calc_us |
---|
| 673 | CALL calc_surface_fluxes |
---|
| 674 | ENDIF |
---|
| 675 | ENDDO |
---|
| 676 | ! |
---|
| 677 | !-- Natural-type surfaces |
---|
| 678 | DO l = 0, 3 |
---|
| 679 | IF ( surf_lsm_v(l)%ns >= 1 ) THEN |
---|
| 680 | surf => surf_lsm_v(l) |
---|
| 681 | CALL calc_uvw_abs_v_sgrid |
---|
| 682 | CALL calc_us |
---|
| 683 | CALL calc_surface_fluxes |
---|
| 684 | ENDIF |
---|
| 685 | ENDDO |
---|
| 686 | ! |
---|
| 687 | !-- Urban-type surfaces |
---|
| 688 | DO l = 0, 3 |
---|
| 689 | IF ( surf_usm_v(l)%ns >= 1 ) THEN |
---|
| 690 | surf => surf_usm_v(l) |
---|
| 691 | CALL calc_uvw_abs_v_sgrid |
---|
| 692 | CALL calc_us |
---|
| 693 | CALL calc_surface_fluxes |
---|
| 694 | ENDIF |
---|
| 695 | ENDDO |
---|
| 696 | mom_tke = .FALSE. |
---|
| 697 | |
---|
[1691] | 698 | |
---|
| 699 | END SUBROUTINE surface_layer_fluxes |
---|
| 700 | |
---|
| 701 | |
---|
| 702 | !------------------------------------------------------------------------------! |
---|
| 703 | ! Description: |
---|
| 704 | ! ------------ |
---|
| 705 | !> Initializing actions for the surface layer routine. Basically, this involves |
---|
| 706 | !> the preparation of a lookup table for the the bulk Richardson number vs |
---|
| 707 | !> Obukhov length L when using the lookup table method. |
---|
| 708 | !------------------------------------------------------------------------------! |
---|
| 709 | SUBROUTINE init_surface_layer_fluxes |
---|
| 710 | |
---|
| 711 | IMPLICIT NONE |
---|
| 712 | |
---|
[2232] | 713 | INTEGER(iwp) :: li, & !< Index for loop to create lookup table |
---|
[1691] | 714 | num_steps_n !< Number of non-stretched zeta steps |
---|
| 715 | |
---|
| 716 | LOGICAL :: terminate_run_l = .FALSE. !< Flag to terminate run (global) |
---|
| 717 | |
---|
| 718 | REAL(wp), PARAMETER :: zeta_stretch = -10.0_wp !< Start of stretching in the free convection limit |
---|
| 719 | |
---|
| 720 | REAL(wp), DIMENSION(:), ALLOCATABLE :: zeta_tmp |
---|
| 721 | |
---|
| 722 | |
---|
| 723 | REAL(wp) :: zeta_step, & !< Increment of zeta |
---|
| 724 | regr = 1.01_wp, & !< Stretching factor of zeta_step in the free convection limit |
---|
| 725 | regr_old = 1.0E9_wp, & !< Stretching factor of last iteration step |
---|
| 726 | z0h_min = 0.0_wp, & !< Minimum value of z0h to create table |
---|
| 727 | z0_min = 0.0_wp !< Minimum value of z0 to create table |
---|
| 728 | |
---|
| 729 | |
---|
[1709] | 730 | |
---|
[2232] | 731 | |
---|
[1709] | 732 | ! |
---|
| 733 | !-- In case of runs with neutral statification, set Obukhov length to a |
---|
| 734 | !-- large value |
---|
[2232] | 735 | IF ( neutral ) THEN |
---|
| 736 | IF ( surf_def_h(0)%ns >= 1 ) surf_def_h(0)%ol = 1.0E10_wp |
---|
| 737 | IF ( surf_lsm_h%ns >= 1 ) surf_lsm_h%ol = 1.0E10_wp |
---|
| 738 | IF ( surf_usm_h%ns >= 1 ) surf_usm_h%ol = 1.0E10_wp |
---|
| 739 | ENDIF |
---|
[1709] | 740 | |
---|
[1691] | 741 | IF ( most_method == 'lookup' ) THEN |
---|
| 742 | |
---|
| 743 | ! |
---|
| 744 | !-- Check for roughness heterogeneity. In that case terminate run and |
---|
[2232] | 745 | !-- inform user. Check for both, natural and non-natural walls. |
---|
| 746 | IF ( surf_def_h(0)%ns >= 1 ) THEN |
---|
| 747 | IF ( MINVAL( surf_def_h(0)%z0h ) /= MAXVAL( surf_def_h(0)%z0h ) .OR. & |
---|
| 748 | MINVAL( surf_def_h(0)%z0 ) /= MAXVAL( surf_def_h(0)%z0 ) ) THEN |
---|
| 749 | terminate_run_l = .TRUE. |
---|
| 750 | ENDIF |
---|
[1691] | 751 | ENDIF |
---|
[2232] | 752 | IF ( surf_lsm_h%ns >= 1 ) THEN |
---|
| 753 | IF ( MINVAL( surf_lsm_h%z0h ) /= MAXVAL( surf_lsm_h%z0h ) .OR. & |
---|
| 754 | MINVAL( surf_lsm_h%z0 ) /= MAXVAL( surf_lsm_h%z0 ) ) THEN |
---|
| 755 | terminate_run_l = .TRUE. |
---|
| 756 | ENDIF |
---|
| 757 | ENDIF |
---|
| 758 | IF ( surf_usm_h%ns >= 1 ) THEN |
---|
| 759 | IF ( MINVAL( surf_usm_h%z0h ) /= MAXVAL( surf_usm_h%z0h ) .OR. & |
---|
| 760 | MINVAL( surf_usm_h%z0 ) /= MAXVAL( surf_usm_h%z0 ) ) THEN |
---|
| 761 | terminate_run_l = .TRUE. |
---|
| 762 | ENDIF |
---|
| 763 | ENDIF |
---|
| 764 | ! |
---|
| 765 | !-- Check roughness homogeneity between differt surface types. |
---|
| 766 | IF ( surf_lsm_h%ns >= 1 .AND. surf_def_h(0)%ns >= 1 ) THEN |
---|
| 767 | IF ( MINVAL( surf_lsm_h%z0h ) /= MAXVAL( surf_def_h(0)%z0h ) .OR. & |
---|
| 768 | MINVAL( surf_lsm_h%z0 ) /= MAXVAL( surf_def_h(0)%z0 ) ) THEN |
---|
| 769 | terminate_run_l = .TRUE. |
---|
| 770 | ENDIF |
---|
| 771 | ENDIF |
---|
| 772 | IF ( surf_usm_h%ns >= 1 .AND. surf_def_h(0)%ns >= 1 ) THEN |
---|
| 773 | IF ( MINVAL( surf_usm_h%z0h ) /= MAXVAL( surf_def_h(0)%z0h ) .OR. & |
---|
| 774 | MINVAL( surf_usm_h%z0 ) /= MAXVAL( surf_def_h(0)%z0 ) ) THEN |
---|
| 775 | terminate_run_l = .TRUE. |
---|
| 776 | ENDIF |
---|
| 777 | ENDIF |
---|
| 778 | IF ( surf_usm_h%ns >= 1 .AND. surf_lsm_h%ns >= 1 ) THEN |
---|
| 779 | IF ( MINVAL( surf_usm_h%z0h ) /= MAXVAL( surf_lsm_h%z0h ) .OR. & |
---|
| 780 | MINVAL( surf_usm_h%z0 ) /= MAXVAL( surf_lsm_h%z0 ) ) THEN |
---|
| 781 | terminate_run_l = .TRUE. |
---|
| 782 | ENDIF |
---|
| 783 | ENDIF |
---|
[1691] | 784 | |
---|
[2232] | 785 | |
---|
[1691] | 786 | #if defined( __parallel ) |
---|
| 787 | ! |
---|
| 788 | !-- Make a logical OR for all processes. Force termiation of model if result |
---|
| 789 | !-- is TRUE |
---|
| 790 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 791 | CALL MPI_ALLREDUCE( terminate_run_l, terminate_run, 1, MPI_LOGICAL, & |
---|
| 792 | MPI_LOR, comm2d, ierr ) |
---|
| 793 | #else |
---|
| 794 | terminate_run = terminate_run_l |
---|
| 795 | #endif |
---|
| 796 | |
---|
| 797 | IF ( terminate_run ) THEN |
---|
| 798 | message_string = 'most_method = "lookup" cannot be used in ' // & |
---|
| 799 | 'combination with a prescribed roughness ' // & |
---|
| 800 | 'heterogeneity' |
---|
| 801 | CALL message( 'surface_layer_fluxes', 'PA0417', 1, 2, 0, 6, 0 ) |
---|
| 802 | ENDIF |
---|
| 803 | |
---|
| 804 | ALLOCATE( zeta_tmp(0:num_steps-1) ) |
---|
| 805 | |
---|
| 806 | ! |
---|
| 807 | !-- Use the lowest possible value for z_mo |
---|
[2232] | 808 | k = nzb |
---|
[1691] | 809 | z_mo = zu(k+1) - zw(k) |
---|
| 810 | |
---|
| 811 | ! |
---|
| 812 | !-- Calculate z/L range from zeta_stretch to zeta_max using 90% of the |
---|
| 813 | !-- available steps (num_steps). The calculation is done with negative |
---|
| 814 | !-- values of zeta in order to simplify the stretching in the free |
---|
| 815 | !-- convection limit for the remaining 10% of steps. |
---|
| 816 | zeta_tmp(0) = - zeta_max |
---|
| 817 | num_steps_n = ( num_steps * 9 / 10 ) - 1 |
---|
| 818 | zeta_step = (zeta_max - zeta_stretch) / REAL(num_steps_n) |
---|
| 819 | |
---|
[2232] | 820 | DO li = 1, num_steps_n |
---|
| 821 | zeta_tmp(li) = zeta_tmp(li-1) + zeta_step |
---|
[1691] | 822 | ENDDO |
---|
| 823 | |
---|
| 824 | ! |
---|
| 825 | !-- Calculate stretching factor for the free convection range |
---|
[1788] | 826 | DO WHILE ( ABS( (regr-regr_old) / regr_old ) > 1.0E-10_wp ) |
---|
[1691] | 827 | regr_old = regr |
---|
| 828 | regr = ( 1.0_wp - ( -zeta_min / zeta_step ) * ( 1.0_wp - regr ) & |
---|
| 829 | )**( 10.0_wp / REAL(num_steps) ) |
---|
| 830 | ENDDO |
---|
| 831 | |
---|
| 832 | ! |
---|
| 833 | !-- Calculate z/L range from zeta_min to zeta_stretch |
---|
[2232] | 834 | DO li = num_steps_n+1, num_steps-1 |
---|
| 835 | zeta_tmp(li) = zeta_tmp(li-1) + zeta_step |
---|
[1691] | 836 | zeta_step = zeta_step * regr |
---|
| 837 | ENDDO |
---|
| 838 | |
---|
| 839 | ! |
---|
[1757] | 840 | !-- Save roughness lengths to temporary variables |
---|
[2232] | 841 | IF ( surf_def_h(0)%ns >= 1 ) THEN |
---|
| 842 | z0h_min = surf_def_h(0)%z0h(1) |
---|
| 843 | z0_min = surf_def_h(0)%z0(1) |
---|
| 844 | ELSEIF ( surf_lsm_h%ns >= 1 ) THEN |
---|
| 845 | z0h_min = surf_lsm_h%z0h(1) |
---|
| 846 | z0_min = surf_lsm_h%z0(1) |
---|
| 847 | ELSEIF ( surf_usm_h%ns >= 1 ) THEN |
---|
| 848 | z0h_min = surf_usm_h%z0h(1) |
---|
| 849 | z0_min = surf_usm_h%z0(1) |
---|
| 850 | ENDIF |
---|
[1691] | 851 | ! |
---|
| 852 | !-- Calculate lookup table for the Richardson number versus Obukhov length |
---|
| 853 | !-- The Richardson number (rib) is defined depending on the choice of |
---|
| 854 | !-- boundary conditions for temperature |
---|
| 855 | IF ( ibc_pt_b == 1 ) THEN |
---|
[2232] | 856 | DO li = 0, num_steps-1 |
---|
| 857 | ol_tab(li) = - z_mo / zeta_tmp(num_steps-1-li) |
---|
| 858 | rib_tab(li) = z_mo / ol_tab(li) / ( LOG( z_mo / z0_min ) & |
---|
| 859 | - psi_m( z_mo / ol_tab(li) ) & |
---|
| 860 | + psi_m( z0_min / ol_tab(li) ) & |
---|
[1691] | 861 | )**3 |
---|
| 862 | ENDDO |
---|
| 863 | ELSE |
---|
[2232] | 864 | DO li = 0, num_steps-1 |
---|
| 865 | ol_tab(li) = - z_mo / zeta_tmp(num_steps-1-li) |
---|
| 866 | rib_tab(li) = z_mo / ol_tab(li) * ( LOG( z_mo / z0h_min ) & |
---|
| 867 | - psi_h( z_mo / ol_tab(li) ) & |
---|
| 868 | + psi_h( z0h_min / ol_tab(li) ) & |
---|
[1691] | 869 | ) & |
---|
| 870 | / ( LOG( z_mo / z0_min ) & |
---|
[2232] | 871 | - psi_m( z_mo / ol_tab(li) ) & |
---|
| 872 | + psi_m( z0_min / ol_tab(li) ) & |
---|
[1691] | 873 | )**2 |
---|
| 874 | ENDDO |
---|
| 875 | ENDIF |
---|
| 876 | |
---|
| 877 | ! |
---|
| 878 | !-- Determine minimum values of rib in the lookup table. Set upper limit |
---|
| 879 | !-- to critical Richardson number (0.25) |
---|
| 880 | rib_min = MINVAL(rib_tab) |
---|
| 881 | rib_max = 0.25 !MAXVAL(rib_tab) |
---|
| 882 | |
---|
| 883 | DEALLOCATE( zeta_tmp ) |
---|
| 884 | ENDIF |
---|
| 885 | |
---|
| 886 | END SUBROUTINE init_surface_layer_fluxes |
---|
| 887 | |
---|
| 888 | |
---|
| 889 | !------------------------------------------------------------------------------! |
---|
| 890 | ! Description: |
---|
| 891 | ! ------------ |
---|
[1709] | 892 | !> Compute the absolute value of the horizontal velocity (relative to the |
---|
[2232] | 893 | !> surface) for horizontal surface elements. This is required by all methods. |
---|
[1691] | 894 | !------------------------------------------------------------------------------! |
---|
[2232] | 895 | SUBROUTINE calc_uvw_abs |
---|
[1691] | 896 | |
---|
| 897 | IMPLICIT NONE |
---|
| 898 | |
---|
[2232] | 899 | INTEGER(iwp) :: i !< running index x direction |
---|
| 900 | INTEGER(iwp) :: ibit !< flag to mask computation of relative velocity in case of downward-facing surfaces |
---|
| 901 | INTEGER(iwp) :: j !< running index y direction |
---|
| 902 | INTEGER(iwp) :: k !< running index z direction |
---|
| 903 | INTEGER(iwp) :: m !< running index surface elements |
---|
[1691] | 904 | |
---|
[2232] | 905 | ! |
---|
| 906 | !-- ibit is 1 for upward-facing surfaces, zero for downward-facing surfaces. |
---|
| 907 | ibit = MERGE( 1, 0, .NOT. downward ) |
---|
[1691] | 908 | |
---|
[2232] | 909 | DO m = 1, surf%ns |
---|
[1691] | 910 | |
---|
[2232] | 911 | i = surf%i(m) |
---|
| 912 | j = surf%j(m) |
---|
| 913 | k = surf%k(m) |
---|
[1691] | 914 | ! |
---|
[2232] | 915 | !-- Compute the absolute value of the horizontal velocity. |
---|
| 916 | !-- (relative to the surface in case the lower surface is the ocean). |
---|
| 917 | !-- Please note, in new surface modelling concept the index values changed, |
---|
| 918 | !-- i.e. the reference grid point is not the surface-grid point itself but |
---|
| 919 | !-- the first grid point outside of the topography. |
---|
| 920 | !-- Note, in case of coupled ocean-atmosphere simulations relative velocity |
---|
| 921 | !-- with respect to the ocean surface is used, hence, (k-1,j,i) values |
---|
| 922 | !-- are used to calculate the absolute velocity. |
---|
| 923 | !-- However, this do not apply for downward-facing walls. To mask this, |
---|
| 924 | !-- use ibit, which checks for upward/downward-facing surfaces. |
---|
[1691] | 925 | |
---|
[2232] | 926 | surf%uvw_abs(m) = SQRT( & |
---|
| 927 | ( 0.5_wp * ( u(k,j,i) + u(k,j,i+1) & |
---|
| 928 | - ( u(k-1,j,i) + u(k-1,j,i+1) & |
---|
| 929 | ) * ibit & |
---|
| 930 | ) & |
---|
| 931 | )**2 + & |
---|
| 932 | ( 0.5_wp * ( v(k,j,i) + v(k,j+1,i) & |
---|
| 933 | - ( v(k-1,j,i) + v(k-1,j+1,i) & |
---|
| 934 | ) * ibit & |
---|
| 935 | ) & |
---|
| 936 | )**2 & |
---|
| 937 | ) |
---|
| 938 | |
---|
[1691] | 939 | ENDDO |
---|
| 940 | |
---|
[2232] | 941 | END SUBROUTINE calc_uvw_abs |
---|
| 942 | |
---|
| 943 | |
---|
| 944 | !------------------------------------------------------------------------------! |
---|
| 945 | ! Description: |
---|
| 946 | ! ------------ |
---|
| 947 | !> Compute the absolute value of the horizontal velocity (relative to the |
---|
| 948 | !> surface) for horizontal surface elements. This is required by all methods. |
---|
| 949 | !------------------------------------------------------------------------------! |
---|
| 950 | SUBROUTINE calc_uvw_abs_v_ugrid |
---|
| 951 | |
---|
| 952 | IMPLICIT NONE |
---|
| 953 | |
---|
| 954 | INTEGER(iwp) :: i !< running index x direction |
---|
| 955 | INTEGER(iwp) :: j !< running index y direction |
---|
| 956 | INTEGER(iwp) :: k !< running index z direction |
---|
| 957 | INTEGER(iwp) :: m !< running index surface elements |
---|
| 958 | |
---|
| 959 | REAL(wp) :: u_i |
---|
| 960 | REAL(wp) :: w_i |
---|
| 961 | |
---|
| 962 | |
---|
| 963 | DO m = 1, surf%ns |
---|
| 964 | i = surf%i(m) |
---|
| 965 | j = surf%j(m) |
---|
| 966 | k = surf%k(m) |
---|
[1691] | 967 | ! |
---|
[2232] | 968 | !-- Compute the absolute value of the surface parallel velocity on u-grid. |
---|
| 969 | u_i = u(k,j,i) |
---|
| 970 | w_i = 0.25_wp * ( w(k-1,j,i-1) + w(k-1,j,i) + & |
---|
| 971 | w(k,j,i-1) + w(k,j,i) ) |
---|
[1691] | 972 | |
---|
[2232] | 973 | surf%uvw_abs(m) = SQRT( u_i**2 + w_i**2 ) |
---|
[1709] | 974 | |
---|
[2232] | 975 | ENDDO |
---|
[1709] | 976 | |
---|
[2232] | 977 | END SUBROUTINE calc_uvw_abs_v_ugrid |
---|
| 978 | |
---|
[1709] | 979 | !------------------------------------------------------------------------------! |
---|
| 980 | ! Description: |
---|
| 981 | ! ------------ |
---|
[2232] | 982 | !> Compute the absolute value of the horizontal velocity (relative to the |
---|
| 983 | !> surface) for horizontal surface elements. This is required by all methods. |
---|
| 984 | !------------------------------------------------------------------------------! |
---|
| 985 | SUBROUTINE calc_uvw_abs_v_vgrid |
---|
| 986 | |
---|
| 987 | IMPLICIT NONE |
---|
| 988 | |
---|
| 989 | INTEGER(iwp) :: i !< running index x direction |
---|
| 990 | INTEGER(iwp) :: j !< running index y direction |
---|
| 991 | INTEGER(iwp) :: k !< running index z direction |
---|
| 992 | INTEGER(iwp) :: m !< running index surface elements |
---|
| 993 | |
---|
| 994 | REAL(wp) :: v_i |
---|
| 995 | REAL(wp) :: w_i |
---|
| 996 | |
---|
| 997 | |
---|
| 998 | DO m = 1, surf%ns |
---|
| 999 | i = surf%i(m) |
---|
| 1000 | j = surf%j(m) |
---|
| 1001 | k = surf%k(m) |
---|
| 1002 | |
---|
| 1003 | v_i = u(k,j,i) |
---|
| 1004 | w_i = 0.25_wp * ( w(k-1,j-1,i) + w(k-1,j,i) + & |
---|
| 1005 | w(k,j-1,i) + w(k,j,i) ) |
---|
| 1006 | |
---|
| 1007 | surf%uvw_abs(m) = SQRT( v_i**2 + w_i**2 ) |
---|
| 1008 | |
---|
| 1009 | ENDDO |
---|
| 1010 | |
---|
| 1011 | END SUBROUTINE calc_uvw_abs_v_vgrid |
---|
| 1012 | |
---|
| 1013 | !------------------------------------------------------------------------------! |
---|
| 1014 | ! Description: |
---|
| 1015 | ! ------------ |
---|
| 1016 | !> Compute the absolute value of the horizontal velocity (relative to the |
---|
| 1017 | !> surface) for horizontal surface elements. This is required by all methods. |
---|
| 1018 | !------------------------------------------------------------------------------! |
---|
| 1019 | SUBROUTINE calc_uvw_abs_v_wgrid |
---|
| 1020 | |
---|
| 1021 | IMPLICIT NONE |
---|
| 1022 | |
---|
| 1023 | INTEGER(iwp) :: i !< running index x direction |
---|
| 1024 | INTEGER(iwp) :: j !< running index y direction |
---|
| 1025 | INTEGER(iwp) :: k !< running index z direction |
---|
| 1026 | INTEGER(iwp) :: m !< running index surface elements |
---|
| 1027 | |
---|
| 1028 | REAL(wp) :: u_i |
---|
| 1029 | REAL(wp) :: v_i |
---|
| 1030 | REAL(wp) :: w_i |
---|
| 1031 | ! |
---|
| 1032 | !-- North- (l=0) and south-facing (l=1) surfaces |
---|
| 1033 | IF ( l == 0 .OR. l == 1 ) THEN |
---|
| 1034 | DO m = 1, surf%ns |
---|
| 1035 | i = surf%i(m) |
---|
| 1036 | j = surf%j(m) |
---|
| 1037 | k = surf%k(m) |
---|
| 1038 | |
---|
| 1039 | u_i = 0.25_wp * ( u(k+1,j,i+1) + u(k+1,j,i) + & |
---|
| 1040 | u(k,j,i+1) + u(k,j,i) ) |
---|
| 1041 | v_i = 0.0_wp |
---|
| 1042 | w_i = w(k,j,i) |
---|
| 1043 | |
---|
| 1044 | surf%uvw_abs(m) = SQRT( u_i**2 + v_i**2 + w_i**2 ) |
---|
| 1045 | ENDDO |
---|
| 1046 | ! |
---|
| 1047 | !-- East- (l=2) and west-facing (l=3) surfaces |
---|
| 1048 | ELSE |
---|
| 1049 | DO m = 1, surf%ns |
---|
| 1050 | i = surf%i(m) |
---|
| 1051 | j = surf%j(m) |
---|
| 1052 | k = surf%k(m) |
---|
| 1053 | |
---|
| 1054 | u_i = 0.0_wp |
---|
| 1055 | v_i = 0.25_wp * ( v(k+1,j+1,i) + v(k+1,j,i) + & |
---|
| 1056 | v(k,j+1,i) + v(k,j,i) ) |
---|
| 1057 | w_i = w(k,j,i) |
---|
| 1058 | |
---|
| 1059 | surf%uvw_abs(m) = SQRT( u_i**2 + v_i**2 + w_i**2 ) |
---|
| 1060 | ENDDO |
---|
| 1061 | ENDIF |
---|
| 1062 | |
---|
| 1063 | END SUBROUTINE calc_uvw_abs_v_wgrid |
---|
| 1064 | |
---|
| 1065 | !------------------------------------------------------------------------------! |
---|
| 1066 | ! Description: |
---|
| 1067 | ! ------------ |
---|
| 1068 | !> Compute the absolute value of the horizontal velocity (relative to the |
---|
| 1069 | !> surface) for horizontal surface elements. This is required by all methods. |
---|
| 1070 | !------------------------------------------------------------------------------! |
---|
| 1071 | SUBROUTINE calc_uvw_abs_v_sgrid |
---|
| 1072 | |
---|
| 1073 | IMPLICIT NONE |
---|
| 1074 | |
---|
| 1075 | INTEGER(iwp) :: i !< running index x direction |
---|
| 1076 | INTEGER(iwp) :: j !< running index y direction |
---|
| 1077 | INTEGER(iwp) :: k !< running index z direction |
---|
| 1078 | INTEGER(iwp) :: m !< running index surface elements |
---|
| 1079 | |
---|
| 1080 | REAL(wp) :: u_i |
---|
| 1081 | REAL(wp) :: v_i |
---|
| 1082 | REAL(wp) :: w_i |
---|
| 1083 | |
---|
| 1084 | ! |
---|
| 1085 | !-- North- (l=0) and south-facing (l=1) walls |
---|
| 1086 | IF ( l == 0 .OR. l == 1 ) THEN |
---|
| 1087 | DO m = 1, surf%ns |
---|
| 1088 | i = surf%i(m) |
---|
| 1089 | j = surf%j(m) |
---|
| 1090 | k = surf%k(m) |
---|
| 1091 | |
---|
| 1092 | u_i = 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) |
---|
| 1093 | v_i = 0.0_wp |
---|
| 1094 | w_i = 0.5_wp * ( w(k,j,i) + w(k-1,j,i) ) |
---|
| 1095 | |
---|
| 1096 | surf%uvw_abs(m) = SQRT( u_i**2 + v_i**2 + w_i**2 ) |
---|
| 1097 | ENDDO |
---|
| 1098 | ! |
---|
| 1099 | !-- East- (l=2) and west-facing (l=3) walls |
---|
| 1100 | ELSE |
---|
| 1101 | DO m = 1, surf%ns |
---|
| 1102 | i = surf%i(m) |
---|
| 1103 | j = surf%j(m) |
---|
| 1104 | k = surf%k(m) |
---|
| 1105 | |
---|
| 1106 | u_i = 0.0_wp |
---|
| 1107 | v_i = 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) |
---|
| 1108 | w_i = 0.5_wp * ( w(k,j,i) + w(k-1,j,i) ) |
---|
| 1109 | |
---|
| 1110 | surf%uvw_abs(m) = SQRT( u_i**2 + v_i**2 + w_i**2 ) |
---|
| 1111 | ENDDO |
---|
| 1112 | ENDIF |
---|
| 1113 | |
---|
| 1114 | END SUBROUTINE calc_uvw_abs_v_sgrid |
---|
| 1115 | |
---|
| 1116 | |
---|
| 1117 | !------------------------------------------------------------------------------! |
---|
| 1118 | ! Description: |
---|
| 1119 | ! ------------ |
---|
[1709] | 1120 | !> Calculate the Obukhov length (L) and Richardson flux number (z/L) |
---|
| 1121 | !------------------------------------------------------------------------------! |
---|
| 1122 | SUBROUTINE calc_ol |
---|
| 1123 | |
---|
| 1124 | IMPLICIT NONE |
---|
| 1125 | |
---|
[2232] | 1126 | INTEGER(iwp) :: iter !< Newton iteration step |
---|
| 1127 | INTEGER(iwp) :: li !< look index |
---|
| 1128 | INTEGER(iwp) :: m !< loop variable over all horizontal wall elements |
---|
[1709] | 1129 | |
---|
| 1130 | REAL(wp) :: f, & !< Function for Newton iteration: f = Ri - [...]/[...]^2 = 0 |
---|
| 1131 | f_d_ol, & !< Derivative of f |
---|
| 1132 | ol_l, & !< Lower bound of L for Newton iteration |
---|
| 1133 | ol_m, & !< Previous value of L for Newton iteration |
---|
| 1134 | ol_old, & !< Previous time step value of L |
---|
| 1135 | ol_u !< Upper bound of L for Newton iteration |
---|
| 1136 | |
---|
[1691] | 1137 | IF ( TRIM( most_method ) /= 'circular' ) THEN |
---|
[2232] | 1138 | ! |
---|
| 1139 | !-- Evaluate bulk Richardson number (calculation depends on |
---|
| 1140 | !-- definition based on setting of boundary conditions |
---|
| 1141 | IF ( ibc_pt_b /= 1 ) THEN |
---|
| 1142 | IF ( humidity ) THEN |
---|
| 1143 | !$OMP PARALLEL DO PRIVATE( i, j, k, z_mo ) |
---|
| 1144 | DO m = 1, surf%ns |
---|
[1691] | 1145 | |
---|
[2232] | 1146 | i = surf%i(m) |
---|
| 1147 | j = surf%j(m) |
---|
| 1148 | k = surf%k(m) |
---|
[1691] | 1149 | |
---|
[2232] | 1150 | z_mo = surf%z_mo(m) |
---|
| 1151 | |
---|
| 1152 | surf%rib(m) = g * z_mo * & |
---|
| 1153 | ( vpt(k,j,i) - vpt(k-1,j,i) ) / & |
---|
| 1154 | ( surf%uvw_abs(m)**2 * vpt(k,j,i) + 1.0E-20_wp ) |
---|
| 1155 | ENDDO |
---|
| 1156 | ELSE |
---|
| 1157 | !$OMP PARALLEL DO PRIVATE( i, j, k, z_mo ) |
---|
| 1158 | DO m = 1, surf%ns |
---|
| 1159 | |
---|
| 1160 | i = surf%i(m) |
---|
| 1161 | j = surf%j(m) |
---|
| 1162 | k = surf%k(m) |
---|
| 1163 | |
---|
| 1164 | z_mo = surf%z_mo(m) |
---|
| 1165 | |
---|
| 1166 | surf%rib(m) = g * z_mo * & |
---|
| 1167 | ( pt(k,j,i) - pt(k-1,j,i) ) / & |
---|
| 1168 | ( surf%uvw_abs(m)**2 * pt(k,j,i) + 1.0E-20_wp ) |
---|
| 1169 | ENDDO |
---|
| 1170 | ENDIF |
---|
| 1171 | ELSE |
---|
| 1172 | IF ( humidity ) THEN |
---|
| 1173 | !$OMP PARALLEL DO PRIVATE( i, j, k, z_mo ) |
---|
| 1174 | DO m = 1, surf%ns |
---|
| 1175 | |
---|
| 1176 | i = surf%i(m) |
---|
| 1177 | j = surf%j(m) |
---|
| 1178 | k = surf%k(m) |
---|
| 1179 | |
---|
| 1180 | z_mo = surf%z_mo(m) |
---|
| 1181 | |
---|
| 1182 | surf%rib(m) = - g * z_mo * ( ( 1.0_wp + 0.61_wp & |
---|
| 1183 | * q(k,j,i) ) * surf%shf(m) + 0.61_wp & |
---|
| 1184 | * pt(k,j,i) * surf%qsws(m) ) * & |
---|
| 1185 | drho_air_zw(k-1) / & |
---|
| 1186 | ( surf%uvw_abs(m)**3 * vpt(k,j,i) * kappa**2 & |
---|
[1709] | 1187 | + 1.0E-20_wp ) |
---|
[2232] | 1188 | ENDDO |
---|
| 1189 | ELSE |
---|
| 1190 | !$OMP PARALLEL DO PRIVATE( i, j, k, z_mo ) |
---|
| 1191 | DO m = 1, surf%ns |
---|
[1691] | 1192 | |
---|
[2232] | 1193 | i = surf%i(m) |
---|
| 1194 | j = surf%j(m) |
---|
| 1195 | k = surf%k(m) |
---|
| 1196 | |
---|
| 1197 | z_mo = surf%z_mo(m) |
---|
| 1198 | |
---|
| 1199 | surf%rib(m) = - g * z_mo * surf%shf(m) * & |
---|
| 1200 | drho_air_zw(k-1) / & |
---|
| 1201 | ( surf%uvw_abs(m)**3 * pt(k,j,i) * kappa**2 & |
---|
| 1202 | + 1.0E-20_wp ) |
---|
| 1203 | ENDDO |
---|
| 1204 | ENDIF |
---|
| 1205 | ENDIF |
---|
| 1206 | |
---|
[1691] | 1207 | ENDIF |
---|
| 1208 | |
---|
[2232] | 1209 | |
---|
[1691] | 1210 | ! |
---|
| 1211 | !-- Calculate the Obukhov length either using a Newton iteration |
---|
| 1212 | !-- method, via a lookup table, or using the old circular way |
---|
| 1213 | IF ( TRIM( most_method ) == 'newton' ) THEN |
---|
| 1214 | |
---|
[2232] | 1215 | DO m = 1, surf%ns |
---|
[1691] | 1216 | |
---|
[2232] | 1217 | i = surf%i(m) |
---|
| 1218 | j = surf%j(m) |
---|
[1691] | 1219 | |
---|
[2232] | 1220 | z_mo = surf%z_mo(m) |
---|
| 1221 | |
---|
[1691] | 1222 | ! |
---|
[2232] | 1223 | !-- Store current value in case the Newton iteration fails |
---|
| 1224 | ol_old = surf%ol(m) |
---|
[1691] | 1225 | |
---|
| 1226 | ! |
---|
[2232] | 1227 | !-- Ensure that the bulk Richardson number and the Obukhov |
---|
| 1228 | !-- length have the same sign |
---|
| 1229 | IF ( surf%rib(m) * surf%ol(m) < 0.0_wp .OR. & |
---|
| 1230 | ABS( surf%ol(m) ) == ol_max ) THEN |
---|
| 1231 | IF ( surf%rib(m) > 1.0_wp ) surf%ol(m) = 0.01_wp |
---|
| 1232 | IF ( surf%rib(m) < 0.0_wp ) surf%ol(m) = -0.01_wp |
---|
| 1233 | ENDIF |
---|
[1691] | 1234 | ! |
---|
[2232] | 1235 | !-- Iteration to find Obukhov length |
---|
| 1236 | iter = 0 |
---|
| 1237 | DO |
---|
| 1238 | iter = iter + 1 |
---|
[1691] | 1239 | ! |
---|
[2232] | 1240 | !-- In case of divergence, use the value of the previous time step |
---|
| 1241 | IF ( iter > 1000 ) THEN |
---|
| 1242 | surf%ol(m) = ol_old |
---|
| 1243 | EXIT |
---|
| 1244 | ENDIF |
---|
[1691] | 1245 | |
---|
[2232] | 1246 | ol_m = surf%ol(m) |
---|
| 1247 | ol_l = ol_m - 0.001_wp * ol_m |
---|
| 1248 | ol_u = ol_m + 0.001_wp * ol_m |
---|
[1691] | 1249 | |
---|
| 1250 | |
---|
[2232] | 1251 | IF ( ibc_pt_b /= 1 ) THEN |
---|
[1691] | 1252 | ! |
---|
[2232] | 1253 | !-- Calculate f = Ri - [...]/[...]^2 = 0 |
---|
| 1254 | f = surf%rib(m) - ( z_mo / ol_m ) * ( & |
---|
| 1255 | LOG( z_mo / surf%z0h(m) ) & |
---|
| 1256 | - psi_h( z_mo / ol_m ) & |
---|
| 1257 | + psi_h( surf%z0h(m) / & |
---|
| 1258 | ol_m ) & |
---|
| 1259 | ) & |
---|
| 1260 | / ( LOG( z_mo / surf%z0(m) ) & |
---|
| 1261 | - psi_m( z_mo / ol_m ) & |
---|
| 1262 | + psi_m( surf%z0(m) / & |
---|
| 1263 | ol_m ) & |
---|
| 1264 | )**2 |
---|
[1691] | 1265 | |
---|
| 1266 | ! |
---|
[2232] | 1267 | !-- Calculate df/dL |
---|
| 1268 | f_d_ol = ( - ( z_mo / ol_u ) * ( LOG( z_mo / & |
---|
| 1269 | surf%z0h(m) ) & |
---|
| 1270 | - psi_h( z_mo / ol_u ) & |
---|
| 1271 | + psi_h( surf%z0h(m) / ol_u ) & |
---|
| 1272 | ) & |
---|
| 1273 | / ( LOG( z_mo / surf%z0(m) ) & |
---|
| 1274 | - psi_m( z_mo / ol_u ) & |
---|
| 1275 | + psi_m( surf%z0(m) / ol_u ) & |
---|
| 1276 | )**2 & |
---|
| 1277 | + ( z_mo / ol_l ) * ( LOG( z_mo / surf%z0h(m) ) & |
---|
| 1278 | - psi_h( z_mo / ol_l ) & |
---|
| 1279 | + psi_h( surf%z0h(m) / ol_l ) & |
---|
| 1280 | ) & |
---|
| 1281 | / ( LOG( z_mo / surf%z0(m) ) & |
---|
| 1282 | - psi_m( z_mo / ol_l ) & |
---|
| 1283 | + psi_m( surf%z0(m) / ol_l ) & |
---|
| 1284 | )**2 & |
---|
| 1285 | ) / ( ol_u - ol_l ) |
---|
| 1286 | ELSE |
---|
[1691] | 1287 | ! |
---|
[2232] | 1288 | !-- Calculate f = Ri - 1 /[...]^3 = 0 |
---|
| 1289 | f = surf%rib(m) - ( z_mo / ol_m ) / & |
---|
| 1290 | ( LOG( z_mo / surf%z0(m) ) & |
---|
| 1291 | - psi_m( z_mo / ol_m ) & |
---|
| 1292 | + psi_m( surf%z0(m) / ol_m ) & |
---|
| 1293 | )**3 |
---|
[1691] | 1294 | |
---|
| 1295 | ! |
---|
[2232] | 1296 | !-- Calculate df/dL |
---|
| 1297 | f_d_ol = ( - ( z_mo / ol_u ) / ( LOG( z_mo / & |
---|
| 1298 | surf%z0(m) ) & |
---|
| 1299 | - psi_m( z_mo / ol_u ) & |
---|
| 1300 | + psi_m( surf%z0(m) / ol_u ) & |
---|
| 1301 | )**3 & |
---|
| 1302 | + ( z_mo / ol_l ) / ( LOG( z_mo / surf%z0(m) ) & |
---|
| 1303 | - psi_m( z_mo / ol_l ) & |
---|
| 1304 | + psi_m( surf%z0(m) / ol_l ) & |
---|
| 1305 | )**3 & |
---|
| 1306 | ) / ( ol_u - ol_l ) |
---|
| 1307 | ENDIF |
---|
[1691] | 1308 | ! |
---|
[2232] | 1309 | !-- Calculate new L |
---|
| 1310 | surf%ol(m) = ol_m - f / f_d_ol |
---|
[1691] | 1311 | |
---|
| 1312 | ! |
---|
[2232] | 1313 | !-- Ensure that the bulk Richardson number and the Obukhov |
---|
| 1314 | !-- length have the same sign and ensure convergence. |
---|
| 1315 | IF ( surf%ol(m) * ol_m < 0.0_wp ) surf%ol(m) = ol_m * 0.5_wp |
---|
[1691] | 1316 | ! |
---|
[2232] | 1317 | !-- If unrealistic value occurs, set L to the maximum |
---|
| 1318 | !-- value that is allowed |
---|
| 1319 | IF ( ABS( surf%ol(m) ) > ol_max ) THEN |
---|
| 1320 | surf%ol(m) = ol_max |
---|
| 1321 | EXIT |
---|
| 1322 | ENDIF |
---|
[1691] | 1323 | ! |
---|
[2232] | 1324 | !-- Check for convergence |
---|
| 1325 | IF ( ABS( ( surf%ol(m) - ol_m ) / & |
---|
| 1326 | surf%ol(m) ) < 1.0E-4_wp ) THEN |
---|
| 1327 | EXIT |
---|
| 1328 | ELSE |
---|
| 1329 | CYCLE |
---|
| 1330 | ENDIF |
---|
[1691] | 1331 | |
---|
| 1332 | ENDDO |
---|
| 1333 | ENDDO |
---|
| 1334 | |
---|
| 1335 | ELSEIF ( TRIM( most_method ) == 'lookup' ) THEN |
---|
| 1336 | |
---|
[2281] | 1337 | !$OMP PARALLEL DO PRIVATE( i, j, z_mo, li ) FIRSTPRIVATE( li_bnd ) LASTPRIVATE( li_bnd ) |
---|
[2232] | 1338 | DO m = 1, surf%ns |
---|
[1691] | 1339 | |
---|
[2232] | 1340 | i = surf%i(m) |
---|
| 1341 | j = surf%j(m) |
---|
[1691] | 1342 | ! |
---|
[2232] | 1343 | !-- If the bulk Richardson number is outside the range of the lookup |
---|
| 1344 | !-- table, set it to the exceeding threshold value |
---|
| 1345 | IF ( surf%rib(m) < rib_min ) surf%rib(m) = rib_min |
---|
| 1346 | IF ( surf%rib(m) > rib_max ) surf%rib(m) = rib_max |
---|
[1691] | 1347 | |
---|
| 1348 | ! |
---|
[2232] | 1349 | !-- Find the correct index bounds for linear interpolation. As the |
---|
| 1350 | !-- Richardson number will not differ very much from time step to |
---|
| 1351 | !-- time step , use the index from the last step and search in the |
---|
| 1352 | !-- correct direction |
---|
| 1353 | li = li_bnd |
---|
[2321] | 1354 | IF ( rib_tab(li) - surf%rib(m) > 0.0_wp ) THEN |
---|
| 1355 | DO WHILE ( rib_tab(li-1) - surf%rib(m) > 0.0_wp .AND. li > 0 ) |
---|
[2232] | 1356 | li = li-1 |
---|
| 1357 | ENDDO |
---|
| 1358 | ELSE |
---|
| 1359 | DO WHILE ( rib_tab(li) - surf%rib(m) < 0.0_wp & |
---|
| 1360 | .AND. li < num_steps-1 ) |
---|
| 1361 | li = li+1 |
---|
| 1362 | ENDDO |
---|
| 1363 | ENDIF |
---|
| 1364 | li_bnd = li |
---|
[1691] | 1365 | |
---|
| 1366 | ! |
---|
[2232] | 1367 | !-- Linear interpolation to find the correct value of z/L |
---|
| 1368 | surf%ol(m) = ( ol_tab(li-1) + ( ol_tab(li) - ol_tab(li-1) ) & |
---|
| 1369 | / ( rib_tab(li) - rib_tab(li-1) ) & |
---|
| 1370 | * ( surf%rib(m) - rib_tab(li-1) ) ) |
---|
[1691] | 1371 | |
---|
| 1372 | ENDDO |
---|
| 1373 | |
---|
| 1374 | ELSEIF ( TRIM( most_method ) == 'circular' ) THEN |
---|
| 1375 | |
---|
[2232] | 1376 | IF ( .NOT. humidity ) THEN |
---|
| 1377 | !$OMP PARALLEL DO PRIVATE( i, j, k, z_mo ) |
---|
| 1378 | DO m = 1, surf%ns |
---|
[1691] | 1379 | |
---|
[2232] | 1380 | i = surf%i(m) |
---|
| 1381 | j = surf%j(m) |
---|
| 1382 | k = surf%k(m) |
---|
[1691] | 1383 | |
---|
[2232] | 1384 | z_mo = surf%z_mo(m) |
---|
[1691] | 1385 | |
---|
[2232] | 1386 | surf%ol(m) = ( pt(k,j,i) * surf%us(m)**2 ) / & |
---|
| 1387 | ( kappa * g * & |
---|
| 1388 | surf%ts(m) + 1E-30_wp ) |
---|
[1691] | 1389 | ! |
---|
| 1390 | !-- Limit the value range of the Obukhov length. |
---|
[2232] | 1391 | !-- This is necessary for very small velocities (u,v --> 1), because |
---|
[1691] | 1392 | !-- the absolute value of ol can then become very small, which in |
---|
| 1393 | !-- consequence would result in very large shear stresses and very |
---|
| 1394 | !-- small momentum fluxes (both are generally unrealistic). |
---|
[2232] | 1395 | IF ( ( z_mo / ( surf%ol(m) + 1E-30_wp ) ) < zeta_min ) & |
---|
| 1396 | surf%ol(m) = z_mo / zeta_min |
---|
| 1397 | IF ( ( z_mo / ( surf%ol(m) + 1E-30_wp ) ) > zeta_max ) & |
---|
| 1398 | surf%ol(m) = z_mo / zeta_max |
---|
| 1399 | |
---|
[1691] | 1400 | ENDDO |
---|
[2547] | 1401 | ELSEIF ( cloud_physics .OR. cloud_droplets ) THEN |
---|
[2232] | 1402 | !$OMP PARALLEL DO PRIVATE( i, j, k, z_mo ) |
---|
| 1403 | DO m = 1, surf%ns |
---|
[1691] | 1404 | |
---|
[2232] | 1405 | i = surf%i(m) |
---|
| 1406 | j = surf%j(m) |
---|
| 1407 | k = surf%k(m) |
---|
[1691] | 1408 | |
---|
[2232] | 1409 | z_mo = surf%z_mo(m) |
---|
| 1410 | |
---|
| 1411 | |
---|
| 1412 | surf%ol(m) = ( vpt(k,j,i) * surf%us(m)**2 ) / & |
---|
| 1413 | ( kappa * g * ( surf%ts(m) + & |
---|
| 1414 | 0.61_wp * surf%pt1(m) * surf%us(m) & |
---|
| 1415 | + 0.61_wp * surf%qv1(m) * surf%ts(m) - & |
---|
| 1416 | surf%ts(m) * ql(k,j,i) ) + 1E-30_wp ) |
---|
[1691] | 1417 | ! |
---|
[2232] | 1418 | !-- Limit the value range of the Obukhov length. |
---|
| 1419 | !-- This is necessary for very small velocities (u,v --> 1), because |
---|
| 1420 | !-- the absolute value of ol can then become very small, which in |
---|
| 1421 | !-- consequence would result in very large shear stresses and very |
---|
| 1422 | !-- small momentum fluxes (both are generally unrealistic). |
---|
| 1423 | IF ( ( z_mo / ( surf%ol(m) + 1E-30_wp ) ) < zeta_min ) & |
---|
| 1424 | surf%ol(m) = z_mo / zeta_min |
---|
| 1425 | IF ( ( z_mo / ( surf%ol(m) + 1E-30_wp ) ) > zeta_max ) & |
---|
| 1426 | surf%ol(m) = z_mo / zeta_max |
---|
[1691] | 1427 | |
---|
[2232] | 1428 | ENDDO |
---|
| 1429 | ELSE |
---|
| 1430 | |
---|
| 1431 | !$OMP PARALLEL DO PRIVATE( i, j, k, z_mo ) |
---|
| 1432 | DO m = 1, surf%ns |
---|
| 1433 | |
---|
| 1434 | i = surf%i(m) |
---|
| 1435 | j = surf%j(m) |
---|
| 1436 | k = surf%k(m) |
---|
| 1437 | |
---|
| 1438 | z_mo = surf%z_mo(m) |
---|
| 1439 | |
---|
| 1440 | surf%ol(m) = ( vpt(k,j,i) * surf%us(m)**2 ) / & |
---|
| 1441 | ( kappa * g * ( surf%ts(m) + 0.61_wp * pt(k,j,i) * & |
---|
| 1442 | surf%qs(m) + 0.61_wp * q(k,j,i) * & |
---|
| 1443 | surf%ts(m) ) + 1E-30_wp ) |
---|
| 1444 | |
---|
| 1445 | ! |
---|
| 1446 | !-- Limit the value range of the Obukhov length. |
---|
| 1447 | !-- This is necessary for very small velocities (u,v --> 1), because |
---|
| 1448 | !-- the absolute value of ol can then become very small, which in |
---|
| 1449 | !-- consequence would result in very large shear stresses and very |
---|
| 1450 | !-- small momentum fluxes (both are generally unrealistic). |
---|
| 1451 | IF ( ( z_mo / ( surf%ol(m) + 1E-30_wp ) ) < zeta_min ) & |
---|
| 1452 | surf%ol(m) = z_mo / zeta_min |
---|
| 1453 | IF ( ( z_mo / ( surf%ol(m) + 1E-30_wp ) ) > zeta_max ) & |
---|
| 1454 | surf%ol(m) = z_mo / zeta_max |
---|
| 1455 | |
---|
| 1456 | ENDDO |
---|
| 1457 | |
---|
| 1458 | ENDIF |
---|
| 1459 | |
---|
| 1460 | ENDIF |
---|
| 1461 | |
---|
[1691] | 1462 | END SUBROUTINE calc_ol |
---|
| 1463 | |
---|
| 1464 | ! |
---|
| 1465 | !-- Calculate friction velocity u* |
---|
| 1466 | SUBROUTINE calc_us |
---|
| 1467 | |
---|
| 1468 | IMPLICIT NONE |
---|
| 1469 | |
---|
[2232] | 1470 | INTEGER(iwp) :: m !< loop variable over all horizontal surf elements |
---|
[1691] | 1471 | |
---|
[2232] | 1472 | ! |
---|
| 1473 | !-- Compute u* at horizontal surfaces at the scalars' grid points |
---|
| 1474 | IF ( .NOT. surf_vertical ) THEN |
---|
| 1475 | ! |
---|
| 1476 | !-- Compute u* at upward-facing surfaces |
---|
| 1477 | IF ( .NOT. downward ) THEN |
---|
[2281] | 1478 | !$OMP PARALLEL DO PRIVATE( z_mo ) |
---|
[2232] | 1479 | DO m = 1, surf%ns |
---|
[1691] | 1480 | |
---|
[2232] | 1481 | z_mo = surf%z_mo(m) |
---|
[1691] | 1482 | ! |
---|
[2232] | 1483 | !-- Compute u* at the scalars' grid points |
---|
| 1484 | surf%us(m) = kappa * surf%uvw_abs(m) / & |
---|
| 1485 | ( LOG( z_mo / surf%z0(m) ) & |
---|
| 1486 | - psi_m( z_mo / surf%ol(m) ) & |
---|
| 1487 | + psi_m( surf%z0(m) / surf%ol(m) ) ) |
---|
| 1488 | |
---|
| 1489 | ENDDO |
---|
| 1490 | ! |
---|
| 1491 | !-- Compute u* at downward-facing surfaces. This case, do not consider |
---|
| 1492 | !-- any stability. |
---|
| 1493 | ELSE |
---|
[2281] | 1494 | !$OMP PARALLEL DO PRIVATE( z_mo ) |
---|
[2232] | 1495 | DO m = 1, surf%ns |
---|
| 1496 | |
---|
| 1497 | z_mo = surf%z_mo(m) |
---|
| 1498 | ! |
---|
| 1499 | !-- Compute u* at the scalars' grid points |
---|
| 1500 | surf%us(m) = kappa * surf%uvw_abs(m) / LOG( z_mo / surf%z0(m) ) |
---|
| 1501 | |
---|
| 1502 | ENDDO |
---|
| 1503 | ENDIF |
---|
| 1504 | ! |
---|
| 1505 | !-- Compute u* at vertical surfaces at the u/v/v grid, respectively. |
---|
| 1506 | !-- No stability is considered in this case. |
---|
| 1507 | ELSE |
---|
| 1508 | !$OMP PARALLEL DO PRIVATE( z_mo ) |
---|
| 1509 | DO m = 1, surf%ns |
---|
| 1510 | z_mo = surf%z_mo(m) |
---|
| 1511 | |
---|
| 1512 | surf%us(m) = kappa * surf%uvw_abs(m) / LOG( z_mo / surf%z0(m) ) |
---|
[1691] | 1513 | ENDDO |
---|
[2232] | 1514 | ENDIF |
---|
[1691] | 1515 | |
---|
| 1516 | END SUBROUTINE calc_us |
---|
| 1517 | |
---|
| 1518 | ! |
---|
| 1519 | !-- Calculate potential temperature and specific humidity at first grid level |
---|
[2232] | 1520 | !-- ( only for upward-facing surfs ) |
---|
[1691] | 1521 | SUBROUTINE calc_pt_q |
---|
| 1522 | |
---|
| 1523 | IMPLICIT NONE |
---|
| 1524 | |
---|
[2232] | 1525 | INTEGER(iwp) :: m !< loop variable over all horizontal surf elements |
---|
| 1526 | |
---|
| 1527 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
| 1528 | DO m = 1, surf%ns |
---|
| 1529 | |
---|
| 1530 | i = surf%i(m) |
---|
| 1531 | j = surf%j(m) |
---|
| 1532 | k = surf%k(m) |
---|
| 1533 | |
---|
[2547] | 1534 | IF ( cloud_physics ) THEN |
---|
| 1535 | surf%pt1(m) = pt(k,j,i) + l_d_cp * pt_d_t(k) * ql(k,j,i) |
---|
| 1536 | surf%qv1(m) = q(k,j,i) - ql(k,j,i) |
---|
| 1537 | ELSEIF( cloud_droplets ) THEN |
---|
| 1538 | surf%pt1(m) = pt(k,j,i) + l_d_cp * pt_d_t(k) * ql(k,j,i) |
---|
| 1539 | surf%qv1(m) = q(k,j,i) |
---|
| 1540 | ENDIF |
---|
[2232] | 1541 | |
---|
[1691] | 1542 | ENDDO |
---|
| 1543 | |
---|
| 1544 | END SUBROUTINE calc_pt_q |
---|
| 1545 | |
---|
| 1546 | ! |
---|
[2292] | 1547 | !-- Calculate the other MOST scaling parameters theta*, q*, (qc*, qr*, nc*, nr*) |
---|
[1691] | 1548 | SUBROUTINE calc_scaling_parameters |
---|
| 1549 | |
---|
| 1550 | IMPLICIT NONE |
---|
| 1551 | |
---|
[2232] | 1552 | |
---|
| 1553 | INTEGER(iwp) :: m !< loop variable over all horizontal surf elements |
---|
| 1554 | |
---|
[1691] | 1555 | ! |
---|
[2232] | 1556 | !-- Compute theta* at horizontal surfaces |
---|
| 1557 | IF ( constant_heatflux .AND. .NOT. surf_vertical ) THEN |
---|
[1691] | 1558 | ! |
---|
| 1559 | !-- For a given heat flux in the surface layer: |
---|
[2232] | 1560 | |
---|
| 1561 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
| 1562 | DO m = 1, surf%ns |
---|
| 1563 | |
---|
| 1564 | i = surf%i(m) |
---|
| 1565 | j = surf%j(m) |
---|
| 1566 | k = surf%k(m) |
---|
| 1567 | |
---|
| 1568 | surf%ts(m) = -surf%shf(m) * drho_air_zw(k-1) / & |
---|
| 1569 | ( surf%us(m) + 1E-30_wp ) |
---|
| 1570 | |
---|
[1691] | 1571 | ! |
---|
[2232] | 1572 | !-- ts must be limited, because otherwise overflow may occur in case |
---|
| 1573 | !-- of us=0 when computing ol further below |
---|
| 1574 | IF ( surf%ts(m) < -1.05E5_wp ) surf%ts(m) = -1.0E5_wp |
---|
| 1575 | IF ( surf%ts(m) > 1.0E5_wp ) surf%ts(m) = 1.0E5_wp |
---|
| 1576 | |
---|
[1691] | 1577 | ENDDO |
---|
| 1578 | |
---|
[2232] | 1579 | ELSEIF ( .NOT. surf_vertical ) THEN |
---|
[1691] | 1580 | ! |
---|
| 1581 | !-- For a given surface temperature: |
---|
[1788] | 1582 | IF ( large_scale_forcing .AND. lsf_surf ) THEN |
---|
[2232] | 1583 | |
---|
| 1584 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
| 1585 | DO m = 1, surf%ns |
---|
| 1586 | i = surf%i(m) |
---|
| 1587 | j = surf%j(m) |
---|
| 1588 | k = surf%k(m) |
---|
| 1589 | |
---|
| 1590 | pt(k-1,j,i) = pt_surface |
---|
[1691] | 1591 | ENDDO |
---|
| 1592 | ENDIF |
---|
| 1593 | |
---|
[2547] | 1594 | IF ( cloud_physics .OR. cloud_droplets ) THEN |
---|
[2232] | 1595 | !$OMP PARALLEL DO PRIVATE( i, j, k, z_mo ) |
---|
| 1596 | DO m = 1, surf%ns |
---|
[1691] | 1597 | |
---|
[2232] | 1598 | i = surf%i(m) |
---|
| 1599 | j = surf%j(m) |
---|
| 1600 | k = surf%k(m) |
---|
[1691] | 1601 | |
---|
[2232] | 1602 | z_mo = surf%z_mo(m) |
---|
[1691] | 1603 | |
---|
[2232] | 1604 | surf%ts(m) = kappa * ( surf%pt1(m) - pt(k-1,j,i) ) & |
---|
| 1605 | / ( LOG( z_mo / surf%z0h(m) ) & |
---|
| 1606 | - psi_h( z_mo / surf%ol(m) ) & |
---|
| 1607 | + psi_h( surf%z0h(m) / surf%ol(m) ) ) |
---|
| 1608 | |
---|
[1691] | 1609 | ENDDO |
---|
[2232] | 1610 | ELSE |
---|
| 1611 | !$OMP PARALLEL DO PRIVATE( i, j, k, z_mo ) |
---|
| 1612 | DO m = 1, surf%ns |
---|
| 1613 | |
---|
| 1614 | i = surf%i(m) |
---|
| 1615 | j = surf%j(m) |
---|
| 1616 | k = surf%k(m) |
---|
| 1617 | |
---|
| 1618 | z_mo = surf%z_mo(m) |
---|
| 1619 | |
---|
| 1620 | surf%ts(m) = kappa * ( pt(k,j,i) - pt(k-1,j,i) ) & |
---|
| 1621 | / ( LOG( z_mo / surf%z0h(m) ) & |
---|
| 1622 | - psi_h( z_mo / surf%ol(m) ) & |
---|
| 1623 | + psi_h( surf%z0h(m) / surf%ol(m) ) ) |
---|
| 1624 | ENDDO |
---|
| 1625 | ENDIF |
---|
| 1626 | ENDIF |
---|
| 1627 | ! |
---|
| 1628 | !-- Compute theta* at vertical surfaces. This is only required in case of |
---|
| 1629 | !-- land-surface model, in order to compute aerodynamical resistance. |
---|
| 1630 | IF ( surf_vertical ) THEN |
---|
[2281] | 1631 | !$OMP PARALLEL DO PRIVATE( i, j ) |
---|
[2232] | 1632 | DO m = 1, surf%ns |
---|
| 1633 | |
---|
| 1634 | i = surf%i(m) |
---|
| 1635 | j = surf%j(m) |
---|
| 1636 | surf%ts(m) = -surf%shf(m) / ( surf%us(m) + 1E-30_wp ) |
---|
| 1637 | ! |
---|
| 1638 | !-- ts must be limited, because otherwise overflow may occur in case |
---|
| 1639 | !-- of us=0 when computing ol further below |
---|
| 1640 | IF ( surf%ts(m) < -1.05E5_wp ) surf%ts(m) = -1.0E5_wp |
---|
| 1641 | IF ( surf%ts(m) > 1.0E5_wp ) surf%ts(m) = 1.0E5_wp |
---|
| 1642 | |
---|
[1691] | 1643 | ENDDO |
---|
| 1644 | ENDIF |
---|
| 1645 | |
---|
| 1646 | ! |
---|
[2232] | 1647 | !-- If required compute q* at horizontal surfaces |
---|
[1960] | 1648 | IF ( humidity ) THEN |
---|
[2232] | 1649 | IF ( constant_waterflux .AND. .NOT. surf_vertical ) THEN |
---|
[1691] | 1650 | ! |
---|
[1788] | 1651 | !-- For a given water flux in the surface layer |
---|
[2232] | 1652 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
| 1653 | DO m = 1, surf%ns |
---|
| 1654 | |
---|
| 1655 | i = surf%i(m) |
---|
| 1656 | j = surf%j(m) |
---|
| 1657 | k = surf%k(m) |
---|
| 1658 | surf%qs(m) = -surf%qsws(m) * drho_air_zw(k-1) / & |
---|
| 1659 | ( surf%us(m) + 1E-30_wp ) |
---|
| 1660 | |
---|
[1691] | 1661 | ENDDO |
---|
| 1662 | |
---|
[2232] | 1663 | ELSEIF ( .NOT. surf_vertical ) THEN |
---|
[1788] | 1664 | coupled_run = ( coupling_mode == 'atmosphere_to_ocean' .AND. & |
---|
[1691] | 1665 | run_coupled ) |
---|
| 1666 | |
---|
[1788] | 1667 | IF ( large_scale_forcing .AND. lsf_surf ) THEN |
---|
[2232] | 1668 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
| 1669 | DO m = 1, surf%ns |
---|
| 1670 | |
---|
| 1671 | i = surf%i(m) |
---|
| 1672 | j = surf%j(m) |
---|
| 1673 | k = surf%k(m) |
---|
| 1674 | q(k-1,j,i) = q_surface |
---|
| 1675 | |
---|
[1691] | 1676 | ENDDO |
---|
| 1677 | ENDIF |
---|
| 1678 | |
---|
| 1679 | ! |
---|
[2232] | 1680 | !-- Assume saturation for atmosphere coupled to ocean (but not |
---|
| 1681 | !-- in case of precursor runs) |
---|
| 1682 | IF ( coupled_run ) THEN |
---|
| 1683 | !$OMP PARALLEL DO PRIVATE( i, j, k, e_s ) |
---|
| 1684 | DO m = 1, surf%ns |
---|
| 1685 | i = surf%i(m) |
---|
| 1686 | j = surf%j(m) |
---|
| 1687 | k = surf%k(m) |
---|
| 1688 | e_s = 6.1_wp * & |
---|
| 1689 | EXP( 0.07_wp * ( MIN(pt(k-1,j,i),pt(k,j,i)) & |
---|
[1691] | 1690 | - 273.15_wp ) ) |
---|
[2232] | 1691 | q(k-1,j,i) = 0.622_wp * e_s / ( surface_pressure - e_s ) |
---|
| 1692 | ENDDO |
---|
| 1693 | ENDIF |
---|
[1691] | 1694 | |
---|
[2547] | 1695 | IF ( cloud_physics .OR. cloud_droplets ) THEN |
---|
[2232] | 1696 | !$OMP PARALLEL DO PRIVATE( i, j, k, z_mo ) |
---|
| 1697 | DO m = 1, surf%ns |
---|
[1691] | 1698 | |
---|
[2232] | 1699 | i = surf%i(m) |
---|
| 1700 | j = surf%j(m) |
---|
| 1701 | k = surf%k(m) |
---|
| 1702 | |
---|
| 1703 | z_mo = surf%z_mo(m) |
---|
[1691] | 1704 | |
---|
[2232] | 1705 | surf%qs(m) = kappa * ( surf%qv1(m) - q(k-1,j,i) ) & |
---|
| 1706 | / ( LOG( z_mo / surf%z0q(m) ) & |
---|
| 1707 | - psi_h( z_mo / surf%ol(m) ) & |
---|
| 1708 | + psi_h( surf%z0q(m) / & |
---|
| 1709 | surf%ol(m) ) ) |
---|
[1691] | 1710 | ENDDO |
---|
[2232] | 1711 | ELSE |
---|
| 1712 | !$OMP PARALLEL DO PRIVATE( i, j, k, z_mo ) |
---|
| 1713 | DO m = 1, surf%ns |
---|
| 1714 | |
---|
| 1715 | i = surf%i(m) |
---|
| 1716 | j = surf%j(m) |
---|
| 1717 | k = surf%k(m) |
---|
| 1718 | |
---|
| 1719 | z_mo = surf%z_mo(m) |
---|
| 1720 | |
---|
| 1721 | surf%qs(m) = kappa * ( q(k,j,i) - q(k-1,j,i) ) & |
---|
| 1722 | / ( LOG( z_mo / surf%z0q(m) ) & |
---|
| 1723 | - psi_h( z_mo / surf%ol(m) ) & |
---|
| 1724 | + psi_h( surf%z0q(m) / & |
---|
| 1725 | surf%ol(m) ) ) |
---|
| 1726 | ENDDO |
---|
| 1727 | ENDIF |
---|
| 1728 | ENDIF |
---|
| 1729 | ! |
---|
| 1730 | !-- Compute q* at vertical surfaces |
---|
| 1731 | IF ( surf_vertical ) THEN |
---|
[2281] | 1732 | !$OMP PARALLEL DO PRIVATE( i, j ) |
---|
[2232] | 1733 | DO m = 1, surf%ns |
---|
| 1734 | |
---|
| 1735 | i = surf%i(m) |
---|
| 1736 | j = surf%j(m) |
---|
| 1737 | surf%qs(m) = -surf%qsws(m) / ( surf%us(m) + 1E-30_wp ) |
---|
| 1738 | |
---|
[1691] | 1739 | ENDDO |
---|
| 1740 | ENDIF |
---|
| 1741 | ENDIF |
---|
[1960] | 1742 | |
---|
| 1743 | ! |
---|
| 1744 | !-- If required compute s* |
---|
| 1745 | IF ( passive_scalar ) THEN |
---|
| 1746 | ! |
---|
[2232] | 1747 | !-- At horizontal surfaces |
---|
| 1748 | IF ( constant_scalarflux .AND. .NOT. surf_vertical ) THEN |
---|
| 1749 | ! |
---|
| 1750 | !-- For a given scalar flux in the surface layer |
---|
[2281] | 1751 | !$OMP PARALLEL DO PRIVATE( i, j ) |
---|
[2232] | 1752 | DO m = 1, surf%ns |
---|
| 1753 | i = surf%i(m) |
---|
| 1754 | j = surf%j(m) |
---|
| 1755 | surf%ss(m) = -surf%ssws(m) / ( surf%us(m) + 1E-30_wp ) |
---|
[1960] | 1756 | ENDDO |
---|
| 1757 | ENDIF |
---|
[2232] | 1758 | ! |
---|
| 1759 | !-- At vertical surfaces |
---|
| 1760 | IF ( surf_vertical ) THEN |
---|
[2281] | 1761 | !$OMP PARALLEL DO PRIVATE( i, j ) |
---|
[2232] | 1762 | DO m = 1, surf%ns |
---|
| 1763 | i = surf%i(m) |
---|
| 1764 | j = surf%j(m) |
---|
| 1765 | surf%ss(m) = -surf%ssws(m) / ( surf%us(m) + 1E-30_wp ) |
---|
| 1766 | ENDDO |
---|
| 1767 | ENDIF |
---|
[1960] | 1768 | ENDIF |
---|
[1691] | 1769 | |
---|
[2292] | 1770 | ! |
---|
| 1771 | !-- If required compute qc* and nc* |
---|
| 1772 | IF ( cloud_physics .AND. microphysics_morrison .AND. & |
---|
| 1773 | .NOT. surf_vertical ) THEN |
---|
| 1774 | !$OMP PARALLEL DO PRIVATE( i, j, k, z_mo ) |
---|
| 1775 | DO m = 1, surf%ns |
---|
[1691] | 1776 | |
---|
[2292] | 1777 | i = surf%i(m) |
---|
| 1778 | j = surf%j(m) |
---|
| 1779 | k = surf%k(m) |
---|
| 1780 | |
---|
| 1781 | z_mo = surf%z_mo(m) |
---|
| 1782 | |
---|
| 1783 | surf%qcs(m) = kappa * ( qc(k,j,i) - qc(k-1,j,i) ) & |
---|
| 1784 | / ( LOG( z_mo / surf%z0q(m) ) & |
---|
| 1785 | - psi_h( z_mo / surf%ol(m) ) & |
---|
| 1786 | + psi_h( surf%z0q(m) / surf%ol(m) ) ) |
---|
| 1787 | |
---|
| 1788 | surf%ncs(m) = kappa * ( nc(k,j,i) - nc(k-1,j,i) ) & |
---|
| 1789 | / ( LOG( z_mo / surf%z0q(m) ) & |
---|
| 1790 | - psi_h( z_mo / surf%ol(m) ) & |
---|
| 1791 | + psi_h( surf%z0q(m) / surf%ol(m) ) ) |
---|
| 1792 | ENDDO |
---|
| 1793 | |
---|
| 1794 | ENDIF |
---|
| 1795 | |
---|
[1691] | 1796 | ! |
---|
| 1797 | !-- If required compute qr* and nr* |
---|
[2232] | 1798 | IF ( cloud_physics .AND. microphysics_seifert .AND. & |
---|
| 1799 | .NOT. surf_vertical ) THEN |
---|
| 1800 | !$OMP PARALLEL DO PRIVATE( i, j, k, z_mo ) |
---|
| 1801 | DO m = 1, surf%ns |
---|
[1691] | 1802 | |
---|
[2232] | 1803 | i = surf%i(m) |
---|
| 1804 | j = surf%j(m) |
---|
| 1805 | k = surf%k(m) |
---|
[1691] | 1806 | |
---|
[2232] | 1807 | z_mo = surf%z_mo(m) |
---|
[1691] | 1808 | |
---|
[2232] | 1809 | surf%qrs(m) = kappa * ( qr(k,j,i) - qr(k-1,j,i) ) & |
---|
| 1810 | / ( LOG( z_mo / surf%z0q(m) ) & |
---|
| 1811 | - psi_h( z_mo / surf%ol(m) ) & |
---|
| 1812 | + psi_h( surf%z0q(m) / surf%ol(m) ) ) |
---|
[1691] | 1813 | |
---|
[2232] | 1814 | surf%nrs(m) = kappa * ( nr(k,j,i) - nr(k-1,j,i) ) & |
---|
| 1815 | / ( LOG( z_mo / surf%z0q(m) ) & |
---|
| 1816 | - psi_h( z_mo / surf%ol(m) ) & |
---|
| 1817 | + psi_h( surf%z0q(m) / surf%ol(m) ) ) |
---|
[1691] | 1818 | ENDDO |
---|
| 1819 | |
---|
| 1820 | ENDIF |
---|
| 1821 | |
---|
| 1822 | END SUBROUTINE calc_scaling_parameters |
---|
| 1823 | |
---|
| 1824 | |
---|
| 1825 | |
---|
| 1826 | ! |
---|
[2292] | 1827 | !-- Calculate surface fluxes usws, vsws, shf, qsws, (qcsws, qrsws, ncsws, nrsws) |
---|
[1691] | 1828 | SUBROUTINE calc_surface_fluxes |
---|
| 1829 | |
---|
| 1830 | IMPLICIT NONE |
---|
| 1831 | |
---|
[2232] | 1832 | INTEGER(iwp) :: m !< loop variable over all horizontal surf elements |
---|
[1691] | 1833 | |
---|
[2232] | 1834 | REAL(wp) :: dum !< dummy to precalculate logarithm |
---|
| 1835 | REAL(wp) :: flag_u !< flag indicating u-grid, used for calculation of horizontal momentum fluxes at vertical surfaces |
---|
| 1836 | REAL(wp) :: flag_v !< flag indicating v-grid, used for calculation of horizontal momentum fluxes at vertical surfaces |
---|
| 1837 | REAL(wp), DIMENSION(:), ALLOCATABLE :: u_i !< u-component interpolated onto scalar grid point, required for momentum fluxes at vertical surfaces |
---|
| 1838 | REAL(wp), DIMENSION(:), ALLOCATABLE :: v_i !< v-component interpolated onto scalar grid point, required for momentum fluxes at vertical surfaces |
---|
| 1839 | REAL(wp), DIMENSION(:), ALLOCATABLE :: w_i !< w-component interpolated onto scalar grid point, required for momentum fluxes at vertical surfaces |
---|
[1691] | 1840 | |
---|
| 1841 | ! |
---|
[2232] | 1842 | !-- Calcuate surface fluxes at horizontal walls |
---|
| 1843 | IF ( .NOT. surf_vertical ) THEN |
---|
| 1844 | ! |
---|
| 1845 | !-- Compute u'w' for the total model domain at upward-facing surfaces. |
---|
| 1846 | !-- First compute the corresponding component of u* and square it. |
---|
| 1847 | IF ( .NOT. downward ) THEN |
---|
| 1848 | !$OMP PARALLEL DO PRIVATE( i, j, k, z_mo ) |
---|
| 1849 | DO m = 1, surf%ns |
---|
| 1850 | |
---|
| 1851 | i = surf%i(m) |
---|
| 1852 | j = surf%j(m) |
---|
| 1853 | k = surf%k(m) |
---|
[1691] | 1854 | |
---|
[2232] | 1855 | z_mo = surf%z_mo(m) |
---|
[1691] | 1856 | |
---|
[2232] | 1857 | surf%usws(m) = kappa * ( u(k,j,i) - u(k-1,j,i) ) & |
---|
| 1858 | / ( LOG( z_mo / surf%z0(m) ) & |
---|
| 1859 | - psi_m( z_mo / surf%ol(m) ) & |
---|
| 1860 | + psi_m( surf%z0(m) / surf%ol(m) ) ) |
---|
| 1861 | ! |
---|
| 1862 | !-- Please note, the computation of usws is not fully accurate. Actually |
---|
| 1863 | !-- a further interpolation of us onto the u-grid, where usws is defined, |
---|
| 1864 | !-- is required. However, this is not done as this would require several |
---|
| 1865 | !-- data transfers between 2D-grid and the surf-type. |
---|
| 1866 | !-- The impact of the missing interpolation is negligible as several |
---|
| 1867 | !-- tests had shown. |
---|
| 1868 | !-- Same also for ol. |
---|
| 1869 | surf%usws(m) = -surf%usws(m) * surf%us(m) * rho_air_zw(k-1) |
---|
[1691] | 1870 | |
---|
[2232] | 1871 | ENDDO |
---|
[1691] | 1872 | ! |
---|
[2232] | 1873 | !-- At downward-facing surfaces |
---|
| 1874 | ELSE |
---|
| 1875 | !$OMP PARALLEL DO PRIVATE( i, j, k, z_mo ) |
---|
| 1876 | DO m = 1, surf%ns |
---|
| 1877 | |
---|
| 1878 | i = surf%i(m) |
---|
| 1879 | j = surf%j(m) |
---|
| 1880 | k = surf%k(m) |
---|
[1691] | 1881 | |
---|
[2232] | 1882 | z_mo = surf%z_mo(m) |
---|
| 1883 | |
---|
| 1884 | surf%usws(m) = kappa * u(k,j,i) / LOG( z_mo / surf%z0(m) ) |
---|
[1691] | 1885 | ! |
---|
[2232] | 1886 | !-- To Do: Is the sign correct??? |
---|
| 1887 | surf%usws(m) = surf%usws(m) * surf%us(m) * rho_air_zw(k) |
---|
[1691] | 1888 | |
---|
[2232] | 1889 | ENDDO |
---|
| 1890 | ENDIF |
---|
[1691] | 1891 | |
---|
[2232] | 1892 | ! |
---|
| 1893 | !-- Compute v'w' for the total model domain. |
---|
| 1894 | !-- First compute the corresponding component of u* and square it. |
---|
| 1895 | !-- Upward-facing surfaces |
---|
| 1896 | IF ( .NOT. downward ) THEN |
---|
| 1897 | !$OMP PARALLEL DO PRIVATE( i, j, k, z_mo ) |
---|
| 1898 | DO m = 1, surf%ns |
---|
| 1899 | i = surf%i(m) |
---|
| 1900 | j = surf%j(m) |
---|
| 1901 | k = surf%k(m) |
---|
[1691] | 1902 | |
---|
[2232] | 1903 | z_mo = surf%z_mo(m) |
---|
[1691] | 1904 | |
---|
[2232] | 1905 | surf%vsws(m) = kappa * ( v(k,j,i) - v(k-1,j,i) ) & |
---|
| 1906 | / ( LOG( z_mo / surf%z0(m) ) & |
---|
| 1907 | - psi_m( z_mo / surf%ol(m) ) & |
---|
| 1908 | + psi_m( surf%z0(m) / surf%ol(m) ) ) |
---|
[1691] | 1909 | ! |
---|
[2232] | 1910 | !-- Please note, the computation of vsws is not fully accurate. Actually |
---|
| 1911 | !-- a further interpolation of us onto the v-grid, where vsws is defined, |
---|
| 1912 | !-- is required. However, this is not done as this would require several |
---|
| 1913 | !-- data transfers between 2D-grid and the surf-type. |
---|
| 1914 | !-- The impact of the missing interpolation is negligible as several |
---|
| 1915 | !-- tests had shown. |
---|
| 1916 | !-- Same also for ol. |
---|
| 1917 | surf%vsws(m) = -surf%vsws(m) * surf%us(m) * rho_air_zw(k-1) |
---|
| 1918 | ENDDO |
---|
| 1919 | ! |
---|
| 1920 | !-- Downward-facing surfaces |
---|
| 1921 | ELSE |
---|
| 1922 | !$OMP PARALLEL DO PRIVATE( i, j, k, z_mo ) |
---|
| 1923 | DO m = 1, surf%ns |
---|
| 1924 | i = surf%i(m) |
---|
| 1925 | j = surf%j(m) |
---|
| 1926 | k = surf%k(m) |
---|
[1691] | 1927 | |
---|
[2232] | 1928 | z_mo = surf%z_mo(m) |
---|
| 1929 | |
---|
| 1930 | surf%vsws(m) = kappa * v(k,j,i) / LOG( z_mo / surf%z0(m) ) |
---|
| 1931 | |
---|
| 1932 | surf%vsws(m) = surf%vsws(m) * surf%us(m) * rho_air_zw(k) |
---|
| 1933 | ENDDO |
---|
| 1934 | ENDIF |
---|
[1691] | 1935 | ! |
---|
[2232] | 1936 | !-- Compute the vertical kinematic heat flux |
---|
[2299] | 1937 | IF ( .NOT. constant_heatflux .AND. ( ( time_since_reference_point& |
---|
| 1938 | <= skip_time_do_lsm .AND. simulated_time > 0.0_wp ) .OR. & |
---|
| 1939 | .NOT. land_surface ) .AND. .NOT. urban_surface .AND. & |
---|
| 1940 | .NOT. downward ) THEN |
---|
[2232] | 1941 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
| 1942 | DO m = 1, surf%ns |
---|
| 1943 | i = surf%i(m) |
---|
| 1944 | j = surf%j(m) |
---|
| 1945 | k = surf%k(m) |
---|
| 1946 | surf%shf(m) = -surf%ts(m) * surf%us(m) * rho_air_zw(k-1) |
---|
[1691] | 1947 | ENDDO |
---|
[2232] | 1948 | ENDIF |
---|
| 1949 | ! |
---|
| 1950 | !-- Compute the vertical water flux |
---|
| 1951 | IF ( .NOT. constant_waterflux .AND. humidity .AND. & |
---|
[2299] | 1952 | ( ( time_since_reference_point <= skip_time_do_lsm .AND. & |
---|
| 1953 | simulated_time > 0.0_wp ) .OR. .NOT. land_surface ) .AND. & |
---|
| 1954 | .NOT. downward ) THEN |
---|
[2232] | 1955 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
| 1956 | DO m = 1, surf%ns |
---|
| 1957 | i = surf%i(m) |
---|
| 1958 | j = surf%j(m) |
---|
| 1959 | k = surf%k(m) |
---|
| 1960 | surf%qsws(m) = -surf%qs(m) * surf%us(m) * rho_air_zw(k-1) |
---|
| 1961 | ENDDO |
---|
| 1962 | ENDIF |
---|
| 1963 | ! |
---|
| 1964 | !-- Compute the vertical scalar flux |
---|
| 1965 | IF ( .NOT. constant_scalarflux .AND. passive_scalar .AND. & |
---|
| 1966 | .NOT. downward ) THEN |
---|
[2281] | 1967 | !$OMP PARALLEL DO PRIVATE( i, j ) |
---|
[2232] | 1968 | DO m = 1, surf%ns |
---|
[1691] | 1969 | |
---|
[2232] | 1970 | i = surf%i(m) |
---|
| 1971 | j = surf%j(m) |
---|
| 1972 | surf%ssws(m) = -surf%ss(m) * surf%us(m) |
---|
[1691] | 1973 | |
---|
[2232] | 1974 | ENDDO |
---|
[2292] | 1975 | ENDIF |
---|
[1691] | 1976 | ! |
---|
[2292] | 1977 | !-- Compute (turbulent) fluxes of cloud water content and cloud drop conc. |
---|
| 1978 | IF ( cloud_physics .AND. microphysics_morrison .AND. & |
---|
| 1979 | .NOT. downward) THEN |
---|
| 1980 | !$OMP PARALLEL DO PRIVATE( i, j ) |
---|
| 1981 | DO m = 1, surf%ns |
---|
| 1982 | |
---|
| 1983 | i = surf%i(m) |
---|
| 1984 | j = surf%j(m) |
---|
| 1985 | |
---|
| 1986 | surf%qcsws(m) = -surf%qcs(m) * surf%us(m) |
---|
| 1987 | surf%ncsws(m) = -surf%ncs(m) * surf%us(m) |
---|
| 1988 | ENDDO |
---|
| 1989 | ENDIF |
---|
| 1990 | ! |
---|
[2232] | 1991 | !-- Compute (turbulent) fluxes of rain water content and rain drop conc. |
---|
[2292] | 1992 | IF ( cloud_physics .AND. microphysics_seifert .AND. & |
---|
[2232] | 1993 | .NOT. downward) THEN |
---|
[2281] | 1994 | !$OMP PARALLEL DO PRIVATE( i, j ) |
---|
[2232] | 1995 | DO m = 1, surf%ns |
---|
| 1996 | |
---|
| 1997 | i = surf%i(m) |
---|
| 1998 | j = surf%j(m) |
---|
| 1999 | |
---|
| 2000 | surf%qrsws(m) = -surf%qrs(m) * surf%us(m) |
---|
| 2001 | surf%nrsws(m) = -surf%nrs(m) * surf%us(m) |
---|
[1691] | 2002 | ENDDO |
---|
[2232] | 2003 | ENDIF |
---|
[1691] | 2004 | |
---|
[1960] | 2005 | ! |
---|
[2232] | 2006 | !-- Bottom boundary condition for the TKE. |
---|
| 2007 | IF ( ibc_e_b == 2 ) THEN |
---|
| 2008 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
| 2009 | DO m = 1, surf%ns |
---|
| 2010 | |
---|
| 2011 | i = surf%i(m) |
---|
| 2012 | j = surf%j(m) |
---|
| 2013 | k = surf%k(m) |
---|
| 2014 | |
---|
| 2015 | e(k,j,i) = ( surf%us(m) / 0.1_wp )**2 |
---|
| 2016 | ! |
---|
| 2017 | !-- As a test: cm = 0.4 |
---|
| 2018 | ! e(k,j,i) = ( us(j,i) / 0.4_wp )**2 |
---|
| 2019 | e(k-1,j,i) = e(k,j,i) |
---|
| 2020 | |
---|
[1960] | 2021 | ENDDO |
---|
[2232] | 2022 | ENDIF |
---|
| 2023 | ! |
---|
| 2024 | !-- Calcuate surface fluxes at vertical surfaces. No stability is considered. |
---|
| 2025 | ELSE |
---|
| 2026 | ! |
---|
| 2027 | !-- Compute usvs l={0,1} and vsus l={2,3} |
---|
| 2028 | IF ( mom_uv ) THEN |
---|
| 2029 | ! |
---|
| 2030 | !-- Generalize computation by introducing flags. At north- and south- |
---|
| 2031 | !-- facing surfaces u-component is used, at east- and west-facing |
---|
| 2032 | !-- surfaces v-component is used. |
---|
| 2033 | flag_u = MERGE( 1.0_wp, 0.0_wp, l == 0 .OR. l == 1 ) |
---|
| 2034 | flag_v = MERGE( 1.0_wp, 0.0_wp, l == 2 .OR. l == 3 ) |
---|
| 2035 | !$OMP PARALLEL DO PRIVATE( i, j, k, z_mo ) |
---|
| 2036 | DO m = 1, surf%ns |
---|
| 2037 | i = surf%i(m) |
---|
| 2038 | j = surf%j(m) |
---|
| 2039 | k = surf%k(m) |
---|
[1691] | 2040 | |
---|
[2232] | 2041 | z_mo = surf%z_mo(m) |
---|
[1960] | 2042 | |
---|
[2232] | 2043 | surf%mom_flux_uv(m) = kappa * & |
---|
| 2044 | ( flag_u * u(k,j,i) + flag_v * v(k,j,i) ) / & |
---|
| 2045 | LOG( z_mo / surf%z0(m) ) |
---|
| 2046 | |
---|
| 2047 | surf%mom_flux_uv(m) = & |
---|
| 2048 | - surf%mom_flux_uv(m) * surf%us(m) |
---|
| 2049 | ENDDO |
---|
| 2050 | ENDIF |
---|
[1691] | 2051 | ! |
---|
[2232] | 2052 | !-- Compute wsus l={0,1} and wsvs l={2,3} |
---|
| 2053 | IF ( mom_w ) THEN |
---|
| 2054 | !$OMP PARALLEL DO PRIVATE( i, j, k, z_mo ) |
---|
| 2055 | DO m = 1, surf%ns |
---|
| 2056 | i = surf%i(m) |
---|
| 2057 | j = surf%j(m) |
---|
| 2058 | k = surf%k(m) |
---|
| 2059 | |
---|
| 2060 | z_mo = surf%z_mo(m) |
---|
| 2061 | |
---|
| 2062 | surf%mom_flux_w(m) = kappa * w(k,j,i) / LOG( z_mo / surf%z0(m) ) |
---|
| 2063 | |
---|
| 2064 | surf%mom_flux_w(m) = & |
---|
| 2065 | - surf%mom_flux_w(m) * surf%us(m) |
---|
[1691] | 2066 | ENDDO |
---|
[2232] | 2067 | ENDIF |
---|
| 2068 | ! |
---|
| 2069 | !-- Compute momentum fluxes used for subgrid-scale TKE production at |
---|
| 2070 | !-- vertical surfaces. In constrast to the calculated momentum fluxes at |
---|
| 2071 | !-- vertical surfaces before, which are defined on the u/v/w-grid, |
---|
| 2072 | !-- respectively), the TKE fluxes are defined at the scalar grid. |
---|
| 2073 | !-- |
---|
| 2074 | IF ( mom_tke ) THEN |
---|
| 2075 | ! |
---|
| 2076 | !-- Precalculate velocity components at scalar grid point. |
---|
| 2077 | ALLOCATE( u_i(1:surf%ns) ) |
---|
| 2078 | ALLOCATE( v_i(1:surf%ns) ) |
---|
| 2079 | ALLOCATE( w_i(1:surf%ns) ) |
---|
[1691] | 2080 | |
---|
[2232] | 2081 | IF ( l == 0 .OR. l == 1 ) THEN |
---|
| 2082 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
| 2083 | DO m = 1, surf%ns |
---|
| 2084 | i = surf%i(m) |
---|
| 2085 | j = surf%j(m) |
---|
| 2086 | k = surf%k(m) |
---|
| 2087 | |
---|
| 2088 | u_i(m) = 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) |
---|
| 2089 | v_i(m) = 0.0_wp |
---|
| 2090 | w_i(m) = 0.5_wp * ( w(k,j,i) + w(k-1,j,i) ) |
---|
| 2091 | ENDDO |
---|
| 2092 | ELSE |
---|
| 2093 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
| 2094 | DO m = 1, surf%ns |
---|
| 2095 | i = surf%i(m) |
---|
| 2096 | j = surf%j(m) |
---|
| 2097 | k = surf%k(m) |
---|
| 2098 | |
---|
| 2099 | u_i(m) = 0.0_wp |
---|
| 2100 | v_i(m) = 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) |
---|
| 2101 | w_i(m) = 0.5_wp * ( w(k,j,i) + w(k-1,j,i) ) |
---|
| 2102 | ENDDO |
---|
| 2103 | ENDIF |
---|
| 2104 | |
---|
[2281] | 2105 | !$OMP PARALLEL DO PRIVATE( i, j, dum, z_mo ) |
---|
[2232] | 2106 | DO m = 1, surf%ns |
---|
| 2107 | i = surf%i(m) |
---|
| 2108 | j = surf%j(m) |
---|
| 2109 | |
---|
| 2110 | z_mo = surf%z_mo(m) |
---|
| 2111 | |
---|
| 2112 | dum = kappa / LOG( z_mo / surf%z0(m) ) |
---|
[1691] | 2113 | ! |
---|
[2232] | 2114 | !-- usvs (l=0,1) and vsus (l=2,3) |
---|
| 2115 | surf%mom_flux_tke(0,m) = dum * ( u_i(m) + v_i(m) ) |
---|
[1691] | 2116 | ! |
---|
[2232] | 2117 | !-- wsvs (l=0,1) and wsus (l=2,3) |
---|
| 2118 | surf%mom_flux_tke(1,m) = dum * w_i(m) |
---|
| 2119 | |
---|
| 2120 | surf%mom_flux_tke(0:1,m) = & |
---|
| 2121 | - surf%mom_flux_tke(0:1,m) * surf%us(m) |
---|
[1691] | 2122 | ENDDO |
---|
[2232] | 2123 | ! |
---|
| 2124 | !-- Deallocate temporary arrays |
---|
| 2125 | DEALLOCATE( u_i ) |
---|
| 2126 | DEALLOCATE( v_i ) |
---|
| 2127 | DEALLOCATE( w_i ) |
---|
| 2128 | ENDIF |
---|
[1691] | 2129 | ENDIF |
---|
| 2130 | |
---|
| 2131 | END SUBROUTINE calc_surface_fluxes |
---|
| 2132 | |
---|
| 2133 | |
---|
| 2134 | ! |
---|
| 2135 | !-- Integrated stability function for momentum |
---|
| 2136 | FUNCTION psi_m( zeta ) |
---|
| 2137 | |
---|
| 2138 | USE kinds |
---|
| 2139 | |
---|
| 2140 | IMPLICIT NONE |
---|
| 2141 | |
---|
| 2142 | REAL(wp) :: psi_m !< Integrated similarity function result |
---|
| 2143 | REAL(wp) :: zeta !< Stability parameter z/L |
---|
| 2144 | REAL(wp) :: x !< dummy variable |
---|
| 2145 | |
---|
| 2146 | REAL(wp), PARAMETER :: a = 1.0_wp !< constant |
---|
| 2147 | REAL(wp), PARAMETER :: b = 0.66666666666_wp !< constant |
---|
| 2148 | REAL(wp), PARAMETER :: c = 5.0_wp !< constant |
---|
| 2149 | REAL(wp), PARAMETER :: d = 0.35_wp !< constant |
---|
| 2150 | REAL(wp), PARAMETER :: c_d_d = c / d !< constant |
---|
| 2151 | REAL(wp), PARAMETER :: bc_d_d = b * c / d !< constant |
---|
| 2152 | |
---|
| 2153 | |
---|
| 2154 | IF ( zeta < 0.0_wp ) THEN |
---|
[1788] | 2155 | x = SQRT( SQRT( 1.0_wp - 16.0_wp * zeta ) ) |
---|
[1691] | 2156 | psi_m = pi * 0.5_wp - 2.0_wp * ATAN( x ) + LOG( ( 1.0_wp + x )**2 & |
---|
| 2157 | * ( 1.0_wp + x**2 ) * 0.125_wp ) |
---|
| 2158 | ELSE |
---|
| 2159 | |
---|
| 2160 | psi_m = - b * ( zeta - c_d_d ) * EXP( -d * zeta ) - a * zeta & |
---|
| 2161 | - bc_d_d |
---|
| 2162 | ! |
---|
| 2163 | !-- Old version for stable conditions (only valid for z/L < 0.5) |
---|
| 2164 | !-- psi_m = - 5.0_wp * zeta |
---|
| 2165 | |
---|
| 2166 | ENDIF |
---|
| 2167 | |
---|
| 2168 | END FUNCTION psi_m |
---|
| 2169 | |
---|
| 2170 | |
---|
| 2171 | ! |
---|
| 2172 | !-- Integrated stability function for heat and moisture |
---|
| 2173 | FUNCTION psi_h( zeta ) |
---|
| 2174 | |
---|
| 2175 | USE kinds |
---|
| 2176 | |
---|
| 2177 | IMPLICIT NONE |
---|
| 2178 | |
---|
| 2179 | REAL(wp) :: psi_h !< Integrated similarity function result |
---|
| 2180 | REAL(wp) :: zeta !< Stability parameter z/L |
---|
| 2181 | REAL(wp) :: x !< dummy variable |
---|
| 2182 | |
---|
| 2183 | REAL(wp), PARAMETER :: a = 1.0_wp !< constant |
---|
| 2184 | REAL(wp), PARAMETER :: b = 0.66666666666_wp !< constant |
---|
| 2185 | REAL(wp), PARAMETER :: c = 5.0_wp !< constant |
---|
| 2186 | REAL(wp), PARAMETER :: d = 0.35_wp !< constant |
---|
| 2187 | REAL(wp), PARAMETER :: c_d_d = c / d !< constant |
---|
| 2188 | REAL(wp), PARAMETER :: bc_d_d = b * c / d !< constant |
---|
| 2189 | |
---|
| 2190 | |
---|
| 2191 | IF ( zeta < 0.0_wp ) THEN |
---|
[1788] | 2192 | x = SQRT( 1.0_wp - 16.0_wp * zeta ) |
---|
[1691] | 2193 | psi_h = 2.0_wp * LOG( (1.0_wp + x ) / 2.0_wp ) |
---|
| 2194 | ELSE |
---|
| 2195 | psi_h = - b * ( zeta - c_d_d ) * EXP( -d * zeta ) - (1.0_wp & |
---|
| 2196 | + 0.66666666666_wp * a * zeta )**1.5_wp - bc_d_d & |
---|
| 2197 | + 1.0_wp |
---|
| 2198 | ! |
---|
| 2199 | !-- Old version for stable conditions (only valid for z/L < 0.5) |
---|
| 2200 | !-- psi_h = - 5.0_wp * zeta |
---|
| 2201 | ENDIF |
---|
| 2202 | |
---|
| 2203 | END FUNCTION psi_h |
---|
| 2204 | |
---|
[1697] | 2205 | END MODULE surface_layer_fluxes_mod |
---|