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