[1826] | 1 | !> @file plant_canopy_model_mod.f90 |
---|
[2000] | 2 | !------------------------------------------------------------------------------! |
---|
[1036] | 3 | ! This file is part of PALM. |
---|
| 4 | ! |
---|
[2000] | 5 | ! PALM is free software: you can redistribute it and/or modify it under the |
---|
| 6 | ! terms of the GNU General Public License as published by the Free Software |
---|
| 7 | ! Foundation, either version 3 of the License, or (at your option) any later |
---|
| 8 | ! version. |
---|
[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 | ! |
---|
[2101] | 17 | ! Copyright 1997-2017 Leibniz Universitaet Hannover |
---|
[2000] | 18 | !------------------------------------------------------------------------------! |
---|
[1036] | 19 | ! |
---|
[257] | 20 | ! Current revisions: |
---|
[138] | 21 | ! ----------------- |
---|
[2214] | 22 | ! |
---|
[2318] | 23 | ! |
---|
[2214] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: plant_canopy_model_mod.f90 2318 2017-07-20 17:27:44Z sward $ |
---|
[2318] | 27 | ! Get topography top index via Function call |
---|
| 28 | ! |
---|
| 29 | ! 2317 2017-07-20 17:27:19Z suehring |
---|
[2274] | 30 | ! Changed error messages |
---|
| 31 | ! |
---|
| 32 | ! 2233 2017-05-30 18:08:54Z suehring |
---|
[2214] | 33 | ! |
---|
[2233] | 34 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
| 35 | ! Adjustments to new topography concept |
---|
| 36 | ! |
---|
[2214] | 37 | ! 2213 2017-04-24 15:10:35Z kanani |
---|
[2213] | 38 | ! Bugfix: exchange of ghost points in array pc_heating_rate needed for output |
---|
| 39 | ! of pcm_heatrate, onetime ghost point exchange of lad_s after initialization. |
---|
| 40 | ! Formatting and clean-up of subroutine pcm_read_plant_canopy_3d, |
---|
| 41 | ! minor re-organization of canopy-heating initialization. |
---|
[2008] | 42 | ! |
---|
[2210] | 43 | ! 2209 2017-04-19 09:34:46Z kanani |
---|
| 44 | ! Added 3d output of leaf area density (pcm_lad) and canopy |
---|
| 45 | ! heat rate (pcm_heatrate) |
---|
| 46 | ! |
---|
[2025] | 47 | ! 2024 2016-10-12 16:42:37Z kanani |
---|
| 48 | ! Added missing lad_s initialization |
---|
| 49 | ! |
---|
[2012] | 50 | ! 2011 2016-09-19 17:29:57Z kanani |
---|
| 51 | ! Renamed canopy_heat_flux to pc_heating_rate, since the original meaning/ |
---|
| 52 | ! calculation of the quantity has changed, related to the urban surface model |
---|
| 53 | ! and similar future applications. |
---|
| 54 | ! |
---|
[2008] | 55 | ! 2007 2016-08-24 15:47:17Z kanani |
---|
[2007] | 56 | ! Added SUBROUTINE pcm_read_plant_canopy_3d for reading 3d plant canopy data |
---|
| 57 | ! from file (new case canopy_mode=read_from_file_3d) in the course of |
---|
| 58 | ! introduction of urban surface model, |
---|
| 59 | ! introduced variable ext_coef, |
---|
| 60 | ! resorted SUBROUTINEs to alphabetical order |
---|
[1827] | 61 | ! |
---|
[2001] | 62 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
| 63 | ! Forced header and separation lines into 80 columns |
---|
| 64 | ! |
---|
[1961] | 65 | ! 1960 2016-07-12 16:34:24Z suehring |
---|
| 66 | ! Separate humidity and passive scalar |
---|
| 67 | ! |
---|
[1954] | 68 | ! 1953 2016-06-21 09:28:42Z suehring |
---|
| 69 | ! Bugfix, lad_s and lad must be public |
---|
| 70 | ! |
---|
[1827] | 71 | ! 1826 2016-04-07 12:01:39Z maronga |
---|
| 72 | ! Further modularization |
---|
| 73 | ! |
---|
[1722] | 74 | ! 1721 2015-11-16 12:56:48Z raasch |
---|
| 75 | ! bugfixes: shf is reduced in areas covered with canopy only, |
---|
| 76 | ! canopy is set on top of topography |
---|
| 77 | ! |
---|
[1683] | 78 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 79 | ! Code annotations made doxygen readable |
---|
| 80 | ! |
---|
[1485] | 81 | ! 1484 2014-10-21 10:53:05Z kanani |
---|
[1484] | 82 | ! Changes due to new module structure of the plant canopy model: |
---|
| 83 | ! module plant_canopy_model_mod now contains a subroutine for the |
---|
[1826] | 84 | ! initialization of the canopy model (pcm_init), |
---|
[1484] | 85 | ! limitation of the canopy drag (previously accounted for by calculation of |
---|
| 86 | ! a limiting canopy timestep for the determination of the maximum LES timestep |
---|
| 87 | ! in subroutine timestep) is now realized by the calculation of pre-tendencies |
---|
[1826] | 88 | ! and preliminary velocities in subroutine pcm_tendency, |
---|
| 89 | ! some redundant MPI communication removed in subroutine pcm_init |
---|
[1484] | 90 | ! (was previously in init_3d_model), |
---|
| 91 | ! unnecessary 3d-arrays lad_u, lad_v, lad_w removed - lad information on the |
---|
| 92 | ! respective grid is now provided only by lad_s (e.g. in the calculation of |
---|
| 93 | ! the tendency terms or of cum_lai_hf), |
---|
| 94 | ! drag_coefficient, lai, leaf_surface_concentration, |
---|
| 95 | ! scalar_exchange_coefficient, sec and sls renamed to canopy_drag_coeff, |
---|
| 96 | ! cum_lai_hf, leaf_surface_conc, leaf_scalar_exch_coeff, lsec and lsc, |
---|
| 97 | ! respectively, |
---|
| 98 | ! unnecessary 3d-arrays cdc, lsc and lsec now defined as single-value constants, |
---|
| 99 | ! USE-statements and ONLY-lists modified accordingly |
---|
[1341] | 100 | ! |
---|
| 101 | ! 1340 2014-03-25 19:45:13Z kanani |
---|
| 102 | ! REAL constants defined as wp-kind |
---|
| 103 | ! |
---|
[1321] | 104 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 105 | ! ONLY-attribute added to USE-statements, |
---|
| 106 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 107 | ! kinds are defined in new module kinds, |
---|
| 108 | ! old module precision_kind is removed, |
---|
| 109 | ! revision history before 2012 removed, |
---|
| 110 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 111 | ! all variable declaration statements |
---|
[153] | 112 | ! |
---|
[1037] | 113 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 114 | ! code put under GPL (PALM 3.9) |
---|
| 115 | ! |
---|
[139] | 116 | ! 138 2007-11-28 10:03:58Z letzel |
---|
| 117 | ! Initial revision |
---|
| 118 | ! |
---|
[138] | 119 | ! Description: |
---|
| 120 | ! ------------ |
---|
[1682] | 121 | !> 1) Initialization of the canopy model, e.g. construction of leaf area density |
---|
[1826] | 122 | !> profile (subroutine pcm_init). |
---|
[1682] | 123 | !> 2) Calculation of sinks and sources of momentum, heat and scalar concentration |
---|
[1826] | 124 | !> due to canopy elements (subroutine pcm_tendency). |
---|
[138] | 125 | !------------------------------------------------------------------------------! |
---|
[1682] | 126 | MODULE plant_canopy_model_mod |
---|
| 127 | |
---|
[1484] | 128 | USE arrays_3d, & |
---|
[2232] | 129 | ONLY: dzu, dzw, e, q, s, tend, u, v, w, zu, zw |
---|
[138] | 130 | |
---|
[1484] | 131 | USE indices, & |
---|
| 132 | ONLY: nbgp, nxl, nxlg, nxlu, nxr, nxrg, nyn, nyng, nys, nysg, nysv, & |
---|
[2317] | 133 | nz, nzb, nzt |
---|
[1484] | 134 | |
---|
| 135 | USE kinds |
---|
| 136 | |
---|
[2317] | 137 | USE surface_mod, & |
---|
| 138 | ONLY: get_topography_top_index |
---|
[1484] | 139 | |
---|
[2317] | 140 | |
---|
[1484] | 141 | IMPLICIT NONE |
---|
| 142 | |
---|
| 143 | |
---|
[1682] | 144 | CHARACTER (LEN=20) :: canopy_mode = 'block' !< canopy coverage |
---|
[1484] | 145 | |
---|
[1682] | 146 | INTEGER(iwp) :: pch_index = 0 !< plant canopy height/top index |
---|
[1484] | 147 | INTEGER(iwp) :: & |
---|
[1682] | 148 | lad_vertical_gradient_level_ind(10) = -9999 !< lad-profile levels (index) |
---|
[1484] | 149 | |
---|
[1682] | 150 | LOGICAL :: calc_beta_lad_profile = .FALSE. !< switch for calc. of lad from beta func. |
---|
| 151 | LOGICAL :: plant_canopy = .FALSE. !< switch for use of canopy model |
---|
[1484] | 152 | |
---|
[1682] | 153 | REAL(wp) :: alpha_lad = 9999999.9_wp !< coefficient for lad calculation |
---|
| 154 | REAL(wp) :: beta_lad = 9999999.9_wp !< coefficient for lad calculation |
---|
| 155 | REAL(wp) :: canopy_drag_coeff = 0.0_wp !< canopy drag coefficient (parameter) |
---|
| 156 | REAL(wp) :: cdc = 0.0_wp !< canopy drag coeff. (abbreviation used in equations) |
---|
| 157 | REAL(wp) :: cthf = 0.0_wp !< canopy top heat flux |
---|
| 158 | REAL(wp) :: dt_plant_canopy = 0.0_wp !< timestep account. for canopy drag |
---|
[2007] | 159 | REAL(wp) :: ext_coef = 0.6_wp !< extinction coefficient |
---|
[1682] | 160 | REAL(wp) :: lad_surface = 0.0_wp !< lad surface value |
---|
| 161 | REAL(wp) :: lai_beta = 0.0_wp !< leaf area index (lai) for lad calc. |
---|
[1484] | 162 | REAL(wp) :: & |
---|
[1682] | 163 | leaf_scalar_exch_coeff = 0.0_wp !< canopy scalar exchange coeff. |
---|
[1484] | 164 | REAL(wp) :: & |
---|
[1682] | 165 | leaf_surface_conc = 0.0_wp !< leaf surface concentration |
---|
| 166 | REAL(wp) :: lsec = 0.0_wp !< leaf scalar exchange coeff. |
---|
| 167 | REAL(wp) :: lsc = 0.0_wp !< leaf surface concentration |
---|
[1484] | 168 | |
---|
| 169 | REAL(wp) :: & |
---|
[1682] | 170 | lad_vertical_gradient(10) = 0.0_wp !< lad gradient |
---|
[1484] | 171 | REAL(wp) :: & |
---|
[1682] | 172 | lad_vertical_gradient_level(10) = -9999999.9_wp !< lad-prof. levels (in m) |
---|
[1484] | 173 | |
---|
[1682] | 174 | REAL(wp), DIMENSION(:), ALLOCATABLE :: lad !< leaf area density |
---|
| 175 | REAL(wp), DIMENSION(:), ALLOCATABLE :: pre_lad !< preliminary lad |
---|
[1484] | 176 | |
---|
| 177 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: & |
---|
[2011] | 178 | pc_heating_rate !< plant canopy heating rate |
---|
[1682] | 179 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: cum_lai_hf !< cumulative lai for heatflux calc. |
---|
| 180 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: lad_s !< lad on scalar-grid |
---|
[1484] | 181 | |
---|
| 182 | |
---|
| 183 | SAVE |
---|
| 184 | |
---|
| 185 | |
---|
[138] | 186 | PRIVATE |
---|
[1826] | 187 | |
---|
| 188 | ! |
---|
| 189 | !-- Public functions |
---|
[2209] | 190 | PUBLIC pcm_check_data_output, pcm_check_parameters, pcm_data_output_3d, & |
---|
| 191 | pcm_define_netcdf_grid, pcm_header, pcm_init, pcm_parin, pcm_tendency |
---|
[138] | 192 | |
---|
[1826] | 193 | ! |
---|
| 194 | !-- Public variables and constants |
---|
[2011] | 195 | PUBLIC pc_heating_rate, canopy_mode, cthf, dt_plant_canopy, lad, lad_s, & |
---|
[2007] | 196 | pch_index, plant_canopy |
---|
| 197 | |
---|
[1484] | 198 | |
---|
[2209] | 199 | INTERFACE pcm_check_data_output |
---|
| 200 | MODULE PROCEDURE pcm_check_data_output |
---|
| 201 | END INTERFACE pcm_check_data_output |
---|
| 202 | |
---|
[1826] | 203 | INTERFACE pcm_check_parameters |
---|
| 204 | MODULE PROCEDURE pcm_check_parameters |
---|
[2209] | 205 | END INTERFACE pcm_check_parameters |
---|
| 206 | |
---|
| 207 | INTERFACE pcm_data_output_3d |
---|
| 208 | MODULE PROCEDURE pcm_data_output_3d |
---|
| 209 | END INTERFACE pcm_data_output_3d |
---|
| 210 | |
---|
| 211 | INTERFACE pcm_define_netcdf_grid |
---|
| 212 | MODULE PROCEDURE pcm_define_netcdf_grid |
---|
| 213 | END INTERFACE pcm_define_netcdf_grid |
---|
[1826] | 214 | |
---|
| 215 | INTERFACE pcm_header |
---|
| 216 | MODULE PROCEDURE pcm_header |
---|
| 217 | END INTERFACE pcm_header |
---|
| 218 | |
---|
| 219 | INTERFACE pcm_init |
---|
| 220 | MODULE PROCEDURE pcm_init |
---|
| 221 | END INTERFACE pcm_init |
---|
[138] | 222 | |
---|
[1826] | 223 | INTERFACE pcm_parin |
---|
| 224 | MODULE PROCEDURE pcm_parin |
---|
[2007] | 225 | END INTERFACE pcm_parin |
---|
| 226 | |
---|
| 227 | INTERFACE pcm_read_plant_canopy_3d |
---|
| 228 | MODULE PROCEDURE pcm_read_plant_canopy_3d |
---|
| 229 | END INTERFACE pcm_read_plant_canopy_3d |
---|
[1826] | 230 | |
---|
| 231 | INTERFACE pcm_tendency |
---|
| 232 | MODULE PROCEDURE pcm_tendency |
---|
| 233 | MODULE PROCEDURE pcm_tendency_ij |
---|
| 234 | END INTERFACE pcm_tendency |
---|
[1484] | 235 | |
---|
| 236 | |
---|
[138] | 237 | CONTAINS |
---|
| 238 | |
---|
[2209] | 239 | |
---|
| 240 | !------------------------------------------------------------------------------! |
---|
| 241 | ! Description: |
---|
| 242 | ! ------------ |
---|
| 243 | !> Check data output for plant canopy model |
---|
| 244 | !------------------------------------------------------------------------------! |
---|
| 245 | SUBROUTINE pcm_check_data_output( var, unit ) |
---|
[1826] | 246 | |
---|
[2209] | 247 | |
---|
| 248 | USE control_parameters, & |
---|
| 249 | ONLY: data_output, message_string |
---|
| 250 | |
---|
| 251 | IMPLICIT NONE |
---|
| 252 | |
---|
| 253 | CHARACTER (LEN=*) :: unit !< |
---|
| 254 | CHARACTER (LEN=*) :: var !< |
---|
| 255 | |
---|
| 256 | |
---|
| 257 | SELECT CASE ( TRIM( var ) ) |
---|
| 258 | |
---|
| 259 | CASE ( 'pcm_heatrate' ) |
---|
| 260 | unit = 'K s-1' |
---|
| 261 | |
---|
| 262 | CASE ( 'pcm_lad' ) |
---|
| 263 | unit = 'm2 m-3' |
---|
| 264 | |
---|
| 265 | |
---|
| 266 | CASE DEFAULT |
---|
| 267 | unit = 'illegal' |
---|
| 268 | |
---|
| 269 | END SELECT |
---|
| 270 | |
---|
| 271 | |
---|
| 272 | END SUBROUTINE pcm_check_data_output |
---|
| 273 | |
---|
| 274 | |
---|
[1826] | 275 | !------------------------------------------------------------------------------! |
---|
| 276 | ! Description: |
---|
| 277 | ! ------------ |
---|
| 278 | !> Check parameters routine for plant canopy model |
---|
| 279 | !------------------------------------------------------------------------------! |
---|
| 280 | SUBROUTINE pcm_check_parameters |
---|
[138] | 281 | |
---|
[1826] | 282 | USE control_parameters, & |
---|
| 283 | ONLY: cloud_physics, message_string, microphysics_seifert |
---|
| 284 | |
---|
| 285 | |
---|
| 286 | IMPLICIT NONE |
---|
| 287 | |
---|
| 288 | |
---|
| 289 | IF ( canopy_drag_coeff == 0.0_wp ) THEN |
---|
| 290 | message_string = 'plant_canopy = .TRUE. requires a non-zero drag '// & |
---|
| 291 | 'coefficient & given value is canopy_drag_coeff = 0.0' |
---|
| 292 | CALL message( 'check_parameters', 'PA0041', 1, 2, 0, 6, 0 ) |
---|
| 293 | ENDIF |
---|
| 294 | |
---|
| 295 | IF ( ( alpha_lad /= 9999999.9_wp .AND. beta_lad == 9999999.9_wp ) .OR.& |
---|
| 296 | beta_lad /= 9999999.9_wp .AND. alpha_lad == 9999999.9_wp ) THEN |
---|
| 297 | message_string = 'using the beta function for the construction ' // & |
---|
| 298 | 'of the leaf area density profile requires ' // & |
---|
| 299 | 'both alpha_lad and beta_lad to be /= 9999999.9' |
---|
| 300 | CALL message( 'check_parameters', 'PA0118', 1, 2, 0, 6, 0 ) |
---|
| 301 | ENDIF |
---|
| 302 | |
---|
| 303 | IF ( calc_beta_lad_profile .AND. lai_beta == 0.0_wp ) THEN |
---|
| 304 | message_string = 'using the beta function for the construction ' // & |
---|
| 305 | 'of the leaf area density profile requires ' // & |
---|
| 306 | 'a non-zero lai_beta, but given value is ' // & |
---|
| 307 | 'lai_beta = 0.0' |
---|
| 308 | CALL message( 'check_parameters', 'PA0119', 1, 2, 0, 6, 0 ) |
---|
| 309 | ENDIF |
---|
| 310 | |
---|
| 311 | IF ( calc_beta_lad_profile .AND. lad_surface /= 0.0_wp ) THEN |
---|
[2274] | 312 | message_string = 'simultaneous setting of alpha_lad /= 9999999.9 '// & |
---|
| 313 | 'combined with beta_lad /= 9999999.9 ' // & |
---|
[1826] | 314 | 'and lad_surface /= 0.0 is not possible, ' // & |
---|
| 315 | 'use either vertical gradients or the beta ' // & |
---|
| 316 | 'function for the construction of the leaf area '// & |
---|
| 317 | 'density profile' |
---|
| 318 | CALL message( 'check_parameters', 'PA0120', 1, 2, 0, 6, 0 ) |
---|
| 319 | ENDIF |
---|
| 320 | |
---|
| 321 | IF ( cloud_physics .AND. microphysics_seifert ) THEN |
---|
| 322 | message_string = 'plant_canopy = .TRUE. requires cloud_scheme /=' // & |
---|
| 323 | ' seifert_beheng' |
---|
| 324 | CALL message( 'check_parameters', 'PA0360', 1, 2, 0, 6, 0 ) |
---|
| 325 | ENDIF |
---|
| 326 | |
---|
| 327 | |
---|
| 328 | END SUBROUTINE pcm_check_parameters |
---|
| 329 | |
---|
| 330 | |
---|
[138] | 331 | !------------------------------------------------------------------------------! |
---|
[2209] | 332 | ! |
---|
[1484] | 333 | ! Description: |
---|
| 334 | ! ------------ |
---|
[2209] | 335 | !> Subroutine defining 3D output variables |
---|
| 336 | !------------------------------------------------------------------------------! |
---|
| 337 | SUBROUTINE pcm_data_output_3d( av, variable, found, local_pf ) |
---|
| 338 | |
---|
| 339 | USE control_parameters, & |
---|
| 340 | ONLY : nz_do3d |
---|
| 341 | |
---|
| 342 | USE indices |
---|
| 343 | |
---|
| 344 | USE kinds |
---|
| 345 | |
---|
| 346 | |
---|
| 347 | IMPLICIT NONE |
---|
| 348 | |
---|
| 349 | CHARACTER (LEN=*) :: variable !< |
---|
| 350 | |
---|
| 351 | INTEGER(iwp) :: av !< |
---|
| 352 | INTEGER(iwp) :: i !< |
---|
| 353 | INTEGER(iwp) :: j !< |
---|
| 354 | INTEGER(iwp) :: k !< |
---|
| 355 | |
---|
| 356 | LOGICAL :: found !< |
---|
| 357 | |
---|
| 358 | REAL(sp), DIMENSION(nxlg:nxrg,nysg:nyng,nzb:nz_do3d) :: local_pf !< |
---|
| 359 | |
---|
| 360 | |
---|
| 361 | found = .TRUE. |
---|
| 362 | |
---|
| 363 | |
---|
| 364 | SELECT CASE ( TRIM( variable ) ) |
---|
| 365 | |
---|
| 366 | CASE ( 'pcm_heatrate' ) |
---|
[2213] | 367 | CALL exchange_horiz( pc_heating_rate, nbgp ) |
---|
[2209] | 368 | IF ( av == 0 ) THEN |
---|
| 369 | DO i = nxlg, nxrg |
---|
| 370 | DO j = nysg, nyng |
---|
| 371 | DO k = nzb_s_inner(j,i), nz_do3d |
---|
[2213] | 372 | local_pf(i,j,k) = pc_heating_rate(k-nzb_s_inner(j,i),j,i) |
---|
[2209] | 373 | ENDDO |
---|
| 374 | ENDDO |
---|
| 375 | ENDDO |
---|
| 376 | ENDIF |
---|
| 377 | |
---|
| 378 | |
---|
| 379 | CASE ( 'pcm_lad' ) |
---|
| 380 | IF ( av == 0 ) THEN |
---|
| 381 | DO i = nxlg, nxrg |
---|
| 382 | DO j = nysg, nyng |
---|
| 383 | DO k = nzb_s_inner(j,i), nz_do3d |
---|
[2213] | 384 | local_pf(i,j,k) = lad_s(k-nzb_s_inner(j,i),j,i) |
---|
[2209] | 385 | ENDDO |
---|
| 386 | ENDDO |
---|
| 387 | ENDDO |
---|
| 388 | ENDIF |
---|
| 389 | |
---|
| 390 | |
---|
| 391 | CASE DEFAULT |
---|
| 392 | found = .FALSE. |
---|
| 393 | |
---|
| 394 | END SELECT |
---|
| 395 | |
---|
| 396 | |
---|
| 397 | END SUBROUTINE pcm_data_output_3d |
---|
| 398 | |
---|
| 399 | !------------------------------------------------------------------------------! |
---|
| 400 | ! |
---|
| 401 | ! Description: |
---|
| 402 | ! ------------ |
---|
| 403 | !> Subroutine defining appropriate grid for netcdf variables. |
---|
| 404 | !> It is called from subroutine netcdf. |
---|
| 405 | !------------------------------------------------------------------------------! |
---|
| 406 | SUBROUTINE pcm_define_netcdf_grid( var, found, grid_x, grid_y, grid_z ) |
---|
| 407 | |
---|
| 408 | IMPLICIT NONE |
---|
| 409 | |
---|
| 410 | CHARACTER (LEN=*), INTENT(IN) :: var !< |
---|
| 411 | LOGICAL, INTENT(OUT) :: found !< |
---|
| 412 | CHARACTER (LEN=*), INTENT(OUT) :: grid_x !< |
---|
| 413 | CHARACTER (LEN=*), INTENT(OUT) :: grid_y !< |
---|
| 414 | CHARACTER (LEN=*), INTENT(OUT) :: grid_z !< |
---|
| 415 | |
---|
| 416 | found = .TRUE. |
---|
| 417 | |
---|
| 418 | ! |
---|
| 419 | !-- Check for the grid |
---|
| 420 | SELECT CASE ( TRIM( var ) ) |
---|
| 421 | |
---|
| 422 | CASE ( 'pcm_heatrate', 'pcm_lad' ) |
---|
| 423 | grid_x = 'x' |
---|
| 424 | grid_y = 'y' |
---|
| 425 | grid_z = 'zu' |
---|
| 426 | |
---|
| 427 | CASE DEFAULT |
---|
| 428 | found = .FALSE. |
---|
| 429 | grid_x = 'none' |
---|
| 430 | grid_y = 'none' |
---|
| 431 | grid_z = 'none' |
---|
| 432 | END SELECT |
---|
| 433 | |
---|
| 434 | END SUBROUTINE pcm_define_netcdf_grid |
---|
| 435 | |
---|
| 436 | |
---|
| 437 | !------------------------------------------------------------------------------! |
---|
| 438 | ! Description: |
---|
| 439 | ! ------------ |
---|
[1826] | 440 | !> Header output for plant canopy model |
---|
| 441 | !------------------------------------------------------------------------------! |
---|
| 442 | SUBROUTINE pcm_header ( io ) |
---|
| 443 | |
---|
| 444 | USE control_parameters, & |
---|
| 445 | ONLY: dz, passive_scalar |
---|
| 446 | |
---|
| 447 | |
---|
| 448 | IMPLICIT NONE |
---|
| 449 | |
---|
| 450 | CHARACTER (LEN=10) :: coor_chr !< |
---|
| 451 | |
---|
| 452 | CHARACTER (LEN=86) :: coordinates !< |
---|
| 453 | CHARACTER (LEN=86) :: gradients !< |
---|
| 454 | CHARACTER (LEN=86) :: leaf_area_density !< |
---|
| 455 | CHARACTER (LEN=86) :: slices !< |
---|
| 456 | |
---|
| 457 | INTEGER(iwp) :: i !< |
---|
| 458 | INTEGER(iwp), INTENT(IN) :: io !< Unit of the output file |
---|
| 459 | INTEGER(iwp) :: k !< |
---|
| 460 | |
---|
| 461 | REAL(wp) :: canopy_height !< canopy height (in m) |
---|
| 462 | |
---|
| 463 | canopy_height = pch_index * dz |
---|
| 464 | |
---|
| 465 | WRITE ( io, 1 ) canopy_mode, canopy_height, pch_index, & |
---|
| 466 | canopy_drag_coeff |
---|
| 467 | IF ( passive_scalar ) THEN |
---|
| 468 | WRITE ( io, 2 ) leaf_scalar_exch_coeff, & |
---|
| 469 | leaf_surface_conc |
---|
| 470 | ENDIF |
---|
| 471 | |
---|
| 472 | ! |
---|
| 473 | !-- Heat flux at the top of vegetation |
---|
| 474 | WRITE ( io, 3 ) cthf |
---|
| 475 | |
---|
| 476 | ! |
---|
| 477 | !-- Leaf area density profile, calculated either from given vertical |
---|
| 478 | !-- gradients or from beta probability density function. |
---|
| 479 | IF ( .NOT. calc_beta_lad_profile ) THEN |
---|
| 480 | |
---|
| 481 | !-- Building output strings, starting with surface value |
---|
| 482 | WRITE ( leaf_area_density, '(F7.4)' ) lad_surface |
---|
| 483 | gradients = '------' |
---|
| 484 | slices = ' 0' |
---|
| 485 | coordinates = ' 0.0' |
---|
| 486 | i = 1 |
---|
| 487 | DO WHILE ( i < 11 .AND. lad_vertical_gradient_level_ind(i) & |
---|
| 488 | /= -9999 ) |
---|
| 489 | |
---|
| 490 | WRITE (coor_chr,'(F7.2)') lad(lad_vertical_gradient_level_ind(i)) |
---|
| 491 | leaf_area_density = TRIM( leaf_area_density ) // ' ' // & |
---|
| 492 | TRIM( coor_chr ) |
---|
| 493 | |
---|
| 494 | WRITE (coor_chr,'(F7.2)') lad_vertical_gradient(i) |
---|
| 495 | gradients = TRIM( gradients ) // ' ' // TRIM( coor_chr ) |
---|
| 496 | |
---|
| 497 | WRITE (coor_chr,'(I7)') lad_vertical_gradient_level_ind(i) |
---|
| 498 | slices = TRIM( slices ) // ' ' // TRIM( coor_chr ) |
---|
| 499 | |
---|
| 500 | WRITE (coor_chr,'(F7.1)') lad_vertical_gradient_level(i) |
---|
| 501 | coordinates = TRIM( coordinates ) // ' ' // TRIM( coor_chr ) |
---|
| 502 | |
---|
| 503 | i = i + 1 |
---|
| 504 | ENDDO |
---|
| 505 | |
---|
| 506 | WRITE ( io, 4 ) TRIM( coordinates ), TRIM( leaf_area_density ), & |
---|
| 507 | TRIM( gradients ), TRIM( slices ) |
---|
| 508 | |
---|
| 509 | ELSE |
---|
| 510 | |
---|
| 511 | WRITE ( leaf_area_density, '(F7.4)' ) lad_surface |
---|
| 512 | coordinates = ' 0.0' |
---|
| 513 | |
---|
| 514 | DO k = 1, pch_index |
---|
| 515 | |
---|
| 516 | WRITE (coor_chr,'(F7.2)') lad(k) |
---|
| 517 | leaf_area_density = TRIM( leaf_area_density ) // ' ' // & |
---|
| 518 | TRIM( coor_chr ) |
---|
| 519 | |
---|
| 520 | WRITE (coor_chr,'(F7.1)') zu(k) |
---|
| 521 | coordinates = TRIM( coordinates ) // ' ' // TRIM( coor_chr ) |
---|
| 522 | |
---|
| 523 | ENDDO |
---|
| 524 | |
---|
| 525 | WRITE ( io, 5 ) TRIM( coordinates ), TRIM( leaf_area_density ), & |
---|
| 526 | alpha_lad, beta_lad, lai_beta |
---|
| 527 | |
---|
| 528 | ENDIF |
---|
| 529 | |
---|
| 530 | 1 FORMAT (//' Vegetation canopy (drag) model:'/ & |
---|
| 531 | ' ------------------------------'// & |
---|
| 532 | ' Canopy mode: ', A / & |
---|
| 533 | ' Canopy height: ',F6.2,'m (',I4,' grid points)' / & |
---|
| 534 | ' Leaf drag coefficient: ',F6.2 /) |
---|
| 535 | 2 FORMAT (/ ' Scalar exchange coefficient: ',F6.2 / & |
---|
| 536 | ' Scalar concentration at leaf surfaces in kg/m**3: ',F6.2 /) |
---|
| 537 | 3 FORMAT (' Predefined constant heatflux at the top of the vegetation: ',F6.2, & |
---|
| 538 | ' K m/s') |
---|
| 539 | 4 FORMAT (/ ' Characteristic levels of the leaf area density:'// & |
---|
| 540 | ' Height: ',A,' m'/ & |
---|
| 541 | ' Leaf area density: ',A,' m**2/m**3'/ & |
---|
| 542 | ' Gradient: ',A,' m**2/m**4'/ & |
---|
| 543 | ' Gridpoint: ',A) |
---|
| 544 | 5 FORMAT (//' Characteristic levels of the leaf area density and coefficients:'& |
---|
| 545 | // ' Height: ',A,' m'/ & |
---|
| 546 | ' Leaf area density: ',A,' m**2/m**3'/ & |
---|
| 547 | ' Coefficient alpha: ',F6.2 / & |
---|
| 548 | ' Coefficient beta: ',F6.2 / & |
---|
| 549 | ' Leaf area index: ',F6.2,' m**2/m**2' /) |
---|
| 550 | |
---|
| 551 | END SUBROUTINE pcm_header |
---|
| 552 | |
---|
| 553 | |
---|
| 554 | !------------------------------------------------------------------------------! |
---|
| 555 | ! Description: |
---|
| 556 | ! ------------ |
---|
[1682] | 557 | !> Initialization of the plant canopy model |
---|
[138] | 558 | !------------------------------------------------------------------------------! |
---|
[1826] | 559 | SUBROUTINE pcm_init |
---|
[1484] | 560 | |
---|
| 561 | |
---|
| 562 | USE control_parameters, & |
---|
[2213] | 563 | ONLY: coupling_char, dz, humidity, io_blocks, io_group, & |
---|
[2232] | 564 | message_string, ocean, passive_scalar, urban_surface |
---|
[1484] | 565 | |
---|
[2232] | 566 | USE surface_mod, & |
---|
| 567 | ONLY: surf_def_h, surf_lsm_h, surf_usm_h |
---|
[1484] | 568 | |
---|
| 569 | IMPLICIT NONE |
---|
| 570 | |
---|
[2007] | 571 | CHARACTER(10) :: pct |
---|
| 572 | |
---|
| 573 | INTEGER(iwp) :: i !< running index |
---|
| 574 | INTEGER(iwp) :: ii !< index |
---|
| 575 | INTEGER(iwp) :: j !< running index |
---|
| 576 | INTEGER(iwp) :: k !< running index |
---|
[2232] | 577 | INTEGER(iwp) :: m !< running index |
---|
[1484] | 578 | |
---|
[2007] | 579 | REAL(wp) :: int_bpdf !< vertical integral for lad-profile construction |
---|
| 580 | REAL(wp) :: dzh !< vertical grid spacing in units of canopy height |
---|
| 581 | REAL(wp) :: gradient !< gradient for lad-profile construction |
---|
| 582 | REAL(wp) :: canopy_height !< canopy height for lad-profile construction |
---|
| 583 | REAL(wp) :: pcv(nzb:nzt+1) !< |
---|
| 584 | |
---|
[1484] | 585 | ! |
---|
| 586 | !-- Allocate one-dimensional arrays for the computation of the |
---|
| 587 | !-- leaf area density (lad) profile |
---|
| 588 | ALLOCATE( lad(0:nz+1), pre_lad(0:nz+1) ) |
---|
| 589 | lad = 0.0_wp |
---|
| 590 | pre_lad = 0.0_wp |
---|
| 591 | |
---|
| 592 | ! |
---|
[1826] | 593 | !-- Set flag that indicates that the lad-profile shall be calculated by using |
---|
| 594 | !-- a beta probability density function |
---|
| 595 | IF ( alpha_lad /= 9999999.9_wp .AND. beta_lad /= 9999999.9_wp ) THEN |
---|
| 596 | calc_beta_lad_profile = .TRUE. |
---|
| 597 | ENDIF |
---|
| 598 | |
---|
| 599 | |
---|
| 600 | ! |
---|
[1484] | 601 | !-- Compute the profile of leaf area density used in the plant |
---|
| 602 | !-- canopy model. The profile can either be constructed from |
---|
| 603 | !-- prescribed vertical gradients of the leaf area density or by |
---|
| 604 | !-- using a beta probability density function (see e.g. Markkanen et al., |
---|
| 605 | !-- 2003: Boundary-Layer Meteorology, 106, 437-459) |
---|
| 606 | IF ( .NOT. calc_beta_lad_profile ) THEN |
---|
| 607 | |
---|
| 608 | ! |
---|
| 609 | !-- Use vertical gradients for lad-profile construction |
---|
| 610 | i = 1 |
---|
| 611 | gradient = 0.0_wp |
---|
| 612 | |
---|
| 613 | IF ( .NOT. ocean ) THEN |
---|
| 614 | |
---|
| 615 | lad(0) = lad_surface |
---|
| 616 | lad_vertical_gradient_level_ind(1) = 0 |
---|
| 617 | |
---|
| 618 | DO k = 1, pch_index |
---|
| 619 | IF ( i < 11 ) THEN |
---|
| 620 | IF ( lad_vertical_gradient_level(i) < zu(k) .AND. & |
---|
| 621 | lad_vertical_gradient_level(i) >= 0.0_wp ) THEN |
---|
| 622 | gradient = lad_vertical_gradient(i) |
---|
| 623 | lad_vertical_gradient_level_ind(i) = k - 1 |
---|
| 624 | i = i + 1 |
---|
| 625 | ENDIF |
---|
| 626 | ENDIF |
---|
| 627 | IF ( gradient /= 0.0_wp ) THEN |
---|
| 628 | IF ( k /= 1 ) THEN |
---|
| 629 | lad(k) = lad(k-1) + dzu(k) * gradient |
---|
| 630 | ELSE |
---|
| 631 | lad(k) = lad_surface + dzu(k) * gradient |
---|
| 632 | ENDIF |
---|
| 633 | ELSE |
---|
| 634 | lad(k) = lad(k-1) |
---|
| 635 | ENDIF |
---|
| 636 | ENDDO |
---|
| 637 | |
---|
| 638 | ENDIF |
---|
| 639 | |
---|
| 640 | ! |
---|
| 641 | !-- In case of no given leaf area density gradients, choose a vanishing |
---|
| 642 | !-- gradient. This information is used for the HEADER and the RUN_CONTROL |
---|
| 643 | !-- file. |
---|
| 644 | IF ( lad_vertical_gradient_level(1) == -9999999.9_wp ) THEN |
---|
| 645 | lad_vertical_gradient_level(1) = 0.0_wp |
---|
| 646 | ENDIF |
---|
| 647 | |
---|
| 648 | ELSE |
---|
| 649 | |
---|
| 650 | ! |
---|
| 651 | !-- Use beta function for lad-profile construction |
---|
| 652 | int_bpdf = 0.0_wp |
---|
| 653 | canopy_height = pch_index * dz |
---|
| 654 | |
---|
[2232] | 655 | DO k = 0, pch_index |
---|
[1484] | 656 | int_bpdf = int_bpdf + & |
---|
[1826] | 657 | ( ( ( zw(k) / canopy_height )**( alpha_lad-1.0_wp ) ) * & |
---|
| 658 | ( ( 1.0_wp - ( zw(k) / canopy_height ) )**( & |
---|
| 659 | beta_lad-1.0_wp ) ) & |
---|
| 660 | * ( ( zw(k+1)-zw(k) ) / canopy_height ) ) |
---|
[1484] | 661 | ENDDO |
---|
| 662 | |
---|
| 663 | ! |
---|
| 664 | !-- Preliminary lad profile (defined on w-grid) |
---|
[2232] | 665 | DO k = 0, pch_index |
---|
[1826] | 666 | pre_lad(k) = lai_beta * & |
---|
| 667 | ( ( ( zw(k) / canopy_height )**( alpha_lad-1.0_wp ) ) & |
---|
| 668 | * ( ( 1.0_wp - ( zw(k) / canopy_height ) )**( & |
---|
| 669 | beta_lad-1.0_wp ) ) / int_bpdf & |
---|
| 670 | ) / canopy_height |
---|
[1484] | 671 | ENDDO |
---|
| 672 | |
---|
| 673 | ! |
---|
| 674 | !-- Final lad profile (defined on scalar-grid level, since most prognostic |
---|
| 675 | !-- quantities are defined there, hence, less interpolation is required |
---|
| 676 | !-- when calculating the canopy tendencies) |
---|
| 677 | lad(0) = pre_lad(0) |
---|
[2232] | 678 | DO k = 1, pch_index |
---|
[1484] | 679 | lad(k) = 0.5 * ( pre_lad(k-1) + pre_lad(k) ) |
---|
| 680 | ENDDO |
---|
| 681 | |
---|
| 682 | ENDIF |
---|
| 683 | |
---|
| 684 | ! |
---|
[2213] | 685 | !-- Allocate 3D-array for the leaf area density (lad_s). |
---|
[1484] | 686 | ALLOCATE( lad_s(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 687 | |
---|
| 688 | ! |
---|
| 689 | !-- Initialize canopy parameters cdc (canopy drag coefficient), |
---|
| 690 | !-- lsec (leaf scalar exchange coefficient), lsc (leaf surface concentration) |
---|
| 691 | !-- with the prescribed values |
---|
| 692 | cdc = canopy_drag_coeff |
---|
| 693 | lsec = leaf_scalar_exch_coeff |
---|
| 694 | lsc = leaf_surface_conc |
---|
| 695 | |
---|
| 696 | ! |
---|
| 697 | !-- Initialization of the canopy coverage in the model domain: |
---|
| 698 | !-- Setting the parameter canopy_mode = 'block' initializes a canopy, which |
---|
| 699 | !-- fully covers the domain surface |
---|
| 700 | SELECT CASE ( TRIM( canopy_mode ) ) |
---|
| 701 | |
---|
| 702 | CASE( 'block' ) |
---|
| 703 | |
---|
| 704 | DO i = nxlg, nxrg |
---|
| 705 | DO j = nysg, nyng |
---|
| 706 | lad_s(:,j,i) = lad(:) |
---|
| 707 | ENDDO |
---|
| 708 | ENDDO |
---|
| 709 | |
---|
[2007] | 710 | CASE ( 'read_from_file_3d' ) |
---|
| 711 | ! |
---|
| 712 | !-- Initialize canopy parameters cdc (canopy drag coefficient), |
---|
| 713 | !-- lsec (leaf scalar exchange coefficient), lsc (leaf surface concentration) |
---|
| 714 | !-- from file which contains complete 3D data (separate vertical profiles for |
---|
| 715 | !-- each location). |
---|
| 716 | CALL pcm_read_plant_canopy_3d |
---|
| 717 | |
---|
[1484] | 718 | CASE DEFAULT |
---|
| 719 | ! |
---|
[2007] | 720 | !-- The DEFAULT case is reached either if the parameter |
---|
| 721 | !-- canopy mode contains a wrong character string or if the |
---|
| 722 | !-- user has coded a special case in the user interface. |
---|
| 723 | !-- There, the subroutine user_init_plant_canopy checks |
---|
| 724 | !-- which of these two conditions applies. |
---|
| 725 | CALL user_init_plant_canopy |
---|
[1484] | 726 | |
---|
| 727 | END SELECT |
---|
| 728 | |
---|
| 729 | ! |
---|
[2011] | 730 | !-- Initialization of the canopy heat source distribution due to heating |
---|
| 731 | !-- of the canopy layers by incoming solar radiation, in case that a non-zero |
---|
| 732 | !-- value is set for the canopy top heat flux (cthf), which equals the |
---|
| 733 | !-- available net radiation at canopy top. |
---|
| 734 | !-- The heat source distribution is calculated by a decaying exponential |
---|
| 735 | !-- function of the downward cumulative leaf area index (cum_lai_hf), |
---|
| 736 | !-- assuming that the foliage inside the plant canopy is heated by solar |
---|
| 737 | !-- radiation penetrating the canopy layers according to the distribution |
---|
| 738 | !-- of net radiation as suggested by Brown & Covey (1966; Agric. Meteorol. 3, |
---|
| 739 | !-- 73â96). This approach has been applied e.g. by Shaw & Schumann (1992; |
---|
[2213] | 740 | !-- Bound.-Layer Meteorol. 61, 47â64). |
---|
| 741 | !-- When using the urban surface model (USM), canopy heating (pc_heating_rate) |
---|
| 742 | !-- by radiation is calculated in the USM. |
---|
| 743 | IF ( cthf /= 0.0_wp .AND. .NOT. urban_surface) THEN |
---|
| 744 | |
---|
| 745 | ALLOCATE( cum_lai_hf(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 746 | pc_heating_rate(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
[1484] | 747 | ! |
---|
[2011] | 748 | !-- Piecewise calculation of the cumulative leaf area index by vertical |
---|
[1484] | 749 | !-- integration of the leaf area density |
---|
| 750 | cum_lai_hf(:,:,:) = 0.0_wp |
---|
| 751 | DO i = nxlg, nxrg |
---|
| 752 | DO j = nysg, nyng |
---|
| 753 | DO k = pch_index-1, 0, -1 |
---|
| 754 | IF ( k == pch_index-1 ) THEN |
---|
| 755 | cum_lai_hf(k,j,i) = cum_lai_hf(k+1,j,i) + & |
---|
| 756 | ( 0.5_wp * lad_s(k+1,j,i) * & |
---|
| 757 | ( zw(k+1) - zu(k+1) ) ) + & |
---|
| 758 | ( 0.5_wp * ( 0.5_wp * ( lad_s(k+1,j,i) + & |
---|
| 759 | lad_s(k,j,i) ) + & |
---|
| 760 | lad_s(k+1,j,i) ) * & |
---|
| 761 | ( zu(k+1) - zw(k) ) ) |
---|
| 762 | ELSE |
---|
| 763 | cum_lai_hf(k,j,i) = cum_lai_hf(k+1,j,i) + & |
---|
| 764 | ( 0.5_wp * ( 0.5_wp * ( lad_s(k+2,j,i) + & |
---|
| 765 | lad_s(k+1,j,i) ) + & |
---|
| 766 | lad_s(k+1,j,i) ) * & |
---|
| 767 | ( zw(k+1) - zu(k+1) ) ) + & |
---|
| 768 | ( 0.5_wp * ( 0.5_wp * ( lad_s(k+1,j,i) + & |
---|
| 769 | lad_s(k,j,i) ) + & |
---|
| 770 | lad_s(k+1,j,i) ) * & |
---|
| 771 | ( zu(k+1) - zw(k) ) ) |
---|
| 772 | ENDIF |
---|
| 773 | ENDDO |
---|
| 774 | ENDDO |
---|
| 775 | ENDDO |
---|
| 776 | |
---|
[2232] | 777 | ! |
---|
| 778 | !-- In areas with canopy the surface value of the canopy heat |
---|
| 779 | !-- flux distribution overrides the surface heat flux (shf) |
---|
| 780 | !-- Start with default surface type |
---|
| 781 | DO m = 1, surf_def_h(0)%ns |
---|
| 782 | k = surf_def_h(0)%k(m) |
---|
| 783 | IF ( cum_lai_hf(0,j,i) /= 0.0_wp ) & |
---|
| 784 | surf_def_h(0)%shf(m) = cthf * exp( -ext_coef * cum_lai_hf(0,j,i) ) |
---|
| 785 | ENDDO |
---|
[1484] | 786 | ! |
---|
[2232] | 787 | !-- Natural surfaces |
---|
| 788 | DO m = 1, surf_lsm_h%ns |
---|
| 789 | k = surf_lsm_h%k(m) |
---|
| 790 | IF ( cum_lai_hf(0,j,i) /= 0.0_wp ) & |
---|
| 791 | surf_lsm_h%shf(m) = cthf * exp( -ext_coef * cum_lai_hf(0,j,i) ) |
---|
| 792 | ENDDO |
---|
| 793 | ! |
---|
| 794 | !-- Urban surfaces |
---|
| 795 | DO m = 1, surf_usm_h%ns |
---|
| 796 | k = surf_usm_h%k(m) |
---|
| 797 | IF ( cum_lai_hf(0,j,i) /= 0.0_wp ) & |
---|
| 798 | surf_usm_h%shf(m) = cthf * exp( -ext_coef * cum_lai_hf(0,j,i) ) |
---|
| 799 | ENDDO |
---|
| 800 | ! |
---|
| 801 | ! |
---|
[2011] | 802 | !-- Calculation of the heating rate (K/s) within the different layers of |
---|
[2232] | 803 | !-- the plant canopy. Calculation is only necessary in areas covered with |
---|
| 804 | !-- canopy. |
---|
| 805 | !-- Within the different canopy layers the plant-canopy heating |
---|
| 806 | !-- rate (pc_heating_rate) is calculated as the vertical |
---|
| 807 | !-- divergence of the canopy heat fluxes at the top and bottom |
---|
| 808 | !-- of the respective layer |
---|
[1484] | 809 | DO i = nxlg, nxrg |
---|
| 810 | DO j = nysg, nyng |
---|
[2232] | 811 | DO k = 1, pch_index |
---|
| 812 | IF ( cum_lai_hf(0,j,i) /= 0.0_wp ) THEN |
---|
| 813 | pc_heating_rate(k,j,i) = cthf * & |
---|
| 814 | ( exp(-ext_coef*cum_lai_hf(k,j,i)) - & |
---|
| 815 | exp(-ext_coef*cum_lai_hf(k-1,j,i) ) ) / dzw(k) |
---|
| 816 | ENDIF |
---|
| 817 | ENDDO |
---|
[1721] | 818 | ENDDO |
---|
| 819 | ENDDO |
---|
[1484] | 820 | |
---|
| 821 | ENDIF |
---|
| 822 | |
---|
| 823 | |
---|
| 824 | |
---|
[1826] | 825 | END SUBROUTINE pcm_init |
---|
[1484] | 826 | |
---|
| 827 | |
---|
[2007] | 828 | !------------------------------------------------------------------------------! |
---|
| 829 | ! Description: |
---|
| 830 | ! ------------ |
---|
| 831 | !> Parin for &canopy_par for plant canopy model |
---|
| 832 | !------------------------------------------------------------------------------! |
---|
| 833 | SUBROUTINE pcm_parin |
---|
[1484] | 834 | |
---|
[2007] | 835 | |
---|
| 836 | IMPLICIT NONE |
---|
| 837 | |
---|
| 838 | CHARACTER (LEN=80) :: line !< dummy string that contains the current line of the parameter file |
---|
| 839 | |
---|
| 840 | NAMELIST /canopy_par/ alpha_lad, beta_lad, canopy_drag_coeff, & |
---|
| 841 | canopy_mode, cthf, & |
---|
| 842 | lad_surface, & |
---|
| 843 | lad_vertical_gradient, & |
---|
| 844 | lad_vertical_gradient_level, & |
---|
| 845 | lai_beta, & |
---|
| 846 | leaf_scalar_exch_coeff, & |
---|
| 847 | leaf_surface_conc, pch_index |
---|
| 848 | |
---|
| 849 | line = ' ' |
---|
| 850 | |
---|
| 851 | ! |
---|
| 852 | !-- Try to find radiation model package |
---|
| 853 | REWIND ( 11 ) |
---|
| 854 | line = ' ' |
---|
| 855 | DO WHILE ( INDEX( line, '&canopy_par' ) == 0 ) |
---|
| 856 | READ ( 11, '(A)', END=10 ) line |
---|
| 857 | ENDDO |
---|
| 858 | BACKSPACE ( 11 ) |
---|
| 859 | |
---|
| 860 | ! |
---|
| 861 | !-- Read user-defined namelist |
---|
| 862 | READ ( 11, canopy_par ) |
---|
| 863 | |
---|
| 864 | ! |
---|
| 865 | !-- Set flag that indicates that the radiation model is switched on |
---|
| 866 | plant_canopy = .TRUE. |
---|
| 867 | |
---|
| 868 | 10 CONTINUE |
---|
| 869 | |
---|
| 870 | |
---|
| 871 | END SUBROUTINE pcm_parin |
---|
| 872 | |
---|
| 873 | |
---|
| 874 | |
---|
[1484] | 875 | !------------------------------------------------------------------------------! |
---|
| 876 | ! Description: |
---|
| 877 | ! ------------ |
---|
[2007] | 878 | ! |
---|
| 879 | !> Loads 3D plant canopy data from file. File format is as follows: |
---|
| 880 | !> |
---|
| 881 | !> num_levels |
---|
| 882 | !> dtype,x,y,value(nzb),value(nzb+1), ... ,value(nzb+num_levels-1) |
---|
| 883 | !> dtype,x,y,value(nzb),value(nzb+1), ... ,value(nzb+num_levels-1) |
---|
| 884 | !> dtype,x,y,value(nzb),value(nzb+1), ... ,value(nzb+num_levels-1) |
---|
| 885 | !> ... |
---|
| 886 | !> |
---|
| 887 | !> i.e. first line determines number of levels and further lines represent plant |
---|
| 888 | !> canopy data, one line per column and variable. In each data line, |
---|
| 889 | !> dtype represents variable to be set: |
---|
| 890 | !> |
---|
| 891 | !> dtype=1: leaf area density (lad_s) |
---|
[2213] | 892 | !> dtype=2....n: some additional plant canopy input data quantity |
---|
[2007] | 893 | !> |
---|
| 894 | !> Zeros are added automatically above num_levels until top of domain. Any |
---|
| 895 | !> non-specified (x,y) columns have zero values as default. |
---|
| 896 | !------------------------------------------------------------------------------! |
---|
| 897 | SUBROUTINE pcm_read_plant_canopy_3d |
---|
[2213] | 898 | |
---|
| 899 | USE control_parameters, & |
---|
| 900 | ONLY: message_string, passive_scalar |
---|
[2007] | 901 | |
---|
[2213] | 902 | USE indices, & |
---|
| 903 | ONLY: nbgp |
---|
| 904 | |
---|
| 905 | IMPLICIT NONE |
---|
[2007] | 906 | |
---|
[2213] | 907 | INTEGER(iwp) :: dtype !< type of input data (1=lad) |
---|
| 908 | INTEGER(iwp) :: i, j !< running index |
---|
| 909 | INTEGER(iwp) :: nzp !< number of vertical layers of plant canopy |
---|
| 910 | INTEGER(iwp) :: nzpltop !< |
---|
| 911 | INTEGER(iwp) :: nzpl !< |
---|
| 912 | |
---|
| 913 | REAL(wp), DIMENSION(:), ALLOCATABLE :: col !< vertical column of input data |
---|
[2007] | 914 | |
---|
[2213] | 915 | ! |
---|
| 916 | !-- Initialize lad_s array |
---|
| 917 | lad_s = 0.0_wp |
---|
| 918 | |
---|
| 919 | ! |
---|
| 920 | !-- Open and read plant canopy input data |
---|
| 921 | OPEN(152, file='PLANT_CANOPY_DATA_3D', access='SEQUENTIAL', & |
---|
| 922 | action='READ', status='OLD', form='FORMATTED', err=515) |
---|
| 923 | READ(152, *, err=516, end=517) nzp !< read first line = number of vertical layers |
---|
| 924 | |
---|
| 925 | ALLOCATE(col(0:nzp-1)) |
---|
[2007] | 926 | |
---|
[2213] | 927 | DO |
---|
| 928 | READ(152, *, err=516, end=517) dtype, i, j, col(:) |
---|
| 929 | IF ( i < nxlg .or. i > nxrg .or. j < nysg .or. j > nyng ) CYCLE |
---|
[2007] | 930 | |
---|
[2213] | 931 | SELECT CASE (dtype) |
---|
| 932 | CASE( 1 ) !< leaf area density |
---|
| 933 | ! |
---|
| 934 | !-- This is just the pure canopy layer assumed to be grounded to |
---|
| 935 | !-- a flat domain surface. At locations where plant canopy sits |
---|
| 936 | !-- on top of any kind of topography, the vertical plant column |
---|
| 937 | !-- must be "lifted", which is done in SUBROUTINE pcm_tendency. |
---|
| 938 | lad_s(0:nzp-1, j, i) = col(0:nzp-1) |
---|
| 939 | |
---|
| 940 | CASE DEFAULT |
---|
| 941 | write(message_string, '(a,i2,a)') & |
---|
| 942 | 'Unknown record type in file PLANT_CANOPY_DATA_3D: "', dtype, '"' |
---|
| 943 | CALL message( 'pcm_read_plant_canopy_3d', 'PA0530', 1, 2, 0, 6, 0 ) |
---|
| 944 | END SELECT |
---|
| 945 | ENDDO |
---|
[2007] | 946 | |
---|
[2213] | 947 | 515 message_string = 'error opening file PLANT_CANOPY_DATA_3D' |
---|
| 948 | CALL message( 'pcm_read_plant_canopy_3d', 'PA0531', 1, 2, 0, 6, 0 ) |
---|
[2007] | 949 | |
---|
[2213] | 950 | 516 message_string = 'error reading file PLANT_CANOPY_DATA_3D' |
---|
| 951 | CALL message( 'pcm_read_plant_canopy_3d', 'PA0532', 1, 2, 0, 6, 0 ) |
---|
| 952 | |
---|
| 953 | 517 CLOSE(152) |
---|
| 954 | DEALLOCATE(col) |
---|
| 955 | |
---|
| 956 | CALL exchange_horiz( lad_s, nbgp ) |
---|
[2007] | 957 | |
---|
| 958 | END SUBROUTINE pcm_read_plant_canopy_3d |
---|
| 959 | |
---|
| 960 | |
---|
| 961 | |
---|
| 962 | !------------------------------------------------------------------------------! |
---|
| 963 | ! Description: |
---|
| 964 | ! ------------ |
---|
[1682] | 965 | !> Calculation of the tendency terms, accounting for the effect of the plant |
---|
| 966 | !> canopy on momentum and scalar quantities. |
---|
| 967 | !> |
---|
| 968 | !> The canopy is located where the leaf area density lad_s(k,j,i) > 0.0 |
---|
[1826] | 969 | !> (defined on scalar grid), as initialized in subroutine pcm_init. |
---|
[1682] | 970 | !> The lad on the w-grid is vertically interpolated from the surrounding |
---|
| 971 | !> lad_s. The upper boundary of the canopy is defined on the w-grid at |
---|
| 972 | !> k = pch_index. Here, the lad is zero. |
---|
| 973 | !> |
---|
| 974 | !> The canopy drag must be limited (previously accounted for by calculation of |
---|
| 975 | !> a limiting canopy timestep for the determination of the maximum LES timestep |
---|
| 976 | !> in subroutine timestep), since it is physically impossible that the canopy |
---|
| 977 | !> drag alone can locally change the sign of a velocity component. This |
---|
| 978 | !> limitation is realized by calculating preliminary tendencies and velocities. |
---|
| 979 | !> It is subsequently checked if the preliminary new velocity has a different |
---|
| 980 | !> sign than the current velocity. If so, the tendency is limited in a way that |
---|
| 981 | !> the velocity can at maximum be reduced to zero by the canopy drag. |
---|
| 982 | !> |
---|
| 983 | !> |
---|
| 984 | !> Call for all grid points |
---|
[1484] | 985 | !------------------------------------------------------------------------------! |
---|
[1826] | 986 | SUBROUTINE pcm_tendency( component ) |
---|
[138] | 987 | |
---|
| 988 | |
---|
[1320] | 989 | USE control_parameters, & |
---|
[1484] | 990 | ONLY: dt_3d, message_string |
---|
[1320] | 991 | |
---|
| 992 | USE kinds |
---|
| 993 | |
---|
[138] | 994 | IMPLICIT NONE |
---|
| 995 | |
---|
[1682] | 996 | INTEGER(iwp) :: component !< prognostic variable (u,v,w,pt,q,e) |
---|
| 997 | INTEGER(iwp) :: i !< running index |
---|
| 998 | INTEGER(iwp) :: j !< running index |
---|
| 999 | INTEGER(iwp) :: k !< running index |
---|
[2232] | 1000 | INTEGER(iwp) :: k_wall !< vertical index of topography top |
---|
[1721] | 1001 | INTEGER(iwp) :: kk !< running index for flat lad arrays |
---|
[1484] | 1002 | |
---|
[1682] | 1003 | REAL(wp) :: ddt_3d !< inverse of the LES timestep (dt_3d) |
---|
| 1004 | REAL(wp) :: lad_local !< local lad value |
---|
| 1005 | REAL(wp) :: pre_tend !< preliminary tendency |
---|
| 1006 | REAL(wp) :: pre_u !< preliminary u-value |
---|
| 1007 | REAL(wp) :: pre_v !< preliminary v-value |
---|
| 1008 | REAL(wp) :: pre_w !< preliminary w-value |
---|
[1484] | 1009 | |
---|
| 1010 | |
---|
| 1011 | ddt_3d = 1.0_wp / dt_3d |
---|
[138] | 1012 | |
---|
| 1013 | ! |
---|
[1484] | 1014 | !-- Compute drag for the three velocity components and the SGS-TKE: |
---|
[138] | 1015 | SELECT CASE ( component ) |
---|
| 1016 | |
---|
| 1017 | ! |
---|
| 1018 | !-- u-component |
---|
| 1019 | CASE ( 1 ) |
---|
| 1020 | DO i = nxlu, nxr |
---|
| 1021 | DO j = nys, nyn |
---|
[2232] | 1022 | ! |
---|
| 1023 | !-- Determine topography-top index on u-grid |
---|
[2317] | 1024 | k_wall = get_topography_top_index( j, i, 'u' ) |
---|
[2232] | 1025 | DO k = k_wall+1, k_wall+pch_index |
---|
[1484] | 1026 | |
---|
[2232] | 1027 | kk = k - k_wall !- lad arrays are defined flat |
---|
[1484] | 1028 | ! |
---|
| 1029 | !-- In order to create sharp boundaries of the plant canopy, |
---|
| 1030 | !-- the lad on the u-grid at index (k,j,i) is equal to |
---|
| 1031 | !-- lad_s(k,j,i), rather than being interpolated from the |
---|
| 1032 | !-- surrounding lad_s, because this would yield smaller lad |
---|
| 1033 | !-- at the canopy boundaries than inside of the canopy. |
---|
| 1034 | !-- For the same reason, the lad at the rightmost(i+1)canopy |
---|
| 1035 | !-- boundary on the u-grid equals lad_s(k,j,i). |
---|
[1721] | 1036 | lad_local = lad_s(kk,j,i) |
---|
| 1037 | IF ( lad_local == 0.0_wp .AND. lad_s(kk,j,i-1) > 0.0_wp )& |
---|
| 1038 | THEN |
---|
| 1039 | lad_local = lad_s(kk,j,i-1) |
---|
[1484] | 1040 | ENDIF |
---|
| 1041 | |
---|
| 1042 | pre_tend = 0.0_wp |
---|
| 1043 | pre_u = 0.0_wp |
---|
| 1044 | ! |
---|
| 1045 | !-- Calculate preliminary value (pre_tend) of the tendency |
---|
| 1046 | pre_tend = - cdc * & |
---|
| 1047 | lad_local * & |
---|
| 1048 | SQRT( u(k,j,i)**2 + & |
---|
| 1049 | ( 0.25_wp * ( v(k,j,i-1) + & |
---|
| 1050 | v(k,j,i) + & |
---|
| 1051 | v(k,j+1,i) + & |
---|
| 1052 | v(k,j+1,i-1) ) & |
---|
| 1053 | )**2 + & |
---|
| 1054 | ( 0.25_wp * ( w(k-1,j,i-1) + & |
---|
| 1055 | w(k-1,j,i) + & |
---|
| 1056 | w(k,j,i-1) + & |
---|
| 1057 | w(k,j,i) ) & |
---|
| 1058 | )**2 & |
---|
| 1059 | ) * & |
---|
| 1060 | u(k,j,i) |
---|
| 1061 | |
---|
| 1062 | ! |
---|
| 1063 | !-- Calculate preliminary new velocity, based on pre_tend |
---|
| 1064 | pre_u = u(k,j,i) + dt_3d * pre_tend |
---|
| 1065 | ! |
---|
| 1066 | !-- Compare sign of old velocity and new preliminary velocity, |
---|
| 1067 | !-- and in case the signs are different, limit the tendency |
---|
| 1068 | IF ( SIGN(pre_u,u(k,j,i)) /= pre_u ) THEN |
---|
| 1069 | pre_tend = - u(k,j,i) * ddt_3d |
---|
| 1070 | ELSE |
---|
| 1071 | pre_tend = pre_tend |
---|
| 1072 | ENDIF |
---|
| 1073 | ! |
---|
| 1074 | !-- Calculate final tendency |
---|
| 1075 | tend(k,j,i) = tend(k,j,i) + pre_tend |
---|
| 1076 | |
---|
[138] | 1077 | ENDDO |
---|
| 1078 | ENDDO |
---|
| 1079 | ENDDO |
---|
| 1080 | |
---|
| 1081 | ! |
---|
| 1082 | !-- v-component |
---|
| 1083 | CASE ( 2 ) |
---|
| 1084 | DO i = nxl, nxr |
---|
| 1085 | DO j = nysv, nyn |
---|
[2232] | 1086 | ! |
---|
| 1087 | !-- Determine topography-top index on v-grid |
---|
[2317] | 1088 | k_wall = get_topography_top_index( j, i, 'v' ) |
---|
| 1089 | |
---|
[2232] | 1090 | DO k = k_wall+1, k_wall+pch_index |
---|
[1484] | 1091 | |
---|
[2232] | 1092 | kk = k - k_wall !- lad arrays are defined flat |
---|
[1484] | 1093 | ! |
---|
| 1094 | !-- In order to create sharp boundaries of the plant canopy, |
---|
| 1095 | !-- the lad on the v-grid at index (k,j,i) is equal to |
---|
| 1096 | !-- lad_s(k,j,i), rather than being interpolated from the |
---|
| 1097 | !-- surrounding lad_s, because this would yield smaller lad |
---|
| 1098 | !-- at the canopy boundaries than inside of the canopy. |
---|
| 1099 | !-- For the same reason, the lad at the northmost(j+1) canopy |
---|
| 1100 | !-- boundary on the v-grid equals lad_s(k,j,i). |
---|
[1721] | 1101 | lad_local = lad_s(kk,j,i) |
---|
| 1102 | IF ( lad_local == 0.0_wp .AND. lad_s(kk,j-1,i) > 0.0_wp )& |
---|
| 1103 | THEN |
---|
| 1104 | lad_local = lad_s(kk,j-1,i) |
---|
[1484] | 1105 | ENDIF |
---|
| 1106 | |
---|
| 1107 | pre_tend = 0.0_wp |
---|
| 1108 | pre_v = 0.0_wp |
---|
| 1109 | ! |
---|
| 1110 | !-- Calculate preliminary value (pre_tend) of the tendency |
---|
| 1111 | pre_tend = - cdc * & |
---|
| 1112 | lad_local * & |
---|
| 1113 | SQRT( ( 0.25_wp * ( u(k,j-1,i) + & |
---|
| 1114 | u(k,j-1,i+1) + & |
---|
| 1115 | u(k,j,i) + & |
---|
| 1116 | u(k,j,i+1) ) & |
---|
| 1117 | )**2 + & |
---|
| 1118 | v(k,j,i)**2 + & |
---|
| 1119 | ( 0.25_wp * ( w(k-1,j-1,i) + & |
---|
| 1120 | w(k-1,j,i) + & |
---|
| 1121 | w(k,j-1,i) + & |
---|
| 1122 | w(k,j,i) ) & |
---|
| 1123 | )**2 & |
---|
| 1124 | ) * & |
---|
| 1125 | v(k,j,i) |
---|
| 1126 | |
---|
| 1127 | ! |
---|
| 1128 | !-- Calculate preliminary new velocity, based on pre_tend |
---|
| 1129 | pre_v = v(k,j,i) + dt_3d * pre_tend |
---|
| 1130 | ! |
---|
| 1131 | !-- Compare sign of old velocity and new preliminary velocity, |
---|
| 1132 | !-- and in case the signs are different, limit the tendency |
---|
| 1133 | IF ( SIGN(pre_v,v(k,j,i)) /= pre_v ) THEN |
---|
| 1134 | pre_tend = - v(k,j,i) * ddt_3d |
---|
| 1135 | ELSE |
---|
| 1136 | pre_tend = pre_tend |
---|
| 1137 | ENDIF |
---|
| 1138 | ! |
---|
| 1139 | !-- Calculate final tendency |
---|
| 1140 | tend(k,j,i) = tend(k,j,i) + pre_tend |
---|
| 1141 | |
---|
[138] | 1142 | ENDDO |
---|
| 1143 | ENDDO |
---|
| 1144 | ENDDO |
---|
| 1145 | |
---|
| 1146 | ! |
---|
| 1147 | !-- w-component |
---|
| 1148 | CASE ( 3 ) |
---|
| 1149 | DO i = nxl, nxr |
---|
| 1150 | DO j = nys, nyn |
---|
[2232] | 1151 | ! |
---|
| 1152 | !-- Determine topography-top index on w-grid |
---|
[2317] | 1153 | k_wall = get_topography_top_index( j, i, 'w' ) |
---|
| 1154 | |
---|
[2232] | 1155 | DO k = k_wall+1, k_wall+pch_index-1 |
---|
[1484] | 1156 | |
---|
[2232] | 1157 | kk = k - k_wall !- lad arrays are defined flat |
---|
[1721] | 1158 | |
---|
[1484] | 1159 | pre_tend = 0.0_wp |
---|
| 1160 | pre_w = 0.0_wp |
---|
| 1161 | ! |
---|
| 1162 | !-- Calculate preliminary value (pre_tend) of the tendency |
---|
| 1163 | pre_tend = - cdc * & |
---|
| 1164 | (0.5_wp * & |
---|
[1721] | 1165 | ( lad_s(kk+1,j,i) + lad_s(kk,j,i) )) * & |
---|
[1484] | 1166 | SQRT( ( 0.25_wp * ( u(k,j,i) + & |
---|
| 1167 | u(k,j,i+1) + & |
---|
| 1168 | u(k+1,j,i) + & |
---|
| 1169 | u(k+1,j,i+1) ) & |
---|
| 1170 | )**2 + & |
---|
| 1171 | ( 0.25_wp * ( v(k,j,i) + & |
---|
| 1172 | v(k,j+1,i) + & |
---|
| 1173 | v(k+1,j,i) + & |
---|
| 1174 | v(k+1,j+1,i) ) & |
---|
| 1175 | )**2 + & |
---|
| 1176 | w(k,j,i)**2 & |
---|
| 1177 | ) * & |
---|
| 1178 | w(k,j,i) |
---|
| 1179 | ! |
---|
| 1180 | !-- Calculate preliminary new velocity, based on pre_tend |
---|
| 1181 | pre_w = w(k,j,i) + dt_3d * pre_tend |
---|
| 1182 | ! |
---|
| 1183 | !-- Compare sign of old velocity and new preliminary velocity, |
---|
| 1184 | !-- and in case the signs are different, limit the tendency |
---|
| 1185 | IF ( SIGN(pre_w,w(k,j,i)) /= pre_w ) THEN |
---|
| 1186 | pre_tend = - w(k,j,i) * ddt_3d |
---|
| 1187 | ELSE |
---|
| 1188 | pre_tend = pre_tend |
---|
| 1189 | ENDIF |
---|
| 1190 | ! |
---|
| 1191 | !-- Calculate final tendency |
---|
| 1192 | tend(k,j,i) = tend(k,j,i) + pre_tend |
---|
| 1193 | |
---|
[138] | 1194 | ENDDO |
---|
| 1195 | ENDDO |
---|
| 1196 | ENDDO |
---|
| 1197 | |
---|
| 1198 | ! |
---|
[153] | 1199 | !-- potential temperature |
---|
[138] | 1200 | CASE ( 4 ) |
---|
| 1201 | DO i = nxl, nxr |
---|
| 1202 | DO j = nys, nyn |
---|
[2232] | 1203 | ! |
---|
| 1204 | !-- Determine topography-top index on scalar-grid |
---|
[2317] | 1205 | k_wall = get_topography_top_index( j, i, 's' ) |
---|
| 1206 | |
---|
[2232] | 1207 | DO k = k_wall+1, k_wall+pch_index |
---|
| 1208 | |
---|
| 1209 | kk = k - k_wall !- lad arrays are defined flat |
---|
[2011] | 1210 | tend(k,j,i) = tend(k,j,i) + pc_heating_rate(kk,j,i) |
---|
[153] | 1211 | ENDDO |
---|
| 1212 | ENDDO |
---|
| 1213 | ENDDO |
---|
| 1214 | |
---|
| 1215 | ! |
---|
[1960] | 1216 | !-- humidity |
---|
[153] | 1217 | CASE ( 5 ) |
---|
| 1218 | DO i = nxl, nxr |
---|
| 1219 | DO j = nys, nyn |
---|
[2232] | 1220 | ! |
---|
| 1221 | !-- Determine topography-top index on scalar-grid |
---|
[2317] | 1222 | k_wall = get_topography_top_index( j, i, 's' ) |
---|
| 1223 | |
---|
[2232] | 1224 | DO k = k_wall+1, k_wall+pch_index |
---|
| 1225 | |
---|
| 1226 | kk = k - k_wall !- lad arrays are defined flat |
---|
[1484] | 1227 | tend(k,j,i) = tend(k,j,i) - & |
---|
| 1228 | lsec * & |
---|
[1721] | 1229 | lad_s(kk,j,i) * & |
---|
[1484] | 1230 | SQRT( ( 0.5_wp * ( u(k,j,i) + & |
---|
| 1231 | u(k,j,i+1) ) & |
---|
| 1232 | )**2 + & |
---|
| 1233 | ( 0.5_wp * ( v(k,j,i) + & |
---|
| 1234 | v(k,j+1,i) ) & |
---|
| 1235 | )**2 + & |
---|
| 1236 | ( 0.5_wp * ( w(k-1,j,i) + & |
---|
| 1237 | w(k,j,i) ) & |
---|
| 1238 | )**2 & |
---|
| 1239 | ) * & |
---|
| 1240 | ( q(k,j,i) - lsc ) |
---|
[153] | 1241 | ENDDO |
---|
| 1242 | ENDDO |
---|
| 1243 | ENDDO |
---|
| 1244 | |
---|
| 1245 | ! |
---|
| 1246 | !-- sgs-tke |
---|
| 1247 | CASE ( 6 ) |
---|
| 1248 | DO i = nxl, nxr |
---|
| 1249 | DO j = nys, nyn |
---|
[2232] | 1250 | ! |
---|
| 1251 | !-- Determine topography-top index on scalar-grid |
---|
[2317] | 1252 | k_wall = get_topography_top_index( j, i, 's' ) |
---|
| 1253 | |
---|
[2232] | 1254 | DO k = k_wall+1, k_wall+pch_index |
---|
| 1255 | |
---|
| 1256 | kk = k - k_wall !- lad arrays are defined flat |
---|
[1484] | 1257 | tend(k,j,i) = tend(k,j,i) - & |
---|
| 1258 | 2.0_wp * cdc * & |
---|
[1721] | 1259 | lad_s(kk,j,i) * & |
---|
[1484] | 1260 | SQRT( ( 0.5_wp * ( u(k,j,i) + & |
---|
| 1261 | u(k,j,i+1) ) & |
---|
| 1262 | )**2 + & |
---|
| 1263 | ( 0.5_wp * ( v(k,j,i) + & |
---|
| 1264 | v(k,j+1,i) ) & |
---|
| 1265 | )**2 + & |
---|
| 1266 | ( 0.5_wp * ( w(k,j,i) + & |
---|
| 1267 | w(k+1,j,i) ) & |
---|
| 1268 | )**2 & |
---|
| 1269 | ) * & |
---|
| 1270 | e(k,j,i) |
---|
[138] | 1271 | ENDDO |
---|
| 1272 | ENDDO |
---|
| 1273 | ENDDO |
---|
[1960] | 1274 | ! |
---|
| 1275 | !-- scalar concentration |
---|
| 1276 | CASE ( 7 ) |
---|
| 1277 | DO i = nxl, nxr |
---|
| 1278 | DO j = nys, nyn |
---|
[2232] | 1279 | ! |
---|
| 1280 | !-- Determine topography-top index on scalar-grid |
---|
[2317] | 1281 | k_wall = get_topography_top_index( j, i, 's' ) |
---|
| 1282 | |
---|
[2232] | 1283 | DO k = k_wall+1, k_wall+pch_index |
---|
| 1284 | |
---|
| 1285 | kk = k - k_wall !- lad arrays are defined flat |
---|
[1960] | 1286 | tend(k,j,i) = tend(k,j,i) - & |
---|
| 1287 | lsec * & |
---|
| 1288 | lad_s(kk,j,i) * & |
---|
| 1289 | SQRT( ( 0.5_wp * ( u(k,j,i) + & |
---|
| 1290 | u(k,j,i+1) ) & |
---|
| 1291 | )**2 + & |
---|
| 1292 | ( 0.5_wp * ( v(k,j,i) + & |
---|
| 1293 | v(k,j+1,i) ) & |
---|
| 1294 | )**2 + & |
---|
| 1295 | ( 0.5_wp * ( w(k-1,j,i) + & |
---|
| 1296 | w(k,j,i) ) & |
---|
| 1297 | )**2 & |
---|
| 1298 | ) * & |
---|
| 1299 | ( s(k,j,i) - lsc ) |
---|
| 1300 | ENDDO |
---|
| 1301 | ENDDO |
---|
| 1302 | ENDDO |
---|
[1484] | 1303 | |
---|
| 1304 | |
---|
[1960] | 1305 | |
---|
[138] | 1306 | CASE DEFAULT |
---|
| 1307 | |
---|
[257] | 1308 | WRITE( message_string, * ) 'wrong component: ', component |
---|
[1826] | 1309 | CALL message( 'pcm_tendency', 'PA0279', 1, 2, 0, 6, 0 ) |
---|
[138] | 1310 | |
---|
| 1311 | END SELECT |
---|
| 1312 | |
---|
[1826] | 1313 | END SUBROUTINE pcm_tendency |
---|
[138] | 1314 | |
---|
| 1315 | |
---|
| 1316 | !------------------------------------------------------------------------------! |
---|
[1484] | 1317 | ! Description: |
---|
| 1318 | ! ------------ |
---|
[1682] | 1319 | !> Calculation of the tendency terms, accounting for the effect of the plant |
---|
| 1320 | !> canopy on momentum and scalar quantities. |
---|
| 1321 | !> |
---|
| 1322 | !> The canopy is located where the leaf area density lad_s(k,j,i) > 0.0 |
---|
[1826] | 1323 | !> (defined on scalar grid), as initialized in subroutine pcm_init. |
---|
[1682] | 1324 | !> The lad on the w-grid is vertically interpolated from the surrounding |
---|
| 1325 | !> lad_s. The upper boundary of the canopy is defined on the w-grid at |
---|
| 1326 | !> k = pch_index. Here, the lad is zero. |
---|
| 1327 | !> |
---|
| 1328 | !> The canopy drag must be limited (previously accounted for by calculation of |
---|
| 1329 | !> a limiting canopy timestep for the determination of the maximum LES timestep |
---|
| 1330 | !> in subroutine timestep), since it is physically impossible that the canopy |
---|
| 1331 | !> drag alone can locally change the sign of a velocity component. This |
---|
| 1332 | !> limitation is realized by calculating preliminary tendencies and velocities. |
---|
| 1333 | !> It is subsequently checked if the preliminary new velocity has a different |
---|
| 1334 | !> sign than the current velocity. If so, the tendency is limited in a way that |
---|
| 1335 | !> the velocity can at maximum be reduced to zero by the canopy drag. |
---|
| 1336 | !> |
---|
| 1337 | !> |
---|
| 1338 | !> Call for grid point i,j |
---|
[138] | 1339 | !------------------------------------------------------------------------------! |
---|
[1826] | 1340 | SUBROUTINE pcm_tendency_ij( i, j, component ) |
---|
[138] | 1341 | |
---|
| 1342 | |
---|
[1320] | 1343 | USE control_parameters, & |
---|
[1484] | 1344 | ONLY: dt_3d, message_string |
---|
[1320] | 1345 | |
---|
| 1346 | USE kinds |
---|
| 1347 | |
---|
[138] | 1348 | IMPLICIT NONE |
---|
| 1349 | |
---|
[1682] | 1350 | INTEGER(iwp) :: component !< prognostic variable (u,v,w,pt,q,e) |
---|
| 1351 | INTEGER(iwp) :: i !< running index |
---|
| 1352 | INTEGER(iwp) :: j !< running index |
---|
| 1353 | INTEGER(iwp) :: k !< running index |
---|
[2232] | 1354 | INTEGER(iwp) :: k_wall !< vertical index of topography top |
---|
[1721] | 1355 | INTEGER(iwp) :: kk !< running index for flat lad arrays |
---|
[138] | 1356 | |
---|
[1682] | 1357 | REAL(wp) :: ddt_3d !< inverse of the LES timestep (dt_3d) |
---|
| 1358 | REAL(wp) :: lad_local !< local lad value |
---|
| 1359 | REAL(wp) :: pre_tend !< preliminary tendency |
---|
| 1360 | REAL(wp) :: pre_u !< preliminary u-value |
---|
| 1361 | REAL(wp) :: pre_v !< preliminary v-value |
---|
| 1362 | REAL(wp) :: pre_w !< preliminary w-value |
---|
[1484] | 1363 | |
---|
| 1364 | |
---|
| 1365 | ddt_3d = 1.0_wp / dt_3d |
---|
| 1366 | |
---|
[138] | 1367 | ! |
---|
[1484] | 1368 | !-- Compute drag for the three velocity components and the SGS-TKE |
---|
[142] | 1369 | SELECT CASE ( component ) |
---|
[138] | 1370 | |
---|
| 1371 | ! |
---|
[142] | 1372 | !-- u-component |
---|
[1484] | 1373 | CASE ( 1 ) |
---|
[2232] | 1374 | ! |
---|
| 1375 | !-- Determine topography-top index on u-grid |
---|
[2317] | 1376 | k_wall = get_topography_top_index( j, i, 'u' ) |
---|
| 1377 | |
---|
[2232] | 1378 | DO k = k_wall+1, k_wall+pch_index |
---|
[138] | 1379 | |
---|
[2232] | 1380 | kk = k - k_wall !- lad arrays are defined flat |
---|
[138] | 1381 | ! |
---|
[1484] | 1382 | !-- In order to create sharp boundaries of the plant canopy, |
---|
| 1383 | !-- the lad on the u-grid at index (k,j,i) is equal to lad_s(k,j,i), |
---|
| 1384 | !-- rather than being interpolated from the surrounding lad_s, |
---|
| 1385 | !-- because this would yield smaller lad at the canopy boundaries |
---|
| 1386 | !-- than inside of the canopy. |
---|
| 1387 | !-- For the same reason, the lad at the rightmost(i+1)canopy |
---|
| 1388 | !-- boundary on the u-grid equals lad_s(k,j,i). |
---|
[1721] | 1389 | lad_local = lad_s(kk,j,i) |
---|
| 1390 | IF ( lad_local == 0.0_wp .AND. lad_s(kk,j,i-1) > 0.0_wp ) THEN |
---|
| 1391 | lad_local = lad_s(kk,j,i-1) |
---|
[1484] | 1392 | ENDIF |
---|
| 1393 | |
---|
| 1394 | pre_tend = 0.0_wp |
---|
| 1395 | pre_u = 0.0_wp |
---|
| 1396 | ! |
---|
| 1397 | !-- Calculate preliminary value (pre_tend) of the tendency |
---|
| 1398 | pre_tend = - cdc * & |
---|
| 1399 | lad_local * & |
---|
| 1400 | SQRT( u(k,j,i)**2 + & |
---|
| 1401 | ( 0.25_wp * ( v(k,j,i-1) + & |
---|
| 1402 | v(k,j,i) + & |
---|
| 1403 | v(k,j+1,i) + & |
---|
| 1404 | v(k,j+1,i-1) ) & |
---|
| 1405 | )**2 + & |
---|
| 1406 | ( 0.25_wp * ( w(k-1,j,i-1) + & |
---|
| 1407 | w(k-1,j,i) + & |
---|
| 1408 | w(k,j,i-1) + & |
---|
| 1409 | w(k,j,i) ) & |
---|
| 1410 | )**2 & |
---|
| 1411 | ) * & |
---|
| 1412 | u(k,j,i) |
---|
| 1413 | |
---|
| 1414 | ! |
---|
| 1415 | !-- Calculate preliminary new velocity, based on pre_tend |
---|
| 1416 | pre_u = u(k,j,i) + dt_3d * pre_tend |
---|
| 1417 | ! |
---|
| 1418 | !-- Compare sign of old velocity and new preliminary velocity, |
---|
| 1419 | !-- and in case the signs are different, limit the tendency |
---|
| 1420 | IF ( SIGN(pre_u,u(k,j,i)) /= pre_u ) THEN |
---|
| 1421 | pre_tend = - u(k,j,i) * ddt_3d |
---|
| 1422 | ELSE |
---|
| 1423 | pre_tend = pre_tend |
---|
| 1424 | ENDIF |
---|
| 1425 | ! |
---|
| 1426 | !-- Calculate final tendency |
---|
| 1427 | tend(k,j,i) = tend(k,j,i) + pre_tend |
---|
| 1428 | ENDDO |
---|
| 1429 | |
---|
| 1430 | |
---|
| 1431 | ! |
---|
[142] | 1432 | !-- v-component |
---|
[1484] | 1433 | CASE ( 2 ) |
---|
[2232] | 1434 | ! |
---|
| 1435 | !-- Determine topography-top index on v-grid |
---|
[2317] | 1436 | k_wall = get_topography_top_index( j, i, 'v' ) |
---|
| 1437 | |
---|
[2232] | 1438 | DO k = k_wall+1, k_wall+pch_index |
---|
[138] | 1439 | |
---|
[2232] | 1440 | kk = k - k_wall !- lad arrays are defined flat |
---|
[138] | 1441 | ! |
---|
[1484] | 1442 | !-- In order to create sharp boundaries of the plant canopy, |
---|
| 1443 | !-- the lad on the v-grid at index (k,j,i) is equal to lad_s(k,j,i), |
---|
| 1444 | !-- rather than being interpolated from the surrounding lad_s, |
---|
| 1445 | !-- because this would yield smaller lad at the canopy boundaries |
---|
| 1446 | !-- than inside of the canopy. |
---|
| 1447 | !-- For the same reason, the lad at the northmost(j+1)canopy |
---|
| 1448 | !-- boundary on the v-grid equals lad_s(k,j,i). |
---|
[1721] | 1449 | lad_local = lad_s(kk,j,i) |
---|
| 1450 | IF ( lad_local == 0.0_wp .AND. lad_s(kk,j-1,i) > 0.0_wp ) THEN |
---|
| 1451 | lad_local = lad_s(kk,j-1,i) |
---|
[1484] | 1452 | ENDIF |
---|
| 1453 | |
---|
| 1454 | pre_tend = 0.0_wp |
---|
| 1455 | pre_v = 0.0_wp |
---|
| 1456 | ! |
---|
| 1457 | !-- Calculate preliminary value (pre_tend) of the tendency |
---|
| 1458 | pre_tend = - cdc * & |
---|
| 1459 | lad_local * & |
---|
| 1460 | SQRT( ( 0.25_wp * ( u(k,j-1,i) + & |
---|
| 1461 | u(k,j-1,i+1) + & |
---|
| 1462 | u(k,j,i) + & |
---|
| 1463 | u(k,j,i+1) ) & |
---|
| 1464 | )**2 + & |
---|
| 1465 | v(k,j,i)**2 + & |
---|
| 1466 | ( 0.25_wp * ( w(k-1,j-1,i) + & |
---|
| 1467 | w(k-1,j,i) + & |
---|
| 1468 | w(k,j-1,i) + & |
---|
| 1469 | w(k,j,i) ) & |
---|
| 1470 | )**2 & |
---|
| 1471 | ) * & |
---|
| 1472 | v(k,j,i) |
---|
| 1473 | |
---|
| 1474 | ! |
---|
| 1475 | !-- Calculate preliminary new velocity, based on pre_tend |
---|
| 1476 | pre_v = v(k,j,i) + dt_3d * pre_tend |
---|
| 1477 | ! |
---|
| 1478 | !-- Compare sign of old velocity and new preliminary velocity, |
---|
| 1479 | !-- and in case the signs are different, limit the tendency |
---|
| 1480 | IF ( SIGN(pre_v,v(k,j,i)) /= pre_v ) THEN |
---|
| 1481 | pre_tend = - v(k,j,i) * ddt_3d |
---|
| 1482 | ELSE |
---|
| 1483 | pre_tend = pre_tend |
---|
| 1484 | ENDIF |
---|
| 1485 | ! |
---|
| 1486 | !-- Calculate final tendency |
---|
| 1487 | tend(k,j,i) = tend(k,j,i) + pre_tend |
---|
| 1488 | ENDDO |
---|
| 1489 | |
---|
| 1490 | |
---|
| 1491 | ! |
---|
[142] | 1492 | !-- w-component |
---|
[1484] | 1493 | CASE ( 3 ) |
---|
[2232] | 1494 | ! |
---|
| 1495 | !-- Determine topography-top index on w-grid |
---|
[2317] | 1496 | k_wall = get_topography_top_index( j, i, 'w' ) |
---|
| 1497 | |
---|
[2232] | 1498 | DO k = k_wall+1, k_wall+pch_index-1 |
---|
[138] | 1499 | |
---|
[2232] | 1500 | kk = k - k_wall !- lad arrays are defined flat |
---|
[1721] | 1501 | |
---|
[1484] | 1502 | pre_tend = 0.0_wp |
---|
| 1503 | pre_w = 0.0_wp |
---|
[138] | 1504 | ! |
---|
[1484] | 1505 | !-- Calculate preliminary value (pre_tend) of the tendency |
---|
| 1506 | pre_tend = - cdc * & |
---|
| 1507 | (0.5_wp * & |
---|
[1721] | 1508 | ( lad_s(kk+1,j,i) + lad_s(kk,j,i) )) * & |
---|
[1484] | 1509 | SQRT( ( 0.25_wp * ( u(k,j,i) + & |
---|
| 1510 | u(k,j,i+1) + & |
---|
| 1511 | u(k+1,j,i) + & |
---|
| 1512 | u(k+1,j,i+1) ) & |
---|
| 1513 | )**2 + & |
---|
| 1514 | ( 0.25_wp * ( v(k,j,i) + & |
---|
| 1515 | v(k,j+1,i) + & |
---|
| 1516 | v(k+1,j,i) + & |
---|
| 1517 | v(k+1,j+1,i) ) & |
---|
| 1518 | )**2 + & |
---|
| 1519 | w(k,j,i)**2 & |
---|
| 1520 | ) * & |
---|
| 1521 | w(k,j,i) |
---|
| 1522 | ! |
---|
| 1523 | !-- Calculate preliminary new velocity, based on pre_tend |
---|
| 1524 | pre_w = w(k,j,i) + dt_3d * pre_tend |
---|
| 1525 | ! |
---|
| 1526 | !-- Compare sign of old velocity and new preliminary velocity, |
---|
| 1527 | !-- and in case the signs are different, limit the tendency |
---|
| 1528 | IF ( SIGN(pre_w,w(k,j,i)) /= pre_w ) THEN |
---|
| 1529 | pre_tend = - w(k,j,i) * ddt_3d |
---|
| 1530 | ELSE |
---|
| 1531 | pre_tend = pre_tend |
---|
| 1532 | ENDIF |
---|
| 1533 | ! |
---|
| 1534 | !-- Calculate final tendency |
---|
| 1535 | tend(k,j,i) = tend(k,j,i) + pre_tend |
---|
| 1536 | ENDDO |
---|
| 1537 | |
---|
| 1538 | ! |
---|
[153] | 1539 | !-- potential temperature |
---|
| 1540 | CASE ( 4 ) |
---|
[2232] | 1541 | ! |
---|
| 1542 | !-- Determine topography-top index on scalar grid |
---|
[2317] | 1543 | k_wall = get_topography_top_index( j, i, 's' ) |
---|
| 1544 | |
---|
[2232] | 1545 | DO k = k_wall+1, k_wall+pch_index |
---|
| 1546 | kk = k - k_wall !- lad arrays are defined flat |
---|
[2011] | 1547 | tend(k,j,i) = tend(k,j,i) + pc_heating_rate(kk,j,i) |
---|
[153] | 1548 | ENDDO |
---|
| 1549 | |
---|
| 1550 | |
---|
| 1551 | ! |
---|
[1960] | 1552 | !-- humidity |
---|
[153] | 1553 | CASE ( 5 ) |
---|
[2232] | 1554 | ! |
---|
| 1555 | !-- Determine topography-top index on scalar grid |
---|
[2317] | 1556 | k_wall = get_topography_top_index( j, i, 's' ) |
---|
| 1557 | |
---|
[2232] | 1558 | DO k = k_wall+1, k_wall+pch_index |
---|
| 1559 | |
---|
| 1560 | kk = k - k_wall |
---|
[1484] | 1561 | tend(k,j,i) = tend(k,j,i) - & |
---|
| 1562 | lsec * & |
---|
[1721] | 1563 | lad_s(kk,j,i) * & |
---|
[1484] | 1564 | SQRT( ( 0.5_wp * ( u(k,j,i) + & |
---|
| 1565 | u(k,j,i+1) ) & |
---|
| 1566 | )**2 + & |
---|
| 1567 | ( 0.5_wp * ( v(k,j,i) + & |
---|
| 1568 | v(k,j+1,i) ) & |
---|
| 1569 | )**2 + & |
---|
| 1570 | ( 0.5_wp * ( w(k-1,j,i) + & |
---|
| 1571 | w(k,j,i) ) & |
---|
| 1572 | )**2 & |
---|
| 1573 | ) * & |
---|
| 1574 | ( q(k,j,i) - lsc ) |
---|
[153] | 1575 | ENDDO |
---|
| 1576 | |
---|
| 1577 | ! |
---|
[142] | 1578 | !-- sgs-tke |
---|
[1484] | 1579 | CASE ( 6 ) |
---|
[2232] | 1580 | ! |
---|
| 1581 | !-- Determine topography-top index on scalar grid |
---|
[2317] | 1582 | k_wall = get_topography_top_index( j, i, 's' ) |
---|
| 1583 | |
---|
[2232] | 1584 | DO k = k_wall+1, k_wall+pch_index |
---|
| 1585 | |
---|
| 1586 | kk = k - k_wall |
---|
[1484] | 1587 | tend(k,j,i) = tend(k,j,i) - & |
---|
| 1588 | 2.0_wp * cdc * & |
---|
[1721] | 1589 | lad_s(kk,j,i) * & |
---|
[1484] | 1590 | SQRT( ( 0.5_wp * ( u(k,j,i) + & |
---|
| 1591 | u(k,j,i+1) ) & |
---|
| 1592 | )**2 + & |
---|
| 1593 | ( 0.5_wp * ( v(k,j,i) + & |
---|
| 1594 | v(k,j+1,i) ) & |
---|
| 1595 | )**2 + & |
---|
| 1596 | ( 0.5_wp * ( w(k,j,i) + & |
---|
| 1597 | w(k+1,j,i) ) & |
---|
| 1598 | )**2 & |
---|
| 1599 | ) * & |
---|
| 1600 | e(k,j,i) |
---|
| 1601 | ENDDO |
---|
[1960] | 1602 | |
---|
| 1603 | ! |
---|
| 1604 | !-- scalar concentration |
---|
| 1605 | CASE ( 7 ) |
---|
[2232] | 1606 | ! |
---|
| 1607 | !-- Determine topography-top index on scalar grid |
---|
[2317] | 1608 | k_wall = get_topography_top_index( j, i, 's' ) |
---|
| 1609 | |
---|
[2232] | 1610 | DO k = k_wall+1, k_wall+pch_index |
---|
| 1611 | |
---|
| 1612 | kk = k - k_wall |
---|
[1960] | 1613 | tend(k,j,i) = tend(k,j,i) - & |
---|
| 1614 | lsec * & |
---|
| 1615 | lad_s(kk,j,i) * & |
---|
| 1616 | SQRT( ( 0.5_wp * ( u(k,j,i) + & |
---|
| 1617 | u(k,j,i+1) ) & |
---|
| 1618 | )**2 + & |
---|
| 1619 | ( 0.5_wp * ( v(k,j,i) + & |
---|
| 1620 | v(k,j+1,i) ) & |
---|
| 1621 | )**2 + & |
---|
| 1622 | ( 0.5_wp * ( w(k-1,j,i) + & |
---|
| 1623 | w(k,j,i) ) & |
---|
| 1624 | )**2 & |
---|
| 1625 | ) * & |
---|
| 1626 | ( s(k,j,i) - lsc ) |
---|
| 1627 | ENDDO |
---|
[138] | 1628 | |
---|
[142] | 1629 | CASE DEFAULT |
---|
[138] | 1630 | |
---|
[257] | 1631 | WRITE( message_string, * ) 'wrong component: ', component |
---|
[1826] | 1632 | CALL message( 'pcm_tendency', 'PA0279', 1, 2, 0, 6, 0 ) |
---|
[138] | 1633 | |
---|
[142] | 1634 | END SELECT |
---|
[138] | 1635 | |
---|
[1826] | 1636 | END SUBROUTINE pcm_tendency_ij |
---|
[138] | 1637 | |
---|
[2007] | 1638 | |
---|
| 1639 | |
---|
[138] | 1640 | END MODULE plant_canopy_model_mod |
---|