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