[1] | 1 | SUBROUTINE init_3d_model |
---|
| 2 | |
---|
[1036] | 3 | !--------------------------------------------------------------------------------! |
---|
| 4 | ! This file is part of PALM. |
---|
| 5 | ! |
---|
| 6 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
| 7 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
| 8 | ! either version 3 of the License, or (at your option) any later version. |
---|
| 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 | ! |
---|
[1310] | 17 | ! Copyright 1997-2014 Leibniz Universitaet Hannover |
---|
[1036] | 18 | !--------------------------------------------------------------------------------! |
---|
| 19 | ! |
---|
[254] | 20 | ! Current revisions: |
---|
[732] | 21 | ! ------------------ |
---|
[1485] | 22 | ! |
---|
[1552] | 23 | ! |
---|
[1485] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: init_3d_model.f90 1552 2015-03-03 14:27:15Z raasch $ |
---|
| 27 | ! |
---|
[1552] | 28 | ! 1551 2015-03-03 14:18:16Z maronga |
---|
| 29 | ! Allocation of land surface arrays is now done in the subroutine init_lsm_arrays, |
---|
| 30 | ! which is part of land_surface_model. |
---|
| 31 | ! |
---|
[1508] | 32 | ! 1507 2014-12-10 12:14:18Z suehring |
---|
| 33 | ! Bugfix: set horizontal velocity components to zero inside topography |
---|
| 34 | ! |
---|
[1497] | 35 | ! 1496 2014-12-02 17:25:50Z maronga |
---|
| 36 | ! Added initialization of the land surface and radiation schemes |
---|
| 37 | ! |
---|
[1485] | 38 | ! 1484 2014-10-21 10:53:05Z kanani |
---|
[1484] | 39 | ! Changes due to new module structure of the plant canopy model: |
---|
[1508] | 40 | ! canopy-related initialization (e.g. lad and canopy_heat_flux) moved to new |
---|
| 41 | ! subroutine init_plant_canopy within the module plant_canopy_model_mod, |
---|
| 42 | ! call of subroutine init_plant_canopy added. |
---|
[1341] | 43 | ! |
---|
[1432] | 44 | ! 1431 2014-07-15 14:47:17Z suehring |
---|
| 45 | ! var_d added, in order to normalize spectra. |
---|
| 46 | ! |
---|
[1430] | 47 | ! 1429 2014-07-15 12:53:45Z knoop |
---|
| 48 | ! Ensemble run capability added to parallel random number generator |
---|
| 49 | ! |
---|
[1412] | 50 | ! 1411 2014-05-16 18:01:51Z suehring |
---|
| 51 | ! Initial horizontal velocity profiles were not set to zero at the first vertical |
---|
| 52 | ! grid level in case of non-cyclic lateral boundary conditions. |
---|
| 53 | ! |
---|
[1407] | 54 | ! 1406 2014-05-16 13:47:01Z raasch |
---|
| 55 | ! bugfix: setting of initial velocities at k=1 to zero not in case of a |
---|
| 56 | ! no-slip boundary condition for uv |
---|
| 57 | ! |
---|
[1403] | 58 | ! 1402 2014-05-09 14:25:13Z raasch |
---|
| 59 | ! location messages modified |
---|
| 60 | ! |
---|
[1401] | 61 | ! 1400 2014-05-09 14:03:54Z knoop |
---|
| 62 | ! Parallel random number generator added |
---|
| 63 | ! |
---|
[1385] | 64 | ! 1384 2014-05-02 14:31:06Z raasch |
---|
| 65 | ! location messages added |
---|
| 66 | ! |
---|
[1362] | 67 | ! 1361 2014-04-16 15:17:48Z hoffmann |
---|
| 68 | ! tend_* removed |
---|
| 69 | ! Bugfix: w_subs is not allocated anymore if it is already allocated |
---|
| 70 | ! |
---|
[1360] | 71 | ! 1359 2014-04-11 17:15:14Z hoffmann |
---|
| 72 | ! module lpm_init_mod added to use statements, because lpm_init has become a |
---|
| 73 | ! module |
---|
| 74 | ! |
---|
[1354] | 75 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
| 76 | ! REAL constants provided with KIND-attribute |
---|
| 77 | ! |
---|
[1341] | 78 | ! 1340 2014-03-25 19:45:13Z kanani |
---|
| 79 | ! REAL constants defined as wp-kind |
---|
| 80 | ! |
---|
[1323] | 81 | ! 1322 2014-03-20 16:38:49Z raasch |
---|
| 82 | ! REAL constants defined as wp-kind |
---|
| 83 | ! module interfaces removed |
---|
| 84 | ! |
---|
[1321] | 85 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
| 86 | ! ONLY-attribute added to USE-statements, |
---|
| 87 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 88 | ! kinds are defined in new module kinds, |
---|
| 89 | ! revision history before 2012 removed, |
---|
| 90 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 91 | ! all variable declaration statements |
---|
| 92 | ! |
---|
[1317] | 93 | ! 1316 2014-03-17 07:44:59Z heinze |
---|
| 94 | ! Bugfix: allocation of w_subs |
---|
| 95 | ! |
---|
[1300] | 96 | ! 1299 2014-03-06 13:15:21Z heinze |
---|
| 97 | ! Allocate w_subs due to extension of large scale subsidence in combination |
---|
| 98 | ! with large scale forcing data (LSF_DATA) |
---|
| 99 | ! |
---|
[1242] | 100 | ! 1241 2013-10-30 11:36:58Z heinze |
---|
| 101 | ! Overwrite initial profiles in case of nudging |
---|
| 102 | ! Inititialize shf and qsws in case of large_scale_forcing |
---|
| 103 | ! |
---|
[1222] | 104 | ! 1221 2013-09-10 08:59:13Z raasch |
---|
| 105 | ! +rflags_s_inner in copyin statement, use copyin for most arrays instead of |
---|
| 106 | ! copy |
---|
| 107 | ! |
---|
[1213] | 108 | ! 1212 2013-08-15 08:46:27Z raasch |
---|
| 109 | ! array tri is allocated and included in data copy statement |
---|
| 110 | ! |
---|
[1196] | 111 | ! 1195 2013-07-01 12:27:57Z heinze |
---|
| 112 | ! Bugfix: move allocation of ref_state to parin.f90 and read_var_list.f90 |
---|
| 113 | ! |
---|
[1182] | 114 | ! 1179 2013-06-14 05:57:58Z raasch |
---|
| 115 | ! allocate and set ref_state to be used in buoyancy terms |
---|
| 116 | ! |
---|
[1172] | 117 | ! 1171 2013-05-30 11:27:45Z raasch |
---|
| 118 | ! diss array is allocated with full size if accelerator boards are used |
---|
| 119 | ! |
---|
[1160] | 120 | ! 1159 2013-05-21 11:58:22Z fricke |
---|
| 121 | ! -bc_lr_dirneu, bc_lr_neudir, bc_ns_dirneu, bc_ns_neudir |
---|
| 122 | ! |
---|
[1154] | 123 | ! 1153 2013-05-10 14:33:08Z raasch |
---|
| 124 | ! diss array is allocated with dummy elements even if it is not needed |
---|
[1171] | 125 | ! (required by PGI 13.4 / CUDA 5.0) |
---|
[1154] | 126 | ! |
---|
[1116] | 127 | ! 1115 2013-03-26 18:16:16Z hoffmann |
---|
| 128 | ! unused variables removed |
---|
| 129 | ! |
---|
[1114] | 130 | ! 1113 2013-03-10 02:48:14Z raasch |
---|
| 131 | ! openACC directive modified |
---|
| 132 | ! |
---|
[1112] | 133 | ! 1111 2013-03-08 23:54:10Z raasch |
---|
| 134 | ! openACC directives added for pres |
---|
| 135 | ! array diss allocated only if required |
---|
| 136 | ! |
---|
[1093] | 137 | ! 1092 2013-02-02 11:24:22Z raasch |
---|
| 138 | ! unused variables removed |
---|
| 139 | ! |
---|
[1066] | 140 | ! 1065 2012-11-22 17:42:36Z hoffmann |
---|
| 141 | ! allocation of diss (dissipation rate) in case of turbulence = .TRUE. added |
---|
| 142 | ! |
---|
[1054] | 143 | ! 1053 2012-11-13 17:11:03Z hoffmann |
---|
[1053] | 144 | ! allocation and initialisation of necessary data arrays for the two-moment |
---|
| 145 | ! cloud physics scheme the two new prognostic equations (nr, qr): |
---|
| 146 | ! +dr, lambda_r, mu_r, sed_*, xr, *s, *sws, *swst, *, *_p, t*_m, *_1, *_2, *_3, |
---|
| 147 | ! +tend_*, prr |
---|
[979] | 148 | ! |
---|
[1037] | 149 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 150 | ! code put under GPL (PALM 3.9) |
---|
| 151 | ! |
---|
[1033] | 152 | ! 1032 2012-10-21 13:03:21Z letzel |
---|
| 153 | ! save memory by not allocating pt_2 in case of neutral = .T. |
---|
| 154 | ! |
---|
[1026] | 155 | ! 1025 2012-10-07 16:04:41Z letzel |
---|
| 156 | ! bugfix: swap indices of mask for ghost boundaries |
---|
| 157 | ! |
---|
[1017] | 158 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
| 159 | ! mask is set to zero for ghost boundaries |
---|
| 160 | ! |
---|
[1011] | 161 | ! 1010 2012-09-20 07:59:54Z raasch |
---|
| 162 | ! cpp switch __nopointer added for pointer free version |
---|
| 163 | ! |
---|
[1004] | 164 | ! 1003 2012-09-14 14:35:53Z raasch |
---|
| 165 | ! nxra,nyna, nzta replaced ny nxr, nyn, nzt |
---|
| 166 | ! |
---|
[1002] | 167 | ! 1001 2012-09-13 14:08:46Z raasch |
---|
| 168 | ! all actions concerning leapfrog scheme removed |
---|
| 169 | ! |
---|
[997] | 170 | ! 996 2012-09-07 10:41:47Z raasch |
---|
| 171 | ! little reformatting |
---|
| 172 | ! |
---|
[979] | 173 | ! 978 2012-08-09 08:28:32Z fricke |
---|
[978] | 174 | ! outflow damping layer removed |
---|
| 175 | ! roughness length for scalar quantites z0h added |
---|
| 176 | ! damping zone for the potential temperatur in case of non-cyclic lateral |
---|
| 177 | ! boundaries added |
---|
| 178 | ! initialization of ptdf_x, ptdf_y |
---|
| 179 | ! initialization of c_u_m, c_u_m_l, c_v_m, c_v_m_l, c_w_m, c_w_m_l |
---|
[708] | 180 | ! |
---|
[850] | 181 | ! 849 2012-03-15 10:35:09Z raasch |
---|
| 182 | ! init_particles renamed lpm_init |
---|
| 183 | ! |
---|
[826] | 184 | ! 825 2012-02-19 03:03:44Z raasch |
---|
| 185 | ! wang_collision_kernel renamed wang_kernel |
---|
| 186 | ! |
---|
[1] | 187 | ! Revision 1.1 1998/03/09 16:22:22 raasch |
---|
| 188 | ! Initial revision |
---|
| 189 | ! |
---|
| 190 | ! |
---|
| 191 | ! Description: |
---|
| 192 | ! ------------ |
---|
| 193 | ! Allocation of arrays and initialization of the 3D model via |
---|
| 194 | ! a) pre-run the 1D model |
---|
| 195 | ! or |
---|
| 196 | ! b) pre-set constant linear profiles |
---|
| 197 | ! or |
---|
| 198 | ! c) read values of a previous run |
---|
| 199 | !------------------------------------------------------------------------------! |
---|
| 200 | |
---|
[667] | 201 | USE advec_ws |
---|
[1320] | 202 | |
---|
[1] | 203 | USE arrays_3d |
---|
[1320] | 204 | |
---|
| 205 | USE cloud_parameters, & |
---|
| 206 | ONLY: nc_const, precipitation_amount, precipitation_rate, prr |
---|
| 207 | |
---|
| 208 | USE constants, & |
---|
| 209 | ONLY: pi |
---|
| 210 | |
---|
[1] | 211 | USE control_parameters |
---|
[1320] | 212 | |
---|
| 213 | USE grid_variables, & |
---|
| 214 | ONLY: dx, dy |
---|
| 215 | |
---|
[1] | 216 | USE indices |
---|
[1359] | 217 | |
---|
[1429] | 218 | USE lpm_init_mod, & |
---|
[1359] | 219 | ONLY: lpm_init |
---|
[1320] | 220 | |
---|
| 221 | USE kinds |
---|
[1496] | 222 | |
---|
| 223 | USE land_surface_model_mod, & |
---|
[1551] | 224 | ONLY: init_lsm, init_lsm_arrays, land_surface |
---|
[1496] | 225 | |
---|
[1241] | 226 | USE ls_forcing_mod |
---|
[1320] | 227 | |
---|
| 228 | USE model_1d, & |
---|
| 229 | ONLY: e1d, kh1d, km1d, l1d, rif1d, u1d, us1d, usws1d, v1d, vsws1d |
---|
| 230 | |
---|
[51] | 231 | USE netcdf_control |
---|
[1320] | 232 | |
---|
| 233 | USE particle_attributes, & |
---|
| 234 | ONLY: particle_advection, use_sgs_for_particles, wang_kernel |
---|
| 235 | |
---|
[1] | 236 | USE pegrid |
---|
[1320] | 237 | |
---|
[1484] | 238 | USE plant_canopy_model_mod, & |
---|
| 239 | ONLY: init_plant_canopy, plant_canopy |
---|
[1496] | 240 | |
---|
| 241 | USE radiation_model_mod, & |
---|
| 242 | ONLY: init_radiation, radiation |
---|
[1484] | 243 | |
---|
[1320] | 244 | USE random_function_mod |
---|
| 245 | |
---|
[1400] | 246 | USE random_generator_parallel, & |
---|
| 247 | ONLY: random_number_parallel, random_seed_parallel, random_dummy, & |
---|
| 248 | id_random_array, seq_random_array |
---|
| 249 | |
---|
[1320] | 250 | USE statistics, & |
---|
| 251 | ONLY: hom, hom_sum, pr_palm, rmask, spectrum_x, spectrum_y, & |
---|
| 252 | statistic_regions, sums, sums_divnew_l, sums_divold_l, sums_l, & |
---|
| 253 | sums_l_l, sums_up_fraction_l, sums_wsts_bc_l, ts_value, & |
---|
[1431] | 254 | var_d, weight_pres, weight_substep |
---|
[1320] | 255 | |
---|
| 256 | USE transpose_indices |
---|
[1] | 257 | |
---|
| 258 | IMPLICIT NONE |
---|
| 259 | |
---|
[1320] | 260 | INTEGER(iwp) :: i !: |
---|
| 261 | INTEGER(iwp) :: ind_array(1) !: |
---|
| 262 | INTEGER(iwp) :: j !: |
---|
| 263 | INTEGER(iwp) :: k !: |
---|
| 264 | INTEGER(iwp) :: sr !: |
---|
[1] | 265 | |
---|
[1320] | 266 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: ngp_2dh_l !: |
---|
[1] | 267 | |
---|
[1320] | 268 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: ngp_2dh_outer_l !: |
---|
| 269 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: ngp_2dh_s_inner_l !: |
---|
[1] | 270 | |
---|
[1320] | 271 | REAL(wp), DIMENSION(1:2) :: volume_flow_area_l !: |
---|
| 272 | REAL(wp), DIMENSION(1:2) :: volume_flow_initial_l !: |
---|
[1] | 273 | |
---|
[1320] | 274 | REAL(wp), DIMENSION(:), ALLOCATABLE :: ngp_3d_inner_l !: |
---|
| 275 | REAL(wp), DIMENSION(:), ALLOCATABLE :: ngp_3d_inner_tmp !: |
---|
[1] | 276 | |
---|
[485] | 277 | |
---|
[1402] | 278 | CALL location_message( 'allocating arrays', .FALSE. ) |
---|
[1] | 279 | ! |
---|
| 280 | !-- Allocate arrays |
---|
| 281 | ALLOCATE( ngp_2dh(0:statistic_regions), ngp_2dh_l(0:statistic_regions), & |
---|
| 282 | ngp_3d(0:statistic_regions), & |
---|
| 283 | ngp_3d_inner(0:statistic_regions), & |
---|
| 284 | ngp_3d_inner_l(0:statistic_regions), & |
---|
[485] | 285 | ngp_3d_inner_tmp(0:statistic_regions), & |
---|
[1] | 286 | sums_divnew_l(0:statistic_regions), & |
---|
| 287 | sums_divold_l(0:statistic_regions) ) |
---|
[1195] | 288 | ALLOCATE( dp_smooth_factor(nzb:nzt), rdf(nzb+1:nzt), rdf_sc(nzb+1:nzt) ) |
---|
[143] | 289 | ALLOCATE( ngp_2dh_outer(nzb:nzt+1,0:statistic_regions), & |
---|
[1] | 290 | ngp_2dh_outer_l(nzb:nzt+1,0:statistic_regions), & |
---|
[132] | 291 | ngp_2dh_s_inner(nzb:nzt+1,0:statistic_regions), & |
---|
| 292 | ngp_2dh_s_inner_l(nzb:nzt+1,0:statistic_regions), & |
---|
[996] | 293 | rmask(nysg:nyng,nxlg:nxrg,0:statistic_regions), & |
---|
[87] | 294 | sums(nzb:nzt+1,pr_palm+max_pr_user), & |
---|
| 295 | sums_l(nzb:nzt+1,pr_palm+max_pr_user,0:threads_per_task-1), & |
---|
[1] | 296 | sums_l_l(nzb:nzt+1,0:statistic_regions,0:threads_per_task-1), & |
---|
| 297 | sums_up_fraction_l(10,3,0:statistic_regions), & |
---|
[48] | 298 | sums_wsts_bc_l(nzb:nzt+1,0:statistic_regions), & |
---|
[394] | 299 | ts_value(dots_max,0:statistic_regions) ) |
---|
[978] | 300 | ALLOCATE( ptdf_x(nxlg:nxrg), ptdf_y(nysg:nyng) ) |
---|
[1] | 301 | |
---|
[1001] | 302 | ALLOCATE( rif(nysg:nyng,nxlg:nxrg), shf(nysg:nyng,nxlg:nxrg), & |
---|
| 303 | ts(nysg:nyng,nxlg:nxrg), tswst(nysg:nyng,nxlg:nxrg), & |
---|
| 304 | us(nysg:nyng,nxlg:nxrg), usws(nysg:nyng,nxlg:nxrg), & |
---|
| 305 | uswst(nysg:nyng,nxlg:nxrg), vsws(nysg:nyng,nxlg:nxrg), & |
---|
| 306 | vswst(nysg:nyng,nxlg:nxrg), z0(nysg:nyng,nxlg:nxrg), & |
---|
[978] | 307 | z0h(nysg:nyng,nxlg:nxrg) ) |
---|
[1] | 308 | |
---|
[1010] | 309 | ALLOCATE( d(nzb+1:nzt,nys:nyn,nxl:nxr), & |
---|
| 310 | kh(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 311 | km(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 312 | p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 313 | tend(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 314 | |
---|
| 315 | #if defined( __nopointer ) |
---|
| 316 | ALLOCATE( e(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 317 | e_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 318 | pt(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 319 | pt_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 320 | u(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 321 | u_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 322 | v(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 323 | v_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 324 | w(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 325 | w_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 326 | te_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 327 | tpt_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 328 | tu_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 329 | tv_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 330 | tw_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 331 | #else |
---|
| 332 | ALLOCATE( e_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 333 | e_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 334 | e_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 335 | pt_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 336 | pt_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 337 | u_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 338 | u_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 339 | u_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 340 | v_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 341 | v_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 342 | v_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 343 | w_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 344 | w_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
[667] | 345 | w_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
[1032] | 346 | IF ( .NOT. neutral ) THEN |
---|
| 347 | ALLOCATE( pt_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 348 | ENDIF |
---|
[1010] | 349 | #endif |
---|
| 350 | |
---|
[673] | 351 | ! |
---|
[707] | 352 | !-- Following array is required for perturbation pressure within the iterative |
---|
| 353 | !-- pressure solvers. For the multistep schemes (Runge-Kutta), array p holds |
---|
| 354 | !-- the weighted average of the substeps and cannot be used in the Poisson |
---|
| 355 | !-- solver. |
---|
| 356 | IF ( psolver == 'sor' ) THEN |
---|
| 357 | ALLOCATE( p_loc(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 358 | ELSEIF ( psolver == 'multigrid' ) THEN |
---|
| 359 | ! |
---|
| 360 | !-- For performance reasons, multigrid is using one ghost layer only |
---|
| 361 | ALLOCATE( p_loc(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
[673] | 362 | ENDIF |
---|
[1] | 363 | |
---|
[1111] | 364 | ! |
---|
| 365 | !-- Array for storing constant coeffficients of the tridiagonal solver |
---|
| 366 | IF ( psolver == 'poisfft' ) THEN |
---|
[1212] | 367 | ALLOCATE( tri(nxl_z:nxr_z,nys_z:nyn_z,0:nz-1,2) ) |
---|
[1111] | 368 | ALLOCATE( tric(nxl_z:nxr_z,nys_z:nyn_z,0:nz-1) ) |
---|
| 369 | ENDIF |
---|
| 370 | |
---|
[75] | 371 | IF ( humidity .OR. passive_scalar ) THEN |
---|
[1] | 372 | ! |
---|
[75] | 373 | !-- 2D-humidity/scalar arrays |
---|
[1001] | 374 | ALLOCATE ( qs(nysg:nyng,nxlg:nxrg), & |
---|
| 375 | qsws(nysg:nyng,nxlg:nxrg), & |
---|
| 376 | qswst(nysg:nyng,nxlg:nxrg) ) |
---|
[1] | 377 | |
---|
| 378 | ! |
---|
[75] | 379 | !-- 3D-humidity/scalar arrays |
---|
[1010] | 380 | #if defined( __nopointer ) |
---|
| 381 | ALLOCATE( q(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 382 | q_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 383 | tq_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 384 | #else |
---|
[667] | 385 | ALLOCATE( q_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 386 | q_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 387 | q_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
[1010] | 388 | #endif |
---|
[1] | 389 | |
---|
| 390 | ! |
---|
[75] | 391 | !-- 3D-arrays needed for humidity only |
---|
| 392 | IF ( humidity ) THEN |
---|
[1010] | 393 | #if defined( __nopointer ) |
---|
| 394 | ALLOCATE( vpt(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 395 | #else |
---|
[667] | 396 | ALLOCATE( vpt_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
[1010] | 397 | #endif |
---|
[1] | 398 | |
---|
| 399 | IF ( cloud_physics ) THEN |
---|
[1053] | 400 | |
---|
[1] | 401 | ! |
---|
| 402 | !-- Liquid water content |
---|
[1010] | 403 | #if defined( __nopointer ) |
---|
| 404 | ALLOCATE ( ql(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 405 | #else |
---|
[667] | 406 | ALLOCATE ( ql_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
[1010] | 407 | #endif |
---|
[72] | 408 | ! |
---|
| 409 | !-- Precipitation amount and rate (only needed if output is switched) |
---|
[667] | 410 | ALLOCATE( precipitation_amount(nysg:nyng,nxlg:nxrg), & |
---|
| 411 | precipitation_rate(nysg:nyng,nxlg:nxrg) ) |
---|
[1053] | 412 | |
---|
| 413 | IF ( icloud_scheme == 0 ) THEN |
---|
| 414 | ! |
---|
[1115] | 415 | !-- 1D-arrays |
---|
| 416 | ALLOCATE ( nc_1d(nzb:nzt+1), pt_1d(nzb:nzt+1), & |
---|
| 417 | q_1d(nzb:nzt+1), qc_1d(nzb:nzt+1) ) |
---|
[1053] | 418 | ! |
---|
[1115] | 419 | !-- 3D-cloud water content |
---|
[1053] | 420 | #if defined( __nopointer ) |
---|
[1115] | 421 | ALLOCATE( qc(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
[1053] | 422 | #else |
---|
[1115] | 423 | ALLOCATE( qc_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
[1053] | 424 | #endif |
---|
[1115] | 425 | |
---|
| 426 | IF ( precipitation ) THEN |
---|
[1053] | 427 | ! |
---|
[1115] | 428 | !-- 1D-arrays |
---|
| 429 | ALLOCATE ( nr_1d(nzb:nzt+1), qr_1d(nzb:nzt+1) ) |
---|
[1361] | 430 | |
---|
[1115] | 431 | ! |
---|
| 432 | !-- 2D-rain water content and rain drop concentration arrays |
---|
| 433 | ALLOCATE ( qrs(nysg:nyng,nxlg:nxrg), & |
---|
| 434 | qrsws(nysg:nyng,nxlg:nxrg), & |
---|
| 435 | qrswst(nysg:nyng,nxlg:nxrg), & |
---|
| 436 | nrs(nysg:nyng,nxlg:nxrg), & |
---|
| 437 | nrsws(nysg:nyng,nxlg:nxrg), & |
---|
| 438 | nrswst(nysg:nyng,nxlg:nxrg) ) |
---|
| 439 | ! |
---|
| 440 | !-- 3D-rain water content, rain drop concentration arrays |
---|
| 441 | #if defined( __nopointer ) |
---|
| 442 | ALLOCATE( nr(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 443 | nr_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 444 | qr(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 445 | qr_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 446 | tnr_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 447 | tqr_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 448 | #else |
---|
| 449 | ALLOCATE( nr_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 450 | nr_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 451 | nr_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 452 | qr_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 453 | qr_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 454 | qr_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 455 | #endif |
---|
| 456 | ! |
---|
| 457 | !-- 3d-precipitation rate |
---|
[1053] | 458 | ALLOCATE( prr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 459 | ENDIF |
---|
| 460 | |
---|
| 461 | ENDIF |
---|
[1] | 462 | ENDIF |
---|
| 463 | |
---|
| 464 | IF ( cloud_droplets ) THEN |
---|
| 465 | ! |
---|
[1010] | 466 | !-- Liquid water content, change in liquid water content |
---|
| 467 | #if defined( __nopointer ) |
---|
| 468 | ALLOCATE ( ql(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 469 | ql_c(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 470 | #else |
---|
[667] | 471 | ALLOCATE ( ql_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
[1010] | 472 | ql_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 473 | #endif |
---|
| 474 | ! |
---|
| 475 | !-- Real volume of particles (with weighting), volume of particles |
---|
| 476 | ALLOCATE ( ql_v(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
[667] | 477 | ql_vp(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
[1] | 478 | ENDIF |
---|
| 479 | |
---|
| 480 | ENDIF |
---|
| 481 | |
---|
| 482 | ENDIF |
---|
| 483 | |
---|
[94] | 484 | IF ( ocean ) THEN |
---|
[1001] | 485 | ALLOCATE( saswsb(nysg:nyng,nxlg:nxrg), & |
---|
| 486 | saswst(nysg:nyng,nxlg:nxrg) ) |
---|
[1010] | 487 | #if defined( __nopointer ) |
---|
| 488 | ALLOCATE( prho(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 489 | rho(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 490 | sa(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 491 | sa_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 492 | tsa_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 493 | #else |
---|
[667] | 494 | ALLOCATE( prho_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 495 | rho_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 496 | sa_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 497 | sa_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 498 | sa_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
[388] | 499 | prho => prho_1 |
---|
| 500 | rho => rho_1 ! routines calc_mean_profile and diffusion_e require |
---|
| 501 | ! density to be apointer |
---|
[1010] | 502 | #endif |
---|
[108] | 503 | IF ( humidity_remote ) THEN |
---|
[667] | 504 | ALLOCATE( qswst_remote(nysg:nyng,nxlg:nxrg)) |
---|
[1340] | 505 | qswst_remote = 0.0_wp |
---|
[108] | 506 | ENDIF |
---|
[94] | 507 | ENDIF |
---|
| 508 | |
---|
[1] | 509 | ! |
---|
| 510 | !-- 3D-array for storing the dissipation, needed for calculating the sgs |
---|
| 511 | !-- particle velocities |
---|
[1171] | 512 | IF ( use_sgs_for_particles .OR. wang_kernel .OR. turbulence .OR. & |
---|
| 513 | num_acc_per_node > 0 ) THEN |
---|
[1153] | 514 | ALLOCATE( diss(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
[1] | 515 | ENDIF |
---|
| 516 | |
---|
[1340] | 517 | IF ( dt_dosp /= 9999999.9_wp ) THEN |
---|
[1] | 518 | ALLOCATE( spectrum_x( 1:nx/2, 1:10, 1:10 ), & |
---|
| 519 | spectrum_y( 1:ny/2, 1:10, 1:10 ) ) |
---|
[1340] | 520 | spectrum_x = 0.0_wp |
---|
| 521 | spectrum_y = 0.0_wp |
---|
[1431] | 522 | |
---|
| 523 | ALLOCATE( var_d(nzb:nzt+1) ) |
---|
| 524 | var_d = 0.0_wp |
---|
[1] | 525 | ENDIF |
---|
| 526 | |
---|
| 527 | ! |
---|
[1299] | 528 | !-- 1D-array for large scale subsidence velocity |
---|
[1361] | 529 | IF ( .NOT. ALLOCATED( w_subs ) ) THEN |
---|
| 530 | ALLOCATE ( w_subs(nzb:nzt+1) ) |
---|
| 531 | w_subs = 0.0_wp |
---|
| 532 | ENDIF |
---|
[1299] | 533 | |
---|
| 534 | ! |
---|
[1400] | 535 | !-- ID-array and state-space-array for the parallel random number generator |
---|
| 536 | IF ( random_generator == 'random-parallel' ) THEN |
---|
| 537 | ALLOCATE ( seq_random_array(5,nysg:nyng,nxlg:nxrg) ) |
---|
| 538 | ALLOCATE ( id_random_array(0:ny,0:nx) ) |
---|
| 539 | seq_random_array = 0 |
---|
| 540 | id_random_array = 0 |
---|
| 541 | ENDIF |
---|
| 542 | |
---|
| 543 | ! |
---|
[51] | 544 | !-- 4D-array for storing the Rif-values at vertical walls |
---|
| 545 | IF ( topography /= 'flat' ) THEN |
---|
[667] | 546 | ALLOCATE( rif_wall(nzb:nzt+1,nysg:nyng,nxlg:nxrg,1:4) ) |
---|
[1340] | 547 | rif_wall = 0.0_wp |
---|
[51] | 548 | ENDIF |
---|
| 549 | |
---|
| 550 | ! |
---|
[106] | 551 | !-- Arrays to store velocity data from t-dt and the phase speeds which |
---|
| 552 | !-- are needed for radiation boundary conditions |
---|
[73] | 553 | IF ( outflow_l ) THEN |
---|
[667] | 554 | ALLOCATE( u_m_l(nzb:nzt+1,nysg:nyng,1:2), & |
---|
| 555 | v_m_l(nzb:nzt+1,nysg:nyng,0:1), & |
---|
| 556 | w_m_l(nzb:nzt+1,nysg:nyng,0:1) ) |
---|
[73] | 557 | ENDIF |
---|
| 558 | IF ( outflow_r ) THEN |
---|
[667] | 559 | ALLOCATE( u_m_r(nzb:nzt+1,nysg:nyng,nx-1:nx), & |
---|
| 560 | v_m_r(nzb:nzt+1,nysg:nyng,nx-1:nx), & |
---|
| 561 | w_m_r(nzb:nzt+1,nysg:nyng,nx-1:nx) ) |
---|
[73] | 562 | ENDIF |
---|
[106] | 563 | IF ( outflow_l .OR. outflow_r ) THEN |
---|
[667] | 564 | ALLOCATE( c_u(nzb:nzt+1,nysg:nyng), c_v(nzb:nzt+1,nysg:nyng), & |
---|
| 565 | c_w(nzb:nzt+1,nysg:nyng) ) |
---|
[106] | 566 | ENDIF |
---|
[73] | 567 | IF ( outflow_s ) THEN |
---|
[667] | 568 | ALLOCATE( u_m_s(nzb:nzt+1,0:1,nxlg:nxrg), & |
---|
| 569 | v_m_s(nzb:nzt+1,1:2,nxlg:nxrg), & |
---|
| 570 | w_m_s(nzb:nzt+1,0:1,nxlg:nxrg) ) |
---|
[73] | 571 | ENDIF |
---|
| 572 | IF ( outflow_n ) THEN |
---|
[667] | 573 | ALLOCATE( u_m_n(nzb:nzt+1,ny-1:ny,nxlg:nxrg), & |
---|
| 574 | v_m_n(nzb:nzt+1,ny-1:ny,nxlg:nxrg), & |
---|
| 575 | w_m_n(nzb:nzt+1,ny-1:ny,nxlg:nxrg) ) |
---|
[73] | 576 | ENDIF |
---|
[106] | 577 | IF ( outflow_s .OR. outflow_n ) THEN |
---|
[667] | 578 | ALLOCATE( c_u(nzb:nzt+1,nxlg:nxrg), c_v(nzb:nzt+1,nxlg:nxrg), & |
---|
| 579 | c_w(nzb:nzt+1,nxlg:nxrg) ) |
---|
[106] | 580 | ENDIF |
---|
[996] | 581 | IF ( outflow_l .OR. outflow_r .OR. outflow_s .OR. outflow_n ) THEN |
---|
[978] | 582 | ALLOCATE( c_u_m_l(nzb:nzt+1), c_v_m_l(nzb:nzt+1), c_w_m_l(nzb:nzt+1) ) |
---|
| 583 | ALLOCATE( c_u_m(nzb:nzt+1), c_v_m(nzb:nzt+1), c_w_m(nzb:nzt+1) ) |
---|
| 584 | ENDIF |
---|
[73] | 585 | |
---|
[978] | 586 | |
---|
[1010] | 587 | #if ! defined( __nopointer ) |
---|
[73] | 588 | ! |
---|
[1] | 589 | !-- Initial assignment of the pointers |
---|
[1001] | 590 | e => e_1; e_p => e_2; te_m => e_3 |
---|
[1032] | 591 | IF ( .NOT. neutral ) THEN |
---|
| 592 | pt => pt_1; pt_p => pt_2; tpt_m => pt_3 |
---|
| 593 | ELSE |
---|
| 594 | pt => pt_1; pt_p => pt_1; tpt_m => pt_3 |
---|
| 595 | ENDIF |
---|
[1001] | 596 | u => u_1; u_p => u_2; tu_m => u_3 |
---|
| 597 | v => v_1; v_p => v_2; tv_m => v_3 |
---|
| 598 | w => w_1; w_p => w_2; tw_m => w_3 |
---|
[1] | 599 | |
---|
[1001] | 600 | IF ( humidity .OR. passive_scalar ) THEN |
---|
| 601 | q => q_1; q_p => q_2; tq_m => q_3 |
---|
[1053] | 602 | IF ( humidity ) THEN |
---|
| 603 | vpt => vpt_1 |
---|
| 604 | IF ( cloud_physics ) THEN |
---|
| 605 | ql => ql_1 |
---|
| 606 | IF ( icloud_scheme == 0 ) THEN |
---|
[1115] | 607 | qc => qc_1 |
---|
| 608 | IF ( precipitation ) THEN |
---|
| 609 | qr => qr_1; qr_p => qr_2; tqr_m => qr_3 |
---|
| 610 | nr => nr_1; nr_p => nr_2; tnr_m => nr_3 |
---|
| 611 | ENDIF |
---|
[1053] | 612 | ENDIF |
---|
| 613 | ENDIF |
---|
| 614 | ENDIF |
---|
[1001] | 615 | IF ( cloud_droplets ) THEN |
---|
| 616 | ql => ql_1 |
---|
| 617 | ql_c => ql_2 |
---|
[1] | 618 | ENDIF |
---|
[1001] | 619 | ENDIF |
---|
[1] | 620 | |
---|
[1001] | 621 | IF ( ocean ) THEN |
---|
| 622 | sa => sa_1; sa_p => sa_2; tsa_m => sa_3 |
---|
| 623 | ENDIF |
---|
[1010] | 624 | #endif |
---|
[1] | 625 | |
---|
| 626 | ! |
---|
[1551] | 627 | !-- Allocate land surface model arrays |
---|
| 628 | IF ( land_surface ) THEN |
---|
| 629 | CALL init_lsm_arrays |
---|
| 630 | ENDIF |
---|
| 631 | |
---|
| 632 | ! |
---|
[709] | 633 | !-- Allocate arrays containing the RK coefficient for calculation of |
---|
| 634 | !-- perturbation pressure and turbulent fluxes. At this point values are |
---|
| 635 | !-- set for pressure calculation during initialization (where no timestep |
---|
| 636 | !-- is done). Further below the values needed within the timestep scheme |
---|
| 637 | !-- will be set. |
---|
| 638 | ALLOCATE( weight_substep(1:intermediate_timestep_count_max), & |
---|
[673] | 639 | weight_pres(1:intermediate_timestep_count_max) ) |
---|
[1340] | 640 | weight_substep = 1.0_wp |
---|
| 641 | weight_pres = 1.0_wp |
---|
[709] | 642 | intermediate_timestep_count = 1 ! needed when simulated_time = 0.0 |
---|
[673] | 643 | |
---|
[1402] | 644 | CALL location_message( 'finished', .TRUE. ) |
---|
[673] | 645 | ! |
---|
[1] | 646 | !-- Initialize model variables |
---|
[147] | 647 | IF ( TRIM( initializing_actions ) /= 'read_restart_data' .AND. & |
---|
[328] | 648 | TRIM( initializing_actions ) /= 'cyclic_fill' ) THEN |
---|
[1] | 649 | ! |
---|
| 650 | !-- First model run of a possible job queue. |
---|
| 651 | !-- Initial profiles of the variables must be computes. |
---|
| 652 | IF ( INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 ) THEN |
---|
[1384] | 653 | |
---|
[1402] | 654 | CALL location_message( 'initializing with 1D model profiles', .FALSE. ) |
---|
[1] | 655 | ! |
---|
| 656 | !-- Use solutions of the 1D model as initial profiles, |
---|
| 657 | !-- start 1D model |
---|
| 658 | CALL init_1d_model |
---|
| 659 | ! |
---|
| 660 | !-- Transfer initial profiles to the arrays of the 3D model |
---|
[667] | 661 | DO i = nxlg, nxrg |
---|
| 662 | DO j = nysg, nyng |
---|
[1] | 663 | e(:,j,i) = e1d |
---|
| 664 | kh(:,j,i) = kh1d |
---|
| 665 | km(:,j,i) = km1d |
---|
| 666 | pt(:,j,i) = pt_init |
---|
| 667 | u(:,j,i) = u1d |
---|
| 668 | v(:,j,i) = v1d |
---|
| 669 | ENDDO |
---|
| 670 | ENDDO |
---|
| 671 | |
---|
[75] | 672 | IF ( humidity .OR. passive_scalar ) THEN |
---|
[667] | 673 | DO i = nxlg, nxrg |
---|
| 674 | DO j = nysg, nyng |
---|
[1] | 675 | q(:,j,i) = q_init |
---|
| 676 | ENDDO |
---|
| 677 | ENDDO |
---|
[1353] | 678 | IF ( cloud_physics .AND. icloud_scheme == 0 .AND. & |
---|
[1115] | 679 | precipitation ) THEN |
---|
[1053] | 680 | DO i = nxlg, nxrg |
---|
| 681 | DO j = nysg, nyng |
---|
[1340] | 682 | qr(:,j,i) = 0.0_wp |
---|
| 683 | nr(:,j,i) = 0.0_wp |
---|
[1053] | 684 | ENDDO |
---|
| 685 | ENDDO |
---|
[1115] | 686 | ! |
---|
| 687 | !-- Initialze nc_1d with default value |
---|
| 688 | nc_1d(:) = nc_const |
---|
| 689 | |
---|
[1053] | 690 | ENDIF |
---|
[1] | 691 | ENDIF |
---|
| 692 | |
---|
| 693 | IF ( .NOT. constant_diffusion ) THEN |
---|
[667] | 694 | DO i = nxlg, nxrg |
---|
| 695 | DO j = nysg, nyng |
---|
[1] | 696 | e(:,j,i) = e1d |
---|
| 697 | ENDDO |
---|
| 698 | ENDDO |
---|
| 699 | ! |
---|
| 700 | !-- Store initial profiles for output purposes etc. |
---|
| 701 | hom(:,1,25,:) = SPREAD( l1d, 2, statistic_regions+1 ) |
---|
| 702 | |
---|
| 703 | IF ( prandtl_layer ) THEN |
---|
| 704 | rif = rif1d(nzb+1) |
---|
[1340] | 705 | ts = 0.0_wp ! could actually be computed more accurately in the |
---|
| 706 | ! 1D model. Update when opportunity arises. |
---|
[1] | 707 | us = us1d |
---|
| 708 | usws = usws1d |
---|
| 709 | vsws = vsws1d |
---|
| 710 | ELSE |
---|
[1340] | 711 | ts = 0.0_wp ! must be set, because used in |
---|
| 712 | rif = 0.0_wp ! flowste |
---|
| 713 | us = 0.0_wp |
---|
| 714 | usws = 0.0_wp |
---|
| 715 | vsws = 0.0_wp |
---|
[1] | 716 | ENDIF |
---|
| 717 | |
---|
| 718 | ELSE |
---|
[1340] | 719 | e = 0.0_wp ! must be set, because used in |
---|
| 720 | rif = 0.0_wp ! flowste |
---|
| 721 | ts = 0.0_wp |
---|
| 722 | us = 0.0_wp |
---|
| 723 | usws = 0.0_wp |
---|
| 724 | vsws = 0.0_wp |
---|
[1] | 725 | ENDIF |
---|
[102] | 726 | uswst = top_momentumflux_u |
---|
| 727 | vswst = top_momentumflux_v |
---|
[1] | 728 | |
---|
| 729 | ! |
---|
| 730 | !-- In every case qs = 0.0 (see also pt) |
---|
| 731 | !-- This could actually be computed more accurately in the 1D model. |
---|
| 732 | !-- Update when opportunity arises! |
---|
[1053] | 733 | IF ( humidity .OR. passive_scalar ) THEN |
---|
[1340] | 734 | qs = 0.0_wp |
---|
[1353] | 735 | IF ( cloud_physics .AND. icloud_scheme == 0 .AND. & |
---|
[1115] | 736 | precipitation ) THEN |
---|
[1340] | 737 | qrs = 0.0_wp |
---|
| 738 | nrs = 0.0_wp |
---|
[1053] | 739 | ENDIF |
---|
| 740 | ENDIF |
---|
[1] | 741 | |
---|
| 742 | ! |
---|
| 743 | !-- inside buildings set velocities back to zero |
---|
| 744 | IF ( topography /= 'flat' ) THEN |
---|
| 745 | DO i = nxl-1, nxr+1 |
---|
| 746 | DO j = nys-1, nyn+1 |
---|
[1340] | 747 | u(nzb:nzb_u_inner(j,i),j,i) = 0.0_wp |
---|
| 748 | v(nzb:nzb_v_inner(j,i),j,i) = 0.0_wp |
---|
[1] | 749 | ENDDO |
---|
| 750 | ENDDO |
---|
[667] | 751 | |
---|
[1] | 752 | ! |
---|
| 753 | !-- WARNING: The extra boundary conditions set after running the |
---|
| 754 | !-- ------- 1D model impose an error on the divergence one layer |
---|
| 755 | !-- below the topography; need to correct later |
---|
| 756 | !-- ATTENTION: Provisional correction for Piacsek & Williams |
---|
| 757 | !-- --------- advection scheme: keep u and v zero one layer below |
---|
| 758 | !-- the topography. |
---|
[667] | 759 | IF ( ibc_uv_b == 1 ) THEN |
---|
| 760 | ! |
---|
[1] | 761 | !-- Neumann condition |
---|
| 762 | DO i = nxl-1, nxr+1 |
---|
| 763 | DO j = nys-1, nyn+1 |
---|
| 764 | IF ( nzb_u_inner(j,i) == 0 ) u(0,j,i) = u(1,j,i) |
---|
| 765 | IF ( nzb_v_inner(j,i) == 0 ) v(0,j,i) = v(1,j,i) |
---|
| 766 | ENDDO |
---|
| 767 | ENDDO |
---|
| 768 | |
---|
| 769 | ENDIF |
---|
| 770 | |
---|
| 771 | ENDIF |
---|
| 772 | |
---|
[1402] | 773 | CALL location_message( 'finished', .TRUE. ) |
---|
[1384] | 774 | |
---|
[1] | 775 | ELSEIF ( INDEX(initializing_actions, 'set_constant_profiles') /= 0 ) & |
---|
| 776 | THEN |
---|
[1241] | 777 | |
---|
[1402] | 778 | CALL location_message( 'initializing with constant profiles', .FALSE. ) |
---|
[1] | 779 | ! |
---|
[1241] | 780 | !-- Overwrite initial profiles in case of nudging |
---|
| 781 | IF ( nudging ) THEN |
---|
| 782 | pt_init = ptnudge(:,1) |
---|
| 783 | u_init = unudge(:,1) |
---|
| 784 | v_init = vnudge(:,1) |
---|
| 785 | IF ( humidity .OR. passive_scalar ) THEN |
---|
| 786 | q_init = qnudge(:,1) |
---|
| 787 | ENDIF |
---|
| 788 | |
---|
| 789 | WRITE( message_string, * ) 'Initial profiles of u, v and ', & |
---|
| 790 | 'scalars from NUDGING_DATA are used.' |
---|
| 791 | CALL message( 'init_3d_model', 'PA0370', 0, 0, 0, 6, 0 ) |
---|
| 792 | ENDIF |
---|
| 793 | |
---|
| 794 | ! |
---|
[1] | 795 | !-- Use constructed initial profiles (velocity constant with height, |
---|
| 796 | !-- temperature profile with constant gradient) |
---|
[667] | 797 | DO i = nxlg, nxrg |
---|
| 798 | DO j = nysg, nyng |
---|
[1] | 799 | pt(:,j,i) = pt_init |
---|
| 800 | u(:,j,i) = u_init |
---|
| 801 | v(:,j,i) = v_init |
---|
| 802 | ENDDO |
---|
| 803 | ENDDO |
---|
[75] | 804 | |
---|
[1] | 805 | ! |
---|
[292] | 806 | !-- Set initial horizontal velocities at the lowest computational grid |
---|
| 807 | !-- levels to zero in order to avoid too small time steps caused by the |
---|
| 808 | !-- diffusion limit in the initial phase of a run (at k=1, dz/2 occurs |
---|
| 809 | !-- in the limiting formula!). The original values are stored to be later |
---|
| 810 | !-- used for volume flow control. |
---|
[1507] | 811 | IF ( ibc_uv_b /= 1 ) THEN |
---|
[1406] | 812 | DO i = nxlg, nxrg |
---|
| 813 | DO j = nysg, nyng |
---|
| 814 | u(nzb:nzb_u_inner(j,i)+1,j,i) = 0.0_wp |
---|
| 815 | v(nzb:nzb_v_inner(j,i)+1,j,i) = 0.0_wp |
---|
| 816 | ENDDO |
---|
[1] | 817 | ENDDO |
---|
[1406] | 818 | ENDIF |
---|
[1] | 819 | |
---|
[75] | 820 | IF ( humidity .OR. passive_scalar ) THEN |
---|
[667] | 821 | DO i = nxlg, nxrg |
---|
| 822 | DO j = nysg, nyng |
---|
[1] | 823 | q(:,j,i) = q_init |
---|
| 824 | ENDDO |
---|
| 825 | ENDDO |
---|
[1115] | 826 | IF ( cloud_physics .AND. icloud_scheme == 0 ) THEN |
---|
| 827 | ! |
---|
| 828 | !-- Initialze nc_1d with default value |
---|
| 829 | nc_1d(:) = nc_const |
---|
| 830 | |
---|
| 831 | IF ( precipitation ) THEN |
---|
| 832 | DO i = nxlg, nxrg |
---|
| 833 | DO j = nysg, nyng |
---|
[1340] | 834 | qr(:,j,i) = 0.0_wp |
---|
| 835 | nr(:,j,i) = 0.0_wp |
---|
[1115] | 836 | ENDDO |
---|
[1053] | 837 | ENDDO |
---|
[1115] | 838 | ENDIF |
---|
| 839 | |
---|
[1053] | 840 | ENDIF |
---|
[1] | 841 | ENDIF |
---|
| 842 | |
---|
[94] | 843 | IF ( ocean ) THEN |
---|
[667] | 844 | DO i = nxlg, nxrg |
---|
| 845 | DO j = nysg, nyng |
---|
[94] | 846 | sa(:,j,i) = sa_init |
---|
| 847 | ENDDO |
---|
| 848 | ENDDO |
---|
| 849 | ENDIF |
---|
[1] | 850 | |
---|
| 851 | IF ( constant_diffusion ) THEN |
---|
| 852 | km = km_constant |
---|
| 853 | kh = km / prandtl_number |
---|
[1340] | 854 | e = 0.0_wp |
---|
| 855 | ELSEIF ( e_init > 0.0_wp ) THEN |
---|
[108] | 856 | DO k = nzb+1, nzt |
---|
[1340] | 857 | km(k,:,:) = 0.1_wp * l_grid(k) * SQRT( e_init ) |
---|
[108] | 858 | ENDDO |
---|
| 859 | km(nzb,:,:) = km(nzb+1,:,:) |
---|
| 860 | km(nzt+1,:,:) = km(nzt,:,:) |
---|
| 861 | kh = km / prandtl_number |
---|
| 862 | e = e_init |
---|
[1] | 863 | ELSE |
---|
[108] | 864 | IF ( .NOT. ocean ) THEN |
---|
[1340] | 865 | kh = 0.01_wp ! there must exist an initial diffusion, because |
---|
| 866 | km = 0.01_wp ! otherwise no TKE would be produced by the |
---|
[108] | 867 | ! production terms, as long as not yet |
---|
| 868 | ! e = (u*/cm)**2 at k=nzb+1 |
---|
| 869 | ELSE |
---|
[1340] | 870 | kh = 0.00001_wp |
---|
| 871 | km = 0.00001_wp |
---|
[108] | 872 | ENDIF |
---|
[1340] | 873 | e = 0.0_wp |
---|
[1] | 874 | ENDIF |
---|
[1340] | 875 | rif = 0.0_wp |
---|
| 876 | ts = 0.0_wp |
---|
| 877 | us = 0.0_wp |
---|
| 878 | usws = 0.0_wp |
---|
[102] | 879 | uswst = top_momentumflux_u |
---|
[1340] | 880 | vsws = 0.0_wp |
---|
[102] | 881 | vswst = top_momentumflux_v |
---|
[1340] | 882 | IF ( humidity .OR. passive_scalar ) qs = 0.0_wp |
---|
[1] | 883 | |
---|
| 884 | ! |
---|
| 885 | !-- Compute initial temperature field and other constants used in case |
---|
| 886 | !-- of a sloping surface |
---|
| 887 | IF ( sloping_surface ) CALL init_slope |
---|
| 888 | |
---|
[1402] | 889 | CALL location_message( 'finished', .TRUE. ) |
---|
[1384] | 890 | |
---|
[46] | 891 | ELSEIF ( INDEX(initializing_actions, 'by_user') /= 0 ) & |
---|
| 892 | THEN |
---|
[1384] | 893 | |
---|
[1402] | 894 | CALL location_message( 'initializing by user', .FALSE. ) |
---|
[46] | 895 | ! |
---|
| 896 | !-- Initialization will completely be done by the user |
---|
| 897 | CALL user_init_3d_model |
---|
| 898 | |
---|
[1402] | 899 | CALL location_message( 'finished', .TRUE. ) |
---|
[1384] | 900 | |
---|
[1] | 901 | ENDIF |
---|
[1384] | 902 | |
---|
[1402] | 903 | CALL location_message( 'initializing statistics, boundary conditions, etc.', & |
---|
| 904 | .FALSE. ) |
---|
[1384] | 905 | |
---|
[667] | 906 | ! |
---|
| 907 | !-- Bottom boundary |
---|
| 908 | IF ( ibc_uv_b == 0 .OR. ibc_uv_b == 2 ) THEN |
---|
[1340] | 909 | u(nzb,:,:) = 0.0_wp |
---|
| 910 | v(nzb,:,:) = 0.0_wp |
---|
[667] | 911 | ENDIF |
---|
[1] | 912 | |
---|
| 913 | ! |
---|
[151] | 914 | !-- Apply channel flow boundary condition |
---|
[132] | 915 | IF ( TRIM( bc_uv_t ) == 'dirichlet_0' ) THEN |
---|
[1340] | 916 | u(nzt+1,:,:) = 0.0_wp |
---|
| 917 | v(nzt+1,:,:) = 0.0_wp |
---|
[132] | 918 | ENDIF |
---|
| 919 | |
---|
| 920 | ! |
---|
[1] | 921 | !-- Calculate virtual potential temperature |
---|
[1340] | 922 | IF ( humidity ) vpt = pt * ( 1.0_wp + 0.61_wp * q ) |
---|
[1] | 923 | |
---|
| 924 | ! |
---|
| 925 | !-- Store initial profiles for output purposes etc. |
---|
| 926 | hom(:,1,5,:) = SPREAD( u(:,nys,nxl), 2, statistic_regions+1 ) |
---|
| 927 | hom(:,1,6,:) = SPREAD( v(:,nys,nxl), 2, statistic_regions+1 ) |
---|
[667] | 928 | IF ( ibc_uv_b == 0 .OR. ibc_uv_b == 2) THEN |
---|
[1340] | 929 | hom(nzb,1,5,:) = 0.0_wp |
---|
| 930 | hom(nzb,1,6,:) = 0.0_wp |
---|
[1] | 931 | ENDIF |
---|
| 932 | hom(:,1,7,:) = SPREAD( pt(:,nys,nxl), 2, statistic_regions+1 ) |
---|
| 933 | hom(:,1,23,:) = SPREAD( km(:,nys,nxl), 2, statistic_regions+1 ) |
---|
| 934 | hom(:,1,24,:) = SPREAD( kh(:,nys,nxl), 2, statistic_regions+1 ) |
---|
| 935 | |
---|
[97] | 936 | IF ( ocean ) THEN |
---|
| 937 | ! |
---|
| 938 | !-- Store initial salinity profile |
---|
| 939 | hom(:,1,26,:) = SPREAD( sa(:,nys,nxl), 2, statistic_regions+1 ) |
---|
| 940 | ENDIF |
---|
[1] | 941 | |
---|
[75] | 942 | IF ( humidity ) THEN |
---|
[1] | 943 | ! |
---|
| 944 | !-- Store initial profile of total water content, virtual potential |
---|
| 945 | !-- temperature |
---|
| 946 | hom(:,1,26,:) = SPREAD( q(:,nys,nxl), 2, statistic_regions+1 ) |
---|
| 947 | hom(:,1,29,:) = SPREAD( vpt(:,nys,nxl), 2, statistic_regions+1 ) |
---|
| 948 | IF ( cloud_physics .OR. cloud_droplets ) THEN |
---|
| 949 | ! |
---|
| 950 | !-- Store initial profile of specific humidity and potential |
---|
| 951 | !-- temperature |
---|
| 952 | hom(:,1,27,:) = SPREAD( q(:,nys,nxl), 2, statistic_regions+1 ) |
---|
| 953 | hom(:,1,28,:) = SPREAD( pt(:,nys,nxl), 2, statistic_regions+1 ) |
---|
| 954 | ENDIF |
---|
| 955 | ENDIF |
---|
| 956 | |
---|
| 957 | IF ( passive_scalar ) THEN |
---|
| 958 | ! |
---|
| 959 | !-- Store initial scalar profile |
---|
| 960 | hom(:,1,26,:) = SPREAD( q(:,nys,nxl), 2, statistic_regions+1 ) |
---|
| 961 | ENDIF |
---|
| 962 | |
---|
| 963 | ! |
---|
[1400] | 964 | !-- Initialize the random number generators (from numerical recipes) |
---|
| 965 | CALL random_function_ini |
---|
[1429] | 966 | |
---|
[1400] | 967 | IF ( random_generator == 'random-parallel' ) THEN |
---|
[1429] | 968 | !-- Asigning an ID to every vertical gridpoint column |
---|
| 969 | !-- dependig on the ensemble run number. |
---|
| 970 | random_dummy=1 |
---|
[1400] | 971 | DO j=0,ny |
---|
| 972 | DO i=0,nx |
---|
[1429] | 973 | id_random_array(j,i) = random_dummy + 1E6 * ( ensemble_member_nr - 1000 ) |
---|
| 974 | random_dummy = random_dummy + 1 |
---|
[1400] | 975 | END DO |
---|
| 976 | ENDDO |
---|
[1429] | 977 | !-- Initializing with random_seed_parallel for every vertical |
---|
| 978 | !-- gridpoint column. |
---|
| 979 | random_dummy=0 |
---|
[1400] | 980 | DO j = nysg, nyng |
---|
| 981 | DO i = nxlg, nxrg |
---|
| 982 | CALL random_seed_parallel (random_sequence=id_random_array(j, i)) |
---|
| 983 | CALL random_number_parallel (random_dummy) |
---|
| 984 | CALL random_seed_parallel (get=seq_random_array(:, j, i)) |
---|
| 985 | END DO |
---|
| 986 | ENDDO |
---|
| 987 | ENDIF |
---|
| 988 | |
---|
| 989 | ! |
---|
[19] | 990 | !-- Initialize fluxes at bottom surface |
---|
[1] | 991 | IF ( use_surface_fluxes ) THEN |
---|
| 992 | |
---|
| 993 | IF ( constant_heatflux ) THEN |
---|
| 994 | ! |
---|
| 995 | !-- Heat flux is prescribed |
---|
| 996 | IF ( random_heatflux ) THEN |
---|
| 997 | CALL disturb_heatflux |
---|
| 998 | ELSE |
---|
| 999 | shf = surface_heatflux |
---|
| 1000 | ! |
---|
[1241] | 1001 | !-- Initialize shf with data from external file LSF_DATA |
---|
| 1002 | IF ( large_scale_forcing .AND. lsf_surf ) THEN |
---|
| 1003 | CALL ls_forcing_surf ( simulated_time ) |
---|
| 1004 | ENDIF |
---|
| 1005 | |
---|
| 1006 | ! |
---|
[1] | 1007 | !-- Over topography surface_heatflux is replaced by wall_heatflux(0) |
---|
| 1008 | IF ( TRIM( topography ) /= 'flat' ) THEN |
---|
[667] | 1009 | DO i = nxlg, nxrg |
---|
| 1010 | DO j = nysg, nyng |
---|
[1] | 1011 | IF ( nzb_s_inner(j,i) /= 0 ) THEN |
---|
| 1012 | shf(j,i) = wall_heatflux(0) |
---|
| 1013 | ENDIF |
---|
| 1014 | ENDDO |
---|
| 1015 | ENDDO |
---|
| 1016 | ENDIF |
---|
| 1017 | ENDIF |
---|
| 1018 | ENDIF |
---|
| 1019 | |
---|
| 1020 | ! |
---|
| 1021 | !-- Determine the near-surface water flux |
---|
[75] | 1022 | IF ( humidity .OR. passive_scalar ) THEN |
---|
[1115] | 1023 | IF ( cloud_physics .AND. icloud_scheme == 0 .AND. & |
---|
| 1024 | precipitation ) THEN |
---|
[1340] | 1025 | qrsws = 0.0_wp |
---|
| 1026 | nrsws = 0.0_wp |
---|
[1053] | 1027 | ENDIF |
---|
[1] | 1028 | IF ( constant_waterflux ) THEN |
---|
| 1029 | qsws = surface_waterflux |
---|
[407] | 1030 | ! |
---|
| 1031 | !-- Over topography surface_waterflux is replaced by |
---|
| 1032 | !-- wall_humidityflux(0) |
---|
| 1033 | IF ( TRIM( topography ) /= 'flat' ) THEN |
---|
| 1034 | wall_qflux = wall_humidityflux |
---|
[667] | 1035 | DO i = nxlg, nxrg |
---|
| 1036 | DO j = nysg, nyng |
---|
[407] | 1037 | IF ( nzb_s_inner(j,i) /= 0 ) THEN |
---|
| 1038 | qsws(j,i) = wall_qflux(0) |
---|
| 1039 | ENDIF |
---|
| 1040 | ENDDO |
---|
| 1041 | ENDDO |
---|
| 1042 | ENDIF |
---|
[1] | 1043 | ENDIF |
---|
| 1044 | ENDIF |
---|
| 1045 | |
---|
| 1046 | ENDIF |
---|
| 1047 | |
---|
| 1048 | ! |
---|
[19] | 1049 | !-- Initialize fluxes at top surface |
---|
[94] | 1050 | !-- Currently, only the heatflux and salinity flux can be prescribed. |
---|
| 1051 | !-- The latent flux is zero in this case! |
---|
[19] | 1052 | IF ( use_top_fluxes ) THEN |
---|
| 1053 | |
---|
| 1054 | IF ( constant_top_heatflux ) THEN |
---|
| 1055 | ! |
---|
| 1056 | !-- Heat flux is prescribed |
---|
| 1057 | tswst = top_heatflux |
---|
| 1058 | |
---|
[1053] | 1059 | IF ( humidity .OR. passive_scalar ) THEN |
---|
[1340] | 1060 | qswst = 0.0_wp |
---|
[1115] | 1061 | IF ( cloud_physics .AND. icloud_scheme == 0 .AND. & |
---|
| 1062 | precipitation ) THEN |
---|
[1340] | 1063 | nrswst = 0.0_wp |
---|
| 1064 | qrswst = 0.0_wp |
---|
[1053] | 1065 | ENDIF |
---|
| 1066 | ENDIF |
---|
[94] | 1067 | |
---|
| 1068 | IF ( ocean ) THEN |
---|
[95] | 1069 | saswsb = bottom_salinityflux |
---|
[94] | 1070 | saswst = top_salinityflux |
---|
| 1071 | ENDIF |
---|
[102] | 1072 | ENDIF |
---|
[19] | 1073 | |
---|
[102] | 1074 | ! |
---|
| 1075 | !-- Initialization in case of a coupled model run |
---|
| 1076 | IF ( coupling_mode == 'ocean_to_atmosphere' ) THEN |
---|
[1340] | 1077 | tswst = 0.0_wp |
---|
[102] | 1078 | ENDIF |
---|
| 1079 | |
---|
[19] | 1080 | ENDIF |
---|
| 1081 | |
---|
| 1082 | ! |
---|
[1] | 1083 | !-- Initialize Prandtl layer quantities |
---|
| 1084 | IF ( prandtl_layer ) THEN |
---|
| 1085 | |
---|
| 1086 | z0 = roughness_length |
---|
[978] | 1087 | z0h = z0h_factor * z0 |
---|
[1] | 1088 | |
---|
| 1089 | IF ( .NOT. constant_heatflux ) THEN |
---|
| 1090 | ! |
---|
| 1091 | !-- Surface temperature is prescribed. Here the heat flux cannot be |
---|
| 1092 | !-- simply estimated, because therefore rif, u* and theta* would have |
---|
| 1093 | !-- to be computed by iteration. This is why the heat flux is assumed |
---|
| 1094 | !-- to be zero before the first time step. It approaches its correct |
---|
| 1095 | !-- value in the course of the first few time steps. |
---|
[1340] | 1096 | shf = 0.0_wp |
---|
[1] | 1097 | ENDIF |
---|
| 1098 | |
---|
[75] | 1099 | IF ( humidity .OR. passive_scalar ) THEN |
---|
[1340] | 1100 | IF ( .NOT. constant_waterflux ) qsws = 0.0_wp |
---|
[1115] | 1101 | IF ( cloud_physics .AND. icloud_scheme == 0 .AND. & |
---|
| 1102 | precipitation ) THEN |
---|
[1340] | 1103 | qrsws = 0.0_wp |
---|
| 1104 | nrsws = 0.0_wp |
---|
[1053] | 1105 | ENDIF |
---|
[1] | 1106 | ENDIF |
---|
| 1107 | |
---|
| 1108 | ENDIF |
---|
| 1109 | |
---|
[1179] | 1110 | ! |
---|
| 1111 | !-- Set the reference state to be used in the buoyancy terms (for ocean runs |
---|
| 1112 | !-- the reference state will be set (overwritten) in init_ocean) |
---|
| 1113 | IF ( use_single_reference_value ) THEN |
---|
| 1114 | IF ( .NOT. humidity ) THEN |
---|
| 1115 | ref_state(:) = pt_reference |
---|
| 1116 | ELSE |
---|
| 1117 | ref_state(:) = vpt_reference |
---|
| 1118 | ENDIF |
---|
| 1119 | ELSE |
---|
| 1120 | IF ( .NOT. humidity ) THEN |
---|
| 1121 | ref_state(:) = pt_init(:) |
---|
| 1122 | ELSE |
---|
| 1123 | ref_state(:) = vpt(:,nys,nxl) |
---|
| 1124 | ENDIF |
---|
| 1125 | ENDIF |
---|
[152] | 1126 | |
---|
| 1127 | ! |
---|
[707] | 1128 | !-- For the moment, vertical velocity is zero |
---|
[1340] | 1129 | w = 0.0_wp |
---|
[1] | 1130 | |
---|
| 1131 | ! |
---|
| 1132 | !-- Initialize array sums (must be defined in first call of pres) |
---|
[1340] | 1133 | sums = 0.0_wp |
---|
[1] | 1134 | |
---|
| 1135 | ! |
---|
[707] | 1136 | !-- In case of iterative solvers, p must get an initial value |
---|
[1340] | 1137 | IF ( psolver == 'multigrid' .OR. psolver == 'sor' ) p = 0.0_wp |
---|
[707] | 1138 | |
---|
| 1139 | ! |
---|
[72] | 1140 | !-- Treating cloud physics, liquid water content and precipitation amount |
---|
| 1141 | !-- are zero at beginning of the simulation |
---|
| 1142 | IF ( cloud_physics ) THEN |
---|
[1340] | 1143 | ql = 0.0_wp |
---|
| 1144 | IF ( precipitation ) precipitation_amount = 0.0_wp |
---|
[1115] | 1145 | IF ( icloud_scheme == 0 ) THEN |
---|
[1340] | 1146 | qc = 0.0_wp |
---|
[1115] | 1147 | nc_1d = nc_const |
---|
| 1148 | ENDIF |
---|
[72] | 1149 | ENDIF |
---|
[673] | 1150 | ! |
---|
[1] | 1151 | !-- Impose vortex with vertical axis on the initial velocity profile |
---|
| 1152 | IF ( INDEX( initializing_actions, 'initialize_vortex' ) /= 0 ) THEN |
---|
| 1153 | CALL init_rankine |
---|
| 1154 | ENDIF |
---|
| 1155 | |
---|
| 1156 | ! |
---|
| 1157 | !-- Impose temperature anomaly (advection test only) |
---|
| 1158 | IF ( INDEX( initializing_actions, 'initialize_ptanom' ) /= 0 ) THEN |
---|
| 1159 | CALL init_pt_anomaly |
---|
| 1160 | ENDIF |
---|
| 1161 | |
---|
| 1162 | ! |
---|
| 1163 | !-- If required, change the surface temperature at the start of the 3D run |
---|
[1340] | 1164 | IF ( pt_surface_initial_change /= 0.0_wp ) THEN |
---|
[1] | 1165 | pt(nzb,:,:) = pt(nzb,:,:) + pt_surface_initial_change |
---|
| 1166 | ENDIF |
---|
| 1167 | |
---|
| 1168 | ! |
---|
| 1169 | !-- If required, change the surface humidity/scalar at the start of the 3D |
---|
| 1170 | !-- run |
---|
[75] | 1171 | IF ( ( humidity .OR. passive_scalar ) .AND. & |
---|
[1340] | 1172 | q_surface_initial_change /= 0.0_wp ) THEN |
---|
[1] | 1173 | q(nzb,:,:) = q(nzb,:,:) + q_surface_initial_change |
---|
| 1174 | ENDIF |
---|
| 1175 | |
---|
| 1176 | ! |
---|
| 1177 | !-- Initialize old and new time levels. |
---|
[1340] | 1178 | te_m = 0.0_wp; tpt_m = 0.0_wp; tu_m = 0.0_wp; tv_m = 0.0_wp; tw_m = 0.0_wp |
---|
[1] | 1179 | e_p = e; pt_p = pt; u_p = u; v_p = v; w_p = w |
---|
| 1180 | |
---|
[75] | 1181 | IF ( humidity .OR. passive_scalar ) THEN |
---|
[1340] | 1182 | tq_m = 0.0_wp |
---|
[1] | 1183 | q_p = q |
---|
[1115] | 1184 | IF ( cloud_physics .AND. icloud_scheme == 0 .AND. & |
---|
| 1185 | precipitation ) THEN |
---|
[1340] | 1186 | tqr_m = 0.0_wp |
---|
[1053] | 1187 | qr_p = qr |
---|
[1340] | 1188 | tnr_m = 0.0_wp |
---|
[1053] | 1189 | nr_p = nr |
---|
| 1190 | ENDIF |
---|
[1] | 1191 | ENDIF |
---|
| 1192 | |
---|
[94] | 1193 | IF ( ocean ) THEN |
---|
[1340] | 1194 | tsa_m = 0.0_wp |
---|
[94] | 1195 | sa_p = sa |
---|
| 1196 | ENDIF |
---|
[667] | 1197 | |
---|
[1402] | 1198 | CALL location_message( 'finished', .TRUE. ) |
---|
[94] | 1199 | |
---|
[147] | 1200 | ELSEIF ( TRIM( initializing_actions ) == 'read_restart_data' .OR. & |
---|
[667] | 1201 | TRIM( initializing_actions ) == 'cyclic_fill' ) & |
---|
[1] | 1202 | THEN |
---|
[1384] | 1203 | |
---|
[1402] | 1204 | CALL location_message( 'initializing in case of restart / cyclic_fill', & |
---|
| 1205 | .FALSE. ) |
---|
[1] | 1206 | ! |
---|
[767] | 1207 | !-- When reading data for cyclic fill of 3D prerun data files, read |
---|
| 1208 | !-- some of the global variables from the restart file which are required |
---|
| 1209 | !-- for initializing the inflow |
---|
[328] | 1210 | IF ( TRIM( initializing_actions ) == 'cyclic_fill' ) THEN |
---|
[559] | 1211 | |
---|
[759] | 1212 | DO i = 0, io_blocks-1 |
---|
| 1213 | IF ( i == io_group ) THEN |
---|
| 1214 | CALL read_parts_of_var_list |
---|
| 1215 | CALL close_file( 13 ) |
---|
| 1216 | ENDIF |
---|
| 1217 | #if defined( __parallel ) |
---|
| 1218 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 1219 | #endif |
---|
| 1220 | ENDDO |
---|
[328] | 1221 | |
---|
[767] | 1222 | ENDIF |
---|
| 1223 | |
---|
[151] | 1224 | ! |
---|
[767] | 1225 | !-- Read binary data from restart file |
---|
| 1226 | DO i = 0, io_blocks-1 |
---|
| 1227 | IF ( i == io_group ) THEN |
---|
| 1228 | CALL read_3d_binary |
---|
| 1229 | ENDIF |
---|
| 1230 | #if defined( __parallel ) |
---|
| 1231 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 1232 | #endif |
---|
| 1233 | ENDDO |
---|
| 1234 | |
---|
[328] | 1235 | ! |
---|
[767] | 1236 | !-- Initialization of the turbulence recycling method |
---|
| 1237 | IF ( TRIM( initializing_actions ) == 'cyclic_fill' .AND. & |
---|
| 1238 | turbulent_inflow ) THEN |
---|
| 1239 | ! |
---|
| 1240 | !-- First store the profiles to be used at the inflow. |
---|
| 1241 | !-- These profiles are the (temporally) and horizontally averaged vertical |
---|
| 1242 | !-- profiles from the prerun. Alternatively, prescribed profiles |
---|
| 1243 | !-- for u,v-components can be used. |
---|
| 1244 | ALLOCATE( mean_inflow_profiles(nzb:nzt+1,5) ) |
---|
[151] | 1245 | |
---|
[767] | 1246 | IF ( use_prescribed_profile_data ) THEN |
---|
| 1247 | mean_inflow_profiles(:,1) = u_init ! u |
---|
| 1248 | mean_inflow_profiles(:,2) = v_init ! v |
---|
| 1249 | ELSE |
---|
[328] | 1250 | mean_inflow_profiles(:,1) = hom_sum(:,1,0) ! u |
---|
| 1251 | mean_inflow_profiles(:,2) = hom_sum(:,2,0) ! v |
---|
[767] | 1252 | ENDIF |
---|
| 1253 | mean_inflow_profiles(:,4) = hom_sum(:,4,0) ! pt |
---|
| 1254 | mean_inflow_profiles(:,5) = hom_sum(:,8,0) ! e |
---|
[151] | 1255 | |
---|
| 1256 | ! |
---|
[767] | 1257 | !-- If necessary, adjust the horizontal flow field to the prescribed |
---|
| 1258 | !-- profiles |
---|
| 1259 | IF ( use_prescribed_profile_data ) THEN |
---|
| 1260 | DO i = nxlg, nxrg |
---|
[667] | 1261 | DO j = nysg, nyng |
---|
[328] | 1262 | DO k = nzb, nzt+1 |
---|
[767] | 1263 | u(k,j,i) = u(k,j,i) - hom_sum(k,1,0) + u_init(k) |
---|
| 1264 | v(k,j,i) = v(k,j,i) - hom_sum(k,2,0) + v_init(k) |
---|
[328] | 1265 | ENDDO |
---|
[151] | 1266 | ENDDO |
---|
[767] | 1267 | ENDDO |
---|
| 1268 | ENDIF |
---|
[151] | 1269 | |
---|
| 1270 | ! |
---|
[767] | 1271 | !-- Use these mean profiles at the inflow (provided that Dirichlet |
---|
| 1272 | !-- conditions are used) |
---|
| 1273 | IF ( inflow_l ) THEN |
---|
| 1274 | DO j = nysg, nyng |
---|
| 1275 | DO k = nzb, nzt+1 |
---|
| 1276 | u(k,j,nxlg:-1) = mean_inflow_profiles(k,1) |
---|
| 1277 | v(k,j,nxlg:-1) = mean_inflow_profiles(k,2) |
---|
[1340] | 1278 | w(k,j,nxlg:-1) = 0.0_wp |
---|
[767] | 1279 | pt(k,j,nxlg:-1) = mean_inflow_profiles(k,4) |
---|
| 1280 | e(k,j,nxlg:-1) = mean_inflow_profiles(k,5) |
---|
| 1281 | ENDDO |
---|
| 1282 | ENDDO |
---|
| 1283 | ENDIF |
---|
| 1284 | |
---|
[151] | 1285 | ! |
---|
[767] | 1286 | !-- Calculate the damping factors to be used at the inflow. For a |
---|
| 1287 | !-- turbulent inflow the turbulent fluctuations have to be limited |
---|
| 1288 | !-- vertically because otherwise the turbulent inflow layer will grow |
---|
| 1289 | !-- in time. |
---|
[1340] | 1290 | IF ( inflow_damping_height == 9999999.9_wp ) THEN |
---|
[767] | 1291 | ! |
---|
| 1292 | !-- Default: use the inversion height calculated by the prerun; if |
---|
| 1293 | !-- this is zero, inflow_damping_height must be explicitly |
---|
| 1294 | !-- specified. |
---|
[1340] | 1295 | IF ( hom_sum(nzb+6,pr_palm,0) /= 0.0_wp ) THEN |
---|
[767] | 1296 | inflow_damping_height = hom_sum(nzb+6,pr_palm,0) |
---|
| 1297 | ELSE |
---|
| 1298 | WRITE( message_string, * ) 'inflow_damping_height must be ',& |
---|
| 1299 | 'explicitly specified because&the inversion height ', & |
---|
| 1300 | 'calculated by the prerun is zero.' |
---|
| 1301 | CALL message( 'init_3d_model', 'PA0318', 1, 2, 0, 6, 0 ) |
---|
[292] | 1302 | ENDIF |
---|
[151] | 1303 | |
---|
[767] | 1304 | ENDIF |
---|
| 1305 | |
---|
[1340] | 1306 | IF ( inflow_damping_width == 9999999.9_wp ) THEN |
---|
[151] | 1307 | ! |
---|
[767] | 1308 | !-- Default for the transition range: one tenth of the undamped |
---|
| 1309 | !-- layer |
---|
[1340] | 1310 | inflow_damping_width = 0.1_wp * inflow_damping_height |
---|
[151] | 1311 | |
---|
[767] | 1312 | ENDIF |
---|
[151] | 1313 | |
---|
[767] | 1314 | ALLOCATE( inflow_damping_factor(nzb:nzt+1) ) |
---|
[151] | 1315 | |
---|
[767] | 1316 | DO k = nzb, nzt+1 |
---|
[151] | 1317 | |
---|
[767] | 1318 | IF ( zu(k) <= inflow_damping_height ) THEN |
---|
[1340] | 1319 | inflow_damping_factor(k) = 1.0_wp |
---|
[996] | 1320 | ELSEIF ( zu(k) <= ( inflow_damping_height + inflow_damping_width ) ) THEN |
---|
[1340] | 1321 | inflow_damping_factor(k) = 1.0_wp - & |
---|
[996] | 1322 | ( zu(k) - inflow_damping_height ) / & |
---|
| 1323 | inflow_damping_width |
---|
[767] | 1324 | ELSE |
---|
[1340] | 1325 | inflow_damping_factor(k) = 0.0_wp |
---|
[767] | 1326 | ENDIF |
---|
[151] | 1327 | |
---|
[767] | 1328 | ENDDO |
---|
[151] | 1329 | |
---|
[147] | 1330 | ENDIF |
---|
| 1331 | |
---|
[152] | 1332 | ! |
---|
[359] | 1333 | !-- Inside buildings set velocities and TKE back to zero |
---|
| 1334 | IF ( TRIM( initializing_actions ) == 'cyclic_fill' .AND. & |
---|
| 1335 | topography /= 'flat' ) THEN |
---|
| 1336 | ! |
---|
| 1337 | !-- Inside buildings set velocities and TKE back to zero. |
---|
| 1338 | !-- Other scalars (pt, q, s, km, kh, p, sa, ...) are ignored at present, |
---|
| 1339 | !-- maybe revise later. |
---|
[1001] | 1340 | DO i = nxlg, nxrg |
---|
| 1341 | DO j = nysg, nyng |
---|
[1340] | 1342 | u (nzb:nzb_u_inner(j,i),j,i) = 0.0_wp |
---|
| 1343 | v (nzb:nzb_v_inner(j,i),j,i) = 0.0_wp |
---|
| 1344 | w (nzb:nzb_w_inner(j,i),j,i) = 0.0_wp |
---|
| 1345 | e (nzb:nzb_w_inner(j,i),j,i) = 0.0_wp |
---|
| 1346 | tu_m(nzb:nzb_u_inner(j,i),j,i) = 0.0_wp |
---|
| 1347 | tv_m(nzb:nzb_v_inner(j,i),j,i) = 0.0_wp |
---|
| 1348 | tw_m(nzb:nzb_w_inner(j,i),j,i) = 0.0_wp |
---|
| 1349 | te_m(nzb:nzb_w_inner(j,i),j,i) = 0.0_wp |
---|
| 1350 | tpt_m(nzb:nzb_w_inner(j,i),j,i) = 0.0_wp |
---|
[359] | 1351 | ENDDO |
---|
[1001] | 1352 | ENDDO |
---|
[359] | 1353 | |
---|
| 1354 | ENDIF |
---|
| 1355 | |
---|
| 1356 | ! |
---|
[1] | 1357 | !-- Calculate initial temperature field and other constants used in case |
---|
| 1358 | !-- of a sloping surface |
---|
| 1359 | IF ( sloping_surface ) CALL init_slope |
---|
| 1360 | |
---|
| 1361 | ! |
---|
| 1362 | !-- Initialize new time levels (only done in order to set boundary values |
---|
| 1363 | !-- including ghost points) |
---|
| 1364 | e_p = e; pt_p = pt; u_p = u; v_p = v; w_p = w |
---|
[1053] | 1365 | IF ( humidity .OR. passive_scalar ) THEN |
---|
| 1366 | q_p = q |
---|
[1115] | 1367 | IF ( cloud_physics .AND. icloud_scheme == 0 .AND. & |
---|
| 1368 | precipitation ) THEN |
---|
[1053] | 1369 | qr_p = qr |
---|
| 1370 | nr_p = nr |
---|
| 1371 | ENDIF |
---|
| 1372 | ENDIF |
---|
[94] | 1373 | IF ( ocean ) sa_p = sa |
---|
[1] | 1374 | |
---|
[181] | 1375 | ! |
---|
| 1376 | !-- Allthough tendency arrays are set in prognostic_equations, they have |
---|
| 1377 | !-- have to be predefined here because they are used (but multiplied with 0) |
---|
| 1378 | !-- there before they are set. |
---|
[1340] | 1379 | te_m = 0.0_wp; tpt_m = 0.0_wp; tu_m = 0.0_wp; tv_m = 0.0_wp; tw_m = 0.0_wp |
---|
[1053] | 1380 | IF ( humidity .OR. passive_scalar ) THEN |
---|
[1340] | 1381 | tq_m = 0.0_wp |
---|
[1115] | 1382 | IF ( cloud_physics .AND. icloud_scheme == 0 .AND. & |
---|
| 1383 | precipitation ) THEN |
---|
[1340] | 1384 | tqr_m = 0.0_wp |
---|
| 1385 | tnr_m = 0.0_wp |
---|
[1053] | 1386 | ENDIF |
---|
| 1387 | ENDIF |
---|
[1340] | 1388 | IF ( ocean ) tsa_m = 0.0_wp |
---|
[181] | 1389 | |
---|
[1402] | 1390 | CALL location_message( 'finished', .TRUE. ) |
---|
[1384] | 1391 | |
---|
[1] | 1392 | ELSE |
---|
| 1393 | ! |
---|
| 1394 | !-- Actually this part of the programm should not be reached |
---|
[254] | 1395 | message_string = 'unknown initializing problem' |
---|
| 1396 | CALL message( 'init_3d_model', 'PA0193', 1, 2, 0, 6, 0 ) |
---|
[1] | 1397 | ENDIF |
---|
| 1398 | |
---|
[151] | 1399 | |
---|
| 1400 | IF ( TRIM( initializing_actions ) /= 'read_restart_data' ) THEN |
---|
[1] | 1401 | ! |
---|
[151] | 1402 | !-- Initialize old timelevels needed for radiation boundary conditions |
---|
| 1403 | IF ( outflow_l ) THEN |
---|
| 1404 | u_m_l(:,:,:) = u(:,:,1:2) |
---|
| 1405 | v_m_l(:,:,:) = v(:,:,0:1) |
---|
| 1406 | w_m_l(:,:,:) = w(:,:,0:1) |
---|
| 1407 | ENDIF |
---|
| 1408 | IF ( outflow_r ) THEN |
---|
| 1409 | u_m_r(:,:,:) = u(:,:,nx-1:nx) |
---|
| 1410 | v_m_r(:,:,:) = v(:,:,nx-1:nx) |
---|
| 1411 | w_m_r(:,:,:) = w(:,:,nx-1:nx) |
---|
| 1412 | ENDIF |
---|
| 1413 | IF ( outflow_s ) THEN |
---|
| 1414 | u_m_s(:,:,:) = u(:,0:1,:) |
---|
| 1415 | v_m_s(:,:,:) = v(:,1:2,:) |
---|
| 1416 | w_m_s(:,:,:) = w(:,0:1,:) |
---|
| 1417 | ENDIF |
---|
| 1418 | IF ( outflow_n ) THEN |
---|
| 1419 | u_m_n(:,:,:) = u(:,ny-1:ny,:) |
---|
| 1420 | v_m_n(:,:,:) = v(:,ny-1:ny,:) |
---|
| 1421 | w_m_n(:,:,:) = w(:,ny-1:ny,:) |
---|
| 1422 | ENDIF |
---|
[667] | 1423 | |
---|
[151] | 1424 | ENDIF |
---|
[680] | 1425 | |
---|
[667] | 1426 | ! |
---|
| 1427 | !-- Calculate the initial volume flow at the right and north boundary |
---|
[709] | 1428 | IF ( conserve_volume_flow ) THEN |
---|
[151] | 1429 | |
---|
[767] | 1430 | IF ( use_prescribed_profile_data ) THEN |
---|
[667] | 1431 | |
---|
[1340] | 1432 | volume_flow_initial_l = 0.0_wp |
---|
| 1433 | volume_flow_area_l = 0.0_wp |
---|
[732] | 1434 | |
---|
[667] | 1435 | IF ( nxr == nx ) THEN |
---|
| 1436 | DO j = nys, nyn |
---|
[709] | 1437 | DO k = nzb_2d(j,nx)+1, nzt |
---|
[667] | 1438 | volume_flow_initial_l(1) = volume_flow_initial_l(1) + & |
---|
[767] | 1439 | u_init(k) * dzw(k) |
---|
| 1440 | volume_flow_area_l(1) = volume_flow_area_l(1) + dzw(k) |
---|
| 1441 | ENDDO |
---|
| 1442 | ENDDO |
---|
| 1443 | ENDIF |
---|
| 1444 | |
---|
| 1445 | IF ( nyn == ny ) THEN |
---|
| 1446 | DO i = nxl, nxr |
---|
| 1447 | DO k = nzb_2d(ny,i)+1, nzt |
---|
| 1448 | volume_flow_initial_l(2) = volume_flow_initial_l(2) + & |
---|
| 1449 | v_init(k) * dzw(k) |
---|
| 1450 | volume_flow_area_l(2) = volume_flow_area_l(2) + dzw(k) |
---|
| 1451 | ENDDO |
---|
| 1452 | ENDDO |
---|
| 1453 | ENDIF |
---|
| 1454 | |
---|
| 1455 | #if defined( __parallel ) |
---|
| 1456 | CALL MPI_ALLREDUCE( volume_flow_initial_l(1), volume_flow_initial(1),& |
---|
| 1457 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
| 1458 | CALL MPI_ALLREDUCE( volume_flow_area_l(1), volume_flow_area(1), & |
---|
| 1459 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
| 1460 | |
---|
| 1461 | #else |
---|
| 1462 | volume_flow_initial = volume_flow_initial_l |
---|
| 1463 | volume_flow_area = volume_flow_area_l |
---|
| 1464 | #endif |
---|
| 1465 | |
---|
| 1466 | ELSEIF ( TRIM( initializing_actions ) == 'cyclic_fill' ) THEN |
---|
| 1467 | |
---|
[1340] | 1468 | volume_flow_initial_l = 0.0_wp |
---|
| 1469 | volume_flow_area_l = 0.0_wp |
---|
[767] | 1470 | |
---|
| 1471 | IF ( nxr == nx ) THEN |
---|
| 1472 | DO j = nys, nyn |
---|
| 1473 | DO k = nzb_2d(j,nx)+1, nzt |
---|
| 1474 | volume_flow_initial_l(1) = volume_flow_initial_l(1) + & |
---|
[667] | 1475 | hom_sum(k,1,0) * dzw(k) |
---|
| 1476 | volume_flow_area_l(1) = volume_flow_area_l(1) + dzw(k) |
---|
| 1477 | ENDDO |
---|
| 1478 | ENDDO |
---|
| 1479 | ENDIF |
---|
| 1480 | |
---|
| 1481 | IF ( nyn == ny ) THEN |
---|
| 1482 | DO i = nxl, nxr |
---|
[709] | 1483 | DO k = nzb_2d(ny,i)+1, nzt |
---|
[667] | 1484 | volume_flow_initial_l(2) = volume_flow_initial_l(2) + & |
---|
[709] | 1485 | hom_sum(k,2,0) * dzw(k) |
---|
[667] | 1486 | volume_flow_area_l(2) = volume_flow_area_l(2) + dzw(k) |
---|
| 1487 | ENDDO |
---|
| 1488 | ENDDO |
---|
| 1489 | ENDIF |
---|
| 1490 | |
---|
[732] | 1491 | #if defined( __parallel ) |
---|
| 1492 | CALL MPI_ALLREDUCE( volume_flow_initial_l(1), volume_flow_initial(1),& |
---|
| 1493 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
| 1494 | CALL MPI_ALLREDUCE( volume_flow_area_l(1), volume_flow_area(1), & |
---|
| 1495 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
| 1496 | |
---|
| 1497 | #else |
---|
| 1498 | volume_flow_initial = volume_flow_initial_l |
---|
| 1499 | volume_flow_area = volume_flow_area_l |
---|
| 1500 | #endif |
---|
| 1501 | |
---|
[667] | 1502 | ELSEIF ( TRIM( initializing_actions ) /= 'read_restart_data' ) THEN |
---|
| 1503 | |
---|
[1340] | 1504 | volume_flow_initial_l = 0.0_wp |
---|
| 1505 | volume_flow_area_l = 0.0_wp |
---|
[732] | 1506 | |
---|
[667] | 1507 | IF ( nxr == nx ) THEN |
---|
| 1508 | DO j = nys, nyn |
---|
[709] | 1509 | DO k = nzb_2d(j,nx)+1, nzt |
---|
[667] | 1510 | volume_flow_initial_l(1) = volume_flow_initial_l(1) + & |
---|
[709] | 1511 | u(k,j,nx) * dzw(k) |
---|
[667] | 1512 | volume_flow_area_l(1) = volume_flow_area_l(1) + dzw(k) |
---|
| 1513 | ENDDO |
---|
| 1514 | ENDDO |
---|
| 1515 | ENDIF |
---|
| 1516 | |
---|
| 1517 | IF ( nyn == ny ) THEN |
---|
| 1518 | DO i = nxl, nxr |
---|
[709] | 1519 | DO k = nzb_2d(ny,i)+1, nzt |
---|
[667] | 1520 | volume_flow_initial_l(2) = volume_flow_initial_l(2) + & |
---|
| 1521 | v(k,ny,i) * dzw(k) |
---|
| 1522 | volume_flow_area_l(2) = volume_flow_area_l(2) + dzw(k) |
---|
| 1523 | ENDDO |
---|
| 1524 | ENDDO |
---|
| 1525 | ENDIF |
---|
| 1526 | |
---|
| 1527 | #if defined( __parallel ) |
---|
[732] | 1528 | CALL MPI_ALLREDUCE( volume_flow_initial_l(1), volume_flow_initial(1),& |
---|
| 1529 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
| 1530 | CALL MPI_ALLREDUCE( volume_flow_area_l(1), volume_flow_area(1), & |
---|
| 1531 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
[667] | 1532 | |
---|
| 1533 | #else |
---|
[732] | 1534 | volume_flow_initial = volume_flow_initial_l |
---|
| 1535 | volume_flow_area = volume_flow_area_l |
---|
[667] | 1536 | #endif |
---|
| 1537 | |
---|
[732] | 1538 | ENDIF |
---|
| 1539 | |
---|
[151] | 1540 | ! |
---|
[709] | 1541 | !-- In case of 'bulk_velocity' mode, volume_flow_initial is calculated |
---|
| 1542 | !-- from u|v_bulk instead |
---|
[680] | 1543 | IF ( TRIM( conserve_volume_flow_mode ) == 'bulk_velocity' ) THEN |
---|
| 1544 | volume_flow_initial(1) = u_bulk * volume_flow_area(1) |
---|
| 1545 | volume_flow_initial(2) = v_bulk * volume_flow_area(2) |
---|
| 1546 | ENDIF |
---|
[667] | 1547 | |
---|
[680] | 1548 | ENDIF |
---|
| 1549 | |
---|
[787] | 1550 | ! |
---|
| 1551 | !-- Initialize quantities for special advections schemes |
---|
| 1552 | CALL init_advec |
---|
[680] | 1553 | |
---|
[667] | 1554 | ! |
---|
[680] | 1555 | !-- Impose random perturbation on the horizontal velocity field and then |
---|
| 1556 | !-- remove the divergences from the velocity field at the initial stage |
---|
| 1557 | IF ( create_disturbances .AND. & |
---|
| 1558 | TRIM( initializing_actions ) /= 'read_restart_data' .AND. & |
---|
| 1559 | TRIM( initializing_actions ) /= 'cyclic_fill' ) THEN |
---|
| 1560 | |
---|
[1402] | 1561 | CALL location_message( 'creating initial disturbances', .FALSE. ) |
---|
[680] | 1562 | CALL disturb_field( nzb_u_inner, tend, u ) |
---|
| 1563 | CALL disturb_field( nzb_v_inner, tend, v ) |
---|
[1402] | 1564 | CALL location_message( 'finished', .TRUE. ) |
---|
[1384] | 1565 | |
---|
[1402] | 1566 | CALL location_message( 'calling pressure solver', .FALSE. ) |
---|
[680] | 1567 | n_sor = nsor_ini |
---|
[1221] | 1568 | !$acc data copyin( d, ddzu, ddzw, nzb_s_inner, nzb_u_inner ) & |
---|
| 1569 | !$acc copyin( nzb_v_inner, nzb_w_inner, p, rflags_s_inner, tend ) & |
---|
| 1570 | !$acc copyin( weight_pres, weight_substep ) & |
---|
| 1571 | !$acc copy( tri, tric, u, v, w ) |
---|
[680] | 1572 | CALL pres |
---|
[1111] | 1573 | !$acc end data |
---|
[680] | 1574 | n_sor = nsor |
---|
[1402] | 1575 | CALL location_message( 'finished', .TRUE. ) |
---|
[1384] | 1576 | |
---|
[680] | 1577 | ENDIF |
---|
| 1578 | |
---|
| 1579 | ! |
---|
[1484] | 1580 | !-- If required, initialize quantities needed for the plant canopy model |
---|
| 1581 | IF ( plant_canopy ) CALL init_plant_canopy |
---|
[138] | 1582 | |
---|
| 1583 | ! |
---|
[1] | 1584 | !-- If required, initialize dvrp-software |
---|
[1340] | 1585 | IF ( dt_dvrp /= 9999999.9_wp ) CALL init_dvrp |
---|
[1] | 1586 | |
---|
[96] | 1587 | IF ( ocean ) THEN |
---|
[1] | 1588 | ! |
---|
[96] | 1589 | !-- Initialize quantities needed for the ocean model |
---|
| 1590 | CALL init_ocean |
---|
[388] | 1591 | |
---|
[96] | 1592 | ELSE |
---|
| 1593 | ! |
---|
| 1594 | !-- Initialize quantities for handling cloud physics |
---|
[849] | 1595 | !-- This routine must be called before lpm_init, because |
---|
[96] | 1596 | !-- otherwise, array pt_d_t, needed in data_output_dvrp (called by |
---|
[849] | 1597 | !-- lpm_init) is not defined. |
---|
[96] | 1598 | CALL init_cloud_physics |
---|
| 1599 | ENDIF |
---|
[1] | 1600 | |
---|
| 1601 | ! |
---|
| 1602 | !-- If required, initialize particles |
---|
[849] | 1603 | IF ( particle_advection ) CALL lpm_init |
---|
[1] | 1604 | |
---|
[1496] | 1605 | |
---|
[1] | 1606 | ! |
---|
[1496] | 1607 | !-- If required, initialize radiation model |
---|
| 1608 | IF ( radiation ) THEN |
---|
| 1609 | CALL init_radiation |
---|
| 1610 | ENDIF |
---|
| 1611 | |
---|
| 1612 | ! |
---|
| 1613 | !-- If required, initialize quantities needed for the LSM |
---|
| 1614 | IF ( land_surface ) THEN |
---|
| 1615 | CALL init_lsm |
---|
| 1616 | ENDIF |
---|
| 1617 | |
---|
| 1618 | ! |
---|
[673] | 1619 | !-- Initialize the ws-scheme. |
---|
| 1620 | IF ( ws_scheme_sca .OR. ws_scheme_mom ) CALL ws_init |
---|
[1] | 1621 | |
---|
| 1622 | ! |
---|
[709] | 1623 | !-- Setting weighting factors for calculation of perturbation pressure |
---|
| 1624 | !-- and turbulent quantities from the RK substeps |
---|
| 1625 | IF ( TRIM(timestep_scheme) == 'runge-kutta-3' ) THEN ! for RK3-method |
---|
| 1626 | |
---|
[1322] | 1627 | weight_substep(1) = 1._wp/6._wp |
---|
| 1628 | weight_substep(2) = 3._wp/10._wp |
---|
| 1629 | weight_substep(3) = 8._wp/15._wp |
---|
[709] | 1630 | |
---|
[1322] | 1631 | weight_pres(1) = 1._wp/3._wp |
---|
| 1632 | weight_pres(2) = 5._wp/12._wp |
---|
| 1633 | weight_pres(3) = 1._wp/4._wp |
---|
[709] | 1634 | |
---|
| 1635 | ELSEIF ( TRIM(timestep_scheme) == 'runge-kutta-2' ) THEN ! for RK2-method |
---|
| 1636 | |
---|
[1322] | 1637 | weight_substep(1) = 1._wp/2._wp |
---|
| 1638 | weight_substep(2) = 1._wp/2._wp |
---|
[673] | 1639 | |
---|
[1322] | 1640 | weight_pres(1) = 1._wp/2._wp |
---|
| 1641 | weight_pres(2) = 1._wp/2._wp |
---|
[709] | 1642 | |
---|
[1001] | 1643 | ELSE ! for Euler-method |
---|
[709] | 1644 | |
---|
[1340] | 1645 | weight_substep(1) = 1.0_wp |
---|
| 1646 | weight_pres(1) = 1.0_wp |
---|
[709] | 1647 | |
---|
[673] | 1648 | ENDIF |
---|
| 1649 | |
---|
| 1650 | ! |
---|
[1] | 1651 | !-- Initialize Rayleigh damping factors |
---|
[1340] | 1652 | rdf = 0.0_wp |
---|
| 1653 | rdf_sc = 0.0_wp |
---|
| 1654 | IF ( rayleigh_damping_factor /= 0.0_wp ) THEN |
---|
[108] | 1655 | IF ( .NOT. ocean ) THEN |
---|
| 1656 | DO k = nzb+1, nzt |
---|
| 1657 | IF ( zu(k) >= rayleigh_damping_height ) THEN |
---|
| 1658 | rdf(k) = rayleigh_damping_factor * & |
---|
[1340] | 1659 | ( SIN( pi * 0.5_wp * ( zu(k) - rayleigh_damping_height ) & |
---|
| 1660 | / ( zu(nzt) - rayleigh_damping_height ) )& |
---|
[1] | 1661 | )**2 |
---|
[108] | 1662 | ENDIF |
---|
| 1663 | ENDDO |
---|
| 1664 | ELSE |
---|
| 1665 | DO k = nzt, nzb+1, -1 |
---|
| 1666 | IF ( zu(k) <= rayleigh_damping_height ) THEN |
---|
| 1667 | rdf(k) = rayleigh_damping_factor * & |
---|
[1340] | 1668 | ( SIN( pi * 0.5_wp * ( rayleigh_damping_height - zu(k) ) & |
---|
| 1669 | / ( rayleigh_damping_height - zu(nzb+1)))& |
---|
[108] | 1670 | )**2 |
---|
| 1671 | ENDIF |
---|
| 1672 | ENDDO |
---|
| 1673 | ENDIF |
---|
[1] | 1674 | ENDIF |
---|
[785] | 1675 | IF ( scalar_rayleigh_damping ) rdf_sc = rdf |
---|
[1] | 1676 | |
---|
| 1677 | ! |
---|
[240] | 1678 | !-- Initialize the starting level and the vertical smoothing factor used for |
---|
| 1679 | !-- the external pressure gradient |
---|
[1340] | 1680 | dp_smooth_factor = 1.0_wp |
---|
[240] | 1681 | IF ( dp_external ) THEN |
---|
| 1682 | ! |
---|
| 1683 | !-- Set the starting level dp_level_ind_b only if it has not been set before |
---|
| 1684 | !-- (e.g. in init_grid). |
---|
| 1685 | IF ( dp_level_ind_b == 0 ) THEN |
---|
| 1686 | ind_array = MINLOC( ABS( dp_level_b - zu ) ) |
---|
| 1687 | dp_level_ind_b = ind_array(1) - 1 + nzb |
---|
| 1688 | ! MINLOC uses lower array bound 1 |
---|
| 1689 | ENDIF |
---|
| 1690 | IF ( dp_smooth ) THEN |
---|
[1340] | 1691 | dp_smooth_factor(:dp_level_ind_b) = 0.0_wp |
---|
[240] | 1692 | DO k = dp_level_ind_b+1, nzt |
---|
[1340] | 1693 | dp_smooth_factor(k) = 0.5_wp * ( 1.0_wp + SIN( pi * & |
---|
| 1694 | ( REAL( k - dp_level_ind_b, KIND=wp ) / & |
---|
| 1695 | REAL( nzt - dp_level_ind_b, KIND=wp ) - 0.5_wp ) ) ) |
---|
[240] | 1696 | ENDDO |
---|
| 1697 | ENDIF |
---|
| 1698 | ENDIF |
---|
| 1699 | |
---|
| 1700 | ! |
---|
[978] | 1701 | !-- Initialize damping zone for the potential temperature in case of |
---|
| 1702 | !-- non-cyclic lateral boundaries. The damping zone has the maximum value |
---|
| 1703 | !-- at the inflow boundary and decreases to zero at pt_damping_width. |
---|
[1340] | 1704 | ptdf_x = 0.0_wp |
---|
| 1705 | ptdf_y = 0.0_wp |
---|
[1159] | 1706 | IF ( bc_lr_dirrad ) THEN |
---|
[996] | 1707 | DO i = nxl, nxr |
---|
[978] | 1708 | IF ( ( i * dx ) < pt_damping_width ) THEN |
---|
[1340] | 1709 | ptdf_x(i) = pt_damping_factor * ( SIN( pi * 0.5_wp * & |
---|
| 1710 | REAL( pt_damping_width - i * dx, KIND=wp ) / ( & |
---|
| 1711 | REAL( pt_damping_width, KIND=wp ) ) ) )**2 |
---|
[73] | 1712 | ENDIF |
---|
| 1713 | ENDDO |
---|
[1159] | 1714 | ELSEIF ( bc_lr_raddir ) THEN |
---|
[996] | 1715 | DO i = nxl, nxr |
---|
[978] | 1716 | IF ( ( i * dx ) > ( nx * dx - pt_damping_width ) ) THEN |
---|
[1322] | 1717 | ptdf_x(i) = pt_damping_factor * & |
---|
[1340] | 1718 | SIN( pi * 0.5_wp * & |
---|
| 1719 | ( ( i - nx ) * dx + pt_damping_width ) / & |
---|
| 1720 | REAL( pt_damping_width, KIND=wp ) )**2 |
---|
[73] | 1721 | ENDIF |
---|
[978] | 1722 | ENDDO |
---|
[1159] | 1723 | ELSEIF ( bc_ns_dirrad ) THEN |
---|
[996] | 1724 | DO j = nys, nyn |
---|
[978] | 1725 | IF ( ( j * dy ) > ( ny * dy - pt_damping_width ) ) THEN |
---|
[1322] | 1726 | ptdf_y(j) = pt_damping_factor * & |
---|
[1340] | 1727 | SIN( pi * 0.5_wp * & |
---|
| 1728 | ( ( j - ny ) * dy + pt_damping_width ) / & |
---|
| 1729 | REAL( pt_damping_width, KIND=wp ) )**2 |
---|
[1] | 1730 | ENDIF |
---|
[978] | 1731 | ENDDO |
---|
[1159] | 1732 | ELSEIF ( bc_ns_raddir ) THEN |
---|
[996] | 1733 | DO j = nys, nyn |
---|
[978] | 1734 | IF ( ( j * dy ) < pt_damping_width ) THEN |
---|
[1322] | 1735 | ptdf_y(j) = pt_damping_factor * & |
---|
[1340] | 1736 | SIN( pi * 0.5_wp * & |
---|
| 1737 | ( pt_damping_width - j * dy ) / & |
---|
| 1738 | REAL( pt_damping_width, KIND=wp ) )**2 |
---|
[1] | 1739 | ENDIF |
---|
[73] | 1740 | ENDDO |
---|
[1] | 1741 | ENDIF |
---|
| 1742 | |
---|
| 1743 | ! |
---|
[709] | 1744 | !-- Initialize local summation arrays for routine flow_statistics. |
---|
| 1745 | !-- This is necessary because they may not yet have been initialized when they |
---|
| 1746 | !-- are called from flow_statistics (or - depending on the chosen model run - |
---|
| 1747 | !-- are never initialized) |
---|
[1340] | 1748 | sums_divnew_l = 0.0_wp |
---|
| 1749 | sums_divold_l = 0.0_wp |
---|
| 1750 | sums_l_l = 0.0_wp |
---|
| 1751 | sums_up_fraction_l = 0.0_wp |
---|
| 1752 | sums_wsts_bc_l = 0.0_wp |
---|
[1] | 1753 | |
---|
| 1754 | ! |
---|
| 1755 | !-- Pre-set masks for regional statistics. Default is the total model domain. |
---|
[1015] | 1756 | !-- Ghost points are excluded because counting values at the ghost boundaries |
---|
| 1757 | !-- would bias the statistics |
---|
[1340] | 1758 | rmask = 1.0_wp |
---|
| 1759 | rmask(:,nxlg:nxl-1,:) = 0.0_wp; rmask(:,nxr+1:nxrg,:) = 0.0_wp |
---|
| 1760 | rmask(nysg:nys-1,:,:) = 0.0_wp; rmask(nyn+1:nyng,:,:) = 0.0_wp |
---|
[1] | 1761 | |
---|
| 1762 | ! |
---|
[51] | 1763 | !-- User-defined initializing actions. Check afterwards, if maximum number |
---|
[709] | 1764 | !-- of allowed timeseries is exceeded |
---|
[1] | 1765 | CALL user_init |
---|
| 1766 | |
---|
[51] | 1767 | IF ( dots_num > dots_max ) THEN |
---|
[254] | 1768 | WRITE( message_string, * ) 'number of time series quantities exceeds', & |
---|
[274] | 1769 | ' its maximum of dots_max = ', dots_max, & |
---|
[254] | 1770 | ' &Please increase dots_max in modules.f90.' |
---|
| 1771 | CALL message( 'init_3d_model', 'PA0194', 1, 2, 0, 6, 0 ) |
---|
[51] | 1772 | ENDIF |
---|
| 1773 | |
---|
[1] | 1774 | ! |
---|
| 1775 | !-- Input binary data file is not needed anymore. This line must be placed |
---|
| 1776 | !-- after call of user_init! |
---|
| 1777 | CALL close_file( 13 ) |
---|
| 1778 | |
---|
| 1779 | ! |
---|
| 1780 | !-- Compute total sum of active mask grid points |
---|
| 1781 | !-- ngp_2dh: number of grid points of a horizontal cross section through the |
---|
| 1782 | !-- total domain |
---|
| 1783 | !-- ngp_3d: number of grid points of the total domain |
---|
[132] | 1784 | ngp_2dh_outer_l = 0 |
---|
| 1785 | ngp_2dh_outer = 0 |
---|
| 1786 | ngp_2dh_s_inner_l = 0 |
---|
| 1787 | ngp_2dh_s_inner = 0 |
---|
| 1788 | ngp_2dh_l = 0 |
---|
| 1789 | ngp_2dh = 0 |
---|
[1340] | 1790 | ngp_3d_inner_l = 0.0_wp |
---|
[132] | 1791 | ngp_3d_inner = 0 |
---|
| 1792 | ngp_3d = 0 |
---|
| 1793 | ngp_sums = ( nz + 2 ) * ( pr_palm + max_pr_user ) |
---|
[1] | 1794 | |
---|
| 1795 | DO sr = 0, statistic_regions |
---|
| 1796 | DO i = nxl, nxr |
---|
| 1797 | DO j = nys, nyn |
---|
[1340] | 1798 | IF ( rmask(j,i,sr) == 1.0_wp ) THEN |
---|
[1] | 1799 | ! |
---|
| 1800 | !-- All xy-grid points |
---|
| 1801 | ngp_2dh_l(sr) = ngp_2dh_l(sr) + 1 |
---|
| 1802 | ! |
---|
| 1803 | !-- xy-grid points above topography |
---|
| 1804 | DO k = nzb_s_outer(j,i), nz + 1 |
---|
| 1805 | ngp_2dh_outer_l(k,sr) = ngp_2dh_outer_l(k,sr) + 1 |
---|
| 1806 | ENDDO |
---|
[132] | 1807 | DO k = nzb_s_inner(j,i), nz + 1 |
---|
| 1808 | ngp_2dh_s_inner_l(k,sr) = ngp_2dh_s_inner_l(k,sr) + 1 |
---|
| 1809 | ENDDO |
---|
[1] | 1810 | ! |
---|
| 1811 | !-- All grid points of the total domain above topography |
---|
| 1812 | ngp_3d_inner_l(sr) = ngp_3d_inner_l(sr) + & |
---|
| 1813 | ( nz - nzb_s_inner(j,i) + 2 ) |
---|
| 1814 | ENDIF |
---|
| 1815 | ENDDO |
---|
| 1816 | ENDDO |
---|
| 1817 | ENDDO |
---|
| 1818 | |
---|
| 1819 | sr = statistic_regions + 1 |
---|
| 1820 | #if defined( __parallel ) |
---|
[622] | 1821 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
[485] | 1822 | CALL MPI_ALLREDUCE( ngp_2dh_l(0), ngp_2dh(0), sr, MPI_INTEGER, MPI_SUM, & |
---|
[1] | 1823 | comm2d, ierr ) |
---|
[622] | 1824 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
[485] | 1825 | CALL MPI_ALLREDUCE( ngp_2dh_outer_l(0,0), ngp_2dh_outer(0,0), (nz+2)*sr, & |
---|
[1] | 1826 | MPI_INTEGER, MPI_SUM, comm2d, ierr ) |
---|
[622] | 1827 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
[485] | 1828 | CALL MPI_ALLREDUCE( ngp_2dh_s_inner_l(0,0), ngp_2dh_s_inner(0,0), & |
---|
[132] | 1829 | (nz+2)*sr, MPI_INTEGER, MPI_SUM, comm2d, ierr ) |
---|
[622] | 1830 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
[485] | 1831 | CALL MPI_ALLREDUCE( ngp_3d_inner_l(0), ngp_3d_inner_tmp(0), sr, MPI_REAL, & |
---|
[1] | 1832 | MPI_SUM, comm2d, ierr ) |
---|
[485] | 1833 | ngp_3d_inner = INT( ngp_3d_inner_tmp, KIND = SELECTED_INT_KIND( 18 ) ) |
---|
[1] | 1834 | #else |
---|
[132] | 1835 | ngp_2dh = ngp_2dh_l |
---|
| 1836 | ngp_2dh_outer = ngp_2dh_outer_l |
---|
| 1837 | ngp_2dh_s_inner = ngp_2dh_s_inner_l |
---|
[485] | 1838 | ngp_3d_inner = INT( ngp_3d_inner_l, KIND = SELECTED_INT_KIND( 18 ) ) |
---|
[1] | 1839 | #endif |
---|
| 1840 | |
---|
[560] | 1841 | ngp_3d = INT ( ngp_2dh, KIND = SELECTED_INT_KIND( 18 ) ) * & |
---|
| 1842 | INT ( (nz + 2 ), KIND = SELECTED_INT_KIND( 18 ) ) |
---|
[1] | 1843 | |
---|
| 1844 | ! |
---|
| 1845 | !-- Set a lower limit of 1 in order to avoid zero divisions in flow_statistics, |
---|
| 1846 | !-- buoyancy, etc. A zero value will occur for cases where all grid points of |
---|
| 1847 | !-- the respective subdomain lie below the surface topography |
---|
[667] | 1848 | ngp_2dh_outer = MAX( 1, ngp_2dh_outer(:,:) ) |
---|
[631] | 1849 | ngp_3d_inner = MAX( INT(1, KIND = SELECTED_INT_KIND( 18 )), & |
---|
| 1850 | ngp_3d_inner(:) ) |
---|
[667] | 1851 | ngp_2dh_s_inner = MAX( 1, ngp_2dh_s_inner(:,:) ) |
---|
[1] | 1852 | |
---|
[485] | 1853 | DEALLOCATE( ngp_2dh_l, ngp_2dh_outer_l, ngp_3d_inner_l, ngp_3d_inner_tmp ) |
---|
[1] | 1854 | |
---|
[1402] | 1855 | CALL location_message( 'leaving init_3d_model', .TRUE. ) |
---|
[1] | 1856 | |
---|
| 1857 | END SUBROUTINE init_3d_model |
---|