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