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