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