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