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