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