[1826] | 1 | !> @file plant_canopy_model_mod.f90 |
---|
[2000] | 2 | !------------------------------------------------------------------------------! |
---|
[2696] | 3 | ! This file is part of the PALM model system. |
---|
[1036] | 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. |
---|
[1036] | 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 | ! |
---|
[4360] | 17 | ! Copyright 1997-2020 Leibniz Universitaet Hannover |
---|
[4392] | 18 | ! Copyright 2017-2020 Institute of Computer Science of the |
---|
[3885] | 19 | ! Czech Academy of Sciences, Prague |
---|
[2000] | 20 | !------------------------------------------------------------------------------! |
---|
[1036] | 21 | ! |
---|
[257] | 22 | ! Current revisions: |
---|
[2977] | 23 | ! ------------------ |
---|
[2214] | 24 | ! |
---|
[4226] | 25 | ! |
---|
[2214] | 26 | ! Former revisions: |
---|
| 27 | ! ----------------- |
---|
[4495] | 28 | ! $Id: plant_canopy_model_mod.f90 4495 2020-04-13 20:11:20Z eckhard $ |
---|
| 29 | ! restart data handling with MPI-IO added |
---|
[4448] | 30 | ! |
---|
[4495] | 31 | ! 4457 2020-03-11 14:20:43Z raasch |
---|
| 32 | ! |
---|
[4457] | 33 | ! use statement for exchange horiz added |
---|
[4448] | 34 | ! (salim) removed the error message PA0672 to consider PC 3d data via ascii file |
---|
| 35 | ! |
---|
| 36 | ! 4392 2020-01-31 16:14:57Z pavelkrc (resler) |
---|
| 37 | ! Make pcm_heatrate_av, pcm_latentrate_av public to allow calculation |
---|
[4392] | 38 | ! of averaged Bowen ratio in the user procedure |
---|
| 39 | ! |
---|
| 40 | ! 4381 2020-01-20 13:51:46Z suehring |
---|
[4381] | 41 | ! Give error message 313 only once |
---|
| 42 | ! |
---|
| 43 | ! 4363 2020-01-07 18:11:28Z suehring |
---|
[4363] | 44 | ! Fix for last commit |
---|
| 45 | ! |
---|
| 46 | ! 4362 2020-01-07 17:15:02Z suehring |
---|
[4362] | 47 | ! Input of plant canopy variables from static driver moved to plant-canopy |
---|
| 48 | ! model |
---|
| 49 | ! |
---|
| 50 | ! 4361 2020-01-07 12:22:38Z suehring |
---|
[4361] | 51 | ! - Remove unused arrays in pmc_rrd_local |
---|
| 52 | ! - Remove one exchange of ghost points |
---|
| 53 | ! |
---|
| 54 | ! 4360 2020-01-07 11:25:50Z suehring |
---|
[4360] | 55 | ! - Bugfix, read restart data for time-averaged pcm output quantities |
---|
| 56 | ! - Output of plant-canopy quantities will fill values |
---|
| 57 | ! |
---|
| 58 | ! 4356 2019-12-20 17:09:33Z suehring |
---|
[4356] | 59 | ! Correct single message call, local check must be given by the respective |
---|
| 60 | ! mpi rank. |
---|
| 61 | ! |
---|
| 62 | ! 4346 2019-12-18 11:55:56Z motisi |
---|
[4346] | 63 | ! Introduction of wall_flags_total_0, which currently sets bits based on static |
---|
| 64 | ! topography information used in wall_flags_static_0 |
---|
| 65 | ! |
---|
| 66 | ! 4342 2019-12-16 13:49:14Z Giersch |
---|
[4342] | 67 | ! Use statements moved to module level, ocean dependency removed, redundant |
---|
| 68 | ! variables removed |
---|
| 69 | ! |
---|
| 70 | ! 4341 2019-12-16 10:43:49Z motisi |
---|
[4341] | 71 | ! - Unification of variable names: pc_-variables now pcm_-variables |
---|
| 72 | ! (pc_latent_rate, pc_heating_rate, pc_transpiration_rate) |
---|
| 73 | ! - Removal of pcm_bowenratio output |
---|
| 74 | ! - Renamed canopy-mode 'block' to 'homogeneous' |
---|
| 75 | ! - Renamed value 'read_from_file_3d' to 'read_from_file' |
---|
| 76 | ! - Removal of confusing comment lines |
---|
| 77 | ! - Replacement of k_wall by topo_top_ind |
---|
| 78 | ! - Removal of Else-Statement in tendency-calculation |
---|
| 79 | ! |
---|
| 80 | ! 4335 2019-12-12 16:39:05Z suehring |
---|
[4335] | 81 | ! Fix for LAD at building edges also implemented in vector branch. |
---|
| 82 | ! |
---|
| 83 | ! 4331 2019-12-10 18:25:02Z suehring |
---|
[4331] | 84 | ! Typo corrected |
---|
| 85 | ! |
---|
| 86 | ! 4329 2019-12-10 15:46:36Z motisi |
---|
[4329] | 87 | ! Renamed wall_flags_0 to wall_flags_static_0 |
---|
| 88 | ! |
---|
| 89 | ! 4314 2019-11-29 10:29:20Z suehring |
---|
[4314] | 90 | ! - Bugfix, plant canopy was still considered at building edges on for the u- |
---|
| 91 | ! and v-component. |
---|
| 92 | ! - Relax restriction of LAD on building tops. LAD is only omitted at |
---|
| 93 | ! locations where building grid points emerged artificially by the |
---|
| 94 | ! topography filtering. |
---|
| 95 | ! |
---|
| 96 | ! 4309 2019-11-26 18:49:59Z suehring |
---|
[4309] | 97 | ! Typo |
---|
| 98 | ! |
---|
| 99 | ! 4302 2019-11-22 13:15:56Z suehring |
---|
[4302] | 100 | ! Omit tall canopy mapped on top of buildings |
---|
| 101 | ! |
---|
| 102 | ! 4279 2019-10-29 08:48:17Z scharf |
---|
[4279] | 103 | ! unused variables removed |
---|
| 104 | ! |
---|
| 105 | ! 4258 2019-10-07 13:29:08Z scharf |
---|
[4278] | 106 | ! changed check for static driver and fixed bugs in initialization and header |
---|
| 107 | ! |
---|
| 108 | ! 4258 2019-10-07 13:29:08Z suehring |
---|
[4258] | 109 | ! Check if any LAD is prescribed when plant-canopy model is applied. |
---|
| 110 | ! |
---|
| 111 | ! 4226 2019-09-10 17:03:24Z suehring |
---|
[4226] | 112 | ! Bugfix, missing initialization of heating rate |
---|
| 113 | ! |
---|
| 114 | ! 4221 2019-09-09 08:50:35Z suehring |
---|
[4220] | 115 | ! Further bugfix in 3d data output for plant canopy |
---|
| 116 | ! |
---|
| 117 | ! 4216 2019-09-04 09:09:03Z suehring |
---|
[4216] | 118 | ! Bugfixes in 3d data output |
---|
| 119 | ! |
---|
| 120 | ! 4205 2019-08-30 13:25:00Z suehring |
---|
[4205] | 121 | ! Missing working precision + bugfix in calculation of wind speed |
---|
| 122 | ! |
---|
| 123 | ! 4188 2019-08-26 14:15:47Z suehring |
---|
[4188] | 124 | ! Minor adjustment in error number |
---|
| 125 | ! |
---|
| 126 | ! 4187 2019-08-26 12:43:15Z suehring |
---|
[4187] | 127 | ! Give specific error numbers instead of PA0999 |
---|
| 128 | ! |
---|
| 129 | ! 4182 2019-08-22 15:20:23Z scharf |
---|
[4182] | 130 | ! Corrected "Former revisions" section |
---|
| 131 | ! |
---|
| 132 | ! 4168 2019-08-16 13:50:17Z suehring |
---|
[4168] | 133 | ! Replace function get_topography_top_index by topo_top_ind |
---|
| 134 | ! |
---|
| 135 | ! 4127 2019-07-30 14:47:10Z suehring |
---|
[4127] | 136 | ! Output of 3D plant canopy variables changed. It is now relative to the local |
---|
| 137 | ! terrain rather than located at the acutal vertical level in the model. This |
---|
| 138 | ! way, the vertical dimension of the output can be significantly reduced. |
---|
| 139 | ! (merge from branch resler) |
---|
| 140 | ! |
---|
| 141 | ! 3885 2019-04-11 11:29:34Z kanani |
---|
[3885] | 142 | ! Changes related to global restructuring of location messages and introduction |
---|
| 143 | ! of additional debug messages |
---|
| 144 | ! |
---|
| 145 | ! 3864 2019-04-05 09:01:56Z monakurppa |
---|
[3761] | 146 | ! unsed variables removed |
---|
| 147 | ! |
---|
| 148 | ! 3745 2019-02-15 18:57:56Z suehring |
---|
[3745] | 149 | ! Bugfix in transpiration, floating invalid when temperature |
---|
| 150 | ! becomes > 40 degrees |
---|
| 151 | ! |
---|
| 152 | ! 3744 2019-02-15 18:38:58Z suehring |
---|
[3685] | 153 | ! Some interface calls moved to module_interface + cleanup |
---|
| 154 | ! |
---|
| 155 | ! 3655 2019-01-07 16:51:22Z knoop |
---|
[3614] | 156 | ! unused variables removed |
---|
[3498] | 157 | ! |
---|
[4182] | 158 | ! 138 2007-11-28 10:03:58Z letzel |
---|
| 159 | ! Initial revision |
---|
| 160 | ! |
---|
[138] | 161 | ! Description: |
---|
| 162 | ! ------------ |
---|
[1682] | 163 | !> 1) Initialization of the canopy model, e.g. construction of leaf area density |
---|
[1826] | 164 | !> profile (subroutine pcm_init). |
---|
[1682] | 165 | !> 2) Calculation of sinks and sources of momentum, heat and scalar concentration |
---|
[1826] | 166 | !> due to canopy elements (subroutine pcm_tendency). |
---|
[3744] | 167 | ! |
---|
| 168 | ! @todo - precalculate constant terms in pcm_calc_transpiration_rate |
---|
[4216] | 169 | ! @todo - unify variable names (pcm_, pc_, ...) |
---|
[138] | 170 | !------------------------------------------------------------------------------! |
---|
[1682] | 171 | MODULE plant_canopy_model_mod |
---|
[4360] | 172 | |
---|
[1484] | 173 | USE arrays_3d, & |
---|
[3449] | 174 | ONLY: dzu, dzw, e, exner, hyp, pt, q, s, tend, u, v, w, zu, zw |
---|
[138] | 175 | |
---|
[3449] | 176 | USE basic_constants_and_equations_mod, & |
---|
| 177 | ONLY: c_p, degc_to_k, l_v, lv_d_cp, r_d, rd_d_rv |
---|
[4360] | 178 | |
---|
[4342] | 179 | USE bulk_cloud_model_mod, & |
---|
| 180 | ONLY: bulk_cloud_model, microphysics_seifert |
---|
[3449] | 181 | |
---|
[3885] | 182 | USE control_parameters, & |
---|
[4360] | 183 | ONLY: average_count_3d, & |
---|
| 184 | coupling_char, & |
---|
| 185 | debug_output, & |
---|
| 186 | dt_3d, & |
---|
| 187 | dz, & |
---|
| 188 | humidity, & |
---|
| 189 | length, & |
---|
| 190 | message_string, & |
---|
| 191 | ocean_mode, & |
---|
| 192 | passive_scalar, & |
---|
| 193 | plant_canopy, & |
---|
[4495] | 194 | restart_data_format_output, & |
---|
[4360] | 195 | restart_string, & |
---|
| 196 | urban_surface |
---|
| 197 | |
---|
[4342] | 198 | USE grid_variables, & |
---|
| 199 | ONLY: dx, dy |
---|
[3449] | 200 | |
---|
[1484] | 201 | USE indices, & |
---|
| 202 | ONLY: nbgp, nxl, nxlg, nxlu, nxr, nxrg, nyn, nyng, nys, nysg, nysv, & |
---|
[4346] | 203 | nz, nzb, nzt, topo_top_ind, wall_flags_total_0 |
---|
[1484] | 204 | |
---|
| 205 | USE kinds |
---|
[4360] | 206 | |
---|
[4342] | 207 | USE netcdf_data_input_mod, & |
---|
[4362] | 208 | ONLY: input_pids_static, & |
---|
| 209 | char_fill, & |
---|
| 210 | check_existence, & |
---|
| 211 | close_input_file, & |
---|
| 212 | get_attribute, & |
---|
| 213 | get_dimension_length, & |
---|
| 214 | get_variable, & |
---|
| 215 | inquire_num_variables, & |
---|
| 216 | inquire_variable_names, & |
---|
| 217 | input_file_static, & |
---|
| 218 | num_var_pids, & |
---|
| 219 | open_read_file, & |
---|
| 220 | pids_id, & |
---|
| 221 | real_3d, & |
---|
| 222 | vars_pids |
---|
[1484] | 223 | |
---|
[3449] | 224 | USE pegrid |
---|
[4360] | 225 | |
---|
[4495] | 226 | USE restart_data_mpi_io_mod, & |
---|
| 227 | ONLY: wrd_mpi_io |
---|
| 228 | |
---|
[4342] | 229 | USE surface_mod, & |
---|
| 230 | ONLY: surf_def_h, surf_lsm_h, surf_usm_h |
---|
[3449] | 231 | |
---|
[1484] | 232 | |
---|
| 233 | IMPLICIT NONE |
---|
| 234 | |
---|
[4341] | 235 | CHARACTER (LEN=30) :: canopy_mode = 'homogeneous' !< canopy coverage |
---|
[3449] | 236 | LOGICAL :: plant_canopy_transpiration = .FALSE. !< flag to switch calculation of transpiration and corresponding latent heat |
---|
| 237 | !< for resolved plant canopy inside radiation model |
---|
| 238 | !< (calls subroutine pcm_calc_transpiration_rate from module plant_canopy_mod) |
---|
[1484] | 239 | |
---|
[3449] | 240 | INTEGER(iwp) :: pch_index = 0 !< plant canopy height/top index |
---|
| 241 | INTEGER(iwp) :: lad_vertical_gradient_level_ind(10) = -9999 !< lad-profile levels (index) |
---|
[1484] | 242 | |
---|
[3449] | 243 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: pch_index_ji !< local plant canopy top |
---|
[2696] | 244 | |
---|
[3449] | 245 | LOGICAL :: calc_beta_lad_profile = .FALSE. !< switch for calc. of lad from beta func. |
---|
[1484] | 246 | |
---|
[2696] | 247 | REAL(wp) :: alpha_lad = 9999999.9_wp !< coefficient for lad calculation |
---|
| 248 | REAL(wp) :: beta_lad = 9999999.9_wp !< coefficient for lad calculation |
---|
| 249 | REAL(wp) :: canopy_drag_coeff = 0.0_wp !< canopy drag coefficient (parameter) |
---|
| 250 | REAL(wp) :: cthf = 0.0_wp !< canopy top heat flux |
---|
| 251 | REAL(wp) :: dt_plant_canopy = 0.0_wp !< timestep account. for canopy drag |
---|
| 252 | REAL(wp) :: ext_coef = 0.6_wp !< extinction coefficient |
---|
| 253 | REAL(wp) :: lad_surface = 0.0_wp !< lad surface value |
---|
| 254 | REAL(wp) :: lai_beta = 0.0_wp !< leaf area index (lai) for lad calc. |
---|
| 255 | REAL(wp) :: leaf_scalar_exch_coeff = 0.0_wp !< canopy scalar exchange coeff. |
---|
| 256 | REAL(wp) :: leaf_surface_conc = 0.0_wp !< leaf surface concentration |
---|
[1484] | 257 | |
---|
[2696] | 258 | REAL(wp) :: lad_vertical_gradient(10) = 0.0_wp !< lad gradient |
---|
| 259 | REAL(wp) :: lad_vertical_gradient_level(10) = -9999999.9_wp !< lad-prof. levels (in m) |
---|
[1484] | 260 | |
---|
[2977] | 261 | REAL(wp) :: lad_type_coef(0:10) = 1.0_wp !< multiplicative coeficients for particular types |
---|
| 262 | !< of plant canopy (e.g. deciduous tree during winter) |
---|
| 263 | |
---|
[1682] | 264 | REAL(wp), DIMENSION(:), ALLOCATABLE :: lad !< leaf area density |
---|
| 265 | REAL(wp), DIMENSION(:), ALLOCATABLE :: pre_lad !< preliminary lad |
---|
[1484] | 266 | |
---|
[4127] | 267 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: cum_lai_hf !< cumulative lai for heatflux calc. |
---|
| 268 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: lad_s !< lad on scalar-grid |
---|
[4341] | 269 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: pcm_heating_rate !< plant canopy heating rate |
---|
| 270 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: pcm_transpiration_rate !< plant canopy transpiration rate |
---|
| 271 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: pcm_latent_rate !< plant canopy latent heating rate |
---|
[1484] | 272 | |
---|
[4127] | 273 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: pcm_heatrate_av !< array for averaging plant canopy sensible heating rate |
---|
| 274 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: pcm_latentrate_av !< array for averaging plant canopy latent heating rate |
---|
| 275 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: pcm_transpirationrate_av !< array for averaging plant canopy transpiration rate |
---|
| 276 | |
---|
[4362] | 277 | TYPE(real_3d) :: basal_area_density_f !< input variable for basal area density - resolved vegetation |
---|
| 278 | TYPE(real_3d) :: leaf_area_density_f !< input variable for leaf area density - resolved vegetation |
---|
| 279 | TYPE(real_3d) :: root_area_density_lad_f !< input variable for root area density - resolved vegetation |
---|
| 280 | |
---|
[1484] | 281 | SAVE |
---|
| 282 | |
---|
[138] | 283 | PRIVATE |
---|
[4342] | 284 | |
---|
[1826] | 285 | ! |
---|
| 286 | !-- Public functions |
---|
[4360] | 287 | PUBLIC pcm_calc_transpiration_rate, & |
---|
| 288 | pcm_check_data_output, & |
---|
| 289 | pcm_check_parameters, & |
---|
| 290 | pcm_3d_data_averaging, & |
---|
| 291 | pcm_data_output_3d, & |
---|
| 292 | pcm_define_netcdf_grid, & |
---|
| 293 | pcm_header, & |
---|
| 294 | pcm_init, & |
---|
| 295 | pcm_parin, & |
---|
| 296 | pcm_rrd_local, & |
---|
| 297 | pcm_tendency, & |
---|
| 298 | pcm_wrd_local |
---|
[138] | 299 | |
---|
[1826] | 300 | ! |
---|
| 301 | !-- Public variables and constants |
---|
[4342] | 302 | PUBLIC canopy_drag_coeff, pcm_heating_rate, pcm_transpiration_rate, & |
---|
| 303 | pcm_latent_rate, canopy_mode, cthf, dt_plant_canopy, lad, lad_s, & |
---|
[4392] | 304 | pch_index, plant_canopy_transpiration, & |
---|
| 305 | pcm_heatrate_av, pcm_latentrate_av |
---|
[1484] | 306 | |
---|
[3449] | 307 | INTERFACE pcm_calc_transpiration_rate |
---|
| 308 | MODULE PROCEDURE pcm_calc_transpiration_rate |
---|
| 309 | END INTERFACE pcm_calc_transpiration_rate |
---|
| 310 | |
---|
[2209] | 311 | INTERFACE pcm_check_data_output |
---|
| 312 | MODULE PROCEDURE pcm_check_data_output |
---|
| 313 | END INTERFACE pcm_check_data_output |
---|
| 314 | |
---|
[1826] | 315 | INTERFACE pcm_check_parameters |
---|
| 316 | MODULE PROCEDURE pcm_check_parameters |
---|
[2209] | 317 | END INTERFACE pcm_check_parameters |
---|
| 318 | |
---|
[4127] | 319 | INTERFACE pcm_3d_data_averaging |
---|
| 320 | MODULE PROCEDURE pcm_3d_data_averaging |
---|
| 321 | END INTERFACE pcm_3d_data_averaging |
---|
| 322 | |
---|
[2209] | 323 | INTERFACE pcm_data_output_3d |
---|
| 324 | MODULE PROCEDURE pcm_data_output_3d |
---|
| 325 | END INTERFACE pcm_data_output_3d |
---|
| 326 | |
---|
| 327 | INTERFACE pcm_define_netcdf_grid |
---|
| 328 | MODULE PROCEDURE pcm_define_netcdf_grid |
---|
| 329 | END INTERFACE pcm_define_netcdf_grid |
---|
[1826] | 330 | |
---|
| 331 | INTERFACE pcm_header |
---|
| 332 | MODULE PROCEDURE pcm_header |
---|
| 333 | END INTERFACE pcm_header |
---|
| 334 | |
---|
| 335 | INTERFACE pcm_init |
---|
| 336 | MODULE PROCEDURE pcm_init |
---|
| 337 | END INTERFACE pcm_init |
---|
[138] | 338 | |
---|
[1826] | 339 | INTERFACE pcm_parin |
---|
| 340 | MODULE PROCEDURE pcm_parin |
---|
[2007] | 341 | END INTERFACE pcm_parin |
---|
| 342 | |
---|
| 343 | INTERFACE pcm_read_plant_canopy_3d |
---|
| 344 | MODULE PROCEDURE pcm_read_plant_canopy_3d |
---|
| 345 | END INTERFACE pcm_read_plant_canopy_3d |
---|
[4360] | 346 | |
---|
| 347 | INTERFACE pcm_rrd_local |
---|
| 348 | MODULE PROCEDURE pcm_rrd_local |
---|
| 349 | END INTERFACE pcm_rrd_local |
---|
| 350 | |
---|
[1826] | 351 | INTERFACE pcm_tendency |
---|
| 352 | MODULE PROCEDURE pcm_tendency |
---|
| 353 | MODULE PROCEDURE pcm_tendency_ij |
---|
| 354 | END INTERFACE pcm_tendency |
---|
[1484] | 355 | |
---|
[4360] | 356 | INTERFACE pcm_wrd_local |
---|
| 357 | MODULE PROCEDURE pcm_wrd_local |
---|
| 358 | END INTERFACE pcm_wrd_local |
---|
[1484] | 359 | |
---|
[4360] | 360 | |
---|
[138] | 361 | CONTAINS |
---|
[4342] | 362 | |
---|
| 363 | |
---|
[2209] | 364 | !------------------------------------------------------------------------------! |
---|
| 365 | ! Description: |
---|
| 366 | ! ------------ |
---|
[3449] | 367 | !> Calculation of the plant canopy transpiration rate based on the Jarvis-Stewart |
---|
| 368 | !> with parametrizations described in Daudet et al. (1999; Agricult. and Forest |
---|
| 369 | !> Meteorol. 97) and Ngao, Adam and Saudreau (2017; Agricult. and Forest Meteorol |
---|
| 370 | !> 237-238). Model functions f1-f4 were adapted from Stewart (1998; Agric. |
---|
| 371 | !> and Forest. Meteorol. 43) instead, because they are valid for broader intervals |
---|
| 372 | !> of values. Funcion f4 used in form present in van Wijk et al. (1998; |
---|
| 373 | !> Tree Physiology 20). |
---|
| 374 | !> |
---|
| 375 | !> This subroutine is called from subroutine radiation_interaction |
---|
| 376 | !> after the calculation of radiation in plant canopy boxes. |
---|
| 377 | !> (arrays pcbinsw and pcbinlw). |
---|
| 378 | !> |
---|
| 379 | !------------------------------------------------------------------------------! |
---|
| 380 | SUBROUTINE pcm_calc_transpiration_rate(i, j, k, kk, pcbsw, pcblw, pcbtr, pcblh) |
---|
| 381 | |
---|
[4342] | 382 | ! |
---|
[3449] | 383 | !-- input parameters |
---|
[4205] | 384 | INTEGER(iwp), INTENT(IN) :: i, j, k, kk !< indices of the pc gridbox |
---|
| 385 | REAL(wp), INTENT(IN) :: pcbsw !< sw radiation in gridbox (W) |
---|
| 386 | REAL(wp), INTENT(IN) :: pcblw !< lw radiation in gridbox (W) |
---|
| 387 | REAL(wp), INTENT(OUT) :: pcbtr !< transpiration rate dq/dt (kg/kg/s) |
---|
| 388 | REAL(wp), INTENT(OUT) :: pcblh !< latent heat from transpiration dT/dt (K/s) |
---|
[3449] | 389 | |
---|
| 390 | !-- variables and parameters for calculation of transpiration rate |
---|
[4205] | 391 | REAL(wp) :: sat_press, sat_press_d, temp, v_lad |
---|
| 392 | REAL(wp) :: d_fact, g_b, g_s, wind_speed, evapor_rate |
---|
| 393 | REAL(wp) :: f1, f2, f3, f4, vpd, rswc, e_eq, e_imp, rad |
---|
| 394 | REAL(wp), PARAMETER :: gama_psychr = 66.0_wp !< psychrometric constant (Pa/K) |
---|
| 395 | REAL(wp), PARAMETER :: g_s_max = 0.01 !< maximum stomatal conductivity (m/s) |
---|
| 396 | REAL(wp), PARAMETER :: m_soil = 0.4_wp !< soil water content (needs to adjust or take from LSM) |
---|
| 397 | REAL(wp), PARAMETER :: m_wilt = 0.01_wp !< wilting point soil water content (needs to adjust or take from LSM) |
---|
| 398 | REAL(wp), PARAMETER :: m_sat = 0.51_wp !< saturation soil water content (needs to adjust or take from LSM) |
---|
| 399 | REAL(wp), PARAMETER :: t2_min = 0.0_wp !< minimal temperature for calculation of f2 |
---|
| 400 | REAL(wp), PARAMETER :: t2_max = 40.0_wp !< maximal temperature for calculation of f2 |
---|
[3449] | 401 | |
---|
| 402 | |
---|
| 403 | !-- Temperature (deg C) |
---|
| 404 | temp = pt(k,j,i) * exner(k) - degc_to_k |
---|
| 405 | !-- Coefficient for conversion of radiation to grid to radiation to unit leaves surface |
---|
[4205] | 406 | v_lad = 1.0_wp / ( MAX( lad_s(kk,j,i), 1.0E-10_wp ) * dx * dy * dz(1) ) |
---|
[3449] | 407 | !-- Magnus formula for the saturation pressure (see Ngao, Adam and Saudreau (2017) eq. 1) |
---|
| 408 | !-- There are updated formulas available, kept consistent with the rest of the parametrization |
---|
| 409 | sat_press = 610.8_wp * exp(17.27_wp * temp/(temp + 237.3_wp)) |
---|
| 410 | !-- Saturation pressure derivative (derivative of the above) |
---|
| 411 | sat_press_d = sat_press * 17.27_wp * 237.3_wp / (temp + 237.3_wp)**2 |
---|
| 412 | !-- Wind speed |
---|
[3744] | 413 | wind_speed = SQRT( ( 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) )**2 + & |
---|
[4205] | 414 | ( 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) )**2 + & |
---|
| 415 | ( 0.5_wp * ( w(k,j,i) + w(k-1,j,i) ) )**2 ) |
---|
[3449] | 416 | !-- Aerodynamic conductivity (Daudet et al. (1999) eq. 14 |
---|
| 417 | g_b = 0.01_wp * wind_speed + 0.0071_wp |
---|
| 418 | !-- Radiation flux per leaf surface unit |
---|
| 419 | rad = pcbsw * v_lad |
---|
| 420 | !-- First function for calculation of stomatal conductivity (radiation dependency) |
---|
| 421 | !-- Stewart (1988; Agric. and Forest. Meteorol. 43) eq. 17 |
---|
[4205] | 422 | f1 = rad * (1000.0_wp+42.1_wp) / 1000.0_wp / (rad+42.1_wp) |
---|
[3449] | 423 | !-- Second function for calculation of stomatal conductivity (temperature dependency) |
---|
| 424 | !-- Stewart (1988; Agric. and Forest. Meteorol. 43) eq. 21 |
---|
[3744] | 425 | f2 = MAX(t2_min, (temp-t2_min) * MAX(0.0_wp,t2_max-temp)**((t2_max-16.9_wp)/(16.9_wp-t2_min)) / & |
---|
[3449] | 426 | ((16.9_wp-t2_min) * (t2_max-16.9_wp)**((t2_max-16.9_wp)/(16.9_wp-t2_min))) ) |
---|
| 427 | !-- Water pressure deficit |
---|
| 428 | !-- Ngao, Adam and Saudreau (2017) eq. 6 but with water vapour partial pressure |
---|
| 429 | vpd = max( sat_press - q(k,j,i) * hyp(k) / rd_d_rv, 0._wp ) |
---|
| 430 | !-- Third function for calculation of stomatal conductivity (water pressure deficit dependency) |
---|
| 431 | !-- Ngao, Adam and Saudreau (2017) Table 1, limited from below according to Stewart (1988) |
---|
| 432 | !-- The coefficients of the linear dependence should better correspond to broad-leaved trees |
---|
| 433 | !-- than the coefficients from Stewart (1988) which correspond to conifer trees. |
---|
| 434 | vpd = MIN(MAX(vpd,770.0_wp),3820.0_wp) |
---|
[4205] | 435 | f3 = -2E-4_wp * vpd + 1.154_wp |
---|
[3449] | 436 | !-- Fourth function for calculation of stomatal conductivity (soil moisture dependency) |
---|
| 437 | !-- Residual soil water content |
---|
| 438 | !-- van Wijk et al. (1998; Tree Physiology 20) eq. 7 |
---|
| 439 | !-- TODO - over LSM surface might be calculated from LSM parameters |
---|
| 440 | rswc = ( m_sat - m_soil ) / ( m_sat - m_wilt ) |
---|
| 441 | !-- van Wijk et al. (1998; Tree Physiology 20) eq. 5-6 (it is a reformulation of eq. 22-23 of Stewart(1988)) |
---|
[4205] | 442 | f4 = MAX(0.0_wp, MIN(1.0_wp - 0.041_wp * EXP(3.2_wp * rswc), 1.0_wp - 0.041_wp)) |
---|
[3449] | 443 | !-- Stomatal conductivity |
---|
| 444 | !-- Stewart (1988; Agric. and Forest. Meteorol. 43) eq. 12 |
---|
| 445 | !-- (notation according to Ngao, Adam and Saudreau (2017) and others) |
---|
[4205] | 446 | g_s = g_s_max * f1 * f2 * f3 * f4 + 1.0E-10_wp |
---|
[3449] | 447 | !-- Decoupling factor |
---|
| 448 | !-- Daudet et al. (1999) eq. 6 |
---|
[4205] | 449 | d_fact = (sat_press_d / gama_psychr + 2.0_wp ) / & |
---|
| 450 | (sat_press_d / gama_psychr + 2.0_wp + 2.0_wp * g_b / g_s ) |
---|
[3449] | 451 | !-- Equilibrium evaporation rate |
---|
| 452 | !-- Daudet et al. (1999) eq. 4 |
---|
| 453 | e_eq = (pcbsw + pcblw) * v_lad * sat_press_d / & |
---|
| 454 | gama_psychr /( sat_press_d / gama_psychr + 2.0_wp ) / l_v |
---|
| 455 | !-- Imposed evaporation rate |
---|
| 456 | !-- Daudet et al. (1999) eq. 5 |
---|
| 457 | e_imp = r_d * pt(k,j,i) * exner(k) / hyp(k) * c_p * g_s * vpd / gama_psychr / l_v |
---|
| 458 | !-- Evaporation rate |
---|
| 459 | !-- Daudet et al. (1999) eq. 3 |
---|
| 460 | !-- (evaporation rate is limited to non-negative values) |
---|
| 461 | evapor_rate = MAX(d_fact * e_eq + ( 1.0_wp - d_fact ) * e_imp, 0.0_wp) |
---|
| 462 | !-- Conversion of evaporation rate to q tendency in gridbox |
---|
| 463 | !-- dq/dt = E * LAD * V_g / (rho_air * V_g) |
---|
| 464 | pcbtr = evapor_rate * r_d * pt(k,j,i) * exner(k) * lad_s(kk,j,i) / hyp(k) !-- = dq/dt |
---|
| 465 | !-- latent heat from evaporation |
---|
| 466 | pcblh = pcbtr * lv_d_cp !-- = - dT/dt |
---|
| 467 | |
---|
| 468 | END SUBROUTINE pcm_calc_transpiration_rate |
---|
| 469 | |
---|
| 470 | |
---|
| 471 | !------------------------------------------------------------------------------! |
---|
| 472 | ! Description: |
---|
| 473 | ! ------------ |
---|
[2209] | 474 | !> Check data output for plant canopy model |
---|
| 475 | !------------------------------------------------------------------------------! |
---|
| 476 | SUBROUTINE pcm_check_data_output( var, unit ) |
---|
[4279] | 477 | |
---|
[2209] | 478 | CHARACTER (LEN=*) :: unit !< |
---|
| 479 | CHARACTER (LEN=*) :: var !< |
---|
| 480 | |
---|
| 481 | |
---|
| 482 | SELECT CASE ( TRIM( var ) ) |
---|
| 483 | |
---|
| 484 | CASE ( 'pcm_heatrate' ) |
---|
[2770] | 485 | IF ( cthf == 0.0_wp .AND. .NOT. urban_surface ) THEN |
---|
[2768] | 486 | message_string = 'output of "' // TRIM( var ) // '" requi' // & |
---|
| 487 | 'res setting of parameter cthf /= 0.0' |
---|
| 488 | CALL message( 'pcm_check_data_output', 'PA1000', 1, 2, 0, 6, 0 ) |
---|
| 489 | ENDIF |
---|
[2209] | 490 | unit = 'K s-1' |
---|
| 491 | |
---|
[3014] | 492 | CASE ( 'pcm_transpirationrate' ) |
---|
| 493 | unit = 'kg kg-1 s-1' |
---|
| 494 | |
---|
[3449] | 495 | CASE ( 'pcm_latentrate' ) |
---|
| 496 | unit = 'K s-1' |
---|
| 497 | |
---|
[2209] | 498 | CASE ( 'pcm_lad' ) |
---|
| 499 | unit = 'm2 m-3' |
---|
| 500 | |
---|
| 501 | |
---|
| 502 | CASE DEFAULT |
---|
| 503 | unit = 'illegal' |
---|
| 504 | |
---|
| 505 | END SELECT |
---|
| 506 | |
---|
| 507 | |
---|
| 508 | END SUBROUTINE pcm_check_data_output |
---|
| 509 | |
---|
| 510 | |
---|
[1826] | 511 | !------------------------------------------------------------------------------! |
---|
| 512 | ! Description: |
---|
| 513 | ! ------------ |
---|
| 514 | !> Check parameters routine for plant canopy model |
---|
| 515 | !------------------------------------------------------------------------------! |
---|
| 516 | SUBROUTINE pcm_check_parameters |
---|
[4342] | 517 | |
---|
| 518 | IF ( ocean_mode ) THEN |
---|
| 519 | message_string = 'plant_canopy = .TRUE. is not allowed in the '// & |
---|
| 520 | 'ocean' |
---|
| 521 | CALL message( 'pcm_check_parameters', 'PA0696', 1, 2, 0, 6, 0 ) |
---|
| 522 | ENDIF |
---|
| 523 | |
---|
[1826] | 524 | IF ( canopy_drag_coeff == 0.0_wp ) THEN |
---|
| 525 | message_string = 'plant_canopy = .TRUE. requires a non-zero drag '// & |
---|
[3046] | 526 | 'coefficient & given value is canopy_drag_coeff = 0.0' |
---|
[2768] | 527 | CALL message( 'pcm_check_parameters', 'PA0041', 1, 2, 0, 6, 0 ) |
---|
[1826] | 528 | ENDIF |
---|
[4279] | 529 | |
---|
[3045] | 530 | IF ( ( alpha_lad /= 9999999.9_wp .AND. beta_lad == 9999999.9_wp ) .OR.& |
---|
[1826] | 531 | beta_lad /= 9999999.9_wp .AND. alpha_lad == 9999999.9_wp ) THEN |
---|
| 532 | message_string = 'using the beta function for the construction ' // & |
---|
| 533 | 'of the leaf area density profile requires ' // & |
---|
| 534 | 'both alpha_lad and beta_lad to be /= 9999999.9' |
---|
[2768] | 535 | CALL message( 'pcm_check_parameters', 'PA0118', 1, 2, 0, 6, 0 ) |
---|
[1826] | 536 | ENDIF |
---|
[4279] | 537 | |
---|
[1826] | 538 | IF ( calc_beta_lad_profile .AND. lai_beta == 0.0_wp ) THEN |
---|
| 539 | message_string = 'using the beta function for the construction ' // & |
---|
| 540 | 'of the leaf area density profile requires ' // & |
---|
| 541 | 'a non-zero lai_beta, but given value is ' // & |
---|
| 542 | 'lai_beta = 0.0' |
---|
[2768] | 543 | CALL message( 'pcm_check_parameters', 'PA0119', 1, 2, 0, 6, 0 ) |
---|
[1826] | 544 | ENDIF |
---|
| 545 | |
---|
| 546 | IF ( calc_beta_lad_profile .AND. lad_surface /= 0.0_wp ) THEN |
---|
[2274] | 547 | message_string = 'simultaneous setting of alpha_lad /= 9999999.9 '// & |
---|
| 548 | 'combined with beta_lad /= 9999999.9 ' // & |
---|
[1826] | 549 | 'and lad_surface /= 0.0 is not possible, ' // & |
---|
| 550 | 'use either vertical gradients or the beta ' // & |
---|
| 551 | 'function for the construction of the leaf area '// & |
---|
| 552 | 'density profile' |
---|
[2768] | 553 | CALL message( 'pcm_check_parameters', 'PA0120', 1, 2, 0, 6, 0 ) |
---|
[1826] | 554 | ENDIF |
---|
| 555 | |
---|
[3274] | 556 | IF ( bulk_cloud_model .AND. microphysics_seifert ) THEN |
---|
[1826] | 557 | message_string = 'plant_canopy = .TRUE. requires cloud_scheme /=' // & |
---|
| 558 | ' seifert_beheng' |
---|
[2768] | 559 | CALL message( 'pcm_check_parameters', 'PA0360', 1, 2, 0, 6, 0 ) |
---|
[1826] | 560 | ENDIF |
---|
| 561 | |
---|
| 562 | END SUBROUTINE pcm_check_parameters |
---|
| 563 | |
---|
| 564 | |
---|
[138] | 565 | !------------------------------------------------------------------------------! |
---|
[2209] | 566 | ! |
---|
[1484] | 567 | ! Description: |
---|
| 568 | ! ------------ |
---|
[4127] | 569 | !> Subroutine for averaging 3D data |
---|
[2209] | 570 | !------------------------------------------------------------------------------! |
---|
[4216] | 571 | SUBROUTINE pcm_3d_data_averaging( mode, variable ) |
---|
[4127] | 572 | |
---|
| 573 | CHARACTER (LEN=*) :: mode !< |
---|
| 574 | CHARACTER (LEN=*) :: variable !< |
---|
| 575 | |
---|
| 576 | INTEGER(iwp) :: i !< |
---|
| 577 | INTEGER(iwp) :: j !< |
---|
| 578 | INTEGER(iwp) :: k !< |
---|
| 579 | |
---|
| 580 | |
---|
| 581 | IF ( mode == 'allocate' ) THEN |
---|
| 582 | |
---|
| 583 | SELECT CASE ( TRIM( variable ) ) |
---|
| 584 | |
---|
| 585 | CASE ( 'pcm_heatrate' ) |
---|
| 586 | IF ( .NOT. ALLOCATED( pcm_heatrate_av ) ) THEN |
---|
| 587 | ALLOCATE( pcm_heatrate_av(0:pch_index,nysg:nyng,nxlg:nxrg) ) |
---|
| 588 | ENDIF |
---|
| 589 | pcm_heatrate_av = 0.0_wp |
---|
| 590 | |
---|
| 591 | |
---|
| 592 | CASE ( 'pcm_latentrate' ) |
---|
| 593 | IF ( .NOT. ALLOCATED( pcm_latentrate_av ) ) THEN |
---|
| 594 | ALLOCATE( pcm_latentrate_av(0:pch_index,nysg:nyng,nxlg:nxrg) ) |
---|
| 595 | ENDIF |
---|
| 596 | pcm_latentrate_av = 0.0_wp |
---|
| 597 | |
---|
| 598 | |
---|
| 599 | CASE ( 'pcm_transpirationrate' ) |
---|
| 600 | IF ( .NOT. ALLOCATED( pcm_transpirationrate_av ) ) THEN |
---|
| 601 | ALLOCATE( pcm_transpirationrate_av(0:pch_index,nysg:nyng,nxlg:nxrg) ) |
---|
| 602 | ENDIF |
---|
| 603 | pcm_transpirationrate_av = 0.0_wp |
---|
| 604 | |
---|
| 605 | CASE DEFAULT |
---|
| 606 | CONTINUE |
---|
| 607 | |
---|
| 608 | END SELECT |
---|
| 609 | |
---|
| 610 | ELSEIF ( mode == 'sum' ) THEN |
---|
| 611 | |
---|
| 612 | SELECT CASE ( TRIM( variable ) ) |
---|
| 613 | |
---|
| 614 | CASE ( 'pcm_heatrate' ) |
---|
| 615 | IF ( ALLOCATED( pcm_heatrate_av ) ) THEN |
---|
| 616 | DO i = nxl, nxr |
---|
| 617 | DO j = nys, nyn |
---|
| 618 | IF ( pch_index_ji(j,i) /= 0 ) THEN |
---|
| 619 | DO k = 0, pch_index_ji(j,i) |
---|
[4341] | 620 | pcm_heatrate_av(k,j,i) = pcm_heatrate_av(k,j,i) + pcm_heating_rate(k,j,i) |
---|
[4127] | 621 | ENDDO |
---|
| 622 | ENDIF |
---|
| 623 | ENDDO |
---|
| 624 | ENDDO |
---|
| 625 | ENDIF |
---|
| 626 | |
---|
| 627 | |
---|
| 628 | CASE ( 'pcm_latentrate' ) |
---|
| 629 | IF ( ALLOCATED( pcm_latentrate_av ) ) THEN |
---|
| 630 | DO i = nxl, nxr |
---|
| 631 | DO j = nys, nyn |
---|
| 632 | IF ( pch_index_ji(j,i) /= 0 ) THEN |
---|
| 633 | DO k = 0, pch_index_ji(j,i) |
---|
[4341] | 634 | pcm_latentrate_av(k,j,i) = pcm_latentrate_av(k,j,i) + pcm_latent_rate(k,j,i) |
---|
[4127] | 635 | ENDDO |
---|
| 636 | ENDIF |
---|
| 637 | ENDDO |
---|
| 638 | ENDDO |
---|
| 639 | ENDIF |
---|
| 640 | |
---|
| 641 | |
---|
| 642 | CASE ( 'pcm_transpirationrate' ) |
---|
| 643 | IF ( ALLOCATED( pcm_transpirationrate_av ) ) THEN |
---|
| 644 | DO i = nxl, nxr |
---|
| 645 | DO j = nys, nyn |
---|
| 646 | IF ( pch_index_ji(j,i) /= 0 ) THEN |
---|
| 647 | DO k = 0, pch_index_ji(j,i) |
---|
[4341] | 648 | pcm_transpirationrate_av(k,j,i) = pcm_transpirationrate_av(k,j,i) + pcm_transpiration_rate(k,j,i) |
---|
[4127] | 649 | ENDDO |
---|
| 650 | ENDIF |
---|
| 651 | ENDDO |
---|
| 652 | ENDDO |
---|
| 653 | ENDIF |
---|
| 654 | |
---|
| 655 | CASE DEFAULT |
---|
| 656 | CONTINUE |
---|
| 657 | |
---|
| 658 | END SELECT |
---|
| 659 | |
---|
| 660 | ELSEIF ( mode == 'average' ) THEN |
---|
| 661 | |
---|
| 662 | SELECT CASE ( TRIM( variable ) ) |
---|
| 663 | |
---|
| 664 | CASE ( 'pcm_heatrate' ) |
---|
| 665 | IF ( ALLOCATED( pcm_heatrate_av ) ) THEN |
---|
| 666 | DO i = nxlg, nxrg |
---|
| 667 | DO j = nysg, nyng |
---|
| 668 | IF ( pch_index_ji(j,i) /= 0 ) THEN |
---|
| 669 | DO k = 0, pch_index_ji(j,i) |
---|
| 670 | pcm_heatrate_av(k,j,i) = pcm_heatrate_av(k,j,i) & |
---|
| 671 | / REAL( average_count_3d, KIND=wp ) |
---|
| 672 | ENDDO |
---|
| 673 | ENDIF |
---|
| 674 | ENDDO |
---|
| 675 | ENDDO |
---|
| 676 | ENDIF |
---|
| 677 | |
---|
| 678 | |
---|
| 679 | CASE ( 'pcm_latentrate' ) |
---|
| 680 | IF ( ALLOCATED( pcm_latentrate_av ) ) THEN |
---|
| 681 | DO i = nxlg, nxrg |
---|
| 682 | DO j = nysg, nyng |
---|
| 683 | IF ( pch_index_ji(j,i) /= 0 ) THEN |
---|
| 684 | DO k = 0, pch_index_ji(j,i) |
---|
| 685 | pcm_latentrate_av(k,j,i) = pcm_latentrate_av(k,j,i) & |
---|
| 686 | / REAL( average_count_3d, KIND=wp ) |
---|
| 687 | ENDDO |
---|
| 688 | ENDIF |
---|
| 689 | ENDDO |
---|
| 690 | ENDDO |
---|
| 691 | ENDIF |
---|
| 692 | |
---|
| 693 | |
---|
| 694 | CASE ( 'pcm_transpirationrate' ) |
---|
| 695 | IF ( ALLOCATED( pcm_transpirationrate_av ) ) THEN |
---|
| 696 | DO i = nxlg, nxrg |
---|
| 697 | DO j = nysg, nyng |
---|
| 698 | IF ( pch_index_ji(j,i) /= 0 ) THEN |
---|
| 699 | DO k = 0, pch_index_ji(j,i) |
---|
| 700 | pcm_transpirationrate_av(k,j,i) = pcm_transpirationrate_av(k,j,i) & |
---|
| 701 | / REAL( average_count_3d, KIND=wp ) |
---|
| 702 | ENDDO |
---|
| 703 | ENDIF |
---|
| 704 | ENDDO |
---|
| 705 | ENDDO |
---|
| 706 | ENDIF |
---|
| 707 | |
---|
| 708 | END SELECT |
---|
| 709 | |
---|
| 710 | ENDIF |
---|
| 711 | |
---|
[4216] | 712 | END SUBROUTINE pcm_3d_data_averaging |
---|
[4127] | 713 | |
---|
| 714 | !------------------------------------------------------------------------------! |
---|
| 715 | ! |
---|
| 716 | ! Description: |
---|
| 717 | ! ------------ |
---|
| 718 | !> Subroutine defining 3D output variables. |
---|
| 719 | !> Note, 3D plant-canopy output has it's own vertical output dimension, meaning |
---|
| 720 | !> that 3D output is relative to the model surface now rather than at the actual |
---|
| 721 | !> grid point where the plant canopy is located. |
---|
| 722 | !------------------------------------------------------------------------------! |
---|
[3014] | 723 | SUBROUTINE pcm_data_output_3d( av, variable, found, local_pf, fill_value, & |
---|
| 724 | nzb_do, nzt_do ) |
---|
[2209] | 725 | |
---|
[4216] | 726 | CHARACTER (LEN=*) :: variable !< treated variable |
---|
[2209] | 727 | |
---|
[4216] | 728 | INTEGER(iwp) :: av !< flag indicating instantaneous or averaged data output |
---|
| 729 | INTEGER(iwp) :: i !< grid index x-direction |
---|
| 730 | INTEGER(iwp) :: j !< grid index y-direction |
---|
| 731 | INTEGER(iwp) :: k !< grid index z-direction |
---|
[3014] | 732 | INTEGER(iwp) :: nzb_do !< lower limit of the data output (usually 0) |
---|
| 733 | INTEGER(iwp) :: nzt_do !< vertical upper limit of the data output (usually nz_do3d) |
---|
[2209] | 734 | |
---|
[4216] | 735 | LOGICAL :: found !< flag indicating if variable is found |
---|
[2209] | 736 | |
---|
[4216] | 737 | REAL(wp) :: fill_value !< fill value |
---|
| 738 | REAL(sp), DIMENSION(nxl:nxr,nys:nyn,nzb_do:nzt_do) :: local_pf !< data output array |
---|
[2209] | 739 | |
---|
| 740 | |
---|
| 741 | found = .TRUE. |
---|
| 742 | |
---|
[2696] | 743 | local_pf = REAL( fill_value, KIND = 4 ) |
---|
[2209] | 744 | |
---|
| 745 | SELECT CASE ( TRIM( variable ) ) |
---|
[4216] | 746 | ! |
---|
| 747 | !-- Note, to save memory arrays for heating are allocated from 0:pch_index. |
---|
| 748 | !-- Thus, output must be relative to these array indices. Further, check |
---|
| 749 | !-- whether the output is within the vertical output range, |
---|
[4220] | 750 | !-- i.e. nzb_do:nzt_do, which is necessary as local_pf is only allocated |
---|
| 751 | !-- for this index space. Note, plant-canopy output has a separate |
---|
| 752 | !-- vertical output coordinate zlad, so that output is mapped down to the |
---|
| 753 | !-- surface. |
---|
[4127] | 754 | CASE ( 'pcm_heatrate' ) |
---|
| 755 | IF ( av == 0 ) THEN |
---|
| 756 | DO i = nxl, nxr |
---|
| 757 | DO j = nys, nyn |
---|
[4360] | 758 | DO k = MAX( 1, nzb_do ), MIN( pch_index_ji(j,i), nzt_do ) |
---|
[4341] | 759 | local_pf(i,j,k) = pcm_heating_rate(k,j,i) |
---|
[4216] | 760 | ENDDO |
---|
[4127] | 761 | ENDDO |
---|
| 762 | ENDDO |
---|
| 763 | ELSE |
---|
| 764 | DO i = nxl, nxr |
---|
| 765 | DO j = nys, nyn |
---|
[4360] | 766 | DO k = MAX( 1, nzb_do ), MIN( pch_index_ji(j,i), nzt_do ) |
---|
[4220] | 767 | local_pf(i,j,k) = pcm_heatrate_av(k,j,i) |
---|
[4127] | 768 | ENDDO |
---|
| 769 | ENDDO |
---|
| 770 | ENDDO |
---|
| 771 | ENDIF |
---|
[3449] | 772 | |
---|
| 773 | CASE ( 'pcm_latentrate' ) |
---|
[4127] | 774 | IF ( av == 0 ) THEN |
---|
| 775 | DO i = nxl, nxr |
---|
| 776 | DO j = nys, nyn |
---|
[4360] | 777 | DO k = MAX( 1, nzb_do ), MIN( pch_index_ji(j,i), nzt_do ) |
---|
[4341] | 778 | local_pf(i,j,k) = pcm_latent_rate(k,j,i) |
---|
[4216] | 779 | ENDDO |
---|
[4127] | 780 | ENDDO |
---|
| 781 | ENDDO |
---|
| 782 | ELSE |
---|
| 783 | DO i = nxl, nxr |
---|
| 784 | DO j = nys, nyn |
---|
[4360] | 785 | DO k = MAX( 1, nzb_do ), MIN( pch_index_ji(j,i), nzt_do ) |
---|
[4220] | 786 | local_pf(i,j,k) = pcm_latentrate_av(k,j,i) |
---|
[4127] | 787 | ENDDO |
---|
| 788 | ENDDO |
---|
| 789 | ENDDO |
---|
| 790 | ENDIF |
---|
[3449] | 791 | |
---|
[4127] | 792 | CASE ( 'pcm_transpirationrate' ) |
---|
| 793 | IF ( av == 0 ) THEN |
---|
| 794 | DO i = nxl, nxr |
---|
| 795 | DO j = nys, nyn |
---|
[4360] | 796 | DO k = MAX( 1, nzb_do ), MIN( pch_index_ji(j,i), nzt_do ) |
---|
[4341] | 797 | local_pf(i,j,k) = pcm_transpiration_rate(k,j,i) |
---|
[4216] | 798 | ENDDO |
---|
[4127] | 799 | ENDDO |
---|
| 800 | ENDDO |
---|
| 801 | ELSE |
---|
| 802 | DO i = nxl, nxr |
---|
| 803 | DO j = nys, nyn |
---|
[4360] | 804 | DO k = MAX( 1, nzb_do ), MIN( pch_index_ji(j,i), nzt_do ) |
---|
[4220] | 805 | local_pf(i,j,k) = pcm_transpirationrate_av(k,j,i) |
---|
[4127] | 806 | ENDDO |
---|
| 807 | ENDDO |
---|
| 808 | ENDDO |
---|
| 809 | ENDIF |
---|
| 810 | |
---|
| 811 | CASE ( 'pcm_lad' ) |
---|
| 812 | IF ( av == 0 ) THEN |
---|
| 813 | DO i = nxl, nxr |
---|
| 814 | DO j = nys, nyn |
---|
[4360] | 815 | DO k = MAX( 1, nzb_do ), MIN( pch_index_ji(j,i), nzt_do ) |
---|
[4220] | 816 | local_pf(i,j,k) = lad_s(k,j,i) |
---|
[4216] | 817 | ENDDO |
---|
[4127] | 818 | ENDDO |
---|
| 819 | ENDDO |
---|
| 820 | ENDIF |
---|
| 821 | |
---|
[2209] | 822 | CASE DEFAULT |
---|
| 823 | found = .FALSE. |
---|
| 824 | |
---|
| 825 | END SELECT |
---|
| 826 | |
---|
| 827 | END SUBROUTINE pcm_data_output_3d |
---|
| 828 | |
---|
| 829 | !------------------------------------------------------------------------------! |
---|
| 830 | ! |
---|
| 831 | ! Description: |
---|
| 832 | ! ------------ |
---|
| 833 | !> Subroutine defining appropriate grid for netcdf variables. |
---|
| 834 | !> It is called from subroutine netcdf. |
---|
| 835 | !------------------------------------------------------------------------------! |
---|
| 836 | SUBROUTINE pcm_define_netcdf_grid( var, found, grid_x, grid_y, grid_z ) |
---|
| 837 | |
---|
| 838 | CHARACTER (LEN=*), INTENT(IN) :: var !< |
---|
| 839 | LOGICAL, INTENT(OUT) :: found !< |
---|
| 840 | CHARACTER (LEN=*), INTENT(OUT) :: grid_x !< |
---|
| 841 | CHARACTER (LEN=*), INTENT(OUT) :: grid_y !< |
---|
| 842 | CHARACTER (LEN=*), INTENT(OUT) :: grid_z !< |
---|
| 843 | |
---|
| 844 | found = .TRUE. |
---|
| 845 | |
---|
| 846 | ! |
---|
[4342] | 847 | !-- Check for the grid. zpc is zu(nzb:nzb+pch_index) |
---|
[2209] | 848 | SELECT CASE ( TRIM( var ) ) |
---|
| 849 | |
---|
[4341] | 850 | CASE ( 'pcm_heatrate', 'pcm_lad', 'pcm_transpirationrate', 'pcm_latentrate') |
---|
[2209] | 851 | grid_x = 'x' |
---|
| 852 | grid_y = 'y' |
---|
[4127] | 853 | grid_z = 'zpc' |
---|
[2209] | 854 | |
---|
| 855 | CASE DEFAULT |
---|
| 856 | found = .FALSE. |
---|
| 857 | grid_x = 'none' |
---|
| 858 | grid_y = 'none' |
---|
| 859 | grid_z = 'none' |
---|
| 860 | END SELECT |
---|
| 861 | |
---|
| 862 | END SUBROUTINE pcm_define_netcdf_grid |
---|
| 863 | |
---|
| 864 | |
---|
| 865 | !------------------------------------------------------------------------------! |
---|
| 866 | ! Description: |
---|
| 867 | ! ------------ |
---|
[1826] | 868 | !> Header output for plant canopy model |
---|
| 869 | !------------------------------------------------------------------------------! |
---|
[4362] | 870 | SUBROUTINE pcm_header ( io ) |
---|
[1826] | 871 | |
---|
[4362] | 872 | CHARACTER (LEN=10) :: coor_chr !< |
---|
[1826] | 873 | |
---|
[4362] | 874 | CHARACTER (LEN=86) :: coordinates !< |
---|
| 875 | CHARACTER (LEN=86) :: gradients !< |
---|
| 876 | CHARACTER (LEN=86) :: leaf_area_density !< |
---|
| 877 | CHARACTER (LEN=86) :: slices !< |
---|
[1826] | 878 | |
---|
[4362] | 879 | INTEGER(iwp) :: i !< |
---|
| 880 | INTEGER(iwp), INTENT(IN) :: io !< Unit of the output file |
---|
| 881 | INTEGER(iwp) :: k !< |
---|
| 882 | |
---|
| 883 | REAL(wp) :: canopy_height !< canopy height (in m) |
---|
| 884 | |
---|
| 885 | canopy_height = zw(pch_index) |
---|
[1826] | 886 | |
---|
[4362] | 887 | WRITE ( io, 1 ) canopy_mode, canopy_height, pch_index, & |
---|
| 888 | canopy_drag_coeff |
---|
| 889 | IF ( passive_scalar ) THEN |
---|
| 890 | WRITE ( io, 2 ) leaf_scalar_exch_coeff, & |
---|
| 891 | leaf_surface_conc |
---|
| 892 | ENDIF |
---|
[1826] | 893 | |
---|
| 894 | ! |
---|
[4362] | 895 | ! Heat flux at the top of vegetation |
---|
| 896 | WRITE ( io, 3 ) cthf |
---|
[1826] | 897 | |
---|
| 898 | ! |
---|
[4362] | 899 | ! Leaf area density profile, calculated either from given vertical |
---|
| 900 | ! gradients or from beta probability density function. |
---|
| 901 | IF ( .NOT. calc_beta_lad_profile ) THEN |
---|
[1826] | 902 | |
---|
[4362] | 903 | ! Building output strings, starting with surface value |
---|
| 904 | WRITE ( leaf_area_density, '(F7.4)' ) lad_surface |
---|
| 905 | gradients = '------' |
---|
| 906 | slices = ' 0' |
---|
| 907 | coordinates = ' 0.0' |
---|
| 908 | DO i = 1, UBOUND(lad_vertical_gradient_level_ind, DIM=1) |
---|
| 909 | IF ( lad_vertical_gradient_level_ind(i) /= -9999 ) THEN |
---|
[1826] | 910 | |
---|
[4362] | 911 | WRITE (coor_chr,'(F7.2)') lad(lad_vertical_gradient_level_ind(i)) |
---|
| 912 | leaf_area_density = TRIM( leaf_area_density ) // ' ' // TRIM( coor_chr ) |
---|
[1826] | 913 | |
---|
[4362] | 914 | WRITE (coor_chr,'(F7.2)') lad_vertical_gradient(i) |
---|
| 915 | gradients = TRIM( gradients ) // ' ' // TRIM( coor_chr ) |
---|
[1826] | 916 | |
---|
[4362] | 917 | WRITE (coor_chr,'(I7)') lad_vertical_gradient_level_ind(i) |
---|
| 918 | slices = TRIM( slices ) // ' ' // TRIM( coor_chr ) |
---|
[1826] | 919 | |
---|
[4362] | 920 | WRITE (coor_chr,'(F7.1)') lad_vertical_gradient_level(i) |
---|
| 921 | coordinates = TRIM( coordinates ) // ' ' // TRIM( coor_chr ) |
---|
| 922 | ELSE |
---|
| 923 | EXIT |
---|
| 924 | ENDIF |
---|
| 925 | ENDDO |
---|
[1826] | 926 | |
---|
[4362] | 927 | WRITE ( io, 4 ) TRIM( coordinates ), TRIM( leaf_area_density ), & |
---|
| 928 | TRIM( gradients ), TRIM( slices ) |
---|
[1826] | 929 | |
---|
[4362] | 930 | ELSE |
---|
| 931 | |
---|
| 932 | WRITE ( leaf_area_density, '(F7.4)' ) lad_surface |
---|
| 933 | coordinates = ' 0.0' |
---|
[1826] | 934 | |
---|
[4362] | 935 | DO k = 1, pch_index |
---|
[1826] | 936 | |
---|
[4362] | 937 | WRITE (coor_chr,'(F7.2)') lad(k) |
---|
| 938 | leaf_area_density = TRIM( leaf_area_density ) // ' ' // & |
---|
| 939 | TRIM( coor_chr ) |
---|
| 940 | |
---|
| 941 | WRITE (coor_chr,'(F7.1)') zu(k) |
---|
| 942 | coordinates = TRIM( coordinates ) // ' ' // TRIM( coor_chr ) |
---|
| 943 | |
---|
| 944 | ENDDO |
---|
| 945 | |
---|
| 946 | WRITE ( io, 5 ) TRIM( coordinates ), TRIM( leaf_area_density ), & |
---|
| 947 | alpha_lad, beta_lad, lai_beta |
---|
[1826] | 948 | |
---|
[4362] | 949 | ENDIF |
---|
[1826] | 950 | |
---|
[4362] | 951 | 1 FORMAT (//' Vegetation canopy (drag) model:'/ & |
---|
[1826] | 952 | ' ------------------------------'// & |
---|
| 953 | ' Canopy mode: ', A / & |
---|
| 954 | ' Canopy height: ',F6.2,'m (',I4,' grid points)' / & |
---|
| 955 | ' Leaf drag coefficient: ',F6.2 /) |
---|
[4362] | 956 | 2 FORMAT (/ ' Scalar exchange coefficient: ',F6.2 / & |
---|
[1826] | 957 | ' Scalar concentration at leaf surfaces in kg/m**3: ',F6.2 /) |
---|
[4362] | 958 | 3 FORMAT (' Predefined constant heatflux at the top of the vegetation: ', & |
---|
| 959 | F6.2, ' K m/s') |
---|
| 960 | 4 FORMAT (/ ' Characteristic levels of the leaf area density:'// & |
---|
[1826] | 961 | ' Height: ',A,' m'/ & |
---|
| 962 | ' Leaf area density: ',A,' m**2/m**3'/ & |
---|
| 963 | ' Gradient: ',A,' m**2/m**4'/ & |
---|
| 964 | ' Gridpoint: ',A) |
---|
[4362] | 965 | 5 FORMAT (//' Characteristic levels of the leaf area density and coefficients:'& |
---|
[1826] | 966 | // ' Height: ',A,' m'/ & |
---|
| 967 | ' Leaf area density: ',A,' m**2/m**3'/ & |
---|
| 968 | ' Coefficient alpha: ',F6.2 / & |
---|
| 969 | ' Coefficient beta: ',F6.2 / & |
---|
| 970 | ' Leaf area index: ',F6.2,' m**2/m**2' /) |
---|
| 971 | |
---|
| 972 | END SUBROUTINE pcm_header |
---|
| 973 | |
---|
| 974 | |
---|
| 975 | !------------------------------------------------------------------------------! |
---|
| 976 | ! Description: |
---|
| 977 | ! ------------ |
---|
[1682] | 978 | !> Initialization of the plant canopy model |
---|
[138] | 979 | !------------------------------------------------------------------------------! |
---|
[1826] | 980 | SUBROUTINE pcm_init |
---|
[1484] | 981 | |
---|
[4457] | 982 | USE exchange_horiz_mod, & |
---|
| 983 | ONLY: exchange_horiz |
---|
| 984 | |
---|
[2007] | 985 | INTEGER(iwp) :: i !< running index |
---|
| 986 | INTEGER(iwp) :: j !< running index |
---|
| 987 | INTEGER(iwp) :: k !< running index |
---|
[2232] | 988 | INTEGER(iwp) :: m !< running index |
---|
[1484] | 989 | |
---|
[4381] | 990 | LOGICAL :: lad_on_top = .FALSE. !< dummy flag to indicate that LAD is defined on a building roof |
---|
| 991 | |
---|
[4258] | 992 | REAL(wp) :: canopy_height !< canopy height for lad-profile construction |
---|
[2007] | 993 | REAL(wp) :: gradient !< gradient for lad-profile construction |
---|
[4258] | 994 | REAL(wp) :: int_bpdf !< vertical integral for lad-profile construction |
---|
| 995 | REAL(wp) :: lad_max !< maximum LAD value in the model domain, used to perform a check |
---|
[3241] | 996 | |
---|
[3885] | 997 | IF ( debug_output ) CALL debug_message( 'pcm_init', 'start' ) |
---|
[1484] | 998 | ! |
---|
| 999 | !-- Allocate one-dimensional arrays for the computation of the |
---|
| 1000 | !-- leaf area density (lad) profile |
---|
| 1001 | ALLOCATE( lad(0:nz+1), pre_lad(0:nz+1) ) |
---|
| 1002 | lad = 0.0_wp |
---|
| 1003 | pre_lad = 0.0_wp |
---|
| 1004 | |
---|
| 1005 | ! |
---|
[1826] | 1006 | !-- Set flag that indicates that the lad-profile shall be calculated by using |
---|
| 1007 | !-- a beta probability density function |
---|
| 1008 | IF ( alpha_lad /= 9999999.9_wp .AND. beta_lad /= 9999999.9_wp ) THEN |
---|
| 1009 | calc_beta_lad_profile = .TRUE. |
---|
| 1010 | ENDIF |
---|
| 1011 | |
---|
| 1012 | |
---|
| 1013 | ! |
---|
[1484] | 1014 | !-- Compute the profile of leaf area density used in the plant |
---|
| 1015 | !-- canopy model. The profile can either be constructed from |
---|
| 1016 | !-- prescribed vertical gradients of the leaf area density or by |
---|
| 1017 | !-- using a beta probability density function (see e.g. Markkanen et al., |
---|
| 1018 | !-- 2003: Boundary-Layer Meteorology, 106, 437-459) |
---|
| 1019 | IF ( .NOT. calc_beta_lad_profile ) THEN |
---|
| 1020 | |
---|
| 1021 | ! |
---|
| 1022 | !-- Use vertical gradients for lad-profile construction |
---|
| 1023 | i = 1 |
---|
| 1024 | gradient = 0.0_wp |
---|
| 1025 | |
---|
[4342] | 1026 | lad(0) = lad_surface |
---|
| 1027 | lad_vertical_gradient_level_ind(1) = 0 |
---|
[1484] | 1028 | |
---|
[4342] | 1029 | DO k = 1, pch_index |
---|
| 1030 | IF ( i < 11 ) THEN |
---|
| 1031 | IF ( lad_vertical_gradient_level(i) < zu(k) .AND. & |
---|
| 1032 | lad_vertical_gradient_level(i) >= 0.0_wp ) THEN |
---|
| 1033 | gradient = lad_vertical_gradient(i) |
---|
| 1034 | lad_vertical_gradient_level_ind(i) = k - 1 |
---|
| 1035 | i = i + 1 |
---|
[1484] | 1036 | ENDIF |
---|
[4342] | 1037 | ENDIF |
---|
| 1038 | IF ( gradient /= 0.0_wp ) THEN |
---|
| 1039 | IF ( k /= 1 ) THEN |
---|
| 1040 | lad(k) = lad(k-1) + dzu(k) * gradient |
---|
[1484] | 1041 | ELSE |
---|
[4342] | 1042 | lad(k) = lad_surface + dzu(k) * gradient |
---|
[1484] | 1043 | ENDIF |
---|
[4342] | 1044 | ELSE |
---|
| 1045 | lad(k) = lad(k-1) |
---|
| 1046 | ENDIF |
---|
| 1047 | ENDDO |
---|
[1484] | 1048 | |
---|
| 1049 | ! |
---|
| 1050 | !-- In case of no given leaf area density gradients, choose a vanishing |
---|
| 1051 | !-- gradient. This information is used for the HEADER and the RUN_CONTROL |
---|
| 1052 | !-- file. |
---|
| 1053 | IF ( lad_vertical_gradient_level(1) == -9999999.9_wp ) THEN |
---|
| 1054 | lad_vertical_gradient_level(1) = 0.0_wp |
---|
| 1055 | ENDIF |
---|
| 1056 | |
---|
| 1057 | ELSE |
---|
| 1058 | |
---|
| 1059 | ! |
---|
| 1060 | !-- Use beta function for lad-profile construction |
---|
| 1061 | int_bpdf = 0.0_wp |
---|
[3065] | 1062 | canopy_height = zw(pch_index) |
---|
[1484] | 1063 | |
---|
[2232] | 1064 | DO k = 0, pch_index |
---|
[1484] | 1065 | int_bpdf = int_bpdf + & |
---|
[1826] | 1066 | ( ( ( zw(k) / canopy_height )**( alpha_lad-1.0_wp ) ) * & |
---|
| 1067 | ( ( 1.0_wp - ( zw(k) / canopy_height ) )**( & |
---|
| 1068 | beta_lad-1.0_wp ) ) & |
---|
| 1069 | * ( ( zw(k+1)-zw(k) ) / canopy_height ) ) |
---|
[1484] | 1070 | ENDDO |
---|
| 1071 | |
---|
| 1072 | ! |
---|
| 1073 | !-- Preliminary lad profile (defined on w-grid) |
---|
[2232] | 1074 | DO k = 0, pch_index |
---|
[1826] | 1075 | pre_lad(k) = lai_beta * & |
---|
| 1076 | ( ( ( zw(k) / canopy_height )**( alpha_lad-1.0_wp ) ) & |
---|
| 1077 | * ( ( 1.0_wp - ( zw(k) / canopy_height ) )**( & |
---|
| 1078 | beta_lad-1.0_wp ) ) / int_bpdf & |
---|
| 1079 | ) / canopy_height |
---|
[1484] | 1080 | ENDDO |
---|
| 1081 | |
---|
| 1082 | ! |
---|
| 1083 | !-- Final lad profile (defined on scalar-grid level, since most prognostic |
---|
| 1084 | !-- quantities are defined there, hence, less interpolation is required |
---|
| 1085 | !-- when calculating the canopy tendencies) |
---|
| 1086 | lad(0) = pre_lad(0) |
---|
[2232] | 1087 | DO k = 1, pch_index |
---|
[1484] | 1088 | lad(k) = 0.5 * ( pre_lad(k-1) + pre_lad(k) ) |
---|
[4302] | 1089 | ENDDO |
---|
[1484] | 1090 | |
---|
| 1091 | ENDIF |
---|
| 1092 | |
---|
| 1093 | ! |
---|
[2213] | 1094 | !-- Allocate 3D-array for the leaf area density (lad_s). |
---|
[1484] | 1095 | ALLOCATE( lad_s(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 1096 | |
---|
| 1097 | ! |
---|
| 1098 | !-- Initialization of the canopy coverage in the model domain: |
---|
[4341] | 1099 | !-- Setting the parameter canopy_mode = 'homogeneous' initializes a canopy, which |
---|
[1484] | 1100 | !-- fully covers the domain surface |
---|
| 1101 | SELECT CASE ( TRIM( canopy_mode ) ) |
---|
| 1102 | |
---|
[4341] | 1103 | CASE( 'homogeneous' ) |
---|
[1484] | 1104 | |
---|
| 1105 | DO i = nxlg, nxrg |
---|
| 1106 | DO j = nysg, nyng |
---|
| 1107 | lad_s(:,j,i) = lad(:) |
---|
| 1108 | ENDDO |
---|
| 1109 | ENDDO |
---|
| 1110 | |
---|
[4341] | 1111 | CASE ( 'read_from_file' ) |
---|
[2007] | 1112 | ! |
---|
[4362] | 1113 | !-- Read plant canopy |
---|
| 1114 | IF ( input_pids_static ) THEN |
---|
| 1115 | ! |
---|
| 1116 | !-- Open the static input file |
---|
| 1117 | #if defined( __netcdf ) |
---|
| 1118 | CALL open_read_file( TRIM( input_file_static ) // & |
---|
| 1119 | TRIM( coupling_char ), & |
---|
| 1120 | pids_id ) |
---|
| 1121 | |
---|
| 1122 | CALL inquire_num_variables( pids_id, num_var_pids ) |
---|
| 1123 | ! |
---|
| 1124 | !-- Allocate memory to store variable names and read them |
---|
| 1125 | ALLOCATE( vars_pids(1:num_var_pids) ) |
---|
| 1126 | CALL inquire_variable_names( pids_id, vars_pids ) |
---|
| 1127 | ! |
---|
| 1128 | !-- Read leaf area density - resolved vegetation |
---|
| 1129 | IF ( check_existence( vars_pids, 'lad' ) ) THEN |
---|
| 1130 | leaf_area_density_f%from_file = .TRUE. |
---|
| 1131 | CALL get_attribute( pids_id, char_fill, & |
---|
| 1132 | leaf_area_density_f%fill, & |
---|
| 1133 | .FALSE., 'lad' ) |
---|
| 1134 | ! |
---|
| 1135 | !-- Inquire number of vertical vegetation layer |
---|
| 1136 | CALL get_dimension_length( pids_id, & |
---|
| 1137 | leaf_area_density_f%nz, & |
---|
| 1138 | 'zlad' ) |
---|
| 1139 | ! |
---|
| 1140 | !-- Allocate variable for leaf-area density |
---|
| 1141 | ALLOCATE( leaf_area_density_f%var & |
---|
| 1142 | (0:leaf_area_density_f%nz-1, & |
---|
| 1143 | nys:nyn,nxl:nxr) ) |
---|
| 1144 | |
---|
| 1145 | CALL get_variable( pids_id, 'lad', leaf_area_density_f%var, & |
---|
| 1146 | nxl, nxr, nys, nyn, & |
---|
| 1147 | 0, leaf_area_density_f%nz-1 ) |
---|
| 1148 | |
---|
| 1149 | ELSE |
---|
| 1150 | leaf_area_density_f%from_file = .FALSE. |
---|
| 1151 | ENDIF |
---|
| 1152 | ! |
---|
| 1153 | !-- Read basal area density - resolved vegetation |
---|
| 1154 | IF ( check_existence( vars_pids, 'bad' ) ) THEN |
---|
| 1155 | basal_area_density_f%from_file = .TRUE. |
---|
| 1156 | CALL get_attribute( pids_id, char_fill, & |
---|
| 1157 | basal_area_density_f%fill, & |
---|
| 1158 | .FALSE., 'bad' ) |
---|
| 1159 | ! |
---|
| 1160 | !-- Inquire number of vertical vegetation layer |
---|
| 1161 | CALL get_dimension_length( pids_id, & |
---|
| 1162 | basal_area_density_f%nz, & |
---|
| 1163 | 'zlad' ) |
---|
| 1164 | ! |
---|
| 1165 | !-- Allocate variable |
---|
| 1166 | ALLOCATE( basal_area_density_f%var & |
---|
| 1167 | (0:basal_area_density_f%nz-1, & |
---|
| 1168 | nys:nyn,nxl:nxr) ) |
---|
| 1169 | |
---|
| 1170 | CALL get_variable( pids_id, 'bad', basal_area_density_f%var,& |
---|
| 1171 | nxl, nxr, nys, nyn, & |
---|
| 1172 | 0, basal_area_density_f%nz-1 ) |
---|
| 1173 | ELSE |
---|
| 1174 | basal_area_density_f%from_file = .FALSE. |
---|
| 1175 | ENDIF |
---|
| 1176 | ! |
---|
| 1177 | !-- Read root area density - resolved vegetation |
---|
| 1178 | IF ( check_existence( vars_pids, 'root_area_dens_r' ) ) THEN |
---|
| 1179 | root_area_density_lad_f%from_file = .TRUE. |
---|
| 1180 | CALL get_attribute( pids_id, char_fill, & |
---|
| 1181 | root_area_density_lad_f%fill, & |
---|
| 1182 | .FALSE., 'root_area_dens_r' ) |
---|
| 1183 | ! |
---|
| 1184 | !-- Inquire number of vertical soil layers |
---|
| 1185 | CALL get_dimension_length( pids_id, & |
---|
| 1186 | root_area_density_lad_f%nz, & |
---|
| 1187 | 'zsoil' ) |
---|
| 1188 | ! |
---|
| 1189 | !-- Allocate variable |
---|
| 1190 | ALLOCATE( root_area_density_lad_f%var & |
---|
| 1191 | (0:root_area_density_lad_f%nz-1,& |
---|
| 1192 | nys:nyn,nxl:nxr) ) |
---|
| 1193 | |
---|
| 1194 | CALL get_variable( pids_id, 'root_area_dens_r', & |
---|
| 1195 | root_area_density_lad_f%var, & |
---|
| 1196 | nxl, nxr, nys, nyn, & |
---|
| 1197 | 0, root_area_density_lad_f%nz-1 ) |
---|
| 1198 | ELSE |
---|
| 1199 | root_area_density_lad_f%from_file = .FALSE. |
---|
| 1200 | ENDIF |
---|
| 1201 | |
---|
| 1202 | DEALLOCATE( vars_pids ) |
---|
| 1203 | ! |
---|
[4363] | 1204 | !-- Finally, close the input file and deallocate temporary array |
---|
| 1205 | CALL close_input_file( pids_id ) |
---|
[4362] | 1206 | #endif |
---|
[4363] | 1207 | ENDIF |
---|
| 1208 | |
---|
[4362] | 1209 | ! |
---|
[2696] | 1210 | !-- Initialize LAD with data from file. If LAD is given in NetCDF file, |
---|
| 1211 | !-- use these values, else take LAD profiles from ASCII file. |
---|
| 1212 | !-- Please note, in NetCDF file LAD is only given up to the maximum |
---|
| 1213 | !-- canopy top, indicated by leaf_area_density_f%nz. |
---|
| 1214 | lad_s = 0.0_wp |
---|
| 1215 | IF ( leaf_area_density_f%from_file ) THEN |
---|
| 1216 | ! |
---|
| 1217 | !-- Set also pch_index, used to be the upper bound of the vertical |
---|
| 1218 | !-- loops. Therefore, use the global top of the canopy layer. |
---|
| 1219 | pch_index = leaf_area_density_f%nz - 1 |
---|
| 1220 | |
---|
| 1221 | DO i = nxl, nxr |
---|
| 1222 | DO j = nys, nyn |
---|
| 1223 | DO k = 0, leaf_area_density_f%nz - 1 |
---|
[3864] | 1224 | IF ( leaf_area_density_f%var(k,j,i) /= & |
---|
| 1225 | leaf_area_density_f%fill ) & |
---|
[2696] | 1226 | lad_s(k,j,i) = leaf_area_density_f%var(k,j,i) |
---|
| 1227 | ENDDO |
---|
[4302] | 1228 | ! |
---|
| 1229 | !-- Check if resolved vegetation is mapped onto buildings. |
---|
[4314] | 1230 | !-- In general, this is allowed and also meaningful, e.g. |
---|
| 1231 | !-- when trees carry across roofs. However, due to the |
---|
| 1232 | !-- topography filtering, new building grid points can emerge |
---|
| 1233 | !-- at location where also plant canopy is defined. As a |
---|
| 1234 | !-- result, plant canopy is mapped on top of roofs, with |
---|
| 1235 | !-- siginficant impact on the downstream flow field and the |
---|
| 1236 | !-- nearby surface radiation. In order to avoid that |
---|
| 1237 | !-- plant canopy is mistakenly mapped onto building roofs, |
---|
| 1238 | !-- check for building grid points (bit 6) that emerge from |
---|
| 1239 | !-- the filtering (bit 4) and set LAD to zero at these |
---|
| 1240 | !-- artificially created building grid points. This case, |
---|
| 1241 | !-- an informative message is given. |
---|
[4302] | 1242 | IF ( ANY( lad_s(:,j,i) /= 0.0_wp ) .AND. & |
---|
[4346] | 1243 | ANY( BTEST( wall_flags_total_0(:,j,i), 6 ) ) .AND. & |
---|
| 1244 | ANY( BTEST( wall_flags_total_0(:,j,i), 4 ) ) ) THEN |
---|
[4302] | 1245 | lad_s(:,j,i) = 0.0_wp |
---|
[4381] | 1246 | lad_on_top = .TRUE. |
---|
| 1247 | ENDIF |
---|
| 1248 | ENDDO |
---|
| 1249 | ENDDO |
---|
| 1250 | #if defined( __parallel ) |
---|
| 1251 | CALL MPI_ALLREDUCE( MPI_IN_PLACE, lad_on_top, 1, MPI_LOGICAL, & |
---|
| 1252 | MPI_LOR, comm2d, ierr) |
---|
| 1253 | #endif |
---|
| 1254 | IF ( lad_on_top ) THEN |
---|
| 1255 | WRITE( message_string, * ) & |
---|
[4314] | 1256 | 'Resolved plant-canopy is ' // & |
---|
| 1257 | 'defined on top of an artificially '// & |
---|
[4381] | 1258 | 'created building grid point(s) ' // & |
---|
[4331] | 1259 | '(emerged from the filtering) - ' // & |
---|
[4381] | 1260 | 'LAD profile is omitted at this / ' // & |
---|
| 1261 | 'these grid point(s).' |
---|
| 1262 | CALL message( 'pcm_init', 'PA0313', 0, 0, 0, 6, 0 ) |
---|
| 1263 | ENDIF |
---|
[2696] | 1264 | CALL exchange_horiz( lad_s, nbgp ) |
---|
| 1265 | ! |
---|
| 1266 | ! ASCII file |
---|
[4342] | 1267 | !-- Initialize canopy parameters canopy_drag_coeff, |
---|
| 1268 | !-- leaf_scalar_exch_coeff, leaf_surface_conc |
---|
[2007] | 1269 | !-- from file which contains complete 3D data (separate vertical profiles for |
---|
| 1270 | !-- each location). |
---|
[2696] | 1271 | ELSE |
---|
| 1272 | CALL pcm_read_plant_canopy_3d |
---|
| 1273 | ENDIF |
---|
[2007] | 1274 | |
---|
[1484] | 1275 | CASE DEFAULT |
---|
| 1276 | ! |
---|
[2007] | 1277 | !-- The DEFAULT case is reached either if the parameter |
---|
| 1278 | !-- canopy mode contains a wrong character string or if the |
---|
| 1279 | !-- user has coded a special case in the user interface. |
---|
| 1280 | !-- There, the subroutine user_init_plant_canopy checks |
---|
| 1281 | !-- which of these two conditions applies. |
---|
| 1282 | CALL user_init_plant_canopy |
---|
[1484] | 1283 | |
---|
| 1284 | END SELECT |
---|
[2696] | 1285 | ! |
---|
[4258] | 1286 | !-- Check that at least one grid point has an LAD /= 0, else this may |
---|
| 1287 | !-- cause errors in the radiation model. |
---|
| 1288 | lad_max = MAXVAL( lad_s ) |
---|
| 1289 | #if defined( __parallel ) |
---|
| 1290 | CALL MPI_ALLREDUCE( MPI_IN_PLACE, lad_max, 1, MPI_REAL, MPI_MAX, & |
---|
| 1291 | comm2d, ierr) |
---|
| 1292 | #endif |
---|
| 1293 | IF ( lad_max <= 0.0_wp ) THEN |
---|
| 1294 | message_string = 'Plant-canopy model is switched-on but no ' // & |
---|
| 1295 | 'plant canopy is present in the model domain.' |
---|
| 1296 | CALL message( 'pcm_init', 'PA0685', 1, 2, 0, 6, 0 ) |
---|
| 1297 | ENDIF |
---|
| 1298 | |
---|
| 1299 | ! |
---|
[2696] | 1300 | !-- Initialize 2D index array indicating canopy top index. |
---|
| 1301 | ALLOCATE( pch_index_ji(nysg:nyng,nxlg:nxrg) ) |
---|
| 1302 | pch_index_ji = 0 |
---|
[4187] | 1303 | |
---|
[4361] | 1304 | DO i = nxlg, nxrg |
---|
| 1305 | DO j = nysg, nyng |
---|
[2696] | 1306 | DO k = 0, pch_index |
---|
| 1307 | IF ( lad_s(k,j,i) /= 0 ) pch_index_ji(j,i) = k |
---|
| 1308 | ENDDO |
---|
[1484] | 1309 | ! |
---|
[2696] | 1310 | !-- Check whether topography and local vegetation on top exceed |
---|
| 1311 | !-- height of the model domain. |
---|
[4356] | 1312 | IF ( topo_top_ind(j,i,0) + pch_index_ji(j,i) >= nzt + 1 ) THEN |
---|
[2696] | 1313 | message_string = 'Local vegetation height on top of ' // & |
---|
| 1314 | 'topography exceeds height of model domain.' |
---|
[4356] | 1315 | CALL message( 'pcm_init', 'PA0674', 2, 2, myid, 6, 0 ) |
---|
[2696] | 1316 | ENDIF |
---|
| 1317 | |
---|
| 1318 | ENDDO |
---|
| 1319 | ENDDO |
---|
[3497] | 1320 | ! |
---|
[3449] | 1321 | !-- Calculate global pch_index value (index of top of plant canopy from ground) |
---|
[3497] | 1322 | pch_index = MAXVAL( pch_index_ji ) |
---|
| 1323 | ! |
---|
[3449] | 1324 | !-- Exchange pch_index from all processors |
---|
| 1325 | #if defined( __parallel ) |
---|
[3497] | 1326 | CALL MPI_ALLREDUCE( MPI_IN_PLACE, pch_index, 1, MPI_INTEGER, & |
---|
| 1327 | MPI_MAX, comm2d, ierr) |
---|
[3449] | 1328 | #endif |
---|
[4360] | 1329 | ! |
---|
[4341] | 1330 | !-- Allocation of arrays pcm_heating_rate, pcm_transpiration_rate and pcm_latent_rate |
---|
| 1331 | ALLOCATE( pcm_heating_rate(0:pch_index,nysg:nyng,nxlg:nxrg) ) |
---|
| 1332 | pcm_heating_rate = 0.0_wp |
---|
[4221] | 1333 | |
---|
[3449] | 1334 | IF ( humidity ) THEN |
---|
[4341] | 1335 | ALLOCATE( pcm_transpiration_rate(0:pch_index,nysg:nyng,nxlg:nxrg) ) |
---|
| 1336 | pcm_transpiration_rate = 0.0_wp |
---|
| 1337 | ALLOCATE( pcm_latent_rate(0:pch_index,nysg:nyng,nxlg:nxrg) ) |
---|
| 1338 | pcm_latent_rate = 0.0_wp |
---|
[3449] | 1339 | ENDIF |
---|
[2696] | 1340 | ! |
---|
[2011] | 1341 | !-- Initialization of the canopy heat source distribution due to heating |
---|
| 1342 | !-- of the canopy layers by incoming solar radiation, in case that a non-zero |
---|
| 1343 | !-- value is set for the canopy top heat flux (cthf), which equals the |
---|
| 1344 | !-- available net radiation at canopy top. |
---|
| 1345 | !-- The heat source distribution is calculated by a decaying exponential |
---|
| 1346 | !-- function of the downward cumulative leaf area index (cum_lai_hf), |
---|
| 1347 | !-- assuming that the foliage inside the plant canopy is heated by solar |
---|
| 1348 | !-- radiation penetrating the canopy layers according to the distribution |
---|
| 1349 | !-- of net radiation as suggested by Brown & Covey (1966; Agric. Meteorol. 3, |
---|
| 1350 | !-- 73â96). This approach has been applied e.g. by Shaw & Schumann (1992; |
---|
[2213] | 1351 | !-- Bound.-Layer Meteorol. 61, 47â64). |
---|
[4341] | 1352 | !-- When using the radiation_interactions, canopy heating (pcm_heating_rate) |
---|
| 1353 | !-- and plant canopy transpiration (pcm_transpiration_rate, pcm_latent_rate) |
---|
[3449] | 1354 | !-- are calculated in the RTM after the calculation of radiation. |
---|
| 1355 | IF ( cthf /= 0.0_wp ) THEN |
---|
[2213] | 1356 | |
---|
[3449] | 1357 | ALLOCATE( cum_lai_hf(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
[1484] | 1358 | ! |
---|
[2011] | 1359 | !-- Piecewise calculation of the cumulative leaf area index by vertical |
---|
[1484] | 1360 | !-- integration of the leaf area density |
---|
| 1361 | cum_lai_hf(:,:,:) = 0.0_wp |
---|
| 1362 | DO i = nxlg, nxrg |
---|
| 1363 | DO j = nysg, nyng |
---|
[2696] | 1364 | DO k = pch_index_ji(j,i)-1, 0, -1 |
---|
| 1365 | IF ( k == pch_index_ji(j,i)-1 ) THEN |
---|
[1484] | 1366 | cum_lai_hf(k,j,i) = cum_lai_hf(k+1,j,i) + & |
---|
| 1367 | ( 0.5_wp * lad_s(k+1,j,i) * & |
---|
| 1368 | ( zw(k+1) - zu(k+1) ) ) + & |
---|
| 1369 | ( 0.5_wp * ( 0.5_wp * ( lad_s(k+1,j,i) + & |
---|
| 1370 | lad_s(k,j,i) ) + & |
---|
| 1371 | lad_s(k+1,j,i) ) * & |
---|
| 1372 | ( zu(k+1) - zw(k) ) ) |
---|
| 1373 | ELSE |
---|
| 1374 | cum_lai_hf(k,j,i) = cum_lai_hf(k+1,j,i) + & |
---|
| 1375 | ( 0.5_wp * ( 0.5_wp * ( lad_s(k+2,j,i) + & |
---|
| 1376 | lad_s(k+1,j,i) ) + & |
---|
| 1377 | lad_s(k+1,j,i) ) * & |
---|
| 1378 | ( zw(k+1) - zu(k+1) ) ) + & |
---|
| 1379 | ( 0.5_wp * ( 0.5_wp * ( lad_s(k+1,j,i) + & |
---|
| 1380 | lad_s(k,j,i) ) + & |
---|
| 1381 | lad_s(k+1,j,i) ) * & |
---|
| 1382 | ( zu(k+1) - zw(k) ) ) |
---|
| 1383 | ENDIF |
---|
| 1384 | ENDDO |
---|
| 1385 | ENDDO |
---|
| 1386 | ENDDO |
---|
| 1387 | |
---|
[4278] | 1388 | ! |
---|
[2232] | 1389 | !-- In areas with canopy the surface value of the canopy heat |
---|
| 1390 | !-- flux distribution overrides the surface heat flux (shf) |
---|
| 1391 | !-- Start with default surface type |
---|
| 1392 | DO m = 1, surf_def_h(0)%ns |
---|
[4278] | 1393 | i = surf_def_h(0)%i(m) |
---|
| 1394 | j = surf_def_h(0)%j(m) |
---|
[2232] | 1395 | IF ( cum_lai_hf(0,j,i) /= 0.0_wp ) & |
---|
| 1396 | surf_def_h(0)%shf(m) = cthf * exp( -ext_coef * cum_lai_hf(0,j,i) ) |
---|
| 1397 | ENDDO |
---|
[1484] | 1398 | ! |
---|
[2232] | 1399 | !-- Natural surfaces |
---|
| 1400 | DO m = 1, surf_lsm_h%ns |
---|
[4278] | 1401 | i = surf_lsm_h%i(m) |
---|
| 1402 | j = surf_lsm_h%j(m) |
---|
[2232] | 1403 | IF ( cum_lai_hf(0,j,i) /= 0.0_wp ) & |
---|
| 1404 | surf_lsm_h%shf(m) = cthf * exp( -ext_coef * cum_lai_hf(0,j,i) ) |
---|
| 1405 | ENDDO |
---|
| 1406 | ! |
---|
| 1407 | !-- Urban surfaces |
---|
| 1408 | DO m = 1, surf_usm_h%ns |
---|
[4278] | 1409 | i = surf_usm_h%i(m) |
---|
| 1410 | j = surf_usm_h%j(m) |
---|
[2232] | 1411 | IF ( cum_lai_hf(0,j,i) /= 0.0_wp ) & |
---|
| 1412 | surf_usm_h%shf(m) = cthf * exp( -ext_coef * cum_lai_hf(0,j,i) ) |
---|
| 1413 | ENDDO |
---|
| 1414 | ! |
---|
| 1415 | ! |
---|
[2011] | 1416 | !-- Calculation of the heating rate (K/s) within the different layers of |
---|
[2232] | 1417 | !-- the plant canopy. Calculation is only necessary in areas covered with |
---|
| 1418 | !-- canopy. |
---|
| 1419 | !-- Within the different canopy layers the plant-canopy heating |
---|
[4341] | 1420 | !-- rate (pcm_heating_rate) is calculated as the vertical |
---|
[2232] | 1421 | !-- divergence of the canopy heat fluxes at the top and bottom |
---|
| 1422 | !-- of the respective layer |
---|
[1484] | 1423 | DO i = nxlg, nxrg |
---|
| 1424 | DO j = nysg, nyng |
---|
[2696] | 1425 | DO k = 1, pch_index_ji(j,i) |
---|
[2232] | 1426 | IF ( cum_lai_hf(0,j,i) /= 0.0_wp ) THEN |
---|
[4341] | 1427 | pcm_heating_rate(k,j,i) = cthf * & |
---|
[3022] | 1428 | ( exp(-ext_coef*cum_lai_hf(k,j,i)) - & |
---|
[2232] | 1429 | exp(-ext_coef*cum_lai_hf(k-1,j,i) ) ) / dzw(k) |
---|
| 1430 | ENDIF |
---|
| 1431 | ENDDO |
---|
[1721] | 1432 | ENDDO |
---|
| 1433 | ENDDO |
---|
[1484] | 1434 | |
---|
| 1435 | ENDIF |
---|
| 1436 | |
---|
[3885] | 1437 | IF ( debug_output ) CALL debug_message( 'pcm_init', 'end' ) |
---|
[1484] | 1438 | |
---|
[1826] | 1439 | END SUBROUTINE pcm_init |
---|
[1484] | 1440 | |
---|
| 1441 | |
---|
[2007] | 1442 | !------------------------------------------------------------------------------! |
---|
| 1443 | ! Description: |
---|
| 1444 | ! ------------ |
---|
[2932] | 1445 | !> Parin for &plant_canopy_parameters for plant canopy model |
---|
[2007] | 1446 | !------------------------------------------------------------------------------! |
---|
| 1447 | SUBROUTINE pcm_parin |
---|
[1484] | 1448 | |
---|
[2007] | 1449 | CHARACTER (LEN=80) :: line !< dummy string that contains the current line of the parameter file |
---|
| 1450 | |
---|
[2932] | 1451 | NAMELIST /plant_canopy_parameters/ & |
---|
| 1452 | alpha_lad, beta_lad, canopy_drag_coeff, & |
---|
| 1453 | canopy_mode, cthf, & |
---|
[2977] | 1454 | lad_surface, lad_type_coef, & |
---|
[2932] | 1455 | lad_vertical_gradient, & |
---|
| 1456 | lad_vertical_gradient_level, & |
---|
| 1457 | lai_beta, & |
---|
| 1458 | leaf_scalar_exch_coeff, & |
---|
[3449] | 1459 | leaf_surface_conc, pch_index, & |
---|
| 1460 | plant_canopy_transpiration |
---|
[2932] | 1461 | |
---|
[2007] | 1462 | NAMELIST /canopy_par/ alpha_lad, beta_lad, canopy_drag_coeff, & |
---|
| 1463 | canopy_mode, cthf, & |
---|
[2977] | 1464 | lad_surface, lad_type_coef, & |
---|
[2007] | 1465 | lad_vertical_gradient, & |
---|
| 1466 | lad_vertical_gradient_level, & |
---|
| 1467 | lai_beta, & |
---|
| 1468 | leaf_scalar_exch_coeff, & |
---|
[3449] | 1469 | leaf_surface_conc, pch_index, & |
---|
| 1470 | plant_canopy_transpiration |
---|
[3246] | 1471 | |
---|
[2007] | 1472 | line = ' ' |
---|
[3246] | 1473 | |
---|
[2007] | 1474 | ! |
---|
[4258] | 1475 | !-- Try to find plant-canopy model package |
---|
[2007] | 1476 | REWIND ( 11 ) |
---|
| 1477 | line = ' ' |
---|
[3248] | 1478 | DO WHILE ( INDEX( line, '&plant_canopy_parameters' ) == 0 ) |
---|
[3246] | 1479 | READ ( 11, '(A)', END=12 ) line |
---|
[2007] | 1480 | ENDDO |
---|
| 1481 | BACKSPACE ( 11 ) |
---|
| 1482 | |
---|
| 1483 | ! |
---|
| 1484 | !-- Read user-defined namelist |
---|
[3246] | 1485 | READ ( 11, plant_canopy_parameters, ERR = 10 ) |
---|
[2932] | 1486 | |
---|
| 1487 | ! |
---|
[4258] | 1488 | !-- Set flag that indicates that the plant-canopy model is switched on |
---|
[2932] | 1489 | plant_canopy = .TRUE. |
---|
[3246] | 1490 | |
---|
| 1491 | GOTO 14 |
---|
| 1492 | |
---|
| 1493 | 10 BACKSPACE( 11 ) |
---|
[3248] | 1494 | READ( 11 , '(A)') line |
---|
| 1495 | CALL parin_fail_message( 'plant_canopy_parameters', line ) |
---|
[2932] | 1496 | ! |
---|
| 1497 | !-- Try to find old namelist |
---|
[3246] | 1498 | 12 REWIND ( 11 ) |
---|
[2932] | 1499 | line = ' ' |
---|
[3248] | 1500 | DO WHILE ( INDEX( line, '&canopy_par' ) == 0 ) |
---|
[3246] | 1501 | READ ( 11, '(A)', END=14 ) line |
---|
[2932] | 1502 | ENDDO |
---|
| 1503 | BACKSPACE ( 11 ) |
---|
| 1504 | |
---|
| 1505 | ! |
---|
| 1506 | !-- Read user-defined namelist |
---|
[3246] | 1507 | READ ( 11, canopy_par, ERR = 13, END = 14 ) |
---|
[2007] | 1508 | |
---|
[2932] | 1509 | message_string = 'namelist canopy_par is deprecated and will be ' // & |
---|
[3046] | 1510 | 'removed in near future. Please use namelist ' // & |
---|
[2932] | 1511 | 'plant_canopy_parameters instead' |
---|
| 1512 | CALL message( 'pcm_parin', 'PA0487', 0, 1, 0, 6, 0 ) |
---|
[3246] | 1513 | |
---|
[2007] | 1514 | ! |
---|
[4258] | 1515 | !-- Set flag that indicates that the plant-canopy model is switched on |
---|
[2007] | 1516 | plant_canopy = .TRUE. |
---|
| 1517 | |
---|
[3246] | 1518 | GOTO 14 |
---|
[2007] | 1519 | |
---|
[3246] | 1520 | 13 BACKSPACE( 11 ) |
---|
[3248] | 1521 | READ( 11 , '(A)') line |
---|
| 1522 | CALL parin_fail_message( 'canopy_par', line ) |
---|
[3246] | 1523 | |
---|
| 1524 | 14 CONTINUE |
---|
| 1525 | |
---|
[2007] | 1526 | END SUBROUTINE pcm_parin |
---|
| 1527 | |
---|
| 1528 | |
---|
[1484] | 1529 | !------------------------------------------------------------------------------! |
---|
| 1530 | ! Description: |
---|
| 1531 | ! ------------ |
---|
[2007] | 1532 | ! |
---|
| 1533 | !> Loads 3D plant canopy data from file. File format is as follows: |
---|
| 1534 | !> |
---|
| 1535 | !> num_levels |
---|
[2977] | 1536 | !> dtype,x,y,pctype,value(nzb),value(nzb+1), ... ,value(nzb+num_levels-1) |
---|
| 1537 | !> dtype,x,y,pctype,value(nzb),value(nzb+1), ... ,value(nzb+num_levels-1) |
---|
| 1538 | !> dtype,x,y,pctype,value(nzb),value(nzb+1), ... ,value(nzb+num_levels-1) |
---|
[2007] | 1539 | !> ... |
---|
| 1540 | !> |
---|
| 1541 | !> i.e. first line determines number of levels and further lines represent plant |
---|
| 1542 | !> canopy data, one line per column and variable. In each data line, |
---|
| 1543 | !> dtype represents variable to be set: |
---|
| 1544 | !> |
---|
| 1545 | !> dtype=1: leaf area density (lad_s) |
---|
[2213] | 1546 | !> dtype=2....n: some additional plant canopy input data quantity |
---|
[2007] | 1547 | !> |
---|
| 1548 | !> Zeros are added automatically above num_levels until top of domain. Any |
---|
| 1549 | !> non-specified (x,y) columns have zero values as default. |
---|
| 1550 | !------------------------------------------------------------------------------! |
---|
| 1551 | SUBROUTINE pcm_read_plant_canopy_3d |
---|
| 1552 | |
---|
[4457] | 1553 | USE exchange_horiz_mod, & |
---|
| 1554 | ONLY: exchange_horiz |
---|
| 1555 | |
---|
[2213] | 1556 | INTEGER(iwp) :: dtype !< type of input data (1=lad) |
---|
[2977] | 1557 | INTEGER(iwp) :: pctype !< type of plant canopy (deciduous,non-deciduous,...) |
---|
[2213] | 1558 | INTEGER(iwp) :: i, j !< running index |
---|
| 1559 | INTEGER(iwp) :: nzp !< number of vertical layers of plant canopy |
---|
[3337] | 1560 | INTEGER(iwp) :: nzpltop !< |
---|
| 1561 | INTEGER(iwp) :: nzpl !< |
---|
| 1562 | INTEGER(iwp) :: kk !< |
---|
[2213] | 1563 | |
---|
| 1564 | REAL(wp), DIMENSION(:), ALLOCATABLE :: col !< vertical column of input data |
---|
[2007] | 1565 | |
---|
[2213] | 1566 | ! |
---|
| 1567 | !-- Initialize lad_s array |
---|
| 1568 | lad_s = 0.0_wp |
---|
| 1569 | |
---|
| 1570 | ! |
---|
| 1571 | !-- Open and read plant canopy input data |
---|
[2977] | 1572 | OPEN(152, FILE='PLANT_CANOPY_DATA_3D' // TRIM( coupling_char ), & |
---|
| 1573 | ACCESS='SEQUENTIAL', ACTION='READ', STATUS='OLD', & |
---|
| 1574 | FORM='FORMATTED', ERR=515) |
---|
| 1575 | READ(152, *, ERR=516, END=517) nzp !< read first line = number of vertical layers |
---|
[3337] | 1576 | nzpltop = MIN(nzt+1, nzb+nzp-1) |
---|
| 1577 | nzpl = nzpltop - nzb + 1 !< no. of layers to assign |
---|
[2977] | 1578 | ALLOCATE( col(0:nzp-1) ) |
---|
[2007] | 1579 | |
---|
[2213] | 1580 | DO |
---|
[2977] | 1581 | READ(152, *, ERR=516, END=517) dtype, i, j, pctype, col(:) |
---|
| 1582 | IF ( i < nxlg .OR. i > nxrg .OR. j < nysg .OR. j > nyng ) CYCLE |
---|
| 1583 | |
---|
| 1584 | SELECT CASE (dtype) |
---|
| 1585 | CASE( 1 ) !< leaf area density |
---|
[2213] | 1586 | ! |
---|
[2977] | 1587 | !-- This is just the pure canopy layer assumed to be grounded to |
---|
| 1588 | !-- a flat domain surface. At locations where plant canopy sits |
---|
| 1589 | !-- on top of any kind of topography, the vertical plant column |
---|
| 1590 | !-- must be "lifted", which is done in SUBROUTINE pcm_tendency. |
---|
| 1591 | IF ( pctype < 0 .OR. pctype > 10 ) THEN !< incorrect plant canopy type |
---|
| 1592 | WRITE( message_string, * ) 'Incorrect type of plant canopy. ' // & |
---|
| 1593 | 'Allowed values 0 <= pctype <= 10, ' // & |
---|
| 1594 | 'but pctype is ', pctype |
---|
| 1595 | CALL message( 'pcm_read_plant_canopy_3d', 'PA0349', 1, 2, 0, 6, 0 ) |
---|
| 1596 | ENDIF |
---|
[4168] | 1597 | kk = topo_top_ind(j,i,0) |
---|
[3337] | 1598 | lad_s(nzb:nzpltop-kk, j, i) = col(kk:nzpl-1)*lad_type_coef(pctype) |
---|
[2977] | 1599 | CASE DEFAULT |
---|
| 1600 | WRITE(message_string, '(a,i2,a)') & |
---|
| 1601 | 'Unknown record type in file PLANT_CANOPY_DATA_3D: "', dtype, '"' |
---|
| 1602 | CALL message( 'pcm_read_plant_canopy_3d', 'PA0530', 1, 2, 0, 6, 0 ) |
---|
| 1603 | END SELECT |
---|
[2213] | 1604 | ENDDO |
---|
[2007] | 1605 | |
---|
[2213] | 1606 | 515 message_string = 'error opening file PLANT_CANOPY_DATA_3D' |
---|
| 1607 | CALL message( 'pcm_read_plant_canopy_3d', 'PA0531', 1, 2, 0, 6, 0 ) |
---|
[2007] | 1608 | |
---|
[2213] | 1609 | 516 message_string = 'error reading file PLANT_CANOPY_DATA_3D' |
---|
| 1610 | CALL message( 'pcm_read_plant_canopy_3d', 'PA0532', 1, 2, 0, 6, 0 ) |
---|
| 1611 | |
---|
| 1612 | 517 CLOSE(152) |
---|
[2977] | 1613 | DEALLOCATE( col ) |
---|
[2213] | 1614 | |
---|
| 1615 | CALL exchange_horiz( lad_s, nbgp ) |
---|
[2007] | 1616 | |
---|
| 1617 | END SUBROUTINE pcm_read_plant_canopy_3d |
---|
[4360] | 1618 | |
---|
[2007] | 1619 | !------------------------------------------------------------------------------! |
---|
| 1620 | ! Description: |
---|
| 1621 | ! ------------ |
---|
[4360] | 1622 | !> Subroutine reads local (subdomain) restart data |
---|
| 1623 | !------------------------------------------------------------------------------! |
---|
| 1624 | SUBROUTINE pcm_rrd_local( k, nxlf, nxlc, nxl_on_file, nxrf, nxrc, & |
---|
| 1625 | nxr_on_file, nynf, nync, nyn_on_file, nysf, & |
---|
[4361] | 1626 | nysc, nys_on_file, found ) |
---|
[4360] | 1627 | |
---|
| 1628 | INTEGER(iwp) :: k !< |
---|
| 1629 | INTEGER(iwp) :: nxlc !< |
---|
| 1630 | INTEGER(iwp) :: nxlf !< |
---|
| 1631 | INTEGER(iwp) :: nxl_on_file !< |
---|
| 1632 | INTEGER(iwp) :: nxrc !< |
---|
| 1633 | INTEGER(iwp) :: nxrf !< |
---|
| 1634 | INTEGER(iwp) :: nxr_on_file !< |
---|
| 1635 | INTEGER(iwp) :: nync !< |
---|
| 1636 | INTEGER(iwp) :: nynf !< |
---|
| 1637 | INTEGER(iwp) :: nyn_on_file !< |
---|
| 1638 | INTEGER(iwp) :: nysc !< |
---|
| 1639 | INTEGER(iwp) :: nysf !< |
---|
| 1640 | INTEGER(iwp) :: nys_on_file !< |
---|
| 1641 | |
---|
| 1642 | LOGICAL, INTENT(OUT) :: found |
---|
| 1643 | |
---|
| 1644 | REAL(wp), DIMENSION(0:pch_index, & |
---|
| 1645 | nys_on_file-nbgp:nyn_on_file+nbgp, & |
---|
| 1646 | nxl_on_file-nbgp:nxr_on_file+nbgp) :: tmp_3d2 !< temporary 3D array for entire vertical |
---|
| 1647 | !< extension of canopy layer |
---|
| 1648 | found = .TRUE. |
---|
| 1649 | |
---|
| 1650 | SELECT CASE ( restart_string(1:length) ) |
---|
| 1651 | |
---|
| 1652 | CASE ( 'pcm_heatrate_av' ) |
---|
| 1653 | IF ( .NOT. ALLOCATED( pcm_heatrate_av ) ) THEN |
---|
| 1654 | ALLOCATE( pcm_heatrate_av(0:pch_index,nysg:nyng,nxlg:nxrg) ) |
---|
| 1655 | pcm_heatrate_av = 0.0_wp |
---|
| 1656 | ENDIF |
---|
| 1657 | IF ( k == 1 ) READ ( 13 ) tmp_3d2 |
---|
| 1658 | pcm_heatrate_av(0:pch_index,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = & |
---|
| 1659 | tmp_3d2(0:pch_index,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp) |
---|
| 1660 | |
---|
| 1661 | CASE ( 'pcm_latentrate_av' ) |
---|
| 1662 | IF ( .NOT. ALLOCATED( pcm_latentrate_av ) ) THEN |
---|
| 1663 | ALLOCATE( pcm_latentrate_av(0:pch_index,nysg:nyng,nxlg:nxrg) ) |
---|
| 1664 | pcm_latentrate_av = 0.0_wp |
---|
| 1665 | ENDIF |
---|
| 1666 | IF ( k == 1 ) READ ( 13 ) tmp_3d2 |
---|
| 1667 | pcm_latentrate_av(0:pch_index,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = & |
---|
| 1668 | tmp_3d2(0:pch_index,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp) |
---|
| 1669 | |
---|
| 1670 | CASE ( 'pcm_transpirationrate_av' ) |
---|
| 1671 | IF ( .NOT. ALLOCATED( pcm_transpirationrate_av ) ) THEN |
---|
| 1672 | ALLOCATE( pcm_transpirationrate_av(0:pch_index,nysg:nyng,nxlg:nxrg) ) |
---|
| 1673 | pcm_transpirationrate_av = 0.0_wp |
---|
| 1674 | ENDIF |
---|
| 1675 | IF ( k == 1 ) READ ( 13 ) tmp_3d2 |
---|
| 1676 | pcm_transpirationrate_av(0:pch_index,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = & |
---|
| 1677 | tmp_3d2(0:pch_index,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp) |
---|
| 1678 | |
---|
| 1679 | CASE DEFAULT |
---|
| 1680 | |
---|
| 1681 | found = .FALSE. |
---|
| 1682 | |
---|
| 1683 | END SELECT |
---|
| 1684 | |
---|
| 1685 | END SUBROUTINE pcm_rrd_local |
---|
| 1686 | |
---|
| 1687 | !------------------------------------------------------------------------------! |
---|
| 1688 | ! Description: |
---|
| 1689 | ! ------------ |
---|
[1682] | 1690 | !> Calculation of the tendency terms, accounting for the effect of the plant |
---|
| 1691 | !> canopy on momentum and scalar quantities. |
---|
| 1692 | !> |
---|
| 1693 | !> The canopy is located where the leaf area density lad_s(k,j,i) > 0.0 |
---|
[1826] | 1694 | !> (defined on scalar grid), as initialized in subroutine pcm_init. |
---|
[1682] | 1695 | !> The lad on the w-grid is vertically interpolated from the surrounding |
---|
| 1696 | !> lad_s. The upper boundary of the canopy is defined on the w-grid at |
---|
| 1697 | !> k = pch_index. Here, the lad is zero. |
---|
| 1698 | !> |
---|
| 1699 | !> The canopy drag must be limited (previously accounted for by calculation of |
---|
| 1700 | !> a limiting canopy timestep for the determination of the maximum LES timestep |
---|
| 1701 | !> in subroutine timestep), since it is physically impossible that the canopy |
---|
| 1702 | !> drag alone can locally change the sign of a velocity component. This |
---|
| 1703 | !> limitation is realized by calculating preliminary tendencies and velocities. |
---|
| 1704 | !> It is subsequently checked if the preliminary new velocity has a different |
---|
| 1705 | !> sign than the current velocity. If so, the tendency is limited in a way that |
---|
| 1706 | !> the velocity can at maximum be reduced to zero by the canopy drag. |
---|
| 1707 | !> |
---|
| 1708 | !> |
---|
| 1709 | !> Call for all grid points |
---|
[1484] | 1710 | !------------------------------------------------------------------------------! |
---|
[1826] | 1711 | SUBROUTINE pcm_tendency( component ) |
---|
[138] | 1712 | |
---|
[1682] | 1713 | INTEGER(iwp) :: component !< prognostic variable (u,v,w,pt,q,e) |
---|
| 1714 | INTEGER(iwp) :: i !< running index |
---|
| 1715 | INTEGER(iwp) :: j !< running index |
---|
| 1716 | INTEGER(iwp) :: k !< running index |
---|
[1721] | 1717 | INTEGER(iwp) :: kk !< running index for flat lad arrays |
---|
[1484] | 1718 | |
---|
[4335] | 1719 | LOGICAL :: building_edge_e !< control flag indicating an eastward-facing building edge |
---|
| 1720 | LOGICAL :: building_edge_n !< control flag indicating a north-facing building edge |
---|
| 1721 | LOGICAL :: building_edge_s !< control flag indicating a south-facing building edge |
---|
| 1722 | LOGICAL :: building_edge_w !< control flag indicating a westward-facing building edge |
---|
| 1723 | |
---|
[1682] | 1724 | REAL(wp) :: ddt_3d !< inverse of the LES timestep (dt_3d) |
---|
| 1725 | REAL(wp) :: lad_local !< local lad value |
---|
| 1726 | REAL(wp) :: pre_tend !< preliminary tendency |
---|
| 1727 | REAL(wp) :: pre_u !< preliminary u-value |
---|
| 1728 | REAL(wp) :: pre_v !< preliminary v-value |
---|
| 1729 | REAL(wp) :: pre_w !< preliminary w-value |
---|
[1484] | 1730 | |
---|
| 1731 | |
---|
| 1732 | ddt_3d = 1.0_wp / dt_3d |
---|
[138] | 1733 | |
---|
| 1734 | ! |
---|
[1484] | 1735 | !-- Compute drag for the three velocity components and the SGS-TKE: |
---|
[138] | 1736 | SELECT CASE ( component ) |
---|
| 1737 | |
---|
| 1738 | ! |
---|
| 1739 | !-- u-component |
---|
| 1740 | CASE ( 1 ) |
---|
| 1741 | DO i = nxlu, nxr |
---|
| 1742 | DO j = nys, nyn |
---|
[2232] | 1743 | ! |
---|
[4335] | 1744 | !-- Set control flags indicating east- and westward-orientated |
---|
| 1745 | !-- building edges. Note, building_egde_w is set from the perspective |
---|
| 1746 | !-- of the potential rooftop grid point, while building_edge_e is |
---|
| 1747 | !-- is set from the perspective of the non-building grid point. |
---|
[4346] | 1748 | building_edge_w = ANY( BTEST( wall_flags_total_0(:,j,i), 6 ) )& |
---|
| 1749 | .AND. .NOT. ANY( BTEST( wall_flags_total_0(:,j,i-1), 6 ) ) |
---|
| 1750 | building_edge_e = ANY( BTEST( wall_flags_total_0(:,j,i-1), 6 ) )& |
---|
| 1751 | .AND. .NOT. ANY( BTEST( wall_flags_total_0(:,j,i), 6 ) ) |
---|
[4335] | 1752 | ! |
---|
[2232] | 1753 | !-- Determine topography-top index on u-grid |
---|
[4341] | 1754 | DO k = topo_top_ind(j,i,1)+1, topo_top_ind(j,i,1) + pch_index_ji(j,i) |
---|
[1484] | 1755 | |
---|
[4341] | 1756 | kk = k - topo_top_ind(j,i,1) !- lad arrays are defined flat |
---|
[1484] | 1757 | ! |
---|
| 1758 | !-- In order to create sharp boundaries of the plant canopy, |
---|
[4335] | 1759 | !-- the lad on the u-grid at index (k,j,i) is equal to lad_s(k,j,i), |
---|
| 1760 | !-- rather than being interpolated from the surrounding lad_s, |
---|
| 1761 | !-- because this would yield smaller lad at the canopy boundaries |
---|
| 1762 | !-- than inside of the canopy. |
---|
[1484] | 1763 | !-- For the same reason, the lad at the rightmost(i+1)canopy |
---|
[4335] | 1764 | !-- boundary on the u-grid equals lad_s(k,j,i), which is considered |
---|
| 1765 | !-- in the next if-statement. Note, at left-sided building edges |
---|
| 1766 | !-- this is not applied, here the LAD is equals the LAD at grid |
---|
| 1767 | !-- point (k,j,i), in order to avoid that LAD is mistakenly mapped |
---|
| 1768 | !-- on top of a roof where (usually) is no LAD is defined. |
---|
[1721] | 1769 | lad_local = lad_s(kk,j,i) |
---|
[4335] | 1770 | IF ( lad_local == 0.0_wp .AND. lad_s(kk,j,i-1) > 0.0_wp & |
---|
| 1771 | .AND. .NOT. building_edge_w ) lad_local = lad_s(kk,j,i-1) |
---|
| 1772 | ! |
---|
| 1773 | !-- In order to avoid that LAD is mistakenly considered at right- |
---|
| 1774 | !-- sided building edges (here the topography-top index for the |
---|
| 1775 | !-- u-component at index j,i is still on the building while the |
---|
| 1776 | !-- topography top for the scalar isn't), LAD is taken from grid |
---|
| 1777 | !-- point (j,i-1). |
---|
| 1778 | IF ( lad_local > 0.0_wp .AND. lad_s(kk,j,i-1) == 0.0_wp & |
---|
| 1779 | .AND. building_edge_e ) lad_local = lad_s(kk,j,i-1) |
---|
[1484] | 1780 | |
---|
| 1781 | pre_tend = 0.0_wp |
---|
| 1782 | pre_u = 0.0_wp |
---|
| 1783 | ! |
---|
| 1784 | !-- Calculate preliminary value (pre_tend) of the tendency |
---|
[4342] | 1785 | pre_tend = - canopy_drag_coeff * & |
---|
[1484] | 1786 | lad_local * & |
---|
| 1787 | SQRT( u(k,j,i)**2 + & |
---|
| 1788 | ( 0.25_wp * ( v(k,j,i-1) + & |
---|
| 1789 | v(k,j,i) + & |
---|
| 1790 | v(k,j+1,i) + & |
---|
| 1791 | v(k,j+1,i-1) ) & |
---|
| 1792 | )**2 + & |
---|
| 1793 | ( 0.25_wp * ( w(k-1,j,i-1) + & |
---|
| 1794 | w(k-1,j,i) + & |
---|
| 1795 | w(k,j,i-1) + & |
---|
| 1796 | w(k,j,i) ) & |
---|
| 1797 | )**2 & |
---|
| 1798 | ) * & |
---|
| 1799 | u(k,j,i) |
---|
| 1800 | |
---|
| 1801 | ! |
---|
| 1802 | !-- Calculate preliminary new velocity, based on pre_tend |
---|
| 1803 | pre_u = u(k,j,i) + dt_3d * pre_tend |
---|
| 1804 | ! |
---|
| 1805 | !-- Compare sign of old velocity and new preliminary velocity, |
---|
| 1806 | !-- and in case the signs are different, limit the tendency |
---|
| 1807 | IF ( SIGN(pre_u,u(k,j,i)) /= pre_u ) THEN |
---|
| 1808 | pre_tend = - u(k,j,i) * ddt_3d |
---|
| 1809 | ENDIF |
---|
| 1810 | ! |
---|
| 1811 | !-- Calculate final tendency |
---|
| 1812 | tend(k,j,i) = tend(k,j,i) + pre_tend |
---|
| 1813 | |
---|
[138] | 1814 | ENDDO |
---|
| 1815 | ENDDO |
---|
| 1816 | ENDDO |
---|
| 1817 | |
---|
| 1818 | ! |
---|
| 1819 | !-- v-component |
---|
| 1820 | CASE ( 2 ) |
---|
| 1821 | DO i = nxl, nxr |
---|
| 1822 | DO j = nysv, nyn |
---|
[2232] | 1823 | ! |
---|
[4335] | 1824 | !-- Set control flags indicating north- and southward-orientated |
---|
| 1825 | !-- building edges. Note, building_egde_s is set from the perspective |
---|
| 1826 | !-- of the potential rooftop grid point, while building_edge_n is |
---|
| 1827 | !-- is set from the perspective of the non-building grid point. |
---|
[4346] | 1828 | building_edge_s = ANY( BTEST( wall_flags_total_0(:,j,i), 6 ) )& |
---|
| 1829 | .AND. .NOT. ANY( BTEST( wall_flags_total_0(:,j-1,i), 6 ) ) |
---|
| 1830 | building_edge_n = ANY( BTEST( wall_flags_total_0(:,j-1,i), 6 ) )& |
---|
| 1831 | .AND. .NOT. ANY( BTEST( wall_flags_total_0(:,j,i), 6 ) ) |
---|
[4335] | 1832 | ! |
---|
[2232] | 1833 | !-- Determine topography-top index on v-grid |
---|
[4341] | 1834 | DO k = topo_top_ind(j,i,2)+1, topo_top_ind(j,i,2) + pch_index_ji(j,i) |
---|
[2317] | 1835 | |
---|
[4341] | 1836 | kk = k - topo_top_ind(j,i,2) !- lad arrays are defined flat |
---|
[1484] | 1837 | ! |
---|
| 1838 | !-- In order to create sharp boundaries of the plant canopy, |
---|
[4335] | 1839 | !-- the lad on the v-grid at index (k,j,i) is equal to lad_s(k,j,i), |
---|
| 1840 | !-- rather than being interpolated from the surrounding lad_s, |
---|
| 1841 | !-- because this would yield smaller lad at the canopy boundaries |
---|
| 1842 | !-- than inside of the canopy. |
---|
| 1843 | !-- For the same reason, the lad at the northmost(j+1)canopy |
---|
| 1844 | !-- boundary on the v-grid equals lad_s(k,j,i), which is considered |
---|
| 1845 | !-- in the next if-statement. Note, at left-sided building edges |
---|
| 1846 | !-- this is not applied, here the LAD is equals the LAD at grid |
---|
| 1847 | !-- point (k,j,i), in order to avoid that LAD is mistakenly mapped |
---|
| 1848 | !-- on top of a roof where (usually) is no LAD is defined. |
---|
[1721] | 1849 | lad_local = lad_s(kk,j,i) |
---|
[4335] | 1850 | IF ( lad_local == 0.0_wp .AND. lad_s(kk,j-1,i) > 0.0_wp & |
---|
| 1851 | .AND. .NOT. building_edge_s ) lad_local = lad_s(kk,j-1,i) |
---|
| 1852 | ! |
---|
| 1853 | !-- In order to avoid that LAD is mistakenly considered at right- |
---|
| 1854 | !-- sided building edges (here the topography-top index for the |
---|
| 1855 | !-- u-component at index j,i is still on the building while the |
---|
| 1856 | !-- topography top for the scalar isn't), LAD is taken from grid |
---|
| 1857 | !-- point (j,i-1). |
---|
| 1858 | IF ( lad_local > 0.0_wp .AND. lad_s(kk,j-1,i) == 0.0_wp & |
---|
| 1859 | .AND. building_edge_n ) lad_local = lad_s(kk,j-1,i) |
---|
[1484] | 1860 | |
---|
| 1861 | pre_tend = 0.0_wp |
---|
| 1862 | pre_v = 0.0_wp |
---|
| 1863 | ! |
---|
| 1864 | !-- Calculate preliminary value (pre_tend) of the tendency |
---|
[4342] | 1865 | pre_tend = - canopy_drag_coeff * & |
---|
[1484] | 1866 | lad_local * & |
---|
| 1867 | SQRT( ( 0.25_wp * ( u(k,j-1,i) + & |
---|
| 1868 | u(k,j-1,i+1) + & |
---|
| 1869 | u(k,j,i) + & |
---|
| 1870 | u(k,j,i+1) ) & |
---|
| 1871 | )**2 + & |
---|
| 1872 | v(k,j,i)**2 + & |
---|
| 1873 | ( 0.25_wp * ( w(k-1,j-1,i) + & |
---|
| 1874 | w(k-1,j,i) + & |
---|
| 1875 | w(k,j-1,i) + & |
---|
| 1876 | w(k,j,i) ) & |
---|
| 1877 | )**2 & |
---|
| 1878 | ) * & |
---|
| 1879 | v(k,j,i) |
---|
| 1880 | |
---|
| 1881 | ! |
---|
| 1882 | !-- Calculate preliminary new velocity, based on pre_tend |
---|
| 1883 | pre_v = v(k,j,i) + dt_3d * pre_tend |
---|
| 1884 | ! |
---|
| 1885 | !-- Compare sign of old velocity and new preliminary velocity, |
---|
| 1886 | !-- and in case the signs are different, limit the tendency |
---|
| 1887 | IF ( SIGN(pre_v,v(k,j,i)) /= pre_v ) THEN |
---|
| 1888 | pre_tend = - v(k,j,i) * ddt_3d |
---|
| 1889 | ELSE |
---|
| 1890 | pre_tend = pre_tend |
---|
| 1891 | ENDIF |
---|
| 1892 | ! |
---|
| 1893 | !-- Calculate final tendency |
---|
| 1894 | tend(k,j,i) = tend(k,j,i) + pre_tend |
---|
| 1895 | |
---|
[138] | 1896 | ENDDO |
---|
| 1897 | ENDDO |
---|
| 1898 | ENDDO |
---|
| 1899 | |
---|
| 1900 | ! |
---|
| 1901 | !-- w-component |
---|
| 1902 | CASE ( 3 ) |
---|
| 1903 | DO i = nxl, nxr |
---|
| 1904 | DO j = nys, nyn |
---|
[2232] | 1905 | ! |
---|
| 1906 | !-- Determine topography-top index on w-grid |
---|
[4341] | 1907 | DO k = topo_top_ind(j,i,3)+1, topo_top_ind(j,i,3) + pch_index_ji(j,i) - 1 |
---|
[2317] | 1908 | |
---|
[4341] | 1909 | kk = k - topo_top_ind(j,i,3) !- lad arrays are defined flat |
---|
[1484] | 1910 | |
---|
| 1911 | pre_tend = 0.0_wp |
---|
| 1912 | pre_w = 0.0_wp |
---|
| 1913 | ! |
---|
| 1914 | !-- Calculate preliminary value (pre_tend) of the tendency |
---|
[4342] | 1915 | pre_tend = - canopy_drag_coeff * & |
---|
[1484] | 1916 | (0.5_wp * & |
---|
[1721] | 1917 | ( lad_s(kk+1,j,i) + lad_s(kk,j,i) )) * & |
---|
[1484] | 1918 | SQRT( ( 0.25_wp * ( u(k,j,i) + & |
---|
| 1919 | u(k,j,i+1) + & |
---|
| 1920 | u(k+1,j,i) + & |
---|
| 1921 | u(k+1,j,i+1) ) & |
---|
| 1922 | )**2 + & |
---|
| 1923 | ( 0.25_wp * ( v(k,j,i) + & |
---|
| 1924 | v(k,j+1,i) + & |
---|
| 1925 | v(k+1,j,i) + & |
---|
| 1926 | v(k+1,j+1,i) ) & |
---|
| 1927 | )**2 + & |
---|
| 1928 | w(k,j,i)**2 & |
---|
| 1929 | ) * & |
---|
| 1930 | w(k,j,i) |
---|
| 1931 | ! |
---|
| 1932 | !-- Calculate preliminary new velocity, based on pre_tend |
---|
| 1933 | pre_w = w(k,j,i) + dt_3d * pre_tend |
---|
| 1934 | ! |
---|
| 1935 | !-- Compare sign of old velocity and new preliminary velocity, |
---|
| 1936 | !-- and in case the signs are different, limit the tendency |
---|
| 1937 | IF ( SIGN(pre_w,w(k,j,i)) /= pre_w ) THEN |
---|
| 1938 | pre_tend = - w(k,j,i) * ddt_3d |
---|
| 1939 | ELSE |
---|
| 1940 | pre_tend = pre_tend |
---|
| 1941 | ENDIF |
---|
| 1942 | ! |
---|
| 1943 | !-- Calculate final tendency |
---|
| 1944 | tend(k,j,i) = tend(k,j,i) + pre_tend |
---|
| 1945 | |
---|
[138] | 1946 | ENDDO |
---|
| 1947 | ENDDO |
---|
| 1948 | ENDDO |
---|
| 1949 | |
---|
| 1950 | ! |
---|
[153] | 1951 | !-- potential temperature |
---|
[138] | 1952 | CASE ( 4 ) |
---|
[3449] | 1953 | IF ( humidity ) THEN |
---|
| 1954 | DO i = nxl, nxr |
---|
| 1955 | DO j = nys, nyn |
---|
| 1956 | !-- Determine topography-top index on scalar-grid |
---|
[4341] | 1957 | DO k = topo_top_ind(j,i,0)+1, topo_top_ind(j,i,0) + pch_index_ji(j,i) |
---|
| 1958 | kk = k - topo_top_ind(j,i,0) !- lad arrays are defined flat |
---|
| 1959 | tend(k,j,i) = tend(k,j,i) + pcm_heating_rate(kk,j,i) - pcm_latent_rate(kk,j,i) |
---|
[3449] | 1960 | ENDDO |
---|
[153] | 1961 | ENDDO |
---|
| 1962 | ENDDO |
---|
[3449] | 1963 | ELSE |
---|
| 1964 | DO i = nxl, nxr |
---|
| 1965 | DO j = nys, nyn |
---|
| 1966 | !-- Determine topography-top index on scalar-grid |
---|
[4341] | 1967 | DO k = topo_top_ind(j,i,0)+1, topo_top_ind(j,i,0) + pch_index_ji(j,i) |
---|
| 1968 | kk = k - topo_top_ind(j,i,0) !- lad arrays are defined flat |
---|
| 1969 | tend(k,j,i) = tend(k,j,i) + pcm_heating_rate(kk,j,i) |
---|
[3449] | 1970 | ENDDO |
---|
| 1971 | ENDDO |
---|
| 1972 | ENDDO |
---|
| 1973 | ENDIF |
---|
[153] | 1974 | |
---|
| 1975 | ! |
---|
[1960] | 1976 | !-- humidity |
---|
[153] | 1977 | CASE ( 5 ) |
---|
| 1978 | DO i = nxl, nxr |
---|
| 1979 | DO j = nys, nyn |
---|
[2232] | 1980 | ! |
---|
| 1981 | !-- Determine topography-top index on scalar-grid |
---|
[4341] | 1982 | DO k = topo_top_ind(j,i,0)+1, topo_top_ind(j,i,0) + pch_index_ji(j,i) |
---|
[2317] | 1983 | |
---|
[4341] | 1984 | kk = k - topo_top_ind(j,i,0) !- lad arrays are defined flat |
---|
[2232] | 1985 | |
---|
[3449] | 1986 | IF ( .NOT. plant_canopy_transpiration ) THEN |
---|
[4341] | 1987 | ! pcm_transpiration_rate is calculated in radiation model |
---|
[3449] | 1988 | ! in case of plant_canopy_transpiration = .T. |
---|
| 1989 | ! to include also the dependecy to the radiation |
---|
| 1990 | ! in the plant canopy box |
---|
[4342] | 1991 | pcm_transpiration_rate(kk,j,i) = - leaf_scalar_exch_coeff & |
---|
| 1992 | * lad_s(kk,j,i) * & |
---|
| 1993 | SQRT( ( 0.5_wp * ( u(k,j,i) + & |
---|
| 1994 | u(k,j,i+1) ) & |
---|
| 1995 | )**2 + & |
---|
| 1996 | ( 0.5_wp * ( v(k,j,i) + & |
---|
| 1997 | v(k,j+1,i) ) & |
---|
| 1998 | )**2 + & |
---|
| 1999 | ( 0.5_wp * ( w(k-1,j,i) + & |
---|
| 2000 | w(k,j,i) ) & |
---|
| 2001 | )**2 & |
---|
| 2002 | ) * & |
---|
| 2003 | ( q(k,j,i) - leaf_surface_conc ) |
---|
[3449] | 2004 | ENDIF |
---|
| 2005 | |
---|
[4341] | 2006 | tend(k,j,i) = tend(k,j,i) + pcm_transpiration_rate(kk,j,i) |
---|
[153] | 2007 | ENDDO |
---|
| 2008 | ENDDO |
---|
| 2009 | ENDDO |
---|
| 2010 | |
---|
| 2011 | ! |
---|
| 2012 | !-- sgs-tke |
---|
| 2013 | CASE ( 6 ) |
---|
| 2014 | DO i = nxl, nxr |
---|
| 2015 | DO j = nys, nyn |
---|
[2232] | 2016 | ! |
---|
| 2017 | !-- Determine topography-top index on scalar-grid |
---|
[4341] | 2018 | DO k = topo_top_ind(j,i,0)+1, topo_top_ind(j,i,0) + pch_index_ji(j,i) |
---|
[2317] | 2019 | |
---|
[4341] | 2020 | kk = k - topo_top_ind(j,i,0) !- lad arrays are defined flat |
---|
[1484] | 2021 | tend(k,j,i) = tend(k,j,i) - & |
---|
[4342] | 2022 | 2.0_wp * canopy_drag_coeff * & |
---|
[1721] | 2023 | lad_s(kk,j,i) * & |
---|
[1484] | 2024 | SQRT( ( 0.5_wp * ( u(k,j,i) + & |
---|
| 2025 | u(k,j,i+1) ) & |
---|
| 2026 | )**2 + & |
---|
| 2027 | ( 0.5_wp * ( v(k,j,i) + & |
---|
| 2028 | v(k,j+1,i) ) & |
---|
| 2029 | )**2 + & |
---|
| 2030 | ( 0.5_wp * ( w(k,j,i) + & |
---|
| 2031 | w(k+1,j,i) ) & |
---|
| 2032 | )**2 & |
---|
| 2033 | ) * & |
---|
| 2034 | e(k,j,i) |
---|
[138] | 2035 | ENDDO |
---|
| 2036 | ENDDO |
---|
| 2037 | ENDDO |
---|
[1960] | 2038 | ! |
---|
| 2039 | !-- scalar concentration |
---|
| 2040 | CASE ( 7 ) |
---|
| 2041 | DO i = nxl, nxr |
---|
| 2042 | DO j = nys, nyn |
---|
[2232] | 2043 | ! |
---|
| 2044 | !-- Determine topography-top index on scalar-grid |
---|
[4341] | 2045 | DO k = topo_top_ind(j,i,0)+1, topo_top_ind(j,i,0) + pch_index_ji(j,i) |
---|
[2317] | 2046 | |
---|
[4341] | 2047 | kk = k - topo_top_ind(j,i,0) !- lad arrays are defined flat |
---|
[1960] | 2048 | tend(k,j,i) = tend(k,j,i) - & |
---|
[4342] | 2049 | leaf_scalar_exch_coeff * & |
---|
[1960] | 2050 | lad_s(kk,j,i) * & |
---|
| 2051 | SQRT( ( 0.5_wp * ( u(k,j,i) + & |
---|
| 2052 | u(k,j,i+1) ) & |
---|
| 2053 | )**2 + & |
---|
| 2054 | ( 0.5_wp * ( v(k,j,i) + & |
---|
| 2055 | v(k,j+1,i) ) & |
---|
| 2056 | )**2 + & |
---|
| 2057 | ( 0.5_wp * ( w(k-1,j,i) + & |
---|
| 2058 | w(k,j,i) ) & |
---|
| 2059 | )**2 & |
---|
| 2060 | ) * & |
---|
[4342] | 2061 | ( s(k,j,i) - leaf_surface_conc ) |
---|
[1960] | 2062 | ENDDO |
---|
| 2063 | ENDDO |
---|
| 2064 | ENDDO |
---|
[1484] | 2065 | |
---|
| 2066 | |
---|
[1960] | 2067 | |
---|
[138] | 2068 | CASE DEFAULT |
---|
| 2069 | |
---|
[257] | 2070 | WRITE( message_string, * ) 'wrong component: ', component |
---|
[1826] | 2071 | CALL message( 'pcm_tendency', 'PA0279', 1, 2, 0, 6, 0 ) |
---|
[138] | 2072 | |
---|
| 2073 | END SELECT |
---|
| 2074 | |
---|
[1826] | 2075 | END SUBROUTINE pcm_tendency |
---|
[138] | 2076 | |
---|
| 2077 | |
---|
| 2078 | !------------------------------------------------------------------------------! |
---|
[1484] | 2079 | ! Description: |
---|
| 2080 | ! ------------ |
---|
[1682] | 2081 | !> Calculation of the tendency terms, accounting for the effect of the plant |
---|
| 2082 | !> canopy on momentum and scalar quantities. |
---|
| 2083 | !> |
---|
| 2084 | !> The canopy is located where the leaf area density lad_s(k,j,i) > 0.0 |
---|
[1826] | 2085 | !> (defined on scalar grid), as initialized in subroutine pcm_init. |
---|
[1682] | 2086 | !> The lad on the w-grid is vertically interpolated from the surrounding |
---|
| 2087 | !> lad_s. The upper boundary of the canopy is defined on the w-grid at |
---|
| 2088 | !> k = pch_index. Here, the lad is zero. |
---|
| 2089 | !> |
---|
| 2090 | !> The canopy drag must be limited (previously accounted for by calculation of |
---|
| 2091 | !> a limiting canopy timestep for the determination of the maximum LES timestep |
---|
| 2092 | !> in subroutine timestep), since it is physically impossible that the canopy |
---|
| 2093 | !> drag alone can locally change the sign of a velocity component. This |
---|
| 2094 | !> limitation is realized by calculating preliminary tendencies and velocities. |
---|
| 2095 | !> It is subsequently checked if the preliminary new velocity has a different |
---|
| 2096 | !> sign than the current velocity. If so, the tendency is limited in a way that |
---|
| 2097 | !> the velocity can at maximum be reduced to zero by the canopy drag. |
---|
| 2098 | !> |
---|
| 2099 | !> |
---|
| 2100 | !> Call for grid point i,j |
---|
[138] | 2101 | !------------------------------------------------------------------------------! |
---|
[1826] | 2102 | SUBROUTINE pcm_tendency_ij( i, j, component ) |
---|
[138] | 2103 | |
---|
[1682] | 2104 | INTEGER(iwp) :: component !< prognostic variable (u,v,w,pt,q,e) |
---|
| 2105 | INTEGER(iwp) :: i !< running index |
---|
| 2106 | INTEGER(iwp) :: j !< running index |
---|
| 2107 | INTEGER(iwp) :: k !< running index |
---|
[1721] | 2108 | INTEGER(iwp) :: kk !< running index for flat lad arrays |
---|
[138] | 2109 | |
---|
[4314] | 2110 | LOGICAL :: building_edge_e !< control flag indicating an eastward-facing building edge |
---|
| 2111 | LOGICAL :: building_edge_n !< control flag indicating a north-facing building edge |
---|
| 2112 | LOGICAL :: building_edge_s !< control flag indicating a south-facing building edge |
---|
| 2113 | LOGICAL :: building_edge_w !< control flag indicating a westward-facing building edge |
---|
| 2114 | |
---|
[1682] | 2115 | REAL(wp) :: ddt_3d !< inverse of the LES timestep (dt_3d) |
---|
| 2116 | REAL(wp) :: lad_local !< local lad value |
---|
| 2117 | REAL(wp) :: pre_tend !< preliminary tendency |
---|
| 2118 | REAL(wp) :: pre_u !< preliminary u-value |
---|
| 2119 | REAL(wp) :: pre_v !< preliminary v-value |
---|
| 2120 | REAL(wp) :: pre_w !< preliminary w-value |
---|
[1484] | 2121 | |
---|
| 2122 | |
---|
| 2123 | ddt_3d = 1.0_wp / dt_3d |
---|
[138] | 2124 | ! |
---|
[1484] | 2125 | !-- Compute drag for the three velocity components and the SGS-TKE |
---|
[142] | 2126 | SELECT CASE ( component ) |
---|
[138] | 2127 | |
---|
| 2128 | ! |
---|
[142] | 2129 | !-- u-component |
---|
[1484] | 2130 | CASE ( 1 ) |
---|
[2232] | 2131 | ! |
---|
[4314] | 2132 | !-- Set control flags indicating east- and westward-orientated |
---|
| 2133 | !-- building edges. Note, building_egde_w is set from the perspective |
---|
| 2134 | !-- of the potential rooftop grid point, while building_edge_e is |
---|
| 2135 | !-- is set from the perspective of the non-building grid point. |
---|
[4346] | 2136 | building_edge_w = ANY( BTEST( wall_flags_total_0(:,j,i), 6 ) ) .AND. & |
---|
| 2137 | .NOT. ANY( BTEST( wall_flags_total_0(:,j,i-1), 6 ) ) |
---|
| 2138 | building_edge_e = ANY( BTEST( wall_flags_total_0(:,j,i-1), 6 ) ) .AND. & |
---|
| 2139 | .NOT. ANY( BTEST( wall_flags_total_0(:,j,i), 6 ) ) |
---|
[4314] | 2140 | ! |
---|
[2232] | 2141 | !-- Determine topography-top index on u-grid |
---|
[4341] | 2142 | DO k = topo_top_ind(j,i,1) + 1, topo_top_ind(j,i,1) + pch_index_ji(j,i) |
---|
[2317] | 2143 | |
---|
[4341] | 2144 | kk = k - topo_top_ind(j,i,1) !- lad arrays are defined flat |
---|
[138] | 2145 | |
---|
| 2146 | ! |
---|
[1484] | 2147 | !-- In order to create sharp boundaries of the plant canopy, |
---|
| 2148 | !-- the lad on the u-grid at index (k,j,i) is equal to lad_s(k,j,i), |
---|
| 2149 | !-- rather than being interpolated from the surrounding lad_s, |
---|
| 2150 | !-- because this would yield smaller lad at the canopy boundaries |
---|
| 2151 | !-- than inside of the canopy. |
---|
| 2152 | !-- For the same reason, the lad at the rightmost(i+1)canopy |
---|
[4314] | 2153 | !-- boundary on the u-grid equals lad_s(k,j,i), which is considered |
---|
| 2154 | !-- in the next if-statement. Note, at left-sided building edges |
---|
| 2155 | !-- this is not applied, here the LAD is equals the LAD at grid |
---|
| 2156 | !-- point (k,j,i), in order to avoid that LAD is mistakenly mapped |
---|
| 2157 | !-- on top of a roof where (usually) is no LAD is defined. |
---|
[1721] | 2158 | lad_local = lad_s(kk,j,i) |
---|
[4314] | 2159 | IF ( lad_local == 0.0_wp .AND. lad_s(kk,j,i-1) > 0.0_wp .AND. & |
---|
| 2160 | .NOT. building_edge_w ) lad_local = lad_s(kk,j,i-1) |
---|
| 2161 | ! |
---|
| 2162 | !-- In order to avoid that LAD is mistakenly considered at right- |
---|
| 2163 | !-- sided building edges (here the topography-top index for the |
---|
| 2164 | !-- u-component at index j,i is still on the building while the |
---|
| 2165 | !-- topography top for the scalar isn't), LAD is taken from grid |
---|
| 2166 | !-- point (j,i-1). |
---|
| 2167 | IF ( lad_local > 0.0_wp .AND. lad_s(kk,j,i-1) == 0.0_wp .AND. & |
---|
| 2168 | building_edge_e ) lad_local = lad_s(kk,j,i-1) |
---|
[1484] | 2169 | |
---|
| 2170 | pre_tend = 0.0_wp |
---|
| 2171 | pre_u = 0.0_wp |
---|
| 2172 | ! |
---|
| 2173 | !-- Calculate preliminary value (pre_tend) of the tendency |
---|
[4342] | 2174 | pre_tend = - canopy_drag_coeff * & |
---|
[1484] | 2175 | lad_local * & |
---|
| 2176 | SQRT( u(k,j,i)**2 + & |
---|
| 2177 | ( 0.25_wp * ( v(k,j,i-1) + & |
---|
| 2178 | v(k,j,i) + & |
---|
| 2179 | v(k,j+1,i) + & |
---|
| 2180 | v(k,j+1,i-1) ) & |
---|
| 2181 | )**2 + & |
---|
| 2182 | ( 0.25_wp * ( w(k-1,j,i-1) + & |
---|
| 2183 | w(k-1,j,i) + & |
---|
| 2184 | w(k,j,i-1) + & |
---|
| 2185 | w(k,j,i) ) & |
---|
| 2186 | )**2 & |
---|
| 2187 | ) * & |
---|
| 2188 | u(k,j,i) |
---|
| 2189 | |
---|
| 2190 | ! |
---|
| 2191 | !-- Calculate preliminary new velocity, based on pre_tend |
---|
| 2192 | pre_u = u(k,j,i) + dt_3d * pre_tend |
---|
| 2193 | ! |
---|
| 2194 | !-- Compare sign of old velocity and new preliminary velocity, |
---|
| 2195 | !-- and in case the signs are different, limit the tendency |
---|
| 2196 | IF ( SIGN(pre_u,u(k,j,i)) /= pre_u ) THEN |
---|
| 2197 | pre_tend = - u(k,j,i) * ddt_3d |
---|
| 2198 | ELSE |
---|
| 2199 | pre_tend = pre_tend |
---|
| 2200 | ENDIF |
---|
| 2201 | ! |
---|
| 2202 | !-- Calculate final tendency |
---|
| 2203 | tend(k,j,i) = tend(k,j,i) + pre_tend |
---|
| 2204 | ENDDO |
---|
| 2205 | |
---|
| 2206 | |
---|
| 2207 | ! |
---|
[142] | 2208 | !-- v-component |
---|
[1484] | 2209 | CASE ( 2 ) |
---|
[2232] | 2210 | ! |
---|
[4314] | 2211 | !-- Set control flags indicating north- and southward-orientated |
---|
| 2212 | !-- building edges. Note, building_egde_s is set from the perspective |
---|
| 2213 | !-- of the potential rooftop grid point, while building_edge_n is |
---|
| 2214 | !-- is set from the perspective of the non-building grid point. |
---|
[4346] | 2215 | building_edge_s = ANY( BTEST( wall_flags_total_0(:,j,i), 6 ) ) .AND. & |
---|
| 2216 | .NOT. ANY( BTEST( wall_flags_total_0(:,j-1,i), 6 ) ) |
---|
| 2217 | building_edge_n = ANY( BTEST( wall_flags_total_0(:,j-1,i), 6 ) ) .AND. & |
---|
| 2218 | .NOT. ANY( BTEST( wall_flags_total_0(:,j,i), 6 ) ) |
---|
[4314] | 2219 | ! |
---|
[2232] | 2220 | !-- Determine topography-top index on v-grid |
---|
[4341] | 2221 | DO k = topo_top_ind(j,i,2) + 1, topo_top_ind(j,i,2) + pch_index_ji(j,i) |
---|
[138] | 2222 | |
---|
[4341] | 2223 | kk = k - topo_top_ind(j,i,2) !- lad arrays are defined flat |
---|
[138] | 2224 | ! |
---|
[1484] | 2225 | !-- In order to create sharp boundaries of the plant canopy, |
---|
| 2226 | !-- the lad on the v-grid at index (k,j,i) is equal to lad_s(k,j,i), |
---|
| 2227 | !-- rather than being interpolated from the surrounding lad_s, |
---|
| 2228 | !-- because this would yield smaller lad at the canopy boundaries |
---|
| 2229 | !-- than inside of the canopy. |
---|
| 2230 | !-- For the same reason, the lad at the northmost(j+1)canopy |
---|
[4314] | 2231 | !-- boundary on the v-grid equals lad_s(k,j,i), which is considered |
---|
| 2232 | !-- in the next if-statement. Note, at left-sided building edges |
---|
| 2233 | !-- this is not applied, here the LAD is equals the LAD at grid |
---|
| 2234 | !-- point (k,j,i), in order to avoid that LAD is mistakenly mapped |
---|
| 2235 | !-- on top of a roof where (usually) is no LAD is defined. |
---|
[1721] | 2236 | lad_local = lad_s(kk,j,i) |
---|
[4314] | 2237 | IF ( lad_local == 0.0_wp .AND. lad_s(kk,j-1,i) > 0.0_wp .AND. & |
---|
| 2238 | .NOT. building_edge_s ) lad_local = lad_s(kk,j-1,i) |
---|
| 2239 | ! |
---|
| 2240 | !-- In order to avoid that LAD is mistakenly considered at right- |
---|
| 2241 | !-- sided building edges (here the topography-top index for the |
---|
| 2242 | !-- u-component at index j,i is still on the building while the |
---|
| 2243 | !-- topography top for the scalar isn't), LAD is taken from grid |
---|
| 2244 | !-- point (j,i-1). |
---|
| 2245 | IF ( lad_local > 0.0_wp .AND. lad_s(kk,j-1,i) == 0.0_wp .AND. & |
---|
| 2246 | building_edge_n ) lad_local = lad_s(kk,j-1,i) |
---|
[1484] | 2247 | |
---|
| 2248 | pre_tend = 0.0_wp |
---|
| 2249 | pre_v = 0.0_wp |
---|
| 2250 | ! |
---|
| 2251 | !-- Calculate preliminary value (pre_tend) of the tendency |
---|
[4342] | 2252 | pre_tend = - canopy_drag_coeff * & |
---|
[1484] | 2253 | lad_local * & |
---|
| 2254 | SQRT( ( 0.25_wp * ( u(k,j-1,i) + & |
---|
| 2255 | u(k,j-1,i+1) + & |
---|
| 2256 | u(k,j,i) + & |
---|
| 2257 | u(k,j,i+1) ) & |
---|
| 2258 | )**2 + & |
---|
| 2259 | v(k,j,i)**2 + & |
---|
| 2260 | ( 0.25_wp * ( w(k-1,j-1,i) + & |
---|
| 2261 | w(k-1,j,i) + & |
---|
| 2262 | w(k,j-1,i) + & |
---|
| 2263 | w(k,j,i) ) & |
---|
| 2264 | )**2 & |
---|
| 2265 | ) * & |
---|
| 2266 | v(k,j,i) |
---|
| 2267 | |
---|
| 2268 | ! |
---|
| 2269 | !-- Calculate preliminary new velocity, based on pre_tend |
---|
| 2270 | pre_v = v(k,j,i) + dt_3d * pre_tend |
---|
| 2271 | ! |
---|
| 2272 | !-- Compare sign of old velocity and new preliminary velocity, |
---|
| 2273 | !-- and in case the signs are different, limit the tendency |
---|
| 2274 | IF ( SIGN(pre_v,v(k,j,i)) /= pre_v ) THEN |
---|
| 2275 | pre_tend = - v(k,j,i) * ddt_3d |
---|
| 2276 | ELSE |
---|
| 2277 | pre_tend = pre_tend |
---|
| 2278 | ENDIF |
---|
| 2279 | ! |
---|
| 2280 | !-- Calculate final tendency |
---|
| 2281 | tend(k,j,i) = tend(k,j,i) + pre_tend |
---|
| 2282 | ENDDO |
---|
| 2283 | |
---|
| 2284 | |
---|
| 2285 | ! |
---|
[142] | 2286 | !-- w-component |
---|
[1484] | 2287 | CASE ( 3 ) |
---|
[2232] | 2288 | ! |
---|
| 2289 | !-- Determine topography-top index on w-grid |
---|
[4341] | 2290 | DO k = topo_top_ind(j,i,3) + 1, topo_top_ind(j,i,3) + pch_index_ji(j,i) - 1 |
---|
[2317] | 2291 | |
---|
[4341] | 2292 | kk = k - topo_top_ind(j,i,3) !- lad arrays are defined flat |
---|
[138] | 2293 | |
---|
[1484] | 2294 | pre_tend = 0.0_wp |
---|
| 2295 | pre_w = 0.0_wp |
---|
[138] | 2296 | ! |
---|
[1484] | 2297 | !-- Calculate preliminary value (pre_tend) of the tendency |
---|
[4342] | 2298 | pre_tend = - canopy_drag_coeff * & |
---|
[1484] | 2299 | (0.5_wp * & |
---|
[1721] | 2300 | ( lad_s(kk+1,j,i) + lad_s(kk,j,i) )) * & |
---|
[1484] | 2301 | SQRT( ( 0.25_wp * ( u(k,j,i) + & |
---|
| 2302 | u(k,j,i+1) + & |
---|
| 2303 | u(k+1,j,i) + & |
---|
| 2304 | u(k+1,j,i+1) ) & |
---|
| 2305 | )**2 + & |
---|
| 2306 | ( 0.25_wp * ( v(k,j,i) + & |
---|
| 2307 | v(k,j+1,i) + & |
---|
| 2308 | v(k+1,j,i) + & |
---|
| 2309 | v(k+1,j+1,i) ) & |
---|
| 2310 | )**2 + & |
---|
| 2311 | w(k,j,i)**2 & |
---|
| 2312 | ) * & |
---|
| 2313 | w(k,j,i) |
---|
| 2314 | ! |
---|
| 2315 | !-- Calculate preliminary new velocity, based on pre_tend |
---|
| 2316 | pre_w = w(k,j,i) + dt_3d * pre_tend |
---|
| 2317 | ! |
---|
| 2318 | !-- Compare sign of old velocity and new preliminary velocity, |
---|
| 2319 | !-- and in case the signs are different, limit the tendency |
---|
| 2320 | IF ( SIGN(pre_w,w(k,j,i)) /= pre_w ) THEN |
---|
| 2321 | pre_tend = - w(k,j,i) * ddt_3d |
---|
| 2322 | ELSE |
---|
| 2323 | pre_tend = pre_tend |
---|
| 2324 | ENDIF |
---|
| 2325 | ! |
---|
| 2326 | !-- Calculate final tendency |
---|
| 2327 | tend(k,j,i) = tend(k,j,i) + pre_tend |
---|
| 2328 | ENDDO |
---|
| 2329 | |
---|
| 2330 | ! |
---|
[153] | 2331 | !-- potential temperature |
---|
| 2332 | CASE ( 4 ) |
---|
[2232] | 2333 | ! |
---|
| 2334 | !-- Determine topography-top index on scalar grid |
---|
[3449] | 2335 | IF ( humidity ) THEN |
---|
[4341] | 2336 | DO k = topo_top_ind(j,i,0) + 1, topo_top_ind(j,i,0) + pch_index_ji(j,i) |
---|
| 2337 | kk = k - topo_top_ind(j,i,0) !- lad arrays are defined flat |
---|
| 2338 | tend(k,j,i) = tend(k,j,i) + pcm_heating_rate(kk,j,i) - & |
---|
| 2339 | pcm_latent_rate(kk,j,i) |
---|
[3449] | 2340 | ENDDO |
---|
| 2341 | ELSE |
---|
[4341] | 2342 | DO k = topo_top_ind(j,i,0) + 1, topo_top_ind(j,i,0) + pch_index_ji(j,i) |
---|
| 2343 | kk = k - topo_top_ind(j,i,0) !- lad arrays are defined flat |
---|
| 2344 | tend(k,j,i) = tend(k,j,i) + pcm_heating_rate(kk,j,i) |
---|
[3449] | 2345 | ENDDO |
---|
| 2346 | ENDIF |
---|
[153] | 2347 | |
---|
| 2348 | ! |
---|
[1960] | 2349 | !-- humidity |
---|
[153] | 2350 | CASE ( 5 ) |
---|
[2232] | 2351 | ! |
---|
| 2352 | !-- Determine topography-top index on scalar grid |
---|
[4341] | 2353 | DO k = topo_top_ind(j,i,0) + 1, topo_top_ind(j,i,0) + pch_index_ji(j,i) |
---|
| 2354 | kk = k - topo_top_ind(j,i,0) !- lad arrays are defined flat |
---|
[3449] | 2355 | IF ( .NOT. plant_canopy_transpiration ) THEN |
---|
[4341] | 2356 | ! pcm_transpiration_rate is calculated in radiation model |
---|
[3449] | 2357 | ! in case of plant_canopy_transpiration = .T. |
---|
| 2358 | ! to include also the dependecy to the radiation |
---|
| 2359 | ! in the plant canopy box |
---|
[4342] | 2360 | pcm_transpiration_rate(kk,j,i) = - leaf_scalar_exch_coeff & |
---|
[3582] | 2361 | * lad_s(kk,j,i) * & |
---|
| 2362 | SQRT( ( 0.5_wp * ( u(k,j,i) + & |
---|
| 2363 | u(k,j,i+1) ) & |
---|
| 2364 | )**2 + & |
---|
| 2365 | ( 0.5_wp * ( v(k,j,i) + & |
---|
| 2366 | v(k,j+1,i) ) & |
---|
| 2367 | )**2 + & |
---|
| 2368 | ( 0.5_wp * ( w(k-1,j,i) + & |
---|
| 2369 | w(k,j,i) ) & |
---|
| 2370 | )**2 & |
---|
| 2371 | ) * & |
---|
[4342] | 2372 | ( q(k,j,i) - leaf_surface_conc ) |
---|
[3449] | 2373 | ENDIF |
---|
[2232] | 2374 | |
---|
[4341] | 2375 | tend(k,j,i) = tend(k,j,i) + pcm_transpiration_rate(kk,j,i) |
---|
[3014] | 2376 | |
---|
[153] | 2377 | ENDDO |
---|
| 2378 | |
---|
| 2379 | ! |
---|
[142] | 2380 | !-- sgs-tke |
---|
[1484] | 2381 | CASE ( 6 ) |
---|
[2232] | 2382 | ! |
---|
| 2383 | !-- Determine topography-top index on scalar grid |
---|
[4341] | 2384 | DO k = topo_top_ind(j,i,0) + 1, topo_top_ind(j,i,0) + pch_index_ji(j,i) |
---|
[2317] | 2385 | |
---|
[4341] | 2386 | kk = k - topo_top_ind(j,i,0) |
---|
[1484] | 2387 | tend(k,j,i) = tend(k,j,i) - & |
---|
[4342] | 2388 | 2.0_wp * canopy_drag_coeff * & |
---|
[1721] | 2389 | lad_s(kk,j,i) * & |
---|
[1484] | 2390 | SQRT( ( 0.5_wp * ( u(k,j,i) + & |
---|
| 2391 | u(k,j,i+1) ) & |
---|
| 2392 | )**2 + & |
---|
| 2393 | ( 0.5_wp * ( v(k,j,i) + & |
---|
| 2394 | v(k,j+1,i) ) & |
---|
| 2395 | )**2 + & |
---|
| 2396 | ( 0.5_wp * ( w(k,j,i) + & |
---|
| 2397 | w(k+1,j,i) ) & |
---|
| 2398 | )**2 & |
---|
| 2399 | ) * & |
---|
| 2400 | e(k,j,i) |
---|
| 2401 | ENDDO |
---|
[1960] | 2402 | |
---|
| 2403 | ! |
---|
| 2404 | !-- scalar concentration |
---|
| 2405 | CASE ( 7 ) |
---|
[2232] | 2406 | ! |
---|
| 2407 | !-- Determine topography-top index on scalar grid |
---|
[4341] | 2408 | DO k = topo_top_ind(j,i,0) + 1, topo_top_ind(j,i,0) + pch_index_ji(j,i) |
---|
[2317] | 2409 | |
---|
[4341] | 2410 | kk = k - topo_top_ind(j,i,0) |
---|
[1960] | 2411 | tend(k,j,i) = tend(k,j,i) - & |
---|
[4342] | 2412 | leaf_scalar_exch_coeff * & |
---|
[1960] | 2413 | lad_s(kk,j,i) * & |
---|
| 2414 | SQRT( ( 0.5_wp * ( u(k,j,i) + & |
---|
| 2415 | u(k,j,i+1) ) & |
---|
| 2416 | )**2 + & |
---|
| 2417 | ( 0.5_wp * ( v(k,j,i) + & |
---|
| 2418 | v(k,j+1,i) ) & |
---|
| 2419 | )**2 + & |
---|
| 2420 | ( 0.5_wp * ( w(k-1,j,i) + & |
---|
| 2421 | w(k,j,i) ) & |
---|
| 2422 | )**2 & |
---|
| 2423 | ) * & |
---|
[4342] | 2424 | ( s(k,j,i) - leaf_surface_conc ) |
---|
[1960] | 2425 | ENDDO |
---|
[138] | 2426 | |
---|
[142] | 2427 | CASE DEFAULT |
---|
[138] | 2428 | |
---|
[257] | 2429 | WRITE( message_string, * ) 'wrong component: ', component |
---|
[1826] | 2430 | CALL message( 'pcm_tendency', 'PA0279', 1, 2, 0, 6, 0 ) |
---|
[138] | 2431 | |
---|
[142] | 2432 | END SELECT |
---|
[138] | 2433 | |
---|
[1826] | 2434 | END SUBROUTINE pcm_tendency_ij |
---|
[138] | 2435 | |
---|
[4360] | 2436 | !------------------------------------------------------------------------------! |
---|
| 2437 | ! Description: |
---|
| 2438 | ! ------------ |
---|
| 2439 | !> Subroutine writes local (subdomain) restart data |
---|
| 2440 | !------------------------------------------------------------------------------! |
---|
| 2441 | SUBROUTINE pcm_wrd_local |
---|
[2007] | 2442 | |
---|
[4495] | 2443 | IF ( TRIM( restart_data_format_output ) == 'fortran_binary' ) THEN |
---|
[4360] | 2444 | |
---|
[4495] | 2445 | IF ( ALLOCATED( pcm_heatrate_av ) ) THEN |
---|
| 2446 | CALL wrd_write_string( 'pcm_heatrate_av' ) |
---|
| 2447 | WRITE ( 14 ) pcm_heatrate_av |
---|
| 2448 | ENDIF |
---|
[4360] | 2449 | |
---|
[4495] | 2450 | IF ( ALLOCATED( pcm_latentrate_av ) ) THEN |
---|
| 2451 | CALL wrd_write_string( 'pcm_latentrate_av' ) |
---|
| 2452 | WRITE ( 14 ) pcm_latentrate_av |
---|
| 2453 | ENDIF |
---|
| 2454 | |
---|
| 2455 | IF ( ALLOCATED( pcm_transpirationrate_av ) ) THEN |
---|
| 2456 | CALL wrd_write_string( 'pcm_transpirationrate_av' ) |
---|
| 2457 | WRITE ( 14 ) pcm_transpirationrate_av |
---|
| 2458 | ENDIF |
---|
| 2459 | |
---|
| 2460 | ELSEIF ( TRIM( restart_data_format_output ) == 'mpi' ) THEN |
---|
| 2461 | |
---|
| 2462 | IF ( ALLOCATED( pcm_heatrate_av ) ) CALL wrd_mpi_io( 'pcm_heatrate_av', pcm_heatrate_av ) |
---|
| 2463 | IF ( ALLOCATED( pcm_latentrate_av ) ) THEN |
---|
| 2464 | CALL wrd_mpi_io( 'pcm_latentrate_av', pcm_latentrate_av ) |
---|
| 2465 | ENDIF |
---|
| 2466 | IF ( ALLOCATED( pcm_transpirationrate_av ) ) THEN |
---|
| 2467 | CALL wrd_write_string( 'pcm_transpirationrate_av', pcm_transpirationrate_av ) |
---|
| 2468 | ENDIF |
---|
| 2469 | |
---|
[4360] | 2470 | ENDIF |
---|
| 2471 | |
---|
| 2472 | END SUBROUTINE pcm_wrd_local |
---|
| 2473 | |
---|
| 2474 | |
---|
[138] | 2475 | END MODULE plant_canopy_model_mod |
---|