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