[1682] | 1 | !> @file init_3d_model.f90 |
---|
[4648] | 2 | !--------------------------------------------------------------------------------------------------! |
---|
[2696] | 3 | ! This file is part of the PALM model system. |
---|
[1036] | 4 | ! |
---|
[4648] | 5 | ! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General |
---|
| 6 | ! Public License as published by the Free Software Foundation, either version 3 of the License, or |
---|
| 7 | ! (at your option) any later version. |
---|
[1036] | 8 | ! |
---|
[4648] | 9 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
---|
| 10 | ! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
---|
| 11 | ! Public License for more details. |
---|
[1036] | 12 | ! |
---|
[4648] | 13 | ! You should have received a copy of the GNU General Public License along with PALM. If not, see |
---|
| 14 | ! <http://www.gnu.org/licenses/>. |
---|
[1036] | 15 | ! |
---|
[4828] | 16 | ! Copyright 1997-2021 Leibniz Universitaet Hannover |
---|
[4648] | 17 | !--------------------------------------------------------------------------------------------------! |
---|
[1036] | 18 | ! |
---|
[254] | 19 | ! Current revisions: |
---|
[732] | 20 | ! ------------------ |
---|
[4648] | 21 | ! |
---|
| 22 | ! |
---|
[2233] | 23 | ! Former revisions: |
---|
| 24 | ! ----------------- |
---|
| 25 | ! $Id: init_3d_model.f90 4878 2021-02-18 09:47:49Z forkel $ |
---|
[4878] | 26 | ! Rename resize_array into add_ghost_layers and remove number of passed indices |
---|
| 27 | ! |
---|
| 28 | ! 4877 2021-02-17 16:17:35Z suehring |
---|
[4877] | 29 | ! Bugfix in initialization of vertical surfaces with roughness and surface heat fluxes |
---|
| 30 | ! |
---|
| 31 | ! 4848 2021-01-21 15:51:51Z gronemeier |
---|
[4848] | 32 | ! replaced use_syn_turb_gen by syn_turb_gen |
---|
| 33 | ! |
---|
| 34 | ! 4845 2021-01-18 11:15:37Z raasch |
---|
[4845] | 35 | ! removed allocation and initialization of arrays required for radiation boundary conditions |
---|
| 36 | ! |
---|
| 37 | ! 4828 2021-01-05 11:21:41Z Giersch |
---|
[4791] | 38 | ! Add possibility to initialize surface flux of passive scalar via static driver |
---|
| 39 | ! |
---|
| 40 | ! 4783 2020-11-13 13:58:45Z raasch |
---|
[4783] | 41 | ! bugfix for reading restart data with MPI-I/O (does not work with blockwise I/O) |
---|
| 42 | ! |
---|
| 43 | ! 4680 2020-09-16 10:20:34Z gronemeier |
---|
[4680] | 44 | ! Add option to fix date or time of the simulation |
---|
| 45 | ! |
---|
| 46 | ! 4671 2020-09-09 20:27:58Z pavelkrc |
---|
[4671] | 47 | ! Implementation of downward facing USM and LSM surfaces |
---|
| 48 | ! |
---|
| 49 | ! 4648 2020-08-25 07:52:08Z raasch |
---|
[4648] | 50 | ! file re-formatted to follow the PALM coding standard |
---|
| 51 | ! |
---|
| 52 | ! 4548 2020-05-28 19:36:45Z suehring |
---|
[4548] | 53 | ! Bugfix, move call for lsf_forcing_surf after lsf_init is called |
---|
[4648] | 54 | ! |
---|
[4548] | 55 | ! 4514 2020-04-30 16:29:59Z suehring |
---|
[4648] | 56 | ! Add possibility to initialize surface sensible and latent heat fluxes via a static driver. |
---|
| 57 | ! |
---|
[4514] | 58 | ! 4493 2020-04-10 09:49:43Z pavelkrc |
---|
[4648] | 59 | ! Overwrite u_init, v_init, pt_init, q_init and s_init with hom for all cyclic_fill-cases, not only |
---|
| 60 | ! for turbulent_inflow = .TRUE. |
---|
| 61 | ! |
---|
[4365] | 62 | ! 4360 2020-01-07 11:25:50Z suehring |
---|
[4648] | 63 | ! Introduction of wall_flags_total_0, which currently sets bits based on static topography |
---|
| 64 | ! information used in wall_flags_static_0 |
---|
| 65 | ! |
---|
[4346] | 66 | ! 4329 2019-12-10 15:46:36Z motisi |
---|
[4329] | 67 | ! Renamed wall_flags_0 to wall_flags_static_0 |
---|
[4648] | 68 | ! |
---|
[4329] | 69 | ! 4286 2019-10-30 16:01:14Z resler |
---|
[4227] | 70 | ! implement new palm_date_time_mod |
---|
[4648] | 71 | ! |
---|
[4227] | 72 | ! 4223 2019-09-10 09:20:47Z gronemeier |
---|
[4648] | 73 | ! Deallocate temporary string array since it may be re-used to read different input data in other |
---|
| 74 | ! modules |
---|
| 75 | ! |
---|
[4187] | 76 | ! 4186 2019-08-23 16:06:14Z suehring |
---|
[4648] | 77 | ! Design change, use variables defined in netcdf_data_input_mod to read netcd variables rather than |
---|
| 78 | ! define local ones. |
---|
| 79 | ! |
---|
[4186] | 80 | ! 4185 2019-08-23 13:49:38Z oliver.maas |
---|
[4185] | 81 | ! For initializing_actions = ' cyclic_fill': |
---|
[4648] | 82 | ! Overwrite u_init, v_init, pt_init, q_init and s_init with the (temporally) and horizontally |
---|
| 83 | ! averaged vertical profiles from the end of the prerun, because these profiles shall be used as the |
---|
| 84 | ! basic state for the rayleigh damping and the pt_damping. |
---|
| 85 | ! |
---|
[4185] | 86 | ! 4182 2019-08-22 15:20:23Z scharf |
---|
[4182] | 87 | ! Corrected "Former revisions" section |
---|
[4648] | 88 | ! |
---|
[4182] | 89 | ! 4168 2019-08-16 13:50:17Z suehring |
---|
[4168] | 90 | ! Replace function get_topography_top_index by topo_top_ind |
---|
[4648] | 91 | ! |
---|
[4168] | 92 | ! 4151 2019-08-09 08:24:30Z suehring |
---|
[4151] | 93 | ! Add netcdf directive around input calls (fix for last commit) |
---|
[4648] | 94 | ! |
---|
[4151] | 95 | ! 4150 2019-08-08 20:00:47Z suehring |
---|
[4648] | 96 | ! Input of additional surface variables independent on land- or urban-surface model |
---|
| 97 | ! |
---|
[4150] | 98 | ! 4131 2019-08-02 11:06:18Z monakurppa |
---|
[4131] | 99 | ! Allocate sums and sums_l to allow profile output for salsa variables. |
---|
[4648] | 100 | ! |
---|
[4131] | 101 | ! 4130 2019-08-01 13:04:13Z suehring |
---|
[4648] | 102 | ! Effectively reduce 3D initialization to 1D initial profiles. This is because 3D initialization |
---|
| 103 | ! produces structures in the w-component that are correlated with the processor grid for some |
---|
| 104 | ! unknown reason |
---|
| 105 | ! |
---|
[4130] | 106 | ! 4090 2019-07-11 15:06:47Z Giersch |
---|
[4090] | 107 | ! Unused variables removed |
---|
[4648] | 108 | ! |
---|
[4090] | 109 | ! 4088 2019-07-11 13:57:56Z Giersch |
---|
[4088] | 110 | ! Pressure and density profile calculations revised using basic functions |
---|
[4648] | 111 | ! |
---|
[4088] | 112 | ! 4048 2019-06-21 21:00:21Z knoop |
---|
[4028] | 113 | ! Further modularization of particle code components |
---|
[4648] | 114 | ! |
---|
[4028] | 115 | ! 4017 2019-06-06 12:16:46Z schwenkel |
---|
[4648] | 116 | ! Convert most location messages to debug messages to reduce output in job logfile to a minimum |
---|
| 117 | ! |
---|
[3939] | 118 | ! unused variable removed |
---|
[4648] | 119 | ! |
---|
[3939] | 120 | ! 3937 2019-04-29 15:09:07Z suehring |
---|
[4648] | 121 | ! Move initialization of synthetic turbulence generator behind initialization of offline nesting. |
---|
| 122 | ! Remove call for stg_adjust, as this is now already done in stg_init. |
---|
| 123 | ! |
---|
[3937] | 124 | ! 3900 2019-04-16 15:17:43Z suehring |
---|
[3900] | 125 | ! Fix problem with LOD = 2 initialization |
---|
[4648] | 126 | ! |
---|
[3900] | 127 | ! 3885 2019-04-11 11:29:34Z kanani |
---|
[4648] | 128 | ! Changes related to global restructuring of location messages and introduction of additional debug |
---|
| 129 | ! messages |
---|
| 130 | ! |
---|
[3885] | 131 | ! 3849 2019-04-01 16:35:16Z knoop |
---|
[3747] | 132 | ! Move initialization of rmask before initializing user_init_arrays |
---|
[4648] | 133 | ! |
---|
[3747] | 134 | ! 3711 2019-01-31 13:44:26Z knoop |
---|
[3711] | 135 | ! Introduced module_interface_init_checks for post-init checks in modules |
---|
[4648] | 136 | ! |
---|
[3711] | 137 | ! 3700 2019-01-26 17:03:42Z knoop |
---|
[3685] | 138 | ! Some interface calls moved to module_interface + cleanup |
---|
[4648] | 139 | ! |
---|
[3685] | 140 | ! 3648 2019-01-02 16:35:46Z suehring |
---|
[3648] | 141 | ! Rename subroutines for surface-data output |
---|
[3569] | 142 | ! |
---|
[4182] | 143 | ! Revision 1.1 1998/03/09 16:22:22 raasch |
---|
| 144 | ! Initial revision |
---|
| 145 | ! |
---|
| 146 | ! |
---|
[1] | 147 | ! Description: |
---|
| 148 | ! ------------ |
---|
[1682] | 149 | !> Allocation of arrays and initialization of the 3D model via |
---|
| 150 | !> a) pre-run the 1D model |
---|
| 151 | !> or |
---|
| 152 | !> b) pre-set constant linear profiles |
---|
| 153 | !> or |
---|
| 154 | !> c) read values of a previous run |
---|
[4648] | 155 | !--------------------------------------------------------------------------------------------------! |
---|
[1682] | 156 | SUBROUTINE init_3d_model |
---|
[1] | 157 | |
---|
[3298] | 158 | |
---|
[667] | 159 | USE advec_ws |
---|
[1320] | 160 | |
---|
[1] | 161 | USE arrays_3d |
---|
[1849] | 162 | |
---|
[4648] | 163 | USE basic_constants_and_equations_mod, & |
---|
| 164 | ONLY: barometric_formula, c_p, exner_function, exner_function_invers, g, & |
---|
| 165 | ideal_gas_law_rho, ideal_gas_law_rho_pt, l_v, pi |
---|
[3274] | 166 | |
---|
[4648] | 167 | USE bulk_cloud_model_mod, & |
---|
[3685] | 168 | ONLY: bulk_cloud_model |
---|
[3274] | 169 | |
---|
[4648] | 170 | USE chem_modules, & |
---|
[3685] | 171 | ONLY: max_pr_cs ! ToDo: this dependency needs to be removed cause it is ugly #new_dom |
---|
[3298] | 172 | |
---|
[1] | 173 | USE control_parameters |
---|
[3298] | 174 | |
---|
[4877] | 175 | USE exchange_horiz_mod, & |
---|
| 176 | ONLY: exchange_horiz_2d |
---|
| 177 | |
---|
[4648] | 178 | USE grid_variables, & |
---|
[2037] | 179 | ONLY: dx, dy, ddx2_mg, ddy2_mg |
---|
[2817] | 180 | |
---|
[1] | 181 | USE indices |
---|
[3469] | 182 | |
---|
[1320] | 183 | USE kinds |
---|
[4648] | 184 | |
---|
| 185 | USE lsf_nudging_mod, & |
---|
[3685] | 186 | ONLY: ls_forcing_surf |
---|
[1849] | 187 | |
---|
[4648] | 188 | USE model_1d_mod, & |
---|
[3241] | 189 | ONLY: init_1d_model, l1d, u1d, v1d |
---|
[2338] | 190 | |
---|
[4648] | 191 | USE module_interface, & |
---|
| 192 | ONLY: module_interface_init_arrays, & |
---|
| 193 | module_interface_init, & |
---|
[3711] | 194 | module_interface_init_checks |
---|
[3685] | 195 | |
---|
[4648] | 196 | USE multi_agent_system_mod, & |
---|
[3159] | 197 | ONLY: agents_active, mas_init |
---|
| 198 | |
---|
[4648] | 199 | USE netcdf_interface, & |
---|
[3700] | 200 | ONLY: dots_max |
---|
[2696] | 201 | |
---|
[4648] | 202 | USE netcdf_data_input_mod, & |
---|
[4878] | 203 | ONLY: add_ghost_layers, & |
---|
| 204 | char_fill, & |
---|
[4648] | 205 | check_existence, & |
---|
| 206 | close_input_file, & |
---|
| 207 | get_attribute, & |
---|
| 208 | get_variable, & |
---|
| 209 | init_3d, & |
---|
| 210 | input_pids_static, & |
---|
| 211 | inquire_num_variables, & |
---|
| 212 | inquire_variable_names, & |
---|
| 213 | input_file_static, & |
---|
| 214 | netcdf_data_input_init_3d, & |
---|
| 215 | num_var_pids, & |
---|
| 216 | open_read_file, & |
---|
| 217 | pids_id, & |
---|
| 218 | real_2d, & |
---|
[4186] | 219 | vars_pids |
---|
[4648] | 220 | |
---|
| 221 | USE nesting_offl_mod, & |
---|
[3347] | 222 | ONLY: nesting_offl_init |
---|
[3294] | 223 | |
---|
[4648] | 224 | USE palm_date_time_mod, & |
---|
[4680] | 225 | ONLY: init_date_time |
---|
[4227] | 226 | |
---|
[1] | 227 | USE pegrid |
---|
[3298] | 228 | |
---|
[3524] | 229 | #if defined( __parallel ) |
---|
[4648] | 230 | USE pmc_interface, & |
---|
[2934] | 231 | ONLY: nested_run |
---|
[3524] | 232 | #endif |
---|
[2934] | 233 | |
---|
[4648] | 234 | USE random_function_mod |
---|
[3685] | 235 | |
---|
[4648] | 236 | USE random_generator_parallel, & |
---|
[2172] | 237 | ONLY: init_parallel_random_generator |
---|
[3685] | 238 | |
---|
[4648] | 239 | USE read_restart_data_mod, & |
---|
| 240 | ONLY: rrd_local, rrd_read_parts_of_global |
---|
[3685] | 241 | |
---|
[4648] | 242 | USE statistics, & |
---|
| 243 | ONLY: hom, hom_sum, mean_surface_level_height, pr_palm, rmask, statistic_regions, sums, & |
---|
| 244 | sums_divnew_l, sums_divold_l, sums_l, sums_l_l, sums_wsts_bc_l, ts_value, & |
---|
[1833] | 245 | weight_pres, weight_substep |
---|
[2259] | 246 | |
---|
[4648] | 247 | USE synthetic_turbulence_generator_mod, & |
---|
[4848] | 248 | ONLY: stg_init |
---|
[3685] | 249 | |
---|
[4648] | 250 | USE surface_layer_fluxes_mod, & |
---|
[1691] | 251 | ONLY: init_surface_layer_fluxes |
---|
[2232] | 252 | |
---|
[4648] | 253 | USE surface_mod, & |
---|
| 254 | ONLY : init_single_surface_properties, & |
---|
| 255 | init_surface_arrays, & |
---|
| 256 | init_surfaces, & |
---|
| 257 | surf_def_h, & |
---|
| 258 | surf_def_v, & |
---|
| 259 | surf_lsm_h, & |
---|
[4168] | 260 | surf_usm_h |
---|
[3685] | 261 | |
---|
[3849] | 262 | #if defined( _OPENACC ) |
---|
[4648] | 263 | USE surface_mod, & |
---|
[3849] | 264 | ONLY : bc_h |
---|
| 265 | #endif |
---|
| 266 | |
---|
[4648] | 267 | USE surface_data_output_mod, & |
---|
[3648] | 268 | ONLY: surface_data_output_init |
---|
[3685] | 269 | |
---|
[2007] | 270 | USE transpose_indices |
---|
[1] | 271 | |
---|
[4648] | 272 | |
---|
[1] | 273 | IMPLICIT NONE |
---|
[4648] | 274 | |
---|
[4150] | 275 | INTEGER(iwp) :: i !< grid index in x direction |
---|
| 276 | INTEGER(iwp) :: ind_array(1) !< dummy used to determine start index for external pressure forcing |
---|
| 277 | INTEGER(iwp) :: j !< grid index in y direction |
---|
| 278 | INTEGER(iwp) :: k !< grid index in z direction |
---|
| 279 | INTEGER(iwp) :: k_surf !< surface level index |
---|
[4648] | 280 | INTEGER(iwp) :: l !< running index over surface orientation |
---|
| 281 | INTEGER(iwp) :: m !< index of surface element in surface data type |
---|
[4150] | 282 | INTEGER(iwp) :: nz_u_shift !< topography-top index on u-grid, used to vertically shift initial profiles |
---|
| 283 | INTEGER(iwp) :: nz_v_shift !< topography-top index on v-grid, used to vertically shift initial profiles |
---|
| 284 | INTEGER(iwp) :: nz_w_shift !< topography-top index on w-grid, used to vertically shift initial profiles |
---|
| 285 | INTEGER(iwp) :: nz_s_shift !< topography-top index on scalar-grid, used to vertically shift initial profiles |
---|
| 286 | INTEGER(iwp) :: nz_u_shift_l !< topography-top index on u-grid, used to vertically shift initial profiles |
---|
| 287 | INTEGER(iwp) :: nz_v_shift_l !< topography-top index on v-grid, used to vertically shift initial profiles |
---|
| 288 | INTEGER(iwp) :: nz_w_shift_l !< topography-top index on w-grid, used to vertically shift initial profiles |
---|
| 289 | INTEGER(iwp) :: nz_s_shift_l !< topography-top index on scalar-grid, used to vertically shift initial profiles |
---|
| 290 | INTEGER(iwp) :: nzt_l !< index of top PE boundary for multigrid level |
---|
| 291 | INTEGER(iwp) :: sr !< index of statistic region |
---|
[1] | 292 | |
---|
[4648] | 293 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: ngp_2dh_l !< toal number of horizontal grid points in statistical region on |
---|
| 294 | !< subdomain |
---|
[1] | 295 | |
---|
[4648] | 296 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: ngp_2dh_outer_l !< number of horizontal non-wall bounded grid points on |
---|
| 297 | !< subdomain |
---|
| 298 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: ngp_2dh_s_inner_l !< number of horizontal non-topography grid points on |
---|
| 299 | !< subdomain |
---|
[1] | 300 | |
---|
[2037] | 301 | REAL(wp) :: dx_l !< grid spacing along x on different multigrid level |
---|
| 302 | REAL(wp) :: dy_l !< grid spacing along y on different multigrid level |
---|
| 303 | |
---|
[4648] | 304 | REAL(wp), DIMENSION(:), ALLOCATABLE :: init_l !< dummy array used for averaging 3D data to obtain |
---|
| 305 | !< inital profiles |
---|
| 306 | REAL(wp), DIMENSION(:), ALLOCATABLE :: mean_surface_level_height_l !< mean surface level height on subdomain |
---|
| 307 | REAL(wp), DIMENSION(:), ALLOCATABLE :: ngp_3d_inner_l !< total number of non-topography grid points on subdomain |
---|
| 308 | REAL(wp), DIMENSION(:), ALLOCATABLE :: ngp_3d_inner_tmp !< total number of non-topography grid points |
---|
| 309 | REAL(wp), DIMENSION(:), ALLOCATABLE :: p_hydrostatic !< hydrostatic pressure |
---|
| 310 | |
---|
[3547] | 311 | REAL(wp), DIMENSION(1:3) :: volume_flow_area_l !< area of lateral and top model domain surface on local subdomain |
---|
| 312 | REAL(wp), DIMENSION(1:3) :: volume_flow_initial_l !< initial volume flow into model domain |
---|
[1] | 313 | |
---|
[4648] | 314 | TYPE(real_2d) :: tmp_2d !< temporary variable to input additional surface-data from static file |
---|
[1] | 315 | |
---|
[3987] | 316 | CALL location_message( 'model initialization', 'start' ) |
---|
[4227] | 317 | ! |
---|
| 318 | !-- Set reference date-time |
---|
[4680] | 319 | CALL init_date_time( date_time_str=origin_date_time, & |
---|
| 320 | use_fixed_date=use_fixed_date, & |
---|
| 321 | use_fixed_time=use_fixed_time ) |
---|
[3987] | 322 | |
---|
| 323 | IF ( debug_output ) CALL debug_message( 'allocating arrays', 'start' ) |
---|
[1] | 324 | ! |
---|
| 325 | !-- Allocate arrays |
---|
[4648] | 326 | ALLOCATE( mean_surface_level_height(0:statistic_regions), & |
---|
| 327 | mean_surface_level_height_l(0:statistic_regions), & |
---|
| 328 | ngp_2dh(0:statistic_regions), ngp_2dh_l(0:statistic_regions), & |
---|
| 329 | ngp_3d(0:statistic_regions), & |
---|
| 330 | ngp_3d_inner(0:statistic_regions), & |
---|
| 331 | ngp_3d_inner_l(0:statistic_regions), & |
---|
| 332 | ngp_3d_inner_tmp(0:statistic_regions), & |
---|
| 333 | sums_divnew_l(0:statistic_regions), & |
---|
[1] | 334 | sums_divold_l(0:statistic_regions) ) |
---|
[1195] | 335 | ALLOCATE( dp_smooth_factor(nzb:nzt), rdf(nzb+1:nzt), rdf_sc(nzb+1:nzt) ) |
---|
[4648] | 336 | ALLOCATE( ngp_2dh_outer(nzb:nzt+1,0:statistic_regions), & |
---|
| 337 | ngp_2dh_outer_l(nzb:nzt+1,0:statistic_regions), & |
---|
| 338 | ngp_2dh_s_inner(nzb:nzt+1,0:statistic_regions), & |
---|
| 339 | ngp_2dh_s_inner_l(nzb:nzt+1,0:statistic_regions), & |
---|
| 340 | rmask(nysg:nyng,nxlg:nxrg,0:statistic_regions), & |
---|
| 341 | sums(nzb:nzt+1,pr_palm+max_pr_user+max_pr_cs+max_pr_salsa), & |
---|
[4131] | 342 | sums_l(nzb:nzt+1,pr_palm+max_pr_user+max_pr_cs+max_pr_salsa,0:threads_per_task-1), & |
---|
[4648] | 343 | sums_l_l(nzb:nzt+1,0:statistic_regions,0:threads_per_task-1), & |
---|
[3700] | 344 | sums_wsts_bc_l(nzb:nzt+1,0:statistic_regions) ) |
---|
| 345 | ALLOCATE( ts_value(dots_max,0:statistic_regions) ) |
---|
[978] | 346 | ALLOCATE( ptdf_x(nxlg:nxrg), ptdf_y(nysg:nyng) ) |
---|
[1] | 347 | |
---|
[4648] | 348 | ALLOCATE( d(nzb+1:nzt,nys:nyn,nxl:nxr), & |
---|
| 349 | p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
[1010] | 350 | tend(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 351 | |
---|
[4648] | 352 | ALLOCATE( pt_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 353 | pt_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 354 | u_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 355 | u_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 356 | u_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 357 | v_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 358 | v_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 359 | v_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 360 | w_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 361 | w_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
[667] | 362 | w_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
[1788] | 363 | IF ( .NOT. neutral ) THEN |
---|
[1032] | 364 | ALLOCATE( pt_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 365 | ENDIF |
---|
[673] | 366 | ! |
---|
[3747] | 367 | !-- Pre-set masks for regional statistics. Default is the total model domain. |
---|
[4648] | 368 | !-- Ghost points are excluded because counting values at the ghost boundaries would bias the |
---|
| 369 | !-- statistics. |
---|
[3747] | 370 | rmask = 1.0_wp |
---|
| 371 | rmask(:,nxlg:nxl-1,:) = 0.0_wp; rmask(:,nxr+1:nxrg,:) = 0.0_wp |
---|
| 372 | rmask(nysg:nys-1,:,:) = 0.0_wp; rmask(nyn+1:nyng,:,:) = 0.0_wp |
---|
| 373 | ! |
---|
[4648] | 374 | !-- Following array is required for perturbation pressure within the iterative pressure solvers. For |
---|
| 375 | !-- the multistep schemes (Runge-Kutta), array p holds the weighted average of the substeps and |
---|
| 376 | !-- cannot be used in the Poisson solver. |
---|
[707] | 377 | IF ( psolver == 'sor' ) THEN |
---|
| 378 | ALLOCATE( p_loc(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
[1575] | 379 | ELSEIF ( psolver(1:9) == 'multigrid' ) THEN |
---|
[707] | 380 | ! |
---|
| 381 | !-- For performance reasons, multigrid is using one ghost layer only |
---|
| 382 | ALLOCATE( p_loc(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
[673] | 383 | ENDIF |
---|
[1] | 384 | |
---|
[1111] | 385 | ! |
---|
| 386 | !-- Array for storing constant coeffficients of the tridiagonal solver |
---|
| 387 | IF ( psolver == 'poisfft' ) THEN |
---|
[1212] | 388 | ALLOCATE( tri(nxl_z:nxr_z,nys_z:nyn_z,0:nz-1,2) ) |
---|
[1111] | 389 | ALLOCATE( tric(nxl_z:nxr_z,nys_z:nyn_z,0:nz-1) ) |
---|
| 390 | ENDIF |
---|
| 391 | |
---|
[1960] | 392 | IF ( humidity ) THEN |
---|
[1] | 393 | ! |
---|
[1960] | 394 | !-- 3D-humidity |
---|
[4648] | 395 | ALLOCATE( q_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 396 | q_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 397 | q_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 398 | vpt_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 399 | ENDIF |
---|
| 400 | |
---|
[1960] | 401 | IF ( passive_scalar ) THEN |
---|
[1] | 402 | |
---|
[1960] | 403 | ! |
---|
| 404 | !-- 3D scalar arrays |
---|
[4648] | 405 | ALLOCATE( s_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 406 | s_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
[1960] | 407 | s_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
[3636] | 408 | |
---|
[1960] | 409 | ENDIF |
---|
| 410 | |
---|
[1] | 411 | ! |
---|
[4648] | 412 | !-- Allocate and set 1d-profiles for Stokes drift velocity. It may be set to non-zero values later |
---|
| 413 | !-- in ocean_init. |
---|
| 414 | ALLOCATE( u_stokes_zu(nzb:nzt+1), u_stokes_zw(nzb:nzt+1), & |
---|
[3302] | 415 | v_stokes_zu(nzb:nzt+1), v_stokes_zw(nzb:nzt+1) ) |
---|
| 416 | u_stokes_zu(:) = 0.0_wp |
---|
| 417 | u_stokes_zw(:) = 0.0_wp |
---|
| 418 | v_stokes_zu(:) = 0.0_wp |
---|
| 419 | v_stokes_zw(:) = 0.0_wp |
---|
| 420 | |
---|
| 421 | ! |
---|
[2037] | 422 | !-- Allocation of anelastic and Boussinesq approximation specific arrays |
---|
| 423 | ALLOCATE( p_hydrostatic(nzb:nzt+1) ) |
---|
| 424 | ALLOCATE( rho_air(nzb:nzt+1) ) |
---|
| 425 | ALLOCATE( rho_air_zw(nzb:nzt+1) ) |
---|
| 426 | ALLOCATE( drho_air(nzb:nzt+1) ) |
---|
| 427 | ALLOCATE( drho_air_zw(nzb:nzt+1) ) |
---|
| 428 | ! |
---|
[4648] | 429 | !-- Density profile calculation for anelastic and Boussinesq approximation. |
---|
| 430 | !-- In case of a Boussinesq approximation, a constant density is calculated mainly for output |
---|
| 431 | !-- purposes. This density does not need to be considered in the model's system of equations. |
---|
[4088] | 432 | IF ( TRIM( approximation ) == 'anelastic' ) THEN |
---|
[2037] | 433 | DO k = nzb, nzt+1 |
---|
[4648] | 434 | p_hydrostatic(k) = barometric_formula(zu(k), pt_surface * & |
---|
| 435 | exner_function(surface_pressure * 100.0_wp), & |
---|
| 436 | surface_pressure * 100.0_wp) |
---|
| 437 | |
---|
[4088] | 438 | rho_air(k) = ideal_gas_law_rho_pt(p_hydrostatic(k), pt_init(k)) |
---|
[2037] | 439 | ENDDO |
---|
[4648] | 440 | |
---|
[2037] | 441 | DO k = nzb, nzt |
---|
| 442 | rho_air_zw(k) = 0.5_wp * ( rho_air(k) + rho_air(k+1) ) |
---|
| 443 | ENDDO |
---|
[4648] | 444 | |
---|
| 445 | rho_air_zw(nzt+1) = rho_air_zw(nzt) + 2.0_wp * ( rho_air(nzt+1) - rho_air_zw(nzt) ) |
---|
| 446 | |
---|
[2037] | 447 | ELSE |
---|
[2252] | 448 | DO k = nzb, nzt+1 |
---|
[4648] | 449 | p_hydrostatic(k) = barometric_formula(zu(nzb), pt_surface * & |
---|
| 450 | exner_function(surface_pressure * 100.0_wp), & |
---|
| 451 | surface_pressure * 100.0_wp) |
---|
[4088] | 452 | |
---|
| 453 | rho_air(k) = ideal_gas_law_rho_pt(p_hydrostatic(k), pt_init(nzb)) |
---|
[2252] | 454 | ENDDO |
---|
[4648] | 455 | |
---|
[2252] | 456 | DO k = nzb, nzt |
---|
| 457 | rho_air_zw(k) = 0.5_wp * ( rho_air(k) + rho_air(k+1) ) |
---|
| 458 | ENDDO |
---|
[4648] | 459 | |
---|
| 460 | rho_air_zw(nzt+1) = rho_air_zw(nzt) + 2.0_wp * ( rho_air(nzt+1) - rho_air_zw(nzt) ) |
---|
| 461 | |
---|
[2037] | 462 | ENDIF |
---|
[2696] | 463 | ! |
---|
[4648] | 464 | !-- Compute the inverse density array in order to avoid expencive divisions |
---|
[2037] | 465 | drho_air = 1.0_wp / rho_air |
---|
| 466 | drho_air_zw = 1.0_wp / rho_air_zw |
---|
| 467 | |
---|
| 468 | ! |
---|
| 469 | !-- Allocation of flux conversion arrays |
---|
| 470 | ALLOCATE( heatflux_input_conversion(nzb:nzt+1) ) |
---|
| 471 | ALLOCATE( waterflux_input_conversion(nzb:nzt+1) ) |
---|
| 472 | ALLOCATE( momentumflux_input_conversion(nzb:nzt+1) ) |
---|
| 473 | ALLOCATE( heatflux_output_conversion(nzb:nzt+1) ) |
---|
| 474 | ALLOCATE( waterflux_output_conversion(nzb:nzt+1) ) |
---|
| 475 | ALLOCATE( momentumflux_output_conversion(nzb:nzt+1) ) |
---|
| 476 | |
---|
| 477 | ! |
---|
[4648] | 478 | !-- Calculate flux conversion factors according to approximation and in-/output mode |
---|
[2037] | 479 | DO k = nzb, nzt+1 |
---|
| 480 | |
---|
| 481 | IF ( TRIM( flux_input_mode ) == 'kinematic' ) THEN |
---|
| 482 | heatflux_input_conversion(k) = rho_air_zw(k) |
---|
| 483 | waterflux_input_conversion(k) = rho_air_zw(k) |
---|
| 484 | momentumflux_input_conversion(k) = rho_air_zw(k) |
---|
| 485 | ELSEIF ( TRIM( flux_input_mode ) == 'dynamic' ) THEN |
---|
[3274] | 486 | heatflux_input_conversion(k) = 1.0_wp / c_p |
---|
[2037] | 487 | waterflux_input_conversion(k) = 1.0_wp / l_v |
---|
| 488 | momentumflux_input_conversion(k) = 1.0_wp |
---|
| 489 | ENDIF |
---|
| 490 | |
---|
| 491 | IF ( TRIM( flux_output_mode ) == 'kinematic' ) THEN |
---|
| 492 | heatflux_output_conversion(k) = drho_air_zw(k) |
---|
| 493 | waterflux_output_conversion(k) = drho_air_zw(k) |
---|
| 494 | momentumflux_output_conversion(k) = drho_air_zw(k) |
---|
| 495 | ELSEIF ( TRIM( flux_output_mode ) == 'dynamic' ) THEN |
---|
[3274] | 496 | heatflux_output_conversion(k) = c_p |
---|
[2037] | 497 | waterflux_output_conversion(k) = l_v |
---|
| 498 | momentumflux_output_conversion(k) = 1.0_wp |
---|
| 499 | ENDIF |
---|
| 500 | |
---|
| 501 | IF ( .NOT. humidity ) THEN |
---|
| 502 | waterflux_input_conversion(k) = 1.0_wp |
---|
| 503 | waterflux_output_conversion(k) = 1.0_wp |
---|
| 504 | ENDIF |
---|
| 505 | |
---|
| 506 | ENDDO |
---|
| 507 | |
---|
| 508 | ! |
---|
[4648] | 509 | !-- In case of multigrid method, compute grid lengths and grid factors for the grid levels with |
---|
| 510 | !-- respective density on each grid. |
---|
[2037] | 511 | IF ( psolver(1:9) == 'multigrid' ) THEN |
---|
| 512 | |
---|
| 513 | ALLOCATE( ddx2_mg(maximum_grid_level) ) |
---|
| 514 | ALLOCATE( ddy2_mg(maximum_grid_level) ) |
---|
| 515 | ALLOCATE( dzu_mg(nzb+1:nzt+1,maximum_grid_level) ) |
---|
| 516 | ALLOCATE( dzw_mg(nzb+1:nzt+1,maximum_grid_level) ) |
---|
| 517 | ALLOCATE( f1_mg(nzb+1:nzt,maximum_grid_level) ) |
---|
| 518 | ALLOCATE( f2_mg(nzb+1:nzt,maximum_grid_level) ) |
---|
| 519 | ALLOCATE( f3_mg(nzb+1:nzt,maximum_grid_level) ) |
---|
| 520 | ALLOCATE( rho_air_mg(nzb:nzt+1,maximum_grid_level) ) |
---|
| 521 | ALLOCATE( rho_air_zw_mg(nzb:nzt+1,maximum_grid_level) ) |
---|
| 522 | |
---|
| 523 | dzu_mg(:,maximum_grid_level) = dzu |
---|
| 524 | rho_air_mg(:,maximum_grid_level) = rho_air |
---|
[4648] | 525 | ! |
---|
| 526 | !-- Next line to ensure an equally spaced grid. |
---|
[2037] | 527 | dzu_mg(1,maximum_grid_level) = dzu(2) |
---|
[4648] | 528 | rho_air_mg(nzb,maximum_grid_level) = rho_air(nzb) + (rho_air(nzb) - rho_air(nzb+1)) |
---|
[2037] | 529 | |
---|
| 530 | dzw_mg(:,maximum_grid_level) = dzw |
---|
| 531 | rho_air_zw_mg(:,maximum_grid_level) = rho_air_zw |
---|
| 532 | nzt_l = nzt |
---|
| 533 | DO l = maximum_grid_level-1, 1, -1 |
---|
| 534 | dzu_mg(nzb+1,l) = 2.0_wp * dzu_mg(nzb+1,l+1) |
---|
| 535 | dzw_mg(nzb+1,l) = 2.0_wp * dzw_mg(nzb+1,l+1) |
---|
[4648] | 536 | rho_air_mg(nzb,l) = rho_air_mg(nzb,l+1) + ( rho_air_mg(nzb,l+1) - & |
---|
| 537 | rho_air_mg(nzb+1,l+1) ) |
---|
| 538 | rho_air_zw_mg(nzb,l) = rho_air_zw_mg(nzb,l+1) + ( rho_air_zw_mg(nzb,l+1) - & |
---|
| 539 | rho_air_zw_mg(nzb+1,l+1) ) |
---|
[2037] | 540 | rho_air_mg(nzb+1,l) = rho_air_mg(nzb+1,l+1) |
---|
| 541 | rho_air_zw_mg(nzb+1,l) = rho_air_zw_mg(nzb+1,l+1) |
---|
| 542 | nzt_l = nzt_l / 2 |
---|
| 543 | DO k = 2, nzt_l+1 |
---|
| 544 | dzu_mg(k,l) = dzu_mg(2*k-2,l+1) + dzu_mg(2*k-1,l+1) |
---|
| 545 | dzw_mg(k,l) = dzw_mg(2*k-2,l+1) + dzw_mg(2*k-1,l+1) |
---|
| 546 | rho_air_mg(k,l) = rho_air_mg(2*k-1,l+1) |
---|
| 547 | rho_air_zw_mg(k,l) = rho_air_zw_mg(2*k-1,l+1) |
---|
| 548 | ENDDO |
---|
| 549 | ENDDO |
---|
| 550 | |
---|
| 551 | nzt_l = nzt |
---|
| 552 | dx_l = dx |
---|
| 553 | dy_l = dy |
---|
| 554 | DO l = maximum_grid_level, 1, -1 |
---|
| 555 | ddx2_mg(l) = 1.0_wp / dx_l**2 |
---|
| 556 | ddy2_mg(l) = 1.0_wp / dy_l**2 |
---|
| 557 | DO k = nzb+1, nzt_l |
---|
| 558 | f2_mg(k,l) = rho_air_zw_mg(k,l) / ( dzu_mg(k+1,l) * dzw_mg(k,l) ) |
---|
| 559 | f3_mg(k,l) = rho_air_zw_mg(k-1,l) / ( dzu_mg(k,l) * dzw_mg(k,l) ) |
---|
[4648] | 560 | f1_mg(k,l) = 2.0_wp * ( ddx2_mg(l) + ddy2_mg(l) ) & |
---|
[2037] | 561 | * rho_air_mg(k,l) + f2_mg(k,l) + f3_mg(k,l) |
---|
| 562 | ENDDO |
---|
| 563 | nzt_l = nzt_l / 2 |
---|
| 564 | dx_l = dx_l * 2.0_wp |
---|
| 565 | dy_l = dy_l * 2.0_wp |
---|
| 566 | ENDDO |
---|
| 567 | |
---|
| 568 | ENDIF |
---|
| 569 | |
---|
| 570 | ! |
---|
[1299] | 571 | !-- 1D-array for large scale subsidence velocity |
---|
[1361] | 572 | IF ( .NOT. ALLOCATED( w_subs ) ) THEN |
---|
| 573 | ALLOCATE ( w_subs(nzb:nzt+1) ) |
---|
| 574 | w_subs = 0.0_wp |
---|
| 575 | ENDIF |
---|
[1299] | 576 | |
---|
| 577 | ! |
---|
[1] | 578 | !-- Initial assignment of the pointers |
---|
[1032] | 579 | IF ( .NOT. neutral ) THEN |
---|
| 580 | pt => pt_1; pt_p => pt_2; tpt_m => pt_3 |
---|
| 581 | ELSE |
---|
| 582 | pt => pt_1; pt_p => pt_1; tpt_m => pt_3 |
---|
| 583 | ENDIF |
---|
[1001] | 584 | u => u_1; u_p => u_2; tu_m => u_3 |
---|
| 585 | v => v_1; v_p => v_2; tv_m => v_3 |
---|
| 586 | w => w_1; w_p => w_2; tw_m => w_3 |
---|
[1] | 587 | |
---|
[1960] | 588 | IF ( humidity ) THEN |
---|
[1001] | 589 | q => q_1; q_p => q_2; tq_m => q_3 |
---|
[3274] | 590 | vpt => vpt_1 |
---|
[1001] | 591 | ENDIF |
---|
[4648] | 592 | |
---|
[1960] | 593 | IF ( passive_scalar ) THEN |
---|
| 594 | s => s_1; s_p => s_2; ts_m => s_3 |
---|
[4648] | 595 | ENDIF |
---|
[1] | 596 | |
---|
| 597 | ! |
---|
[2696] | 598 | !-- Initialize surface arrays |
---|
[2232] | 599 | CALL init_surface_arrays |
---|
| 600 | ! |
---|
[3294] | 601 | !-- Allocate arrays for other modules |
---|
[3685] | 602 | CALL module_interface_init_arrays |
---|
[1551] | 603 | |
---|
[1914] | 604 | |
---|
[2320] | 605 | ! |
---|
[4648] | 606 | !-- Allocate arrays containing the RK coefficient for calculation of perturbation pressure and |
---|
| 607 | !-- turbulent fluxes. At this point values are set for pressure calculation during initialization |
---|
| 608 | !-- (where no timestep is done). Further below the values needed within the timestep scheme will be |
---|
| 609 | !-- set. |
---|
| 610 | ALLOCATE( weight_substep(1:intermediate_timestep_count_max), & |
---|
[1878] | 611 | weight_pres(1:intermediate_timestep_count_max) ) |
---|
[1340] | 612 | weight_substep = 1.0_wp |
---|
| 613 | weight_pres = 1.0_wp |
---|
[1918] | 614 | intermediate_timestep_count = 0 ! needed when simulated_time = 0.0 |
---|
[4648] | 615 | |
---|
[3987] | 616 | IF ( debug_output ) CALL debug_message( 'allocating arrays', 'end' ) |
---|
[1918] | 617 | |
---|
[673] | 618 | ! |
---|
[3014] | 619 | !-- Initialize time series |
---|
| 620 | ts_value = 0.0_wp |
---|
| 621 | |
---|
| 622 | ! |
---|
[1918] | 623 | !-- Initialize local summation arrays for routine flow_statistics. |
---|
[4648] | 624 | !-- This is necessary because they may not yet have been initialized when they are called from |
---|
| 625 | !-- flow_statistics (or - depending on the chosen model run - are never initialized) |
---|
| 626 | sums_divnew_l = 0.0_wp |
---|
| 627 | sums_divold_l = 0.0_wp |
---|
| 628 | sums_l_l = 0.0_wp |
---|
| 629 | sums_wsts_bc_l = 0.0_wp |
---|
| 630 | |
---|
[1918] | 631 | ! |
---|
[1] | 632 | !-- Initialize model variables |
---|
[4648] | 633 | IF ( TRIM( initializing_actions ) /= 'read_restart_data' .AND. & |
---|
[328] | 634 | TRIM( initializing_actions ) /= 'cyclic_fill' ) THEN |
---|
[1] | 635 | ! |
---|
[2696] | 636 | !-- Initialization with provided input data derived from larger-scale model |
---|
| 637 | IF ( INDEX( initializing_actions, 'inifor' ) /= 0 ) THEN |
---|
[3987] | 638 | IF ( debug_output ) CALL debug_message( 'initializing with INIFOR', 'start' ) |
---|
[2696] | 639 | ! |
---|
[4648] | 640 | !-- Read initial 1D profiles or 3D data from NetCDF file, depending on the provided |
---|
| 641 | !-- level-of-detail. |
---|
| 642 | !-- At the moment, only u, v, w, pt and q are provided. |
---|
[2696] | 643 | CALL netcdf_data_input_init_3d |
---|
| 644 | ! |
---|
[4648] | 645 | !-- Please note, Inifor provides data from nzb+1 to nzt. |
---|
| 646 | !-- Bottom and top boundary conditions for Inifor profiles are already set (just after |
---|
| 647 | !-- reading), so that this is not necessary here. |
---|
| 648 | !-- Depending on the provided level-of-detail, initial Inifor data is either stored on data |
---|
| 649 | !-- type (lod=1), or directly on 3D arrays (lod=2). |
---|
| 650 | !-- In order to obtain also initial profiles in case of lod=2 (which is required for e.g. |
---|
| 651 | !-- damping), average over 3D data. |
---|
[3182] | 652 | IF( init_3d%lod_u == 1 ) THEN |
---|
| 653 | u_init = init_3d%u_init |
---|
[4648] | 654 | ELSEIF( init_3d%lod_u == 2 ) THEN |
---|
| 655 | ALLOCATE( init_l(nzb:nzt+1) ) |
---|
[3182] | 656 | DO k = nzb, nzt+1 |
---|
| 657 | init_l(k) = SUM( u(k,nys:nyn,nxl:nxr) ) |
---|
| 658 | ENDDO |
---|
| 659 | init_l = init_l / REAL( ( nx + 1 ) * ( ny + 1 ), KIND = wp ) |
---|
[1384] | 660 | |
---|
[3182] | 661 | #if defined( __parallel ) |
---|
[4648] | 662 | CALL MPI_ALLREDUCE( init_l, u_init, nzt+1-nzb+1, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
[3182] | 663 | #else |
---|
| 664 | u_init = init_l |
---|
| 665 | #endif |
---|
| 666 | DEALLOCATE( init_l ) |
---|
[3051] | 667 | |
---|
[2696] | 668 | ENDIF |
---|
[4648] | 669 | |
---|
| 670 | IF( init_3d%lod_v == 1 ) THEN |
---|
[3182] | 671 | v_init = init_3d%v_init |
---|
[4648] | 672 | ELSEIF( init_3d%lod_v == 2 ) THEN |
---|
| 673 | ALLOCATE( init_l(nzb:nzt+1) ) |
---|
[3182] | 674 | DO k = nzb, nzt+1 |
---|
| 675 | init_l(k) = SUM( v(k,nys:nyn,nxl:nxr) ) |
---|
| 676 | ENDDO |
---|
| 677 | init_l = init_l / REAL( ( nx + 1 ) * ( ny + 1 ), KIND = wp ) |
---|
[2696] | 678 | |
---|
[3182] | 679 | #if defined( __parallel ) |
---|
[4648] | 680 | CALL MPI_ALLREDUCE( init_l, v_init, nzt+1-nzb+1, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
[3182] | 681 | #else |
---|
| 682 | v_init = init_l |
---|
| 683 | #endif |
---|
| 684 | DEALLOCATE( init_l ) |
---|
| 685 | ENDIF |
---|
| 686 | IF( .NOT. neutral ) THEN |
---|
| 687 | IF( init_3d%lod_pt == 1 ) THEN |
---|
| 688 | pt_init = init_3d%pt_init |
---|
[4648] | 689 | ELSEIF( init_3d%lod_pt == 2 ) THEN |
---|
| 690 | ALLOCATE( init_l(nzb:nzt+1) ) |
---|
[3182] | 691 | DO k = nzb, nzt+1 |
---|
| 692 | init_l(k) = SUM( pt(k,nys:nyn,nxl:nxr) ) |
---|
| 693 | ENDDO |
---|
| 694 | init_l = init_l / REAL( ( nx + 1 ) * ( ny + 1 ), KIND = wp ) |
---|
| 695 | |
---|
| 696 | #if defined( __parallel ) |
---|
[4648] | 697 | CALL MPI_ALLREDUCE( init_l, pt_init, nzt+1-nzb+1, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
[3182] | 698 | #else |
---|
| 699 | pt_init = init_l |
---|
| 700 | #endif |
---|
| 701 | DEALLOCATE( init_l ) |
---|
| 702 | ENDIF |
---|
| 703 | ENDIF |
---|
| 704 | |
---|
| 705 | |
---|
| 706 | IF( humidity ) THEN |
---|
| 707 | IF( init_3d%lod_q == 1 ) THEN |
---|
| 708 | q_init = init_3d%q_init |
---|
[4648] | 709 | ELSEIF( init_3d%lod_q == 2 ) THEN |
---|
| 710 | ALLOCATE( init_l(nzb:nzt+1) ) |
---|
[3182] | 711 | DO k = nzb, nzt+1 |
---|
| 712 | init_l(k) = SUM( q(k,nys:nyn,nxl:nxr) ) |
---|
| 713 | ENDDO |
---|
| 714 | init_l = init_l / REAL( ( nx + 1 ) * ( ny + 1 ), KIND = wp ) |
---|
| 715 | |
---|
| 716 | #if defined( __parallel ) |
---|
[4648] | 717 | CALL MPI_ALLREDUCE( init_l, q_init, nzt+1-nzb+1, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
[3182] | 718 | #else |
---|
| 719 | q_init = init_l |
---|
| 720 | #endif |
---|
| 721 | DEALLOCATE( init_l ) |
---|
| 722 | ENDIF |
---|
| 723 | ENDIF |
---|
| 724 | |
---|
[2696] | 725 | ! |
---|
[4648] | 726 | !-- Write initial profiles onto 3D arrays. |
---|
| 727 | !-- Work-around, 3D initialization of u,v,w creates artificial structures which correlate with |
---|
| 728 | !-- the processor grid. The reason for this is still unknown. To work-around this, 3D |
---|
| 729 | !-- initialization will be effectively reduce to a 1D initialization where no such artificial |
---|
| 730 | !-- structures appear. |
---|
[2696] | 731 | DO i = nxlg, nxrg |
---|
| 732 | DO j = nysg, nyng |
---|
[4648] | 733 | IF( init_3d%lod_u == 1 .OR. init_3d%lod_u == 2 ) u(:,j,i) = u_init(:) |
---|
| 734 | IF( init_3d%lod_v == 1 .OR. init_3d%lod_u == 2 ) v(:,j,i) = v_init(:) |
---|
| 735 | IF( .NOT. neutral .AND. ( init_3d%lod_pt == 1 .OR. init_3d%lod_pt == 2 ) ) & |
---|
[3051] | 736 | pt(:,j,i) = pt_init(:) |
---|
[4648] | 737 | IF( humidity .AND. ( init_3d%lod_q == 1 .OR. init_3d%lod_q == 2 ) ) & |
---|
[4130] | 738 | q(:,j,i) = q_init(:) |
---|
[2696] | 739 | ENDDO |
---|
| 740 | ENDDO |
---|
| 741 | ! |
---|
[4648] | 742 | !-- Set geostrophic wind components. |
---|
[2938] | 743 | IF ( init_3d%from_file_ug ) THEN |
---|
| 744 | ug(:) = init_3d%ug_init(:) |
---|
| 745 | ENDIF |
---|
| 746 | IF ( init_3d%from_file_vg ) THEN |
---|
| 747 | vg(:) = init_3d%vg_init(:) |
---|
| 748 | ENDIF |
---|
[3404] | 749 | ! |
---|
| 750 | !-- Set bottom and top boundary condition for geostrophic wind |
---|
[2938] | 751 | ug(nzt+1) = ug(nzt) |
---|
| 752 | vg(nzt+1) = vg(nzt) |
---|
[3404] | 753 | ug(nzb) = ug(nzb+1) |
---|
| 754 | vg(nzb) = vg(nzb+1) |
---|
[2696] | 755 | ! |
---|
| 756 | !-- Set inital w to 0 |
---|
| 757 | w = 0.0_wp |
---|
| 758 | |
---|
| 759 | IF ( passive_scalar ) THEN |
---|
| 760 | DO i = nxlg, nxrg |
---|
| 761 | DO j = nysg, nyng |
---|
| 762 | s(:,j,i) = s_init |
---|
| 763 | ENDDO |
---|
| 764 | ENDDO |
---|
| 765 | ENDIF |
---|
| 766 | |
---|
| 767 | ! |
---|
[4648] | 768 | !-- Set velocity components at non-atmospheric / oceanic grid points to zero. |
---|
[4346] | 769 | u = MERGE( u, 0.0_wp, BTEST( wall_flags_total_0, 1 ) ) |
---|
| 770 | v = MERGE( v, 0.0_wp, BTEST( wall_flags_total_0, 2 ) ) |
---|
| 771 | w = MERGE( w, 0.0_wp, BTEST( wall_flags_total_0, 3 ) ) |
---|
[2700] | 772 | ! |
---|
[4648] | 773 | !-- Initialize surface variables, e.g. friction velocity, momentum fluxes, etc. |
---|
| 774 | CALL init_surfaces |
---|
[2696] | 775 | |
---|
[4648] | 776 | IF ( debug_output ) CALL debug_message( 'initializing with INIFOR', 'end' ) |
---|
[2696] | 777 | ! |
---|
| 778 | !-- Initialization via computed 1D-model profiles |
---|
| 779 | ELSEIF ( INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 ) THEN |
---|
| 780 | |
---|
[4648] | 781 | IF ( debug_output ) CALL debug_message( 'initializing with 1D model profiles', 'start' ) |
---|
[1] | 782 | ! |
---|
| 783 | !-- Use solutions of the 1D model as initial profiles, |
---|
| 784 | !-- start 1D model |
---|
| 785 | CALL init_1d_model |
---|
| 786 | ! |
---|
| 787 | !-- Transfer initial profiles to the arrays of the 3D model |
---|
[667] | 788 | DO i = nxlg, nxrg |
---|
| 789 | DO j = nysg, nyng |
---|
[1] | 790 | pt(:,j,i) = pt_init |
---|
| 791 | u(:,j,i) = u1d |
---|
| 792 | v(:,j,i) = v1d |
---|
| 793 | ENDDO |
---|
| 794 | ENDDO |
---|
| 795 | |
---|
[1960] | 796 | IF ( humidity ) THEN |
---|
[667] | 797 | DO i = nxlg, nxrg |
---|
| 798 | DO j = nysg, nyng |
---|
[1] | 799 | q(:,j,i) = q_init |
---|
| 800 | ENDDO |
---|
| 801 | ENDDO |
---|
| 802 | ENDIF |
---|
[2292] | 803 | |
---|
[1960] | 804 | IF ( passive_scalar ) THEN |
---|
| 805 | DO i = nxlg, nxrg |
---|
| 806 | DO j = nysg, nyng |
---|
| 807 | s(:,j,i) = s_init |
---|
| 808 | ENDDO |
---|
[4648] | 809 | ENDDO |
---|
[1960] | 810 | ENDIF |
---|
[1] | 811 | ! |
---|
| 812 | !-- Store initial profiles for output purposes etc. |
---|
[2696] | 813 | IF ( .NOT. constant_diffusion ) THEN |
---|
[1] | 814 | hom(:,1,25,:) = SPREAD( l1d, 2, statistic_regions+1 ) |
---|
| 815 | ENDIF |
---|
| 816 | ! |
---|
[2696] | 817 | !-- Set velocities back to zero |
---|
[4346] | 818 | u = MERGE( u, 0.0_wp, BTEST( wall_flags_total_0, 1 ) ) |
---|
[4648] | 819 | v = MERGE( v, 0.0_wp, BTEST( wall_flags_total_0, 2 ) ) |
---|
[1] | 820 | ! |
---|
[4648] | 821 | !-- WARNING: The extra boundary conditions set after running the 1D model impose an error on |
---|
| 822 | !-- -------- the divergence one layer below the topography; need to correct later |
---|
| 823 | !-- ATTENTION: Provisional correction for Piacsek & Williams advection scheme: keep u and v |
---|
| 824 | !-- ---------- zero one layer below the topography. |
---|
[2696] | 825 | IF ( ibc_uv_b == 1 ) THEN |
---|
[667] | 826 | ! |
---|
[2696] | 827 | !-- Neumann condition |
---|
| 828 | DO i = nxl-1, nxr+1 |
---|
| 829 | DO j = nys-1, nyn+1 |
---|
| 830 | u(nzb,j,i) = u(nzb+1,j,i) |
---|
| 831 | v(nzb,j,i) = v(nzb+1,j,i) |
---|
[1] | 832 | ENDDO |
---|
[2696] | 833 | ENDDO |
---|
[1] | 834 | |
---|
| 835 | ENDIF |
---|
[2618] | 836 | ! |
---|
[4648] | 837 | !-- Initialize surface variables, e.g. friction velocity, momentum fluxes, etc. |
---|
[2618] | 838 | CALL init_surfaces |
---|
[1] | 839 | |
---|
[4648] | 840 | IF ( debug_output ) CALL debug_message( 'initializing with 1D model profiles', 'end' ) |
---|
[1384] | 841 | |
---|
[4648] | 842 | ELSEIF ( INDEX(initializing_actions, 'set_constant_profiles') /= 0 ) THEN |
---|
[1241] | 843 | |
---|
[4648] | 844 | IF ( debug_output ) CALL debug_message( 'initializing with constant profiles', 'start' ) |
---|
[2259] | 845 | |
---|
| 846 | ! |
---|
[4648] | 847 | !-- Use constructed initial profiles (velocity constant with height, temperature profile with |
---|
| 848 | !-- constant gradient) |
---|
[667] | 849 | DO i = nxlg, nxrg |
---|
| 850 | DO j = nysg, nyng |
---|
[1] | 851 | pt(:,j,i) = pt_init |
---|
| 852 | u(:,j,i) = u_init |
---|
| 853 | v(:,j,i) = v_init |
---|
| 854 | ENDDO |
---|
| 855 | ENDDO |
---|
| 856 | ! |
---|
[2758] | 857 | !-- Mask topography |
---|
[4346] | 858 | u = MERGE( u, 0.0_wp, BTEST( wall_flags_total_0, 1 ) ) |
---|
| 859 | v = MERGE( v, 0.0_wp, BTEST( wall_flags_total_0, 2 ) ) |
---|
[2758] | 860 | ! |
---|
[4648] | 861 | !-- Set initial horizontal velocities at the lowest computational grid levels to zero in order |
---|
| 862 | !-- to avoid too small time steps caused by the diffusion limit in the initial phase of a run |
---|
| 863 | !-- (at k=1, dz/2 occurs in the limiting formula!). |
---|
| 864 | !-- Please note, in case land- or urban-surface model is used and a spinup is applied, masking |
---|
| 865 | !-- the lowest computational level is not possible as MOST as well as energy-balance |
---|
| 866 | !-- parametrizations will not work with zero wind velocity. |
---|
| 867 | IF ( ibc_uv_b /= 1 .AND. .NOT. spinup ) THEN |
---|
[1815] | 868 | DO i = nxlg, nxrg |
---|
| 869 | DO j = nysg, nyng |
---|
[2232] | 870 | DO k = nzb, nzt |
---|
[4648] | 871 | u(k,j,i) = MERGE( u(k,j,i), 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 20 ) ) |
---|
| 872 | v(k,j,i) = MERGE( v(k,j,i), 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 21 ) ) |
---|
[2232] | 873 | ENDDO |
---|
[1815] | 874 | ENDDO |
---|
| 875 | ENDDO |
---|
| 876 | ENDIF |
---|
[1] | 877 | |
---|
[1960] | 878 | IF ( humidity ) THEN |
---|
[667] | 879 | DO i = nxlg, nxrg |
---|
| 880 | DO j = nysg, nyng |
---|
[1] | 881 | q(:,j,i) = q_init |
---|
| 882 | ENDDO |
---|
| 883 | ENDDO |
---|
| 884 | ENDIF |
---|
[4648] | 885 | |
---|
[1960] | 886 | IF ( passive_scalar ) THEN |
---|
| 887 | DO i = nxlg, nxrg |
---|
| 888 | DO j = nysg, nyng |
---|
| 889 | s(:,j,i) = s_init |
---|
| 890 | ENDDO |
---|
| 891 | ENDDO |
---|
| 892 | ENDIF |
---|
[1] | 893 | |
---|
[1920] | 894 | ! |
---|
[4648] | 895 | !-- Compute initial temperature field and other constants used in case of a sloping surface. |
---|
[1] | 896 | IF ( sloping_surface ) CALL init_slope |
---|
[2618] | 897 | ! |
---|
[4648] | 898 | !-- Initialize surface variables, e.g. friction velocity, momentum fluxes, etc. |
---|
[2618] | 899 | CALL init_surfaces |
---|
[4648] | 900 | |
---|
[3987] | 901 | IF ( debug_output ) CALL debug_message( 'initializing with constant profiles', 'end' ) |
---|
[1384] | 902 | |
---|
[4648] | 903 | ELSEIF ( INDEX(initializing_actions, 'by_user') /= 0 ) THEN |
---|
[1384] | 904 | |
---|
[3987] | 905 | IF ( debug_output ) CALL debug_message( 'initializing by user', 'start' ) |
---|
[46] | 906 | ! |
---|
[4648] | 907 | !-- Pre-initialize surface variables, i.e. setting start- and end-indices at each |
---|
| 908 | !-- (j,i)-location. Please note, this does not supersede user-defined initialization of |
---|
| 909 | !-- surface quantities. |
---|
[2618] | 910 | CALL init_surfaces |
---|
| 911 | ! |
---|
[46] | 912 | !-- Initialization will completely be done by the user |
---|
| 913 | CALL user_init_3d_model |
---|
| 914 | |
---|
[3987] | 915 | IF ( debug_output ) CALL debug_message( 'initializing by user', 'end' ) |
---|
[1384] | 916 | |
---|
[1] | 917 | ENDIF |
---|
[1384] | 918 | |
---|
[4648] | 919 | IF ( debug_output ) THEN |
---|
| 920 | CALL debug_message( 'initializing statistics, boundary conditions, etc.', 'start' ) |
---|
| 921 | ENDIF |
---|
[1384] | 922 | |
---|
[667] | 923 | ! |
---|
| 924 | !-- Bottom boundary |
---|
[4648] | 925 | IF ( ibc_uv_b == 0 .OR. ibc_uv_b == 2 ) THEN |
---|
[1340] | 926 | u(nzb,:,:) = 0.0_wp |
---|
| 927 | v(nzb,:,:) = 0.0_wp |
---|
[667] | 928 | ENDIF |
---|
[1] | 929 | |
---|
| 930 | ! |
---|
[151] | 931 | !-- Apply channel flow boundary condition |
---|
[132] | 932 | IF ( TRIM( bc_uv_t ) == 'dirichlet_0' ) THEN |
---|
[1340] | 933 | u(nzt+1,:,:) = 0.0_wp |
---|
| 934 | v(nzt+1,:,:) = 0.0_wp |
---|
[132] | 935 | ENDIF |
---|
| 936 | |
---|
| 937 | ! |
---|
[1] | 938 | !-- Calculate virtual potential temperature |
---|
[1960] | 939 | IF ( humidity ) vpt = pt * ( 1.0_wp + 0.61_wp * q ) |
---|
[1] | 940 | |
---|
| 941 | ! |
---|
[4648] | 942 | !-- Store initial profiles for output purposes etc.. Please note, in case of initialization of u, |
---|
| 943 | !-- v, w, pt, and q via output data derived from larger scale models, data will not be |
---|
| 944 | !-- horizontally homogeneous. Actually, a mean profile should be calculated before. |
---|
[1] | 945 | hom(:,1,5,:) = SPREAD( u(:,nys,nxl), 2, statistic_regions+1 ) |
---|
| 946 | hom(:,1,6,:) = SPREAD( v(:,nys,nxl), 2, statistic_regions+1 ) |
---|
[667] | 947 | IF ( ibc_uv_b == 0 .OR. ibc_uv_b == 2) THEN |
---|
[1340] | 948 | hom(nzb,1,5,:) = 0.0_wp |
---|
| 949 | hom(nzb,1,6,:) = 0.0_wp |
---|
[1] | 950 | ENDIF |
---|
| 951 | hom(:,1,7,:) = SPREAD( pt(:,nys,nxl), 2, statistic_regions+1 ) |
---|
| 952 | |
---|
[75] | 953 | IF ( humidity ) THEN |
---|
[1] | 954 | ! |
---|
[4648] | 955 | !-- Store initial profile of total water content, virtual potential temperature |
---|
[1] | 956 | hom(:,1,26,:) = SPREAD( q(:,nys,nxl), 2, statistic_regions+1 ) |
---|
| 957 | hom(:,1,29,:) = SPREAD( vpt(:,nys,nxl), 2, statistic_regions+1 ) |
---|
[2696] | 958 | ! |
---|
[4648] | 959 | !-- Store initial profile of mixing ratio and potential temperature |
---|
[3274] | 960 | IF ( bulk_cloud_model .OR. cloud_droplets ) THEN |
---|
[1] | 961 | hom(:,1,27,:) = SPREAD( q(:,nys,nxl), 2, statistic_regions+1 ) |
---|
| 962 | hom(:,1,28,:) = SPREAD( pt(:,nys,nxl), 2, statistic_regions+1 ) |
---|
| 963 | ENDIF |
---|
| 964 | ENDIF |
---|
| 965 | |
---|
[2696] | 966 | ! |
---|
| 967 | !-- Store initial scalar profile |
---|
[1] | 968 | IF ( passive_scalar ) THEN |
---|
[2513] | 969 | hom(:,1,121,:) = SPREAD( s(:,nys,nxl), 2, statistic_regions+1 ) |
---|
[1] | 970 | ENDIF |
---|
| 971 | |
---|
| 972 | ! |
---|
[1400] | 973 | !-- Initialize the random number generators (from numerical recipes) |
---|
| 974 | CALL random_function_ini |
---|
[4648] | 975 | |
---|
[1400] | 976 | IF ( random_generator == 'random-parallel' ) THEN |
---|
[3241] | 977 | CALL init_parallel_random_generator( nx, nys, nyn, nxl, nxr ) |
---|
[1400] | 978 | ENDIF |
---|
| 979 | ! |
---|
[4648] | 980 | !-- Set the reference state to be used in the buoyancy terms (for ocean runs the reference state |
---|
| 981 | !-- will be set (overwritten) in init_ocean). |
---|
[1179] | 982 | IF ( use_single_reference_value ) THEN |
---|
[4648] | 983 | IF ( .NOT. humidity ) THEN |
---|
[1179] | 984 | ref_state(:) = pt_reference |
---|
| 985 | ELSE |
---|
| 986 | ref_state(:) = vpt_reference |
---|
| 987 | ENDIF |
---|
| 988 | ELSE |
---|
[4648] | 989 | IF ( .NOT. humidity ) THEN |
---|
[1179] | 990 | ref_state(:) = pt_init(:) |
---|
| 991 | ELSE |
---|
| 992 | ref_state(:) = vpt(:,nys,nxl) |
---|
| 993 | ENDIF |
---|
| 994 | ENDIF |
---|
[152] | 995 | |
---|
| 996 | ! |
---|
[707] | 997 | !-- For the moment, vertical velocity is zero |
---|
[1340] | 998 | w = 0.0_wp |
---|
[1] | 999 | |
---|
| 1000 | ! |
---|
| 1001 | !-- Initialize array sums (must be defined in first call of pres) |
---|
[1340] | 1002 | sums = 0.0_wp |
---|
[1] | 1003 | |
---|
| 1004 | ! |
---|
[707] | 1005 | !-- In case of iterative solvers, p must get an initial value |
---|
[1575] | 1006 | IF ( psolver(1:9) == 'multigrid' .OR. psolver == 'sor' ) p = 0.0_wp |
---|
[707] | 1007 | ! |
---|
[1] | 1008 | !-- Impose vortex with vertical axis on the initial velocity profile |
---|
| 1009 | IF ( INDEX( initializing_actions, 'initialize_vortex' ) /= 0 ) THEN |
---|
| 1010 | CALL init_rankine |
---|
| 1011 | ENDIF |
---|
| 1012 | |
---|
| 1013 | ! |
---|
[4648] | 1014 | !-- Impose temperature anomaly (advection test only) or warm air bubble close to surface. |
---|
| 1015 | IF ( INDEX( initializing_actions, 'initialize_ptanom' ) /= 0 .OR. & |
---|
[3035] | 1016 | INDEX( initializing_actions, 'initialize_bubble' ) /= 0 ) THEN |
---|
[1] | 1017 | CALL init_pt_anomaly |
---|
| 1018 | ENDIF |
---|
[4648] | 1019 | |
---|
[1] | 1020 | ! |
---|
| 1021 | !-- If required, change the surface temperature at the start of the 3D run |
---|
[1340] | 1022 | IF ( pt_surface_initial_change /= 0.0_wp ) THEN |
---|
[1] | 1023 | pt(nzb,:,:) = pt(nzb,:,:) + pt_surface_initial_change |
---|
| 1024 | ENDIF |
---|
| 1025 | |
---|
| 1026 | ! |
---|
| 1027 | !-- If required, change the surface humidity/scalar at the start of the 3D |
---|
| 1028 | !-- run |
---|
[4648] | 1029 | IF ( humidity .AND. q_surface_initial_change /= 0.0_wp ) & |
---|
[1] | 1030 | q(nzb,:,:) = q(nzb,:,:) + q_surface_initial_change |
---|
[4648] | 1031 | |
---|
| 1032 | IF ( passive_scalar .AND. s_surface_initial_change /= 0.0_wp ) & |
---|
[1960] | 1033 | s(nzb,:,:) = s(nzb,:,:) + s_surface_initial_change |
---|
[1] | 1034 | |
---|
[4648] | 1035 | |
---|
[1] | 1036 | ! |
---|
| 1037 | !-- Initialize old and new time levels. |
---|
[2696] | 1038 | tpt_m = 0.0_wp; tu_m = 0.0_wp; tv_m = 0.0_wp; tw_m = 0.0_wp |
---|
| 1039 | pt_p = pt; u_p = u; v_p = v; w_p = w |
---|
[1] | 1040 | |
---|
[1960] | 1041 | IF ( humidity ) THEN |
---|
[1340] | 1042 | tq_m = 0.0_wp |
---|
[1] | 1043 | q_p = q |
---|
| 1044 | ENDIF |
---|
[4648] | 1045 | |
---|
[1960] | 1046 | IF ( passive_scalar ) THEN |
---|
| 1047 | ts_m = 0.0_wp |
---|
| 1048 | s_p = s |
---|
[4648] | 1049 | ENDIF |
---|
[1] | 1050 | |
---|
[4648] | 1051 | IF ( debug_output ) THEN |
---|
| 1052 | CALL debug_message( 'initializing statistics, boundary conditions, etc.', 'end' ) |
---|
| 1053 | ENDIF |
---|
[94] | 1054 | |
---|
[1788] | 1055 | ELSEIF ( TRIM( initializing_actions ) == 'read_restart_data' .OR. & |
---|
[2232] | 1056 | TRIM( initializing_actions ) == 'cyclic_fill' ) & |
---|
[1] | 1057 | THEN |
---|
[1384] | 1058 | |
---|
[4648] | 1059 | IF ( debug_output ) THEN |
---|
| 1060 | CALL debug_message( 'initializing in case of restart / cyclic_fill', 'start' ) |
---|
| 1061 | ENDIF |
---|
[1] | 1062 | ! |
---|
[4648] | 1063 | !-- Initialize surface elements and its attributes, e.g. heat- and momentumfluxes, roughness, |
---|
| 1064 | !-- scaling parameters. As number of surface elements might be different between runs, e.g. in |
---|
| 1065 | !-- case of cyclic fill, and not all surface elements are read, surface elements need to be |
---|
| 1066 | !-- initialized before. |
---|
| 1067 | !-- Please note, in case of cyclic fill, surfaces should be initialized after restart data is |
---|
| 1068 | !-- read, else, individual settings of surface parameters will be overwritten from data of |
---|
| 1069 | !-- precursor run, hence, init_surfaces is called a second time after reading the restart data. |
---|
| 1070 | CALL init_surfaces |
---|
[3609] | 1071 | ! |
---|
[4648] | 1072 | !-- When reading data for cyclic fill of 3D prerun data files, read some of the global variables |
---|
| 1073 | !-- from the restart file which are required for initializing the inflow |
---|
[328] | 1074 | IF ( TRIM( initializing_actions ) == 'cyclic_fill' ) THEN |
---|
[559] | 1075 | |
---|
[4783] | 1076 | ! |
---|
| 1077 | !-- Blockwise I/O does not work together with MPI-I/O |
---|
| 1078 | IF ( restart_data_format_input(1:3) == 'mpi' ) THEN |
---|
| 1079 | CALL rrd_read_parts_of_global |
---|
| 1080 | ELSE |
---|
| 1081 | DO i = 0, io_blocks-1 |
---|
| 1082 | IF ( i == io_group ) THEN |
---|
| 1083 | CALL rrd_read_parts_of_global |
---|
| 1084 | ENDIF |
---|
| 1085 | #if defined( __parallel ) |
---|
| 1086 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 1087 | #endif |
---|
| 1088 | ENDDO |
---|
| 1089 | ENDIF |
---|
| 1090 | |
---|
| 1091 | ENDIF |
---|
| 1092 | |
---|
| 1093 | ! |
---|
| 1094 | !-- Read processor specific binary data from restart file. |
---|
| 1095 | !-- Blockwise I/O does not work together with MPI-I/O |
---|
| 1096 | IF ( restart_data_format_input(1:3) == 'mpi' ) THEN |
---|
| 1097 | CALL rrd_local |
---|
| 1098 | ELSE |
---|
[759] | 1099 | DO i = 0, io_blocks-1 |
---|
| 1100 | IF ( i == io_group ) THEN |
---|
[4783] | 1101 | CALL rrd_local |
---|
[759] | 1102 | ENDIF |
---|
| 1103 | #if defined( __parallel ) |
---|
| 1104 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 1105 | #endif |
---|
| 1106 | ENDDO |
---|
[767] | 1107 | ENDIF |
---|
| 1108 | |
---|
[4648] | 1109 | |
---|
[4365] | 1110 | IF ( TRIM( initializing_actions ) == 'cyclic_fill' ) THEN |
---|
| 1111 | |
---|
[3608] | 1112 | ! |
---|
[4648] | 1113 | !-- In case of cyclic fill, call init_surfaces a second time, so that surface properties such |
---|
| 1114 | !-- as heat fluxes are initialized as prescribed. |
---|
[3609] | 1115 | CALL init_surfaces |
---|
[767] | 1116 | |
---|
[328] | 1117 | ! |
---|
[4648] | 1118 | !-- Overwrite u_init, v_init, pt_init, q_init and s_init with the horizontally mean (hom) |
---|
| 1119 | !-- vertical profiles from the end of the prerun, because these profiles shall be used as the |
---|
| 1120 | !-- reference state for the rayleigh damping and the pt_damping. This is especially important |
---|
| 1121 | !-- for the use of large_scale_subsidence, because the reference temperature in the free |
---|
| 1122 | !-- atmosphere changes in time. |
---|
[4365] | 1123 | u_init(:) = hom_sum(:,1,0) |
---|
| 1124 | v_init(:) = hom_sum(:,2,0) |
---|
| 1125 | pt_init(:) = hom_sum(:,4,0) |
---|
[4648] | 1126 | IF ( humidity ) q_init(:) = hom_sum(:,41,0) |
---|
| 1127 | IF ( passive_scalar ) s_init(:) = hom_sum(:,115,0) |
---|
[4365] | 1128 | ENDIF |
---|
| 1129 | ! |
---|
[4648] | 1130 | !-- In case of complex terrain and cyclic fill method as initialization, shift initial data in |
---|
| 1131 | !-- the vertical direction for each point in the x-y-plane depending on local surface height. |
---|
| 1132 | IF ( complex_terrain .AND. TRIM( initializing_actions ) == 'cyclic_fill' ) THEN |
---|
[2550] | 1133 | DO i = nxlg, nxrg |
---|
| 1134 | DO j = nysg, nyng |
---|
[4168] | 1135 | nz_u_shift = topo_top_ind(j,i,1) |
---|
| 1136 | nz_v_shift = topo_top_ind(j,i,2) |
---|
| 1137 | nz_w_shift = topo_top_ind(j,i,3) |
---|
| 1138 | nz_s_shift = topo_top_ind(j,i,0) |
---|
[2550] | 1139 | |
---|
[4648] | 1140 | u(nz_u_shift:nzt+1,j,i) = u(0:nzt+1-nz_u_shift,j,i) |
---|
[2550] | 1141 | |
---|
| 1142 | v(nz_v_shift:nzt+1,j,i) = v(0:nzt+1-nz_v_shift,j,i) |
---|
| 1143 | |
---|
| 1144 | w(nz_w_shift:nzt+1,j,i) = w(0:nzt+1-nz_w_shift,j,i) |
---|
| 1145 | |
---|
| 1146 | p(nz_s_shift:nzt+1,j,i) = p(0:nzt+1-nz_s_shift,j,i) |
---|
| 1147 | pt(nz_s_shift:nzt+1,j,i) = pt(0:nzt+1-nz_s_shift,j,i) |
---|
| 1148 | ENDDO |
---|
| 1149 | ENDDO |
---|
| 1150 | ENDIF |
---|
| 1151 | ! |
---|
[767] | 1152 | !-- Initialization of the turbulence recycling method |
---|
[4648] | 1153 | IF ( TRIM( initializing_actions ) == 'cyclic_fill' .AND. turbulent_inflow ) THEN |
---|
[767] | 1154 | ! |
---|
| 1155 | !-- First store the profiles to be used at the inflow. |
---|
[4648] | 1156 | !-- These profiles are the (temporally) and horizontally averaged vertical profiles from the |
---|
| 1157 | !-- prerun. Alternatively, prescribed profiles for u,v-components can be used. |
---|
[3288] | 1158 | ALLOCATE( mean_inflow_profiles(nzb:nzt+1,1:num_mean_inflow_profiles) ) |
---|
[151] | 1159 | |
---|
[767] | 1160 | IF ( use_prescribed_profile_data ) THEN |
---|
| 1161 | mean_inflow_profiles(:,1) = u_init ! u |
---|
| 1162 | mean_inflow_profiles(:,2) = v_init ! v |
---|
| 1163 | ELSE |
---|
[328] | 1164 | mean_inflow_profiles(:,1) = hom_sum(:,1,0) ! u |
---|
| 1165 | mean_inflow_profiles(:,2) = hom_sum(:,2,0) ! v |
---|
[767] | 1166 | ENDIF |
---|
| 1167 | mean_inflow_profiles(:,4) = hom_sum(:,4,0) ! pt |
---|
[4648] | 1168 | IF ( humidity ) mean_inflow_profiles(:,6) = hom_sum(:,41,0) ! q |
---|
| 1169 | IF ( passive_scalar ) mean_inflow_profiles(:,7) = hom_sum(:,115,0) ! s |
---|
[4365] | 1170 | |
---|
[2550] | 1171 | ! |
---|
[4648] | 1172 | !-- In case of complex terrain, determine vertical displacement at inflow boundary and adjust |
---|
| 1173 | !-- mean inflow profiles |
---|
[2550] | 1174 | IF ( complex_terrain ) THEN |
---|
[4648] | 1175 | IF ( nxlg <= 0 .AND. nxrg >= 0 .AND. nysg <= 0 .AND. nyng >= 0 ) THEN |
---|
[4168] | 1176 | nz_u_shift_l = topo_top_ind(j,i,1) |
---|
| 1177 | nz_v_shift_l = topo_top_ind(j,i,2) |
---|
| 1178 | nz_w_shift_l = topo_top_ind(j,i,3) |
---|
| 1179 | nz_s_shift_l = topo_top_ind(j,i,0) |
---|
[2550] | 1180 | ELSE |
---|
| 1181 | nz_u_shift_l = 0 |
---|
| 1182 | nz_v_shift_l = 0 |
---|
| 1183 | nz_w_shift_l = 0 |
---|
| 1184 | nz_s_shift_l = 0 |
---|
| 1185 | ENDIF |
---|
[151] | 1186 | |
---|
[2550] | 1187 | #if defined( __parallel ) |
---|
[4648] | 1188 | CALL MPI_ALLREDUCE( nz_u_shift_l, nz_u_shift, 1, MPI_INTEGER, MPI_MAX, comm2d, ierr ) |
---|
| 1189 | CALL MPI_ALLREDUCE( nz_v_shift_l, nz_v_shift, 1, MPI_INTEGER, MPI_MAX, comm2d, ierr ) |
---|
| 1190 | CALL MPI_ALLREDUCE( nz_w_shift_l, nz_w_shift, 1, MPI_INTEGER, MPI_MAX, comm2d, ierr ) |
---|
| 1191 | CALL MPI_ALLREDUCE( nz_s_shift_l, nz_s_shift, 1, MPI_INTEGER, MPI_MAX, comm2d, ierr ) |
---|
[2550] | 1192 | #else |
---|
| 1193 | nz_u_shift = nz_u_shift_l |
---|
| 1194 | nz_v_shift = nz_v_shift_l |
---|
| 1195 | nz_w_shift = nz_w_shift_l |
---|
| 1196 | nz_s_shift = nz_s_shift_l |
---|
| 1197 | #endif |
---|
| 1198 | |
---|
| 1199 | mean_inflow_profiles(:,1) = 0.0_wp |
---|
| 1200 | mean_inflow_profiles(nz_u_shift:nzt+1,1) = hom_sum(0:nzt+1-nz_u_shift,1,0) ! u |
---|
| 1201 | |
---|
| 1202 | mean_inflow_profiles(:,2) = 0.0_wp |
---|
| 1203 | mean_inflow_profiles(nz_v_shift:nzt+1,2) = hom_sum(0:nzt+1-nz_v_shift,2,0) ! v |
---|
| 1204 | |
---|
| 1205 | mean_inflow_profiles(nz_s_shift:nzt+1,4) = hom_sum(0:nzt+1-nz_s_shift,4,0) ! pt |
---|
| 1206 | |
---|
| 1207 | ENDIF |
---|
| 1208 | |
---|
[151] | 1209 | ! |
---|
[4648] | 1210 | !-- If necessary, adjust the horizontal flow field to the prescribed profiles |
---|
[767] | 1211 | IF ( use_prescribed_profile_data ) THEN |
---|
| 1212 | DO i = nxlg, nxrg |
---|
[667] | 1213 | DO j = nysg, nyng |
---|
[328] | 1214 | DO k = nzb, nzt+1 |
---|
[767] | 1215 | u(k,j,i) = u(k,j,i) - hom_sum(k,1,0) + u_init(k) |
---|
| 1216 | v(k,j,i) = v(k,j,i) - hom_sum(k,2,0) + v_init(k) |
---|
[328] | 1217 | ENDDO |
---|
[151] | 1218 | ENDDO |
---|
[767] | 1219 | ENDDO |
---|
| 1220 | ENDIF |
---|
[151] | 1221 | |
---|
| 1222 | ! |
---|
[4648] | 1223 | !-- Use these mean profiles at the inflow (provided that Dirichlet conditions are used) |
---|
[3182] | 1224 | IF ( bc_dirichlet_l ) THEN |
---|
[767] | 1225 | DO j = nysg, nyng |
---|
| 1226 | DO k = nzb, nzt+1 |
---|
| 1227 | u(k,j,nxlg:-1) = mean_inflow_profiles(k,1) |
---|
| 1228 | v(k,j,nxlg:-1) = mean_inflow_profiles(k,2) |
---|
[1340] | 1229 | w(k,j,nxlg:-1) = 0.0_wp |
---|
[767] | 1230 | pt(k,j,nxlg:-1) = mean_inflow_profiles(k,4) |
---|
[4648] | 1231 | IF ( humidity ) q(k,j,nxlg:-1) = mean_inflow_profiles(k,6) |
---|
| 1232 | IF ( passive_scalar ) s(k,j,nxlg:-1) = mean_inflow_profiles(k,7) |
---|
[767] | 1233 | ENDDO |
---|
| 1234 | ENDDO |
---|
| 1235 | ENDIF |
---|
| 1236 | |
---|
[151] | 1237 | ! |
---|
[4648] | 1238 | !-- Calculate the damping factors to be used at the inflow. For a turbulent inflow the |
---|
| 1239 | !-- turbulent fluctuations have to be limited vertically because otherwise the turbulent |
---|
| 1240 | !-- inflow layer will grow in time. |
---|
[1340] | 1241 | IF ( inflow_damping_height == 9999999.9_wp ) THEN |
---|
[767] | 1242 | ! |
---|
[4648] | 1243 | !-- Default: use the inversion height calculated by the prerun; if this is zero, |
---|
| 1244 | !-- inflow_damping_height must be explicitly specified. |
---|
[1340] | 1245 | IF ( hom_sum(nzb+6,pr_palm,0) /= 0.0_wp ) THEN |
---|
[767] | 1246 | inflow_damping_height = hom_sum(nzb+6,pr_palm,0) |
---|
| 1247 | ELSE |
---|
[4648] | 1248 | WRITE( message_string, * ) 'inflow_damping_height must be ', & |
---|
| 1249 | 'explicitly specified because&the inversion height ', & |
---|
| 1250 | 'calculated by the prerun is zero.' |
---|
[767] | 1251 | CALL message( 'init_3d_model', 'PA0318', 1, 2, 0, 6, 0 ) |
---|
[292] | 1252 | ENDIF |
---|
[151] | 1253 | |
---|
[767] | 1254 | ENDIF |
---|
| 1255 | |
---|
[1340] | 1256 | IF ( inflow_damping_width == 9999999.9_wp ) THEN |
---|
[151] | 1257 | ! |
---|
[4648] | 1258 | !-- Default for the transition range: one tenth of the undamped layer |
---|
[1340] | 1259 | inflow_damping_width = 0.1_wp * inflow_damping_height |
---|
[151] | 1260 | |
---|
[767] | 1261 | ENDIF |
---|
[151] | 1262 | |
---|
[767] | 1263 | ALLOCATE( inflow_damping_factor(nzb:nzt+1) ) |
---|
[151] | 1264 | |
---|
[767] | 1265 | DO k = nzb, nzt+1 |
---|
[151] | 1266 | |
---|
[767] | 1267 | IF ( zu(k) <= inflow_damping_height ) THEN |
---|
[1340] | 1268 | inflow_damping_factor(k) = 1.0_wp |
---|
[996] | 1269 | ELSEIF ( zu(k) <= ( inflow_damping_height + inflow_damping_width ) ) THEN |
---|
[4648] | 1270 | inflow_damping_factor(k) = 1.0_wp - & |
---|
| 1271 | ( zu(k) - inflow_damping_height ) / inflow_damping_width |
---|
[767] | 1272 | ELSE |
---|
[1340] | 1273 | inflow_damping_factor(k) = 0.0_wp |
---|
[767] | 1274 | ENDIF |
---|
[151] | 1275 | |
---|
[767] | 1276 | ENDDO |
---|
[151] | 1277 | |
---|
[147] | 1278 | ENDIF |
---|
| 1279 | |
---|
[152] | 1280 | ! |
---|
[2696] | 1281 | !-- Inside buildings set velocities back to zero |
---|
[4648] | 1282 | IF ( TRIM( initializing_actions ) == 'cyclic_fill' .AND. topography /= 'flat' ) THEN |
---|
[359] | 1283 | ! |
---|
[2696] | 1284 | !-- Inside buildings set velocities back to zero. |
---|
| 1285 | !-- Other scalars (pt, q, s, p, sa, ...) are ignored at present, |
---|
[359] | 1286 | !-- maybe revise later. |
---|
[1001] | 1287 | DO i = nxlg, nxrg |
---|
| 1288 | DO j = nysg, nyng |
---|
[2232] | 1289 | DO k = nzb, nzt |
---|
[4648] | 1290 | u(k,j,i) = MERGE( u(k,j,i), 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 1 ) ) |
---|
| 1291 | v(k,j,i) = MERGE( v(k,j,i), 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 2 ) ) |
---|
| 1292 | w(k,j,i) = MERGE( w(k,j,i), 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 3 ) ) |
---|
[2232] | 1293 | ENDDO |
---|
[359] | 1294 | ENDDO |
---|
[1001] | 1295 | ENDDO |
---|
[359] | 1296 | |
---|
| 1297 | ENDIF |
---|
| 1298 | |
---|
| 1299 | ! |
---|
[4648] | 1300 | !-- Calculate initial temperature field and other constants used in case of a sloping surface |
---|
[1] | 1301 | IF ( sloping_surface ) CALL init_slope |
---|
| 1302 | |
---|
| 1303 | ! |
---|
[4648] | 1304 | !-- Initialize new time levels (only done in order to set boundary values including ghost points) |
---|
[2696] | 1305 | pt_p = pt; u_p = u; v_p = v; w_p = w |
---|
[1960] | 1306 | IF ( humidity ) THEN |
---|
[1053] | 1307 | q_p = q |
---|
| 1308 | ENDIF |
---|
[1960] | 1309 | IF ( passive_scalar ) s_p = s |
---|
[181] | 1310 | ! |
---|
[4648] | 1311 | !-- Allthough tendency arrays are set in prognostic_equations, they have have to be predefined |
---|
| 1312 | !-- here because they are used (but multiplied with 0) there before they are set. |
---|
[2696] | 1313 | tpt_m = 0.0_wp; tu_m = 0.0_wp; tv_m = 0.0_wp; tw_m = 0.0_wp |
---|
[1960] | 1314 | IF ( humidity ) THEN |
---|
[1340] | 1315 | tq_m = 0.0_wp |
---|
[1053] | 1316 | ENDIF |
---|
[1960] | 1317 | IF ( passive_scalar ) ts_m = 0.0_wp |
---|
[181] | 1318 | |
---|
[4648] | 1319 | IF ( debug_output ) THEN |
---|
| 1320 | CALL debug_message( 'initializing in case of restart / cyclic_fill', 'end' ) |
---|
| 1321 | ENDIF |
---|
[1384] | 1322 | |
---|
[1] | 1323 | ELSE |
---|
| 1324 | ! |
---|
| 1325 | !-- Actually this part of the programm should not be reached |
---|
[254] | 1326 | message_string = 'unknown initializing problem' |
---|
| 1327 | CALL message( 'init_3d_model', 'PA0193', 1, 2, 0, 6, 0 ) |
---|
[1] | 1328 | ENDIF |
---|
| 1329 | |
---|
| 1330 | ! |
---|
[667] | 1331 | !-- Calculate the initial volume flow at the right and north boundary |
---|
[709] | 1332 | IF ( conserve_volume_flow ) THEN |
---|
[151] | 1333 | |
---|
[767] | 1334 | IF ( use_prescribed_profile_data ) THEN |
---|
[667] | 1335 | |
---|
[1340] | 1336 | volume_flow_initial_l = 0.0_wp |
---|
| 1337 | volume_flow_area_l = 0.0_wp |
---|
[732] | 1338 | |
---|
[667] | 1339 | IF ( nxr == nx ) THEN |
---|
| 1340 | DO j = nys, nyn |
---|
[2232] | 1341 | DO k = nzb+1, nzt |
---|
[4648] | 1342 | volume_flow_initial_l(1) = volume_flow_initial_l(1) + & |
---|
| 1343 | u_init(k) * dzw(k) & |
---|
| 1344 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 1345 | BTEST( wall_flags_total_0(k,j,nxr), 1 ) & |
---|
| 1346 | ) |
---|
[2232] | 1347 | |
---|
[4648] | 1348 | volume_flow_area_l(1) = volume_flow_area_l(1) + dzw(k) & |
---|
| 1349 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 1350 | BTEST( wall_flags_total_0(k,j,nxr), 1 ) & |
---|
| 1351 | ) |
---|
[767] | 1352 | ENDDO |
---|
| 1353 | ENDDO |
---|
| 1354 | ENDIF |
---|
[4648] | 1355 | |
---|
[767] | 1356 | IF ( nyn == ny ) THEN |
---|
| 1357 | DO i = nxl, nxr |
---|
[2232] | 1358 | DO k = nzb+1, nzt |
---|
[4648] | 1359 | volume_flow_initial_l(2) = volume_flow_initial_l(2) + & |
---|
| 1360 | v_init(k) * dzw(k) & |
---|
| 1361 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 1362 | BTEST( wall_flags_total_0(k,nyn,i), 2 ) & |
---|
| 1363 | ) |
---|
| 1364 | volume_flow_area_l(2) = volume_flow_area_l(2) + dzw(k) & |
---|
| 1365 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 1366 | BTEST( wall_flags_total_0(k,nyn,i), 2 ) & |
---|
| 1367 | ) |
---|
[767] | 1368 | ENDDO |
---|
| 1369 | ENDDO |
---|
| 1370 | ENDIF |
---|
| 1371 | |
---|
| 1372 | #if defined( __parallel ) |
---|
[4648] | 1373 | CALL MPI_ALLREDUCE( volume_flow_initial_l(1), volume_flow_initial(1), 2, MPI_REAL, & |
---|
| 1374 | MPI_SUM, comm2d, ierr ) |
---|
| 1375 | CALL MPI_ALLREDUCE( volume_flow_area_l(1), volume_flow_area(1), 2, MPI_REAL, MPI_SUM, & |
---|
| 1376 | comm2d, ierr ) |
---|
[767] | 1377 | |
---|
| 1378 | #else |
---|
| 1379 | volume_flow_initial = volume_flow_initial_l |
---|
| 1380 | volume_flow_area = volume_flow_area_l |
---|
[4648] | 1381 | #endif |
---|
[767] | 1382 | |
---|
| 1383 | ELSEIF ( TRIM( initializing_actions ) == 'cyclic_fill' ) THEN |
---|
| 1384 | |
---|
[1340] | 1385 | volume_flow_initial_l = 0.0_wp |
---|
| 1386 | volume_flow_area_l = 0.0_wp |
---|
[767] | 1387 | |
---|
| 1388 | IF ( nxr == nx ) THEN |
---|
| 1389 | DO j = nys, nyn |
---|
[2232] | 1390 | DO k = nzb+1, nzt |
---|
[4648] | 1391 | volume_flow_initial_l(1) = volume_flow_initial_l(1) + & |
---|
| 1392 | hom_sum(k,1,0) * dzw(k) & |
---|
| 1393 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 1394 | BTEST( wall_flags_total_0(k,j,nx), 1 ) & |
---|
| 1395 | ) |
---|
| 1396 | volume_flow_area_l(1) = volume_flow_area_l(1) + dzw(k) & |
---|
| 1397 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 1398 | BTEST( wall_flags_total_0(k,j,nx), 1 ) & |
---|
| 1399 | ) |
---|
[667] | 1400 | ENDDO |
---|
| 1401 | ENDDO |
---|
| 1402 | ENDIF |
---|
[4648] | 1403 | |
---|
[667] | 1404 | IF ( nyn == ny ) THEN |
---|
| 1405 | DO i = nxl, nxr |
---|
[2232] | 1406 | DO k = nzb+1, nzt |
---|
[4648] | 1407 | volume_flow_initial_l(2) = volume_flow_initial_l(2) + & |
---|
| 1408 | hom_sum(k,2,0) * dzw(k) & |
---|
| 1409 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 1410 | BTEST( wall_flags_total_0(k,ny,i), 2 ) & |
---|
| 1411 | ) |
---|
| 1412 | volume_flow_area_l(2) = volume_flow_area_l(2) + dzw(k) & |
---|
| 1413 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 1414 | BTEST( wall_flags_total_0(k,ny,i), 2 ) & |
---|
| 1415 | ) |
---|
[667] | 1416 | ENDDO |
---|
| 1417 | ENDDO |
---|
| 1418 | ENDIF |
---|
| 1419 | |
---|
[732] | 1420 | #if defined( __parallel ) |
---|
[4648] | 1421 | CALL MPI_ALLREDUCE( volume_flow_initial_l(1), volume_flow_initial(1), 2, MPI_REAL, & |
---|
| 1422 | MPI_SUM, comm2d, ierr ) |
---|
| 1423 | CALL MPI_ALLREDUCE( volume_flow_area_l(1), volume_flow_area(1), 2, MPI_REAL, MPI_SUM, & |
---|
| 1424 | comm2d, ierr ) |
---|
[732] | 1425 | |
---|
| 1426 | #else |
---|
| 1427 | volume_flow_initial = volume_flow_initial_l |
---|
| 1428 | volume_flow_area = volume_flow_area_l |
---|
[4648] | 1429 | #endif |
---|
[732] | 1430 | |
---|
[667] | 1431 | ELSEIF ( TRIM( initializing_actions ) /= 'read_restart_data' ) THEN |
---|
| 1432 | |
---|
[1340] | 1433 | volume_flow_initial_l = 0.0_wp |
---|
| 1434 | volume_flow_area_l = 0.0_wp |
---|
[732] | 1435 | |
---|
[667] | 1436 | IF ( nxr == nx ) THEN |
---|
| 1437 | DO j = nys, nyn |
---|
[2232] | 1438 | DO k = nzb+1, nzt |
---|
[4648] | 1439 | volume_flow_initial_l(1) = volume_flow_initial_l(1) + & |
---|
| 1440 | u(k,j,nx) * dzw(k) & |
---|
| 1441 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 1442 | BTEST( wall_flags_total_0(k,j,nx), 1 ) & |
---|
| 1443 | ) |
---|
| 1444 | volume_flow_area_l(1) = volume_flow_area_l(1) + dzw(k) & |
---|
| 1445 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 1446 | BTEST( wall_flags_total_0(k,j,nx), 1 ) & |
---|
| 1447 | ) |
---|
[667] | 1448 | ENDDO |
---|
| 1449 | ENDDO |
---|
| 1450 | ENDIF |
---|
[4648] | 1451 | |
---|
[667] | 1452 | IF ( nyn == ny ) THEN |
---|
| 1453 | DO i = nxl, nxr |
---|
[2232] | 1454 | DO k = nzb+1, nzt |
---|
[4648] | 1455 | volume_flow_initial_l(2) = volume_flow_initial_l(2) + & |
---|
| 1456 | v(k,ny,i) * dzw(k) & |
---|
| 1457 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 1458 | BTEST( wall_flags_total_0(k,ny,i), 2 ) & |
---|
| 1459 | ) |
---|
| 1460 | volume_flow_area_l(2) = volume_flow_area_l(2) + dzw(k) & |
---|
| 1461 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 1462 | BTEST( wall_flags_total_0(k,ny,i), 2 ) & |
---|
| 1463 | ) |
---|
[667] | 1464 | ENDDO |
---|
| 1465 | ENDDO |
---|
| 1466 | ENDIF |
---|
| 1467 | |
---|
| 1468 | #if defined( __parallel ) |
---|
[4648] | 1469 | CALL MPI_ALLREDUCE( volume_flow_initial_l(1), volume_flow_initial(1), 2, MPI_REAL, & |
---|
| 1470 | MPI_SUM, comm2d, ierr ) |
---|
| 1471 | CALL MPI_ALLREDUCE( volume_flow_area_l(1), volume_flow_area(1), 2, MPI_REAL, MPI_SUM, & |
---|
| 1472 | comm2d, ierr ) |
---|
[667] | 1473 | |
---|
| 1474 | #else |
---|
[732] | 1475 | volume_flow_initial = volume_flow_initial_l |
---|
| 1476 | volume_flow_area = volume_flow_area_l |
---|
[4648] | 1477 | #endif |
---|
[667] | 1478 | |
---|
[732] | 1479 | ENDIF |
---|
| 1480 | |
---|
[151] | 1481 | ! |
---|
[4648] | 1482 | !-- In case of 'bulk_velocity' mode, volume_flow_initial is calculated from u|v_bulk instead |
---|
[680] | 1483 | IF ( TRIM( conserve_volume_flow_mode ) == 'bulk_velocity' ) THEN |
---|
| 1484 | volume_flow_initial(1) = u_bulk * volume_flow_area(1) |
---|
| 1485 | volume_flow_initial(2) = v_bulk * volume_flow_area(2) |
---|
| 1486 | ENDIF |
---|
[667] | 1487 | |
---|
[680] | 1488 | ENDIF |
---|
[2232] | 1489 | ! |
---|
[4648] | 1490 | !-- In the following, surface properties can be further initialized with input from static driver |
---|
| 1491 | !-- file. |
---|
| 1492 | !-- At the moment this affects only default surfaces. For example, roughness length or sensible / |
---|
| 1493 | !-- latent heat fluxes can be initialized heterogeneously for default surfaces. Therefore, a generic |
---|
| 1494 | !-- routine from netcdf_data_input_mod is called to read a 2D array. |
---|
[4150] | 1495 | IF ( input_pids_static ) THEN |
---|
| 1496 | ! |
---|
[4151] | 1497 | !-- Allocate memory for possible static input |
---|
| 1498 | ALLOCATE( tmp_2d%var(nys:nyn,nxl:nxr) ) |
---|
| 1499 | tmp_2d%var = 0.0_wp |
---|
| 1500 | ! |
---|
[4150] | 1501 | !-- Open the static input file |
---|
[4151] | 1502 | #if defined( __netcdf ) |
---|
[4648] | 1503 | CALL open_read_file( TRIM( input_file_static ) // & |
---|
| 1504 | TRIM( coupling_char ), pids_id ) |
---|
| 1505 | |
---|
[4186] | 1506 | CALL inquire_num_variables( pids_id, num_var_pids ) |
---|
[4150] | 1507 | ! |
---|
| 1508 | !-- Allocate memory to store variable names and read them |
---|
[4186] | 1509 | ALLOCATE( vars_pids(1:num_var_pids) ) |
---|
| 1510 | CALL inquire_variable_names( pids_id, vars_pids ) |
---|
[4150] | 1511 | ! |
---|
[4648] | 1512 | !-- Input roughness length. |
---|
[4186] | 1513 | IF ( check_existence( vars_pids, 'z0' ) ) THEN |
---|
[4150] | 1514 | ! |
---|
| 1515 | !-- Read _FillValue attribute |
---|
[4648] | 1516 | CALL get_attribute( pids_id, char_fill, tmp_2d%fill, .FALSE., 'z0' ) |
---|
| 1517 | ! |
---|
| 1518 | !-- Read variable |
---|
| 1519 | CALL get_variable( pids_id, 'z0', tmp_2d%var, nxl, nxr, nys, nyn ) |
---|
[4878] | 1520 | CALL add_ghost_layers( tmp_2d%var ) |
---|
[4877] | 1521 | CALL exchange_horiz_2d( tmp_2d%var ) |
---|
[4648] | 1522 | ! |
---|
| 1523 | !-- Initialize roughness length. Note, z0 will be only initialized at default-type surfaces. |
---|
| 1524 | !-- At natural or urban z0 is implicitly initialized by the respective parameter lists. |
---|
| 1525 | !-- Initialize horizontal surface elements. |
---|
| 1526 | CALL init_single_surface_properties( surf_def_h(0)%z0, tmp_2d%var, surf_def_h(0)%ns, & |
---|
| 1527 | tmp_2d%fill, surf_def_h(0)%i, surf_def_h(0)%j ) |
---|
| 1528 | ! |
---|
| 1529 | !-- Initialize roughness also at vertical surface elements. |
---|
| 1530 | !-- Note, the actual 2D input arrays are only defined on the subdomain. Therefore, pass the |
---|
| 1531 | !-- index arrays with their respective offset values. |
---|
| 1532 | DO l = 0, 3 |
---|
| 1533 | CALL init_single_surface_properties( surf_def_v(l)%z0, tmp_2d%var, surf_def_v(l)%ns, & |
---|
| 1534 | tmp_2d%fill, surf_def_v(l)%i+surf_def_v(l)%ioff, & |
---|
| 1535 | surf_def_v(l)%j+surf_def_v(l)%joff ) |
---|
[4150] | 1536 | ENDDO |
---|
[4648] | 1537 | |
---|
[4150] | 1538 | ENDIF |
---|
| 1539 | ! |
---|
[4648] | 1540 | !-- Input surface sensible heat flux. |
---|
[4514] | 1541 | IF ( check_existence( vars_pids, 'shf' ) ) THEN |
---|
| 1542 | ! |
---|
| 1543 | !-- Read _FillValue attribute |
---|
[4648] | 1544 | CALL get_attribute( pids_id, char_fill, tmp_2d%fill, .FALSE., 'shf' ) |
---|
[4514] | 1545 | ! |
---|
| 1546 | !-- Read variable |
---|
[4648] | 1547 | CALL get_variable( pids_id, 'shf', tmp_2d%var, nxl, nxr, nys, nyn ) |
---|
[4878] | 1548 | CALL add_ghost_layers( tmp_2d%var ) |
---|
[4877] | 1549 | CALL exchange_horiz_2d( tmp_2d%var ) |
---|
[4514] | 1550 | ! |
---|
[4648] | 1551 | !-- Initialize heat flux. Note, shf will be only initialized at default-type surfaces. At |
---|
| 1552 | !-- natural or urban shf is implicitly initialized by the respective parameter lists. |
---|
[4514] | 1553 | !-- Initialize horizontal surface elements. |
---|
[4648] | 1554 | CALL init_single_surface_properties( surf_def_h(0)%shf, tmp_2d%var, surf_def_h(0)%ns, & |
---|
| 1555 | tmp_2d%fill, surf_def_h(0)%i, surf_def_h(0)%j ) |
---|
[4514] | 1556 | ! |
---|
| 1557 | !-- Initialize heat flux also at vertical surface elements. |
---|
[4648] | 1558 | !-- Note, the actual 2D input arrays are only defined on the subdomain. Therefore, pass the |
---|
| 1559 | !-- index arrays with their respective offset values. |
---|
[4514] | 1560 | DO l = 0, 3 |
---|
[4648] | 1561 | CALL init_single_surface_properties( surf_def_v(l)%shf, tmp_2d%var, surf_def_v(l)%ns, & |
---|
| 1562 | tmp_2d%fill, surf_def_v(l)%i+surf_def_v(l)%ioff, & |
---|
| 1563 | surf_def_v(l)%j+surf_def_v(l)%joff ) |
---|
[4514] | 1564 | ENDDO |
---|
| 1565 | |
---|
| 1566 | ENDIF |
---|
| 1567 | ! |
---|
[4791] | 1568 | !-- Input surface latent heat flux. |
---|
| 1569 | IF ( humidity ) THEN |
---|
| 1570 | IF ( check_existence( vars_pids, 'qsws' ) ) THEN |
---|
[4514] | 1571 | ! |
---|
[4791] | 1572 | !-- Read _FillValue attribute |
---|
| 1573 | CALL get_attribute( pids_id, char_fill, tmp_2d%fill, .FALSE., 'qsws' ) |
---|
[4514] | 1574 | ! |
---|
[4791] | 1575 | !-- Read variable |
---|
| 1576 | CALL get_variable( pids_id, 'qsws', tmp_2d%var, nxl, nxr, nys, nyn ) |
---|
[4878] | 1577 | CALL add_ghost_layers( tmp_2d%var ) |
---|
[4877] | 1578 | CALL exchange_horiz_2d( tmp_2d%var ) |
---|
[4514] | 1579 | ! |
---|
[4791] | 1580 | !-- Initialize latent heat flux. Note, qsws will be only initialized at default-type surfaces. |
---|
| 1581 | !-- At natural or urban qsws is implicitly initialized by the respective parameter lists. |
---|
| 1582 | !-- Initialize horizontal surface elements. |
---|
| 1583 | CALL init_single_surface_properties( surf_def_h(0)%qsws, tmp_2d%var, surf_def_h(0)%ns,& |
---|
| 1584 | tmp_2d%fill, surf_def_h(0)%i, surf_def_h(0)%j ) |
---|
[4514] | 1585 | ! |
---|
[4791] | 1586 | !-- Initialize latent heat flux also at vertical surface elements. |
---|
| 1587 | !-- Note, the actual 2D input arrays are only defined on the subdomain. Therefore, pass the |
---|
| 1588 | !-- index arrays with their respective offset values. |
---|
| 1589 | DO l = 0, 3 |
---|
| 1590 | CALL init_single_surface_properties( surf_def_v(l)%qsws, tmp_2d%var, & |
---|
| 1591 | surf_def_v(l)%ns, tmp_2d%fill, & |
---|
| 1592 | surf_def_v(l)%i+surf_def_v(l)%ioff, & |
---|
| 1593 | surf_def_v(l)%j+surf_def_v(l)%joff ) |
---|
| 1594 | ENDDO |
---|
[4514] | 1595 | |
---|
[4791] | 1596 | ENDIF |
---|
[4514] | 1597 | ENDIF |
---|
| 1598 | ! |
---|
[4791] | 1599 | !-- Input passive scalar flux. |
---|
| 1600 | IF ( passive_scalar ) THEN |
---|
| 1601 | IF ( check_existence( vars_pids, 'ssws' ) ) THEN |
---|
| 1602 | ! |
---|
| 1603 | !-- Read _FillValue attribute |
---|
| 1604 | CALL get_attribute( pids_id, char_fill, tmp_2d%fill, .FALSE., 'ssws' ) |
---|
| 1605 | ! |
---|
| 1606 | !-- Read variable |
---|
| 1607 | CALL get_variable( pids_id, 'ssws', tmp_2d%var, nxl, nxr, nys, nyn ) |
---|
[4878] | 1608 | CALL add_ghost_layers( tmp_2d%var ) |
---|
[4877] | 1609 | CALL exchange_horiz_2d( tmp_2d%var ) |
---|
[4791] | 1610 | ! |
---|
| 1611 | !-- Initialize passive scalar flux. Initialize horizontal surface elements. |
---|
| 1612 | CALL init_single_surface_properties( surf_def_h(0)%ssws, tmp_2d%var, surf_def_h(0)%ns,& |
---|
| 1613 | tmp_2d%fill, surf_def_h(0)%i, surf_def_h(0)%j ) |
---|
| 1614 | |
---|
| 1615 | DO l = 0, 3 |
---|
| 1616 | CALL init_single_surface_properties( surf_def_v(l)%ssws, tmp_2d%var, & |
---|
| 1617 | surf_def_v(l)%ns, tmp_2d%fill, & |
---|
| 1618 | surf_def_v(l)%i+surf_def_v(l)%ioff, & |
---|
| 1619 | surf_def_v(l)%j+surf_def_v(l)%joff ) |
---|
| 1620 | ENDDO |
---|
| 1621 | |
---|
| 1622 | ENDIF |
---|
| 1623 | ENDIF |
---|
| 1624 | ! |
---|
[4648] | 1625 | !-- Additional variables, can be initialized the |
---|
[4150] | 1626 | !-- same way. |
---|
[4514] | 1627 | |
---|
[4150] | 1628 | ! |
---|
[4187] | 1629 | !-- Finally, close the input file and deallocate temporary arrays |
---|
| 1630 | DEALLOCATE( vars_pids ) |
---|
[4648] | 1631 | |
---|
[4186] | 1632 | CALL close_input_file( pids_id ) |
---|
[4151] | 1633 | #endif |
---|
| 1634 | DEALLOCATE( tmp_2d%var ) |
---|
[4150] | 1635 | ENDIF |
---|
| 1636 | ! |
---|
[4648] | 1637 | !-- Finally, if random_heatflux is set, disturb shf at horizontal surfaces. Actually, this should be |
---|
| 1638 | !-- done in surface_mod, where all other initializations of surface quantities are done. However, |
---|
| 1639 | !-- this would create a ring dependency, hence, it is done here. Maybe delete disturb_heatflux and |
---|
| 1640 | !-- tranfer the respective code directly into the initialization in surface_mod. |
---|
| 1641 | IF ( TRIM( initializing_actions ) /= 'read_restart_data' .AND. & |
---|
[2232] | 1642 | TRIM( initializing_actions ) /= 'cyclic_fill' ) THEN |
---|
[4648] | 1643 | |
---|
| 1644 | IF ( use_surface_fluxes .AND. constant_heatflux .AND. random_heatflux ) THEN |
---|
[2232] | 1645 | IF ( surf_def_h(0)%ns >= 1 ) CALL disturb_heatflux( surf_def_h(0) ) |
---|
[4671] | 1646 | IF ( surf_lsm_h(0)%ns >= 1 ) CALL disturb_heatflux( surf_lsm_h(0) ) |
---|
| 1647 | IF ( surf_usm_h(0)%ns >= 1 ) CALL disturb_heatflux( surf_usm_h(0) ) |
---|
[2232] | 1648 | ENDIF |
---|
| 1649 | ENDIF |
---|
[680] | 1650 | |
---|
[787] | 1651 | ! |
---|
[4648] | 1652 | !-- Compute total sum of grid points and the mean surface level height for each statistic region. |
---|
| 1653 | !-- These are mainly used for horizontal averaging of turbulence statistics. |
---|
| 1654 | !-- ngp_2dh: number of grid points of a horizontal cross section through the respective statistic |
---|
| 1655 | !-- region |
---|
[3747] | 1656 | !-- ngp_3d: number of grid points of the respective statistic region |
---|
[2696] | 1657 | ngp_2dh_outer_l = 0 |
---|
| 1658 | ngp_2dh_outer = 0 |
---|
| 1659 | ngp_2dh_s_inner_l = 0 |
---|
| 1660 | ngp_2dh_s_inner = 0 |
---|
| 1661 | ngp_2dh_l = 0 |
---|
| 1662 | ngp_2dh = 0 |
---|
| 1663 | ngp_3d_inner_l = 0.0_wp |
---|
| 1664 | ngp_3d_inner = 0 |
---|
| 1665 | ngp_3d = 0 |
---|
| 1666 | ngp_sums = ( nz + 2 ) * ( pr_palm + max_pr_user ) |
---|
| 1667 | |
---|
| 1668 | mean_surface_level_height = 0.0_wp |
---|
| 1669 | mean_surface_level_height_l = 0.0_wp |
---|
| 1670 | ! |
---|
| 1671 | !-- To do: New concept for these non-topography grid points! |
---|
| 1672 | DO sr = 0, statistic_regions |
---|
| 1673 | DO i = nxl, nxr |
---|
| 1674 | DO j = nys, nyn |
---|
| 1675 | IF ( rmask(j,i,sr) == 1.0_wp ) THEN |
---|
| 1676 | ! |
---|
| 1677 | !-- All xy-grid points |
---|
| 1678 | ngp_2dh_l(sr) = ngp_2dh_l(sr) + 1 |
---|
| 1679 | ! |
---|
[4648] | 1680 | !-- Determine mean surface-level height. In case of downward-facing walls are present, |
---|
| 1681 | !-- more than one surface level exist. |
---|
| 1682 | !-- In this case, use the lowest surface-level height. |
---|
| 1683 | IF ( surf_def_h(0)%start_index(j,i) <= surf_def_h(0)%end_index(j,i) ) THEN |
---|
[2696] | 1684 | m = surf_def_h(0)%start_index(j,i) |
---|
| 1685 | k = surf_def_h(0)%k(m) |
---|
[4648] | 1686 | mean_surface_level_height_l(sr) = mean_surface_level_height_l(sr) + zw(k-1) |
---|
[2696] | 1687 | ENDIF |
---|
[4671] | 1688 | IF ( surf_lsm_h(0)%start_index(j,i) <= surf_lsm_h(0)%end_index(j,i) ) THEN |
---|
| 1689 | m = surf_lsm_h(0)%start_index(j,i) |
---|
| 1690 | k = surf_lsm_h(0)%k(m) |
---|
[4648] | 1691 | mean_surface_level_height_l(sr) = mean_surface_level_height_l(sr) + zw(k-1) |
---|
[2696] | 1692 | ENDIF |
---|
[4671] | 1693 | IF ( surf_usm_h(0)%start_index(j,i) <= surf_usm_h(0)%end_index(j,i) ) THEN |
---|
| 1694 | m = surf_usm_h(0)%start_index(j,i) |
---|
| 1695 | k = surf_usm_h(0)%k(m) |
---|
[4648] | 1696 | mean_surface_level_height_l(sr) = mean_surface_level_height_l(sr) + zw(k-1) |
---|
[2696] | 1697 | ENDIF |
---|
| 1698 | |
---|
| 1699 | k_surf = k - 1 |
---|
| 1700 | |
---|
| 1701 | DO k = nzb, nzt+1 |
---|
| 1702 | ! |
---|
| 1703 | !-- xy-grid points above topography |
---|
[4648] | 1704 | ngp_2dh_outer_l(k,sr) = ngp_2dh_outer_l(k,sr) + & |
---|
| 1705 | MERGE( 1, 0, BTEST( wall_flags_total_0(k,j,i), 24 ) ) |
---|
[2696] | 1706 | |
---|
[4648] | 1707 | ngp_2dh_s_inner_l(k,sr) = ngp_2dh_s_inner_l(k,sr) + & |
---|
| 1708 | MERGE( 1, 0, BTEST( wall_flags_total_0(k,j,i), 22 ) ) |
---|
[2696] | 1709 | |
---|
| 1710 | ENDDO |
---|
| 1711 | ! |
---|
| 1712 | !-- All grid points of the total domain above topography |
---|
| 1713 | ngp_3d_inner_l(sr) = ngp_3d_inner_l(sr) + ( nz - k_surf + 2 ) |
---|
| 1714 | |
---|
| 1715 | |
---|
| 1716 | |
---|
| 1717 | ENDIF |
---|
| 1718 | ENDDO |
---|
| 1719 | ENDDO |
---|
| 1720 | ENDDO |
---|
[3747] | 1721 | |
---|
[2696] | 1722 | sr = statistic_regions + 1 |
---|
| 1723 | #if defined( __parallel ) |
---|
| 1724 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
[4648] | 1725 | CALL MPI_ALLREDUCE( ngp_2dh_l(0), ngp_2dh(0), sr, MPI_INTEGER, MPI_SUM, comm2d, ierr ) |
---|
| 1726 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 1727 | CALL MPI_ALLREDUCE( ngp_2dh_outer_l(0,0), ngp_2dh_outer(0,0), (nz+2)*sr, MPI_INTEGER, MPI_SUM, & |
---|
[2696] | 1728 | comm2d, ierr ) |
---|
| 1729 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
[4648] | 1730 | CALL MPI_ALLREDUCE( ngp_2dh_s_inner_l(0,0), ngp_2dh_s_inner(0,0), (nz+2)*sr, MPI_INTEGER, & |
---|
| 1731 | MPI_SUM, comm2d, ierr ) |
---|
[2696] | 1732 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
[4648] | 1733 | CALL MPI_ALLREDUCE( ngp_3d_inner_l(0), ngp_3d_inner_tmp(0), sr, MPI_REAL, MPI_SUM, comm2d, & |
---|
| 1734 | ierr ) |
---|
[2696] | 1735 | ngp_3d_inner = INT( ngp_3d_inner_tmp, KIND = SELECTED_INT_KIND( 18 ) ) |
---|
| 1736 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
[4648] | 1737 | CALL MPI_ALLREDUCE( mean_surface_level_height_l(0), mean_surface_level_height(0), sr, MPI_REAL,& |
---|
[2696] | 1738 | MPI_SUM, comm2d, ierr ) |
---|
| 1739 | mean_surface_level_height = mean_surface_level_height / REAL( ngp_2dh ) |
---|
| 1740 | #else |
---|
| 1741 | ngp_2dh = ngp_2dh_l |
---|
| 1742 | ngp_2dh_outer = ngp_2dh_outer_l |
---|
| 1743 | ngp_2dh_s_inner = ngp_2dh_s_inner_l |
---|
| 1744 | ngp_3d_inner = INT( ngp_3d_inner_l, KIND = SELECTED_INT_KIND( 18 ) ) |
---|
| 1745 | mean_surface_level_height = mean_surface_level_height_l / REAL( ngp_2dh_l ) |
---|
| 1746 | #endif |
---|
| 1747 | |
---|
[4648] | 1748 | ngp_3d = INT ( ngp_2dh, KIND = SELECTED_INT_KIND( 18 ) ) * & |
---|
[2696] | 1749 | INT ( (nz + 2 ), KIND = SELECTED_INT_KIND( 18 ) ) |
---|
| 1750 | |
---|
| 1751 | ! |
---|
[4648] | 1752 | !-- Set a lower limit of 1 in order to avoid zero divisions in flow_statistics, buoyancy, etc. A |
---|
| 1753 | !-- zero value will occur for cases where all grid points of the respective subdomain lie below the |
---|
| 1754 | !-- surface topography |
---|
| 1755 | ngp_2dh_outer = MAX( 1, ngp_2dh_outer(:,:) ) |
---|
| 1756 | ngp_3d_inner = MAX( INT(1, KIND = SELECTED_INT_KIND( 18 )), ngp_3d_inner(:) ) |
---|
| 1757 | ngp_2dh_s_inner = MAX( 1, ngp_2dh_s_inner(:,:) ) |
---|
[2696] | 1758 | |
---|
[4648] | 1759 | DEALLOCATE( mean_surface_level_height_l, ngp_2dh_l, ngp_2dh_outer_l, ngp_3d_inner_l, & |
---|
| 1760 | ngp_3d_inner_tmp ) |
---|
[4548] | 1761 | |
---|
[2696] | 1762 | ! |
---|
[4648] | 1763 | !-- Initializae 3D offline nesting in COSMO model and read data from |
---|
[3347] | 1764 | !-- external NetCDF file. |
---|
| 1765 | IF ( nesting_offline ) CALL nesting_offl_init |
---|
| 1766 | ! |
---|
[787] | 1767 | !-- Initialize quantities for special advections schemes |
---|
| 1768 | CALL init_advec |
---|
[680] | 1769 | |
---|
[667] | 1770 | ! |
---|
[680] | 1771 | !-- Impose random perturbation on the horizontal velocity field and then |
---|
| 1772 | !-- remove the divergences from the velocity field at the initial stage |
---|
[4648] | 1773 | IF ( create_disturbances .AND. disturbance_energy_limit /= 0.0_wp .AND. & |
---|
| 1774 | TRIM( initializing_actions ) /= 'read_restart_data' .AND. & |
---|
[680] | 1775 | TRIM( initializing_actions ) /= 'cyclic_fill' ) THEN |
---|
| 1776 | |
---|
[4648] | 1777 | IF ( debug_output ) THEN |
---|
| 1778 | CALL debug_message( 'creating disturbances + applying pressure solver', 'start' ) |
---|
| 1779 | ENDIF |
---|
[3849] | 1780 | ! |
---|
| 1781 | !-- Needed for both disturb_field and pres |
---|
| 1782 | !$ACC DATA & |
---|
| 1783 | !$ACC CREATE(tend(nzb:nzt+1,nysg:nyng,nxlg:nxrg)) & |
---|
| 1784 | !$ACC COPY(u(nzb:nzt+1,nysg:nyng,nxlg:nxrg)) & |
---|
| 1785 | !$ACC COPY(v(nzb:nzt+1,nysg:nyng,nxlg:nxrg)) |
---|
| 1786 | |
---|
[2232] | 1787 | CALL disturb_field( 'u', tend, u ) |
---|
| 1788 | CALL disturb_field( 'v', tend, v ) |
---|
[1384] | 1789 | |
---|
[3849] | 1790 | !$ACC DATA & |
---|
| 1791 | !$ACC CREATE(d(nzb+1:nzt,nys:nyn,nxl:nxr)) & |
---|
| 1792 | !$ACC COPY(w(nzb:nzt+1,nysg:nyng,nxlg:nxrg)) & |
---|
| 1793 | !$ACC COPY(p(nzb:nzt+1,nysg:nyng,nxlg:nxrg)) & |
---|
| 1794 | !$ACC COPYIN(rho_air(nzb:nzt+1), rho_air_zw(nzb:nzt+1)) & |
---|
| 1795 | !$ACC COPYIN(ddzu(1:nzt+1), ddzw(1:nzt+1)) & |
---|
[4346] | 1796 | !$ACC COPYIN(wall_flags_total_0(nzb:nzt+1,nysg:nyng,nxlg:nxrg)) & |
---|
[3849] | 1797 | !$ACC COPYIN(bc_h(0:1)) & |
---|
| 1798 | !$ACC COPYIN(bc_h(0)%i(1:bc_h(0)%ns)) & |
---|
| 1799 | !$ACC COPYIN(bc_h(0)%j(1:bc_h(0)%ns)) & |
---|
| 1800 | !$ACC COPYIN(bc_h(0)%k(1:bc_h(0)%ns)) & |
---|
| 1801 | !$ACC COPYIN(bc_h(1)%i(1:bc_h(1)%ns)) & |
---|
| 1802 | !$ACC COPYIN(bc_h(1)%j(1:bc_h(1)%ns)) & |
---|
| 1803 | !$ACC COPYIN(bc_h(1)%k(1:bc_h(1)%ns)) |
---|
| 1804 | |
---|
[680] | 1805 | n_sor = nsor_ini |
---|
| 1806 | CALL pres |
---|
| 1807 | n_sor = nsor |
---|
[1384] | 1808 | |
---|
[3849] | 1809 | !$ACC END DATA |
---|
| 1810 | !$ACC END DATA |
---|
| 1811 | |
---|
[4648] | 1812 | IF ( debug_output ) THEN |
---|
| 1813 | CALL debug_message( 'creating disturbances + applying pressure solver', 'end' ) |
---|
| 1814 | ENDIF |
---|
[3987] | 1815 | |
---|
[680] | 1816 | ENDIF |
---|
| 1817 | |
---|
[3294] | 1818 | IF ( .NOT. ocean_mode ) THEN |
---|
[3274] | 1819 | |
---|
| 1820 | ALLOCATE( hyp(nzb:nzt+1) ) |
---|
| 1821 | ALLOCATE( d_exner(nzb:nzt+1) ) |
---|
| 1822 | ALLOCATE( exner(nzb:nzt+1) ) |
---|
| 1823 | ALLOCATE( hyrho(nzb:nzt+1) ) |
---|
[1849] | 1824 | ! |
---|
[3274] | 1825 | !-- Check temperature in case of too large domain height |
---|
| 1826 | DO k = nzb, nzt+1 |
---|
[4648] | 1827 | IF ( ( pt_surface * exner_function( surface_pressure * 100.0_wp ) - g/c_p * zu(k) ) & |
---|
| 1828 | < 0.0_wp ) THEN |
---|
| 1829 | WRITE( message_string, * ) 'absolute temperature < 0.0 at zu(', k, ') = ', zu(k) |
---|
[3685] | 1830 | CALL message( 'init_3d_model', 'PA0142', 1, 2, 0, 6, 0 ) |
---|
[3274] | 1831 | ENDIF |
---|
| 1832 | ENDDO |
---|
| 1833 | |
---|
| 1834 | ! |
---|
| 1835 | !-- Calculate vertical profile of the hydrostatic pressure (hyp) |
---|
[4648] | 1836 | hyp = barometric_formula( zu, pt_surface * exner_function( surface_pressure * 100.0_wp ),& |
---|
| 1837 | surface_pressure * 100.0_wp ) |
---|
| 1838 | d_exner = exner_function_invers( hyp ) |
---|
| 1839 | exner = 1.0_wp / exner_function_invers( hyp ) |
---|
| 1840 | hyrho = ideal_gas_law_rho_pt( hyp, pt_init ) |
---|
[3274] | 1841 | ! |
---|
| 1842 | !-- Compute reference density |
---|
[4648] | 1843 | rho_surface = ideal_gas_law_rho( surface_pressure * 100.0_wp, & |
---|
| 1844 | pt_surface * exner_function( surface_pressure * 100.0_wp ) ) |
---|
[3274] | 1845 | |
---|
[96] | 1846 | ENDIF |
---|
[1] | 1847 | |
---|
| 1848 | ! |
---|
| 1849 | !-- If required, initialize particles |
---|
[3159] | 1850 | IF ( agents_active ) CALL mas_init |
---|
| 1851 | ! |
---|
[3937] | 1852 | !-- Initialization of synthetic turbulence generator |
---|
[4848] | 1853 | IF ( syn_turb_gen ) CALL stg_init |
---|
[2696] | 1854 | ! |
---|
[3685] | 1855 | !-- Initializing actions for all other modules |
---|
| 1856 | CALL module_interface_init |
---|
[2696] | 1857 | ! |
---|
[4648] | 1858 | !-- Initialize surface layer (done after LSM as roughness length are required for initialization |
---|
[3685] | 1859 | IF ( constant_flux_layer ) CALL init_surface_layer_fluxes |
---|
[2977] | 1860 | ! |
---|
[3421] | 1861 | !-- Initialize surface data output |
---|
[3685] | 1862 | IF ( surface_output ) CALL surface_data_output_init |
---|
[3472] | 1863 | ! |
---|
[4648] | 1864 | !-- Initialize the ws-scheme. |
---|
| 1865 | IF ( ws_scheme_sca .OR. ws_scheme_mom ) CALL ws_init |
---|
[3711] | 1866 | ! |
---|
| 1867 | !-- Perform post-initializing checks for all other modules |
---|
| 1868 | CALL module_interface_init_checks |
---|
[1] | 1869 | |
---|
| 1870 | ! |
---|
[4648] | 1871 | !-- Initialize surface forcing corresponding to large-scale forcing. Therein, |
---|
[4548] | 1872 | !-- initialize heat-fluxes, etc. via datatype. Revise it later! |
---|
[4648] | 1873 | IF ( large_scale_forcing .AND. lsf_surf ) THEN |
---|
[4548] | 1874 | IF ( use_surface_fluxes .AND. constant_heatflux ) THEN |
---|
[4648] | 1875 | CALL ls_forcing_surf( simulated_time ) |
---|
[4548] | 1876 | ENDIF |
---|
| 1877 | ENDIF |
---|
| 1878 | ! |
---|
[4648] | 1879 | !-- Setting weighting factors for calculation of perturbation pressure and turbulent quantities from |
---|
| 1880 | !-- the RK substeps. |
---|
| 1881 | IF ( TRIM( timestep_scheme ) == 'runge-kutta-3' ) THEN ! for RK3-method |
---|
[709] | 1882 | |
---|
[1322] | 1883 | weight_substep(1) = 1._wp/6._wp |
---|
| 1884 | weight_substep(2) = 3._wp/10._wp |
---|
| 1885 | weight_substep(3) = 8._wp/15._wp |
---|
[709] | 1886 | |
---|
[1322] | 1887 | weight_pres(1) = 1._wp/3._wp |
---|
| 1888 | weight_pres(2) = 5._wp/12._wp |
---|
| 1889 | weight_pres(3) = 1._wp/4._wp |
---|
[709] | 1890 | |
---|
[4648] | 1891 | ELSEIF ( TRIM( timestep_scheme ) == 'runge-kutta-2' ) THEN ! for RK2-method |
---|
[709] | 1892 | |
---|
[1322] | 1893 | weight_substep(1) = 1._wp/2._wp |
---|
| 1894 | weight_substep(2) = 1._wp/2._wp |
---|
[4648] | 1895 | |
---|
[1322] | 1896 | weight_pres(1) = 1._wp/2._wp |
---|
[4648] | 1897 | weight_pres(2) = 1._wp/2._wp |
---|
[709] | 1898 | |
---|
[1001] | 1899 | ELSE ! for Euler-method |
---|
[709] | 1900 | |
---|
[4648] | 1901 | weight_substep(1) = 1.0_wp |
---|
| 1902 | weight_pres(1) = 1.0_wp |
---|
[709] | 1903 | |
---|
[673] | 1904 | ENDIF |
---|
| 1905 | |
---|
| 1906 | ! |
---|
[1] | 1907 | !-- Initialize Rayleigh damping factors |
---|
[1340] | 1908 | rdf = 0.0_wp |
---|
| 1909 | rdf_sc = 0.0_wp |
---|
| 1910 | IF ( rayleigh_damping_factor /= 0.0_wp ) THEN |
---|
[3294] | 1911 | |
---|
| 1912 | IF ( .NOT. ocean_mode ) THEN |
---|
[108] | 1913 | DO k = nzb+1, nzt |
---|
| 1914 | IF ( zu(k) >= rayleigh_damping_height ) THEN |
---|
[4648] | 1915 | rdf(k) = rayleigh_damping_factor * & |
---|
| 1916 | ( SIN( pi * 0.5_wp * ( zu(k) - rayleigh_damping_height ) & |
---|
| 1917 | / ( zu(nzt) - rayleigh_damping_height ) ) & |
---|
| 1918 | )**2 |
---|
[108] | 1919 | ENDIF |
---|
| 1920 | ENDDO |
---|
| 1921 | ELSE |
---|
[3294] | 1922 | ! |
---|
[4648] | 1923 | !-- In ocean mode, rayleigh damping is applied in the lower part of the model domain |
---|
[108] | 1924 | DO k = nzt, nzb+1, -1 |
---|
| 1925 | IF ( zu(k) <= rayleigh_damping_height ) THEN |
---|
[4648] | 1926 | rdf(k) = rayleigh_damping_factor * & |
---|
| 1927 | ( SIN( pi * 0.5_wp * ( rayleigh_damping_height - zu(k) ) & |
---|
| 1928 | / ( rayleigh_damping_height - zu(nzb+1) ) ) & |
---|
| 1929 | )**2 |
---|
[108] | 1930 | ENDIF |
---|
| 1931 | ENDDO |
---|
| 1932 | ENDIF |
---|
[3294] | 1933 | |
---|
[1] | 1934 | ENDIF |
---|
[785] | 1935 | IF ( scalar_rayleigh_damping ) rdf_sc = rdf |
---|
[1] | 1936 | |
---|
| 1937 | ! |
---|
[4648] | 1938 | !-- Initialize the starting level and the vertical smoothing factor used for the external pressure |
---|
| 1939 | !-- gradient |
---|
[1340] | 1940 | dp_smooth_factor = 1.0_wp |
---|
[240] | 1941 | IF ( dp_external ) THEN |
---|
| 1942 | ! |
---|
[4648] | 1943 | !-- Set the starting level dp_level_ind_b only if it has not been set before (e.g. in init_grid). |
---|
[240] | 1944 | IF ( dp_level_ind_b == 0 ) THEN |
---|
| 1945 | ind_array = MINLOC( ABS( dp_level_b - zu ) ) |
---|
[4648] | 1946 | dp_level_ind_b = ind_array(1) - 1 + nzb |
---|
[240] | 1947 | ! MINLOC uses lower array bound 1 |
---|
| 1948 | ENDIF |
---|
| 1949 | IF ( dp_smooth ) THEN |
---|
[1340] | 1950 | dp_smooth_factor(:dp_level_ind_b) = 0.0_wp |
---|
[240] | 1951 | DO k = dp_level_ind_b+1, nzt |
---|
[4648] | 1952 | dp_smooth_factor(k) = 0.5_wp * ( 1.0_wp + SIN( pi * & |
---|
| 1953 | ( REAL( k - dp_level_ind_b, KIND=wp ) / & |
---|
| 1954 | REAL( nzt - dp_level_ind_b, KIND=wp ) - 0.5_wp ) ) ) |
---|
[240] | 1955 | ENDDO |
---|
| 1956 | ENDIF |
---|
| 1957 | ENDIF |
---|
| 1958 | |
---|
| 1959 | ! |
---|
[4648] | 1960 | !-- Initialize damping zone for the potential temperature in case of non-cyclic lateral boundaries. |
---|
| 1961 | !-- The damping zone has the maximum value at the inflow boundary and decreases to zero at |
---|
| 1962 | !-- pt_damping_width. |
---|
[1340] | 1963 | ptdf_x = 0.0_wp |
---|
| 1964 | ptdf_y = 0.0_wp |
---|
[1159] | 1965 | IF ( bc_lr_dirrad ) THEN |
---|
[996] | 1966 | DO i = nxl, nxr |
---|
[978] | 1967 | IF ( ( i * dx ) < pt_damping_width ) THEN |
---|
[4648] | 1968 | ptdf_x(i) = pt_damping_factor * ( SIN( pi * 0.5_wp * & |
---|
| 1969 | REAL( pt_damping_width - i * dx, KIND=wp ) / & |
---|
| 1970 | REAL( pt_damping_width, KIND=wp ) ) )**2 |
---|
| 1971 | ENDIF |
---|
[73] | 1972 | ENDDO |
---|
[1159] | 1973 | ELSEIF ( bc_lr_raddir ) THEN |
---|
[996] | 1974 | DO i = nxl, nxr |
---|
[978] | 1975 | IF ( ( i * dx ) > ( nx * dx - pt_damping_width ) ) THEN |
---|
[4648] | 1976 | ptdf_x(i) = pt_damping_factor * SIN( pi * 0.5_wp * & |
---|
| 1977 | ( ( i - nx ) * dx + pt_damping_width ) / & |
---|
| 1978 | REAL( pt_damping_width, KIND=wp ) )**2 |
---|
[73] | 1979 | ENDIF |
---|
[4648] | 1980 | ENDDO |
---|
[1159] | 1981 | ELSEIF ( bc_ns_dirrad ) THEN |
---|
[996] | 1982 | DO j = nys, nyn |
---|
[978] | 1983 | IF ( ( j * dy ) > ( ny * dy - pt_damping_width ) ) THEN |
---|
[4648] | 1984 | ptdf_y(j) = pt_damping_factor * SIN( pi * 0.5_wp * & |
---|
| 1985 | ( ( j - ny ) * dy + pt_damping_width ) / & |
---|
| 1986 | REAL( pt_damping_width, KIND=wp ) )**2 |
---|
[1] | 1987 | ENDIF |
---|
[4648] | 1988 | ENDDO |
---|
[1159] | 1989 | ELSEIF ( bc_ns_raddir ) THEN |
---|
[996] | 1990 | DO j = nys, nyn |
---|
[978] | 1991 | IF ( ( j * dy ) < pt_damping_width ) THEN |
---|
[4648] | 1992 | ptdf_y(j) = pt_damping_factor * SIN( pi * 0.5_wp * & |
---|
| 1993 | ( pt_damping_width - j * dy ) / & |
---|
| 1994 | REAL( pt_damping_width, KIND=wp ) )**2 |
---|
[1] | 1995 | ENDIF |
---|
[73] | 1996 | ENDDO |
---|
[1] | 1997 | ENDIF |
---|
[51] | 1998 | |
---|
[1] | 1999 | ! |
---|
[4648] | 2000 | !-- Input binary data file is not needed anymore. This line must be placed after call of user_init! |
---|
[1] | 2001 | CALL close_file( 13 ) |
---|
[2934] | 2002 | ! |
---|
[4648] | 2003 | !-- In case of nesting, put an barrier to assure that all parent and child domains finished |
---|
| 2004 | !-- initialization. |
---|
[2934] | 2005 | #if defined( __parallel ) |
---|
| 2006 | IF ( nested_run ) CALL MPI_BARRIER( MPI_COMM_WORLD, ierr ) |
---|
| 2007 | #endif |
---|
[1] | 2008 | |
---|
[2934] | 2009 | |
---|
[3987] | 2010 | CALL location_message( 'model initialization', 'finished' ) |
---|
[1] | 2011 | |
---|
| 2012 | END SUBROUTINE init_3d_model |
---|