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