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