[1682] | 1 | !> @file init_3d_model.f90 |
---|
[2000] | 2 | !------------------------------------------------------------------------------! |
---|
[2696] | 3 | ! This file is part of the PALM model system. |
---|
[1036] | 4 | ! |
---|
[2000] | 5 | ! PALM is free software: you can redistribute it and/or modify it under the |
---|
| 6 | ! terms of the GNU General Public License as published by the Free Software |
---|
| 7 | ! Foundation, either version 3 of the License, or (at your option) any later |
---|
| 8 | ! version. |
---|
[1036] | 9 | ! |
---|
| 10 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
| 11 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
| 12 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
| 13 | ! |
---|
| 14 | ! You should have received a copy of the GNU General Public License along with |
---|
| 15 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
| 16 | ! |
---|
[3648] | 17 | ! Copyright 1997-2019 Leibniz Universitaet Hannover |
---|
[2000] | 18 | !------------------------------------------------------------------------------! |
---|
[1036] | 19 | ! |
---|
[254] | 20 | ! Current revisions: |
---|
[732] | 21 | ! ------------------ |
---|
[2233] | 22 | ! |
---|
[3589] | 23 | ! |
---|
[2233] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: init_3d_model.f90 3761 2019-02-25 15:31:42Z banzhafs $ |
---|
[3747] | 27 | ! Move initialization of rmask before initializing user_init_arrays |
---|
| 28 | ! |
---|
| 29 | ! 3711 2019-01-31 13:44:26Z knoop |
---|
[3711] | 30 | ! Introduced module_interface_init_checks for post-init checks in modules |
---|
| 31 | ! |
---|
| 32 | ! 3700 2019-01-26 17:03:42Z knoop |
---|
[3685] | 33 | ! Some interface calls moved to module_interface + cleanup |
---|
| 34 | ! |
---|
| 35 | ! 3648 2019-01-02 16:35:46Z suehring |
---|
[3648] | 36 | ! Rename subroutines for surface-data output |
---|
| 37 | ! |
---|
| 38 | ! 3636 2018-12-19 13:48:34Z raasch |
---|
[3636] | 39 | ! nopointer option removed |
---|
| 40 | ! |
---|
| 41 | ! 3609 2018-12-07 13:37:59Z suehring |
---|
[3609] | 42 | ! Furhter correction in initialization of surfaces in cyclic-fill case |
---|
| 43 | ! |
---|
| 44 | ! 3608 2018-12-07 12:59:57Z suehring |
---|
[3608] | 45 | ! Bugfix in initialization of surfaces in cyclic-fill case |
---|
| 46 | ! |
---|
| 47 | ! 3589 2018-11-30 15:09:51Z suehring |
---|
[3589] | 48 | ! Move the control parameter "salsa" from salsa_mod to control_parameters |
---|
| 49 | ! (M. Kurppa) |
---|
| 50 | ! |
---|
| 51 | ! 3582 2018-11-29 19:16:36Z suehring |
---|
[3579] | 52 | ! Bugfix in initialization of turbulence generator |
---|
| 53 | ! |
---|
| 54 | ! 3569 2018-11-27 17:03:40Z kanani |
---|
[3569] | 55 | ! dom_dwd_user, Schrempf: |
---|
| 56 | ! Remove uv exposure model code, this is now part of biometeorology_mod, |
---|
| 57 | ! remove bio_init_arrays. |
---|
| 58 | ! |
---|
| 59 | ! 3547 2018-11-21 13:21:24Z suehring |
---|
[3547] | 60 | ! variables documented |
---|
| 61 | ! |
---|
| 62 | ! 3525 2018-11-14 16:06:14Z kanani |
---|
[3525] | 63 | ! Changes related to clean-up of biometeorology (dom_dwd_user) |
---|
| 64 | ! |
---|
| 65 | ! 3524 2018-11-14 13:36:44Z raasch |
---|
[3524] | 66 | ! preprocessor directive added to avoid the compiler to complain about unused |
---|
| 67 | ! variable |
---|
| 68 | ! |
---|
| 69 | ! 3473 2018-10-30 20:50:15Z suehring |
---|
[3473] | 70 | ! Add virtual measurement module |
---|
| 71 | ! |
---|
| 72 | ! 3472 2018-10-30 20:43:50Z suehring |
---|
[3469] | 73 | ! Add indoor model (kanani, srissman, tlang) |
---|
| 74 | ! |
---|
| 75 | ! 3467 2018-10-30 19:05:21Z suehring |
---|
[3467] | 76 | ! Implementation of a new aerosol module salsa. |
---|
| 77 | ! |
---|
| 78 | ! 3458 2018-10-30 14:51:23Z kanani |
---|
[3458] | 79 | ! from chemistry branch r3443, basit: |
---|
| 80 | ! bug fixed in sums and sums_l for chemistry profile output |
---|
| 81 | ! |
---|
| 82 | ! 3448 2018-10-29 18:14:31Z kanani |
---|
[3448] | 83 | ! Add biometeorology |
---|
| 84 | ! |
---|
| 85 | ! 3421 2018-10-24 18:39:32Z gronemeier |
---|
[3421] | 86 | ! Initialize surface data output |
---|
| 87 | ! |
---|
| 88 | ! 3415 2018-10-24 11:57:50Z suehring |
---|
[3404] | 89 | ! Set bottom boundary condition for geostrophic wind components in inifor |
---|
| 90 | ! initialization |
---|
| 91 | ! |
---|
| 92 | ! 3347 2018-10-15 14:21:08Z suehring |
---|
[3347] | 93 | ! - Separate offline nesting from large_scale_nudging_mod |
---|
| 94 | ! - Improve the synthetic turbulence generator |
---|
| 95 | ! |
---|
| 96 | ! 3298 2018-10-02 12:21:11Z kanani |
---|
| 97 | ! Minor formatting (kanani) |
---|
| 98 | ! Added CALL to the chem_emissions module (Russo) |
---|
| 99 | ! |
---|
| 100 | ! 3294 2018-10-01 02:37:10Z raasch |
---|
[3302] | 101 | ! allocate and set stokes drift velocity profiles |
---|
| 102 | ! |
---|
| 103 | ! 3298 2018-10-02 12:21:11Z kanani |
---|
[3298] | 104 | ! Minor formatting (kanani) |
---|
| 105 | ! Added CALL to the chem_emissions module (Russo) |
---|
| 106 | ! |
---|
| 107 | ! 3294 2018-10-01 02:37:10Z raasch |
---|
[3294] | 108 | ! changes concerning modularization of ocean option |
---|
| 109 | ! |
---|
| 110 | ! 3289 2018-09-28 10:23:58Z suehring |
---|
[3289] | 111 | ! Introduce module parameter for number of inflow profiles |
---|
| 112 | ! |
---|
| 113 | ! 3288 2018-09-28 10:23:08Z suehring |
---|
[3274] | 114 | ! Modularization of all bulk cloud physics code components |
---|
| 115 | ! |
---|
| 116 | ! 3241 2018-09-12 15:02:00Z raasch |
---|
[3241] | 117 | ! unused variables removed |
---|
| 118 | ! |
---|
| 119 | ! 3234 2018-09-07 13:46:58Z schwenkel |
---|
[3234] | 120 | ! The increase of dots_num in case of radiation or land surface model must |
---|
| 121 | ! be done before user_init is called |
---|
| 122 | ! |
---|
| 123 | ! 3183 2018-07-27 14:25:55Z suehring |
---|
[3183] | 124 | ! Revise Inifor initialization |
---|
| 125 | ! |
---|
| 126 | ! 3182 2018-07-27 13:36:03Z suehring |
---|
[3159] | 127 | ! Added multi agent system |
---|
| 128 | ! |
---|
| 129 | ! 3129 2018-07-16 07:45:13Z gronemeier |
---|
[3051] | 130 | ! Move initialization call for nudging and 1D/3D offline nesting. |
---|
| 131 | ! Revise initialization with inifor data. |
---|
| 132 | ! |
---|
| 133 | ! 3045 2018-05-28 07:55:41Z Giersch |
---|
[3045] | 134 | ! Error messages revised |
---|
| 135 | ! |
---|
[3049] | 136 | ! 3045 2018-05-28 07:55:41Z Giersch |
---|
| 137 | ! Error messages revised |
---|
| 138 | ! |
---|
[3045] | 139 | ! 3042 2018-05-25 10:44:37Z schwenkel |
---|
[3042] | 140 | ! Changed the name specific humidity to mixing ratio |
---|
| 141 | ! |
---|
| 142 | ! 3040 2018-05-25 10:22:08Z schwenkel |
---|
[3035] | 143 | ! Add option to initialize warm air bubble close to surface |
---|
| 144 | ! |
---|
| 145 | ! 3014 2018-05-09 08:42:38Z maronga |
---|
[3014] | 146 | ! Bugfix: initialization of ts_value missing |
---|
| 147 | ! |
---|
| 148 | ! 3011 2018-05-07 14:38:42Z schwenkel |
---|
[3011] | 149 | ! removed redundant if statement |
---|
| 150 | ! |
---|
| 151 | ! 3004 2018-04-27 12:33:25Z Giersch |
---|
[3004] | 152 | ! precipitation_rate removed |
---|
| 153 | ! |
---|
| 154 | ! 2995 2018-04-19 12:13:16Z Giersch |
---|
[2995] | 155 | ! CALL radiation_control is not necessary during initialization because |
---|
| 156 | ! calculation of radiative fluxes at model start is done in radiation_init |
---|
| 157 | ! in any case |
---|
| 158 | ! |
---|
| 159 | ! 2977 2018-04-17 10:27:57Z kanani |
---|
[2977] | 160 | ! Implement changes from branch radiation (r2948-2971) with minor modifications |
---|
| 161 | ! (moh.hefny): |
---|
| 162 | ! - set radiation_interactions according to the existence of urban/land vertical |
---|
| 163 | ! surfaces and trees to activiate RTM |
---|
| 164 | ! - set average_radiation to TRUE if RTM is activiated |
---|
| 165 | ! |
---|
| 166 | ! 2938 2018-03-27 15:52:42Z suehring |
---|
[2938] | 167 | ! - Revise Inifor initialization for geostrophic wind components |
---|
| 168 | ! - Initialize synthetic turbulence generator in case of Inifor initialization |
---|
| 169 | ! |
---|
| 170 | ! 2936 2018-03-27 14:49:27Z suehring |
---|
[2934] | 171 | ! Synchronize parent and child models after initialization. |
---|
| 172 | ! Remove obsolete masking of topography grid points for Runge-Kutta weighted |
---|
| 173 | ! tendency arrays. |
---|
| 174 | ! |
---|
| 175 | ! 2920 2018-03-22 11:22:01Z kanani |
---|
[2920] | 176 | ! Add call for precalculating apparent solar positions (moh.hefny) |
---|
| 177 | ! |
---|
| 178 | ! 2906 2018-03-19 08:56:40Z Giersch |
---|
[2906] | 179 | ! The variables read/write_svf_on_init have been removed. Instead ENVIRONMENT |
---|
| 180 | ! variables read/write_svf have been introduced. Location_message has been |
---|
| 181 | ! added. |
---|
| 182 | ! |
---|
| 183 | ! 2894 2018-03-15 09:17:58Z Giersch |
---|
[2894] | 184 | ! Renamed routines with respect to reading restart data, file 13 is closed in |
---|
| 185 | ! rrd_read_parts_of_global now |
---|
| 186 | ! |
---|
| 187 | ! 2867 2018-03-09 09:40:23Z suehring |
---|
[2867] | 188 | ! Further bugfix concerning call of user_init. |
---|
| 189 | ! |
---|
| 190 | ! 2864 2018-03-08 11:57:45Z suehring |
---|
[2864] | 191 | ! Bugfix, move call of user_init in front of initialization of grid-point |
---|
| 192 | ! arrays |
---|
| 193 | ! |
---|
| 194 | ! 2817 2018-02-19 16:32:21Z knoop |
---|
[2817] | 195 | ! Preliminary gust module interface implemented |
---|
| 196 | ! |
---|
| 197 | ! 2776 2018-01-31 10:44:42Z Giersch |
---|
[2776] | 198 | ! Variable use_synthetic_turbulence_generator has been abbreviated |
---|
| 199 | ! |
---|
| 200 | ! 2766 2018-01-22 17:17:47Z kanani |
---|
[2766] | 201 | ! Removed preprocessor directive __chem |
---|
| 202 | ! |
---|
| 203 | ! 2758 2018-01-17 12:55:21Z suehring |
---|
[2758] | 204 | ! In case of spinup of land- and urban-surface model, do not mask wind velocity |
---|
| 205 | ! at first computational grid level |
---|
| 206 | ! |
---|
| 207 | ! 2746 2018-01-15 12:06:04Z suehring |
---|
[2746] | 208 | ! Move flag plant canopy to modules |
---|
| 209 | ! |
---|
| 210 | ! 2718 2018-01-02 08:49:38Z maronga |
---|
[2716] | 211 | ! Corrected "Former revisions" section |
---|
| 212 | ! |
---|
| 213 | ! 2705 2017-12-18 11:26:23Z maronga |
---|
[2705] | 214 | ! Bugfix for reading initial profiles from ls/nuding file |
---|
[2716] | 215 | ! |
---|
| 216 | ! 2701 2017-12-15 15:40:50Z suehring |
---|
| 217 | ! Changes from last commit documented |
---|
[2705] | 218 | ! |
---|
[2716] | 219 | ! 2700 2017-12-15 14:12:35Z suehring |
---|
[2701] | 220 | ! Bugfix, missing initialization of surface attributes in case of |
---|
| 221 | ! inifor-initialization branch |
---|
[2716] | 222 | ! |
---|
| 223 | ! 2698 2017-12-14 18:46:24Z suehring |
---|
| 224 | ! Bugfix in get_topography_top_index |
---|
| 225 | ! |
---|
| 226 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
| 227 | ! Change in file header (GPL part) |
---|
[2696] | 228 | ! Implementation of uv exposure model (FK) |
---|
| 229 | ! Moved initialisation of diss, e, kh, km to turbulence_closure_mod (TG) |
---|
| 230 | ! Added chemical emissions (FK) |
---|
| 231 | ! Initialize masking arrays and number-of-grid-points arrays before initialize |
---|
| 232 | ! LSM, USM and radiation module |
---|
| 233 | ! Initialization with inifor (MS) |
---|
| 234 | ! |
---|
| 235 | ! 2618 2017-11-16 15:37:30Z suehring |
---|
[2618] | 236 | ! Reorder calls of init_surfaces. |
---|
| 237 | ! |
---|
| 238 | ! 2564 2017-10-19 15:56:56Z Giersch |
---|
[2564] | 239 | ! Variable wind_turbine was added to control_parameters. |
---|
| 240 | ! |
---|
| 241 | ! 2550 2017-10-16 17:12:01Z boeske |
---|
[2550] | 242 | ! Modifications to cyclic fill method and turbulence recycling method in case of |
---|
| 243 | ! complex terrain simulations |
---|
| 244 | ! |
---|
| 245 | ! 2513 2017-10-04 09:24:39Z kanani |
---|
[2513] | 246 | ! Bugfix in storing initial scalar profile (wrong index) |
---|
| 247 | ! |
---|
| 248 | ! 2350 2017-08-15 11:48:26Z kanani |
---|
[2350] | 249 | ! Bugfix in nopointer version |
---|
| 250 | ! |
---|
| 251 | ! 2339 2017-08-07 13:55:26Z gronemeier |
---|
[2339] | 252 | ! corrected timestamp in header |
---|
| 253 | ! |
---|
| 254 | ! 2338 2017-08-07 12:15:38Z gronemeier |
---|
[2338] | 255 | ! Modularize 1D model |
---|
| 256 | ! |
---|
[2339] | 257 | ! 2329 2017-08-03 14:24:56Z knoop |
---|
[2329] | 258 | ! Removed temporary bugfix (r2327) as bug is properly resolved by this revision |
---|
| 259 | ! |
---|
| 260 | ! 2327 2017-08-02 07:40:57Z maronga |
---|
[2327] | 261 | ! Temporary bugfix |
---|
| 262 | ! |
---|
| 263 | ! 2320 2017-07-21 12:47:43Z suehring |
---|
[2320] | 264 | ! Modularize large-scale forcing and nudging |
---|
| 265 | ! |
---|
| 266 | ! 2292 2017-06-20 09:51:42Z schwenkel |
---|
[2292] | 267 | ! Implementation of new microphysic scheme: cloud_scheme = 'morrison' |
---|
| 268 | ! includes two more prognostic equations for cloud drop concentration (nc) |
---|
| 269 | ! and cloud water content (qc). |
---|
| 270 | ! |
---|
| 271 | ! 2277 2017-06-12 10:47:51Z kanani |
---|
[2277] | 272 | ! Removed unused variable sums_up_fraction_l |
---|
| 273 | ! |
---|
| 274 | ! 2270 2017-06-09 12:18:47Z maronga |
---|
[2270] | 275 | ! dots_num must be increased when LSM and/or radiation is used |
---|
| 276 | ! |
---|
| 277 | ! 2259 2017-06-08 09:09:11Z gronemeier |
---|
[2259] | 278 | ! Implemented synthetic turbulence generator |
---|
| 279 | ! |
---|
| 280 | ! 2252 2017-06-07 09:35:37Z knoop |
---|
[2252] | 281 | ! rho_air now depending on surface_pressure even in Boussinesq mode |
---|
| 282 | ! |
---|
| 283 | ! 2233 2017-05-30 18:08:54Z suehring |
---|
[2233] | 284 | ! |
---|
| 285 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
[2232] | 286 | ! Adjustments to new topography and surface concept: |
---|
| 287 | ! - Modify passed parameters for disturb_field |
---|
| 288 | ! - Topography representation via flags |
---|
| 289 | ! - Remove unused arrays. |
---|
| 290 | ! - Move initialization of surface-related quantities to surface_mod |
---|
[1961] | 291 | ! |
---|
[2173] | 292 | ! 2172 2017-03-08 15:55:25Z knoop |
---|
| 293 | ! Bugfix: moved parallel random generator initialization into its module |
---|
| 294 | ! |
---|
[2119] | 295 | ! 2118 2017-01-17 16:38:49Z raasch |
---|
| 296 | ! OpenACC directives removed |
---|
| 297 | ! |
---|
[2038] | 298 | ! 2037 2016-10-26 11:15:40Z knoop |
---|
| 299 | ! Anelastic approximation implemented |
---|
| 300 | ! |
---|
[2032] | 301 | ! 2031 2016-10-21 15:11:58Z knoop |
---|
| 302 | ! renamed variable rho to rho_ocean |
---|
| 303 | ! |
---|
[2012] | 304 | ! 2011 2016-09-19 17:29:57Z kanani |
---|
| 305 | ! Flag urban_surface is now defined in module control_parameters. |
---|
| 306 | ! |
---|
[2008] | 307 | ! 2007 2016-08-24 15:47:17Z kanani |
---|
| 308 | ! Added support for urban surface model, |
---|
| 309 | ! adjusted location_message in case of plant_canopy |
---|
| 310 | ! |
---|
[2001] | 311 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
| 312 | ! Forced header and separation lines into 80 columns |
---|
| 313 | ! |
---|
[1993] | 314 | ! 1992 2016-08-12 15:14:59Z suehring |
---|
| 315 | ! Initializaton of scalarflux at model top |
---|
| 316 | ! Bugfixes in initialization of surface and top salinity flux, top scalar and |
---|
| 317 | ! humidity fluxes |
---|
| 318 | ! |
---|
[1961] | 319 | ! 1960 2016-07-12 16:34:24Z suehring |
---|
[1960] | 320 | ! Separate humidity and passive scalar |
---|
| 321 | ! Increase dimension for mean_inflow_profiles |
---|
| 322 | ! Remove inadvertent write-statement |
---|
| 323 | ! Bugfix, large-scale forcing is still not implemented for passive scalars |
---|
[1919] | 324 | ! |
---|
[1958] | 325 | ! 1957 2016-07-07 10:43:48Z suehring |
---|
| 326 | ! flight module added |
---|
| 327 | ! |
---|
[1921] | 328 | ! 1920 2016-05-30 10:50:15Z suehring |
---|
| 329 | ! Initialize us with very small number to avoid segmentation fault during |
---|
| 330 | ! calculation of Obukhov length |
---|
| 331 | ! |
---|
[1919] | 332 | ! 1918 2016-05-27 14:35:57Z raasch |
---|
| 333 | ! intermediate_timestep_count is set 0 instead 1 for first call of pres, |
---|
| 334 | ! bugfix: initialization of local sum arrays are moved to the beginning of the |
---|
| 335 | ! routine because otherwise results from pres are overwritten |
---|
| 336 | ! |
---|
[1917] | 337 | ! 1914 2016-05-26 14:44:07Z witha |
---|
| 338 | ! Added initialization of the wind turbine model |
---|
| 339 | ! |
---|
[1879] | 340 | ! 1878 2016-04-19 12:30:36Z hellstea |
---|
| 341 | ! The zeroth element of weight_pres removed as unnecessary |
---|
| 342 | ! |
---|
[1851] | 343 | ! 1849 2016-04-08 11:33:18Z hoffmann |
---|
[1849] | 344 | ! Adapted for modularization of microphysics. |
---|
| 345 | ! precipitation_amount, precipitation_rate, prr moved to arrays_3d. |
---|
[1852] | 346 | ! Initialization of nc_1d, nr_1d, pt_1d, qc_1d, qr_1d, q_1d moved to |
---|
[3274] | 347 | ! bcm_init. |
---|
[1849] | 348 | ! |
---|
[1846] | 349 | ! 1845 2016-04-08 08:29:13Z raasch |
---|
| 350 | ! nzb_2d replaced by nzb_u|v_inner |
---|
[1914] | 351 | ! |
---|
[1834] | 352 | ! 1833 2016-04-07 14:23:03Z raasch |
---|
| 353 | ! initialization of spectra quantities moved to spectra_mod |
---|
| 354 | ! |
---|
[1832] | 355 | ! 1831 2016-04-07 13:15:51Z hoffmann |
---|
| 356 | ! turbulence renamed collision_turbulence |
---|
| 357 | ! |
---|
[1827] | 358 | ! 1826 2016-04-07 12:01:39Z maronga |
---|
| 359 | ! Renamed radiation calls. |
---|
| 360 | ! Renamed canopy model calls. |
---|
| 361 | ! |
---|
[1823] | 362 | ! 1822 2016-04-07 07:49:42Z hoffmann |
---|
| 363 | ! icloud_scheme replaced by microphysics_* |
---|
[1914] | 364 | ! |
---|
[1818] | 365 | ! 1817 2016-04-06 15:44:20Z maronga |
---|
| 366 | ! Renamed lsm calls. |
---|
| 367 | ! |
---|
[1816] | 368 | ! 1815 2016-04-06 13:49:59Z raasch |
---|
| 369 | ! zero-settings for velocities inside topography re-activated (was deactivated |
---|
| 370 | ! in r1762) |
---|
| 371 | ! |
---|
[1789] | 372 | ! 1788 2016-03-10 11:01:04Z maronga |
---|
| 373 | ! Added z0q. |
---|
| 374 | ! Syntax layout improved. |
---|
| 375 | ! |
---|
[1784] | 376 | ! 1783 2016-03-06 18:36:17Z raasch |
---|
| 377 | ! netcdf module name changed + related changes |
---|
| 378 | ! |
---|
[1765] | 379 | ! 1764 2016-02-28 12:45:19Z raasch |
---|
| 380 | ! bugfix: increase size of volume_flow_area_l and volume_flow_initial_l by 1 |
---|
| 381 | ! |
---|
[1763] | 382 | ! 1762 2016-02-25 12:31:13Z hellstea |
---|
| 383 | ! Introduction of nested domain feature |
---|
| 384 | ! |
---|
[1739] | 385 | ! 1738 2015-12-18 13:56:05Z raasch |
---|
| 386 | ! calculate mean surface level height for each statistic region |
---|
| 387 | ! |
---|
[1735] | 388 | ! 1734 2015-12-02 12:17:12Z raasch |
---|
| 389 | ! no initial disturbances in case that the disturbance energy limit has been |
---|
| 390 | ! set zero |
---|
| 391 | ! |
---|
[1708] | 392 | ! 1707 2015-11-02 15:24:52Z maronga |
---|
| 393 | ! Bugfix: transfer of Richardson number from 1D model to Obukhov length caused |
---|
| 394 | ! devision by zero in neutral stratification |
---|
| 395 | ! |
---|
[1692] | 396 | ! 1691 2015-10-26 16:17:44Z maronga |
---|
| 397 | ! Call to init_surface_layer added. rif is replaced by ol and zeta. |
---|
| 398 | ! |
---|
[1683] | 399 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 400 | ! Code annotations made doxygen readable |
---|
| 401 | ! |
---|
[1616] | 402 | ! 1615 2015-07-08 18:49:19Z suehring |
---|
| 403 | ! Enable turbulent inflow for passive_scalar and humidity |
---|
| 404 | ! |
---|
[1586] | 405 | ! 1585 2015-04-30 07:05:52Z maronga |
---|
| 406 | ! Initialization of radiation code is now done after LSM initializtion |
---|
| 407 | ! |
---|
[1576] | 408 | ! 1575 2015-03-27 09:56:27Z raasch |
---|
| 409 | ! adjustments for psolver-queries |
---|
| 410 | ! |
---|
[1552] | 411 | ! 1551 2015-03-03 14:18:16Z maronga |
---|
[1817] | 412 | ! Allocation of land surface arrays is now done in the subroutine lsm_init_arrays, |
---|
[1552] | 413 | ! which is part of land_surface_model. |
---|
| 414 | ! |
---|
[1508] | 415 | ! 1507 2014-12-10 12:14:18Z suehring |
---|
| 416 | ! Bugfix: set horizontal velocity components to zero inside topography |
---|
| 417 | ! |
---|
[1497] | 418 | ! 1496 2014-12-02 17:25:50Z maronga |
---|
| 419 | ! Added initialization of the land surface and radiation schemes |
---|
| 420 | ! |
---|
[1485] | 421 | ! 1484 2014-10-21 10:53:05Z kanani |
---|
[1484] | 422 | ! Changes due to new module structure of the plant canopy model: |
---|
[1508] | 423 | ! canopy-related initialization (e.g. lad and canopy_heat_flux) moved to new |
---|
| 424 | ! subroutine init_plant_canopy within the module plant_canopy_model_mod, |
---|
| 425 | ! call of subroutine init_plant_canopy added. |
---|
[1341] | 426 | ! |
---|
[1432] | 427 | ! 1431 2014-07-15 14:47:17Z suehring |
---|
| 428 | ! var_d added, in order to normalize spectra. |
---|
| 429 | ! |
---|
[1430] | 430 | ! 1429 2014-07-15 12:53:45Z knoop |
---|
| 431 | ! Ensemble run capability added to parallel random number generator |
---|
| 432 | ! |
---|
[1412] | 433 | ! 1411 2014-05-16 18:01:51Z suehring |
---|
| 434 | ! Initial horizontal velocity profiles were not set to zero at the first vertical |
---|
| 435 | ! grid level in case of non-cyclic lateral boundary conditions. |
---|
| 436 | ! |
---|
[1407] | 437 | ! 1406 2014-05-16 13:47:01Z raasch |
---|
| 438 | ! bugfix: setting of initial velocities at k=1 to zero not in case of a |
---|
| 439 | ! no-slip boundary condition for uv |
---|
| 440 | ! |
---|
[1403] | 441 | ! 1402 2014-05-09 14:25:13Z raasch |
---|
| 442 | ! location messages modified |
---|
| 443 | ! |
---|
[1401] | 444 | ! 1400 2014-05-09 14:03:54Z knoop |
---|
| 445 | ! Parallel random number generator added |
---|
| 446 | ! |
---|
[1385] | 447 | ! 1384 2014-05-02 14:31:06Z raasch |
---|
| 448 | ! location messages added |
---|
| 449 | ! |
---|
[1362] | 450 | ! 1361 2014-04-16 15:17:48Z hoffmann |
---|
| 451 | ! tend_* removed |
---|
| 452 | ! Bugfix: w_subs is not allocated anymore if it is already allocated |
---|
| 453 | ! |
---|
[1360] | 454 | ! 1359 2014-04-11 17:15:14Z hoffmann |
---|
| 455 | ! module lpm_init_mod added to use statements, because lpm_init has become a |
---|
| 456 | ! module |
---|
| 457 | ! |
---|
[1354] | 458 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
| 459 | ! REAL constants provided with KIND-attribute |
---|
| 460 | ! |
---|
[1341] | 461 | ! 1340 2014-03-25 19:45:13Z kanani |
---|
| 462 | ! REAL constants defined as wp-kind |
---|
| 463 | ! |
---|
[1323] | 464 | ! 1322 2014-03-20 16:38:49Z raasch |
---|
| 465 | ! REAL constants defined as wp-kind |
---|
| 466 | ! module interfaces removed |
---|
| 467 | ! |
---|
[1321] | 468 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
| 469 | ! ONLY-attribute added to USE-statements, |
---|
| 470 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 471 | ! kinds are defined in new module kinds, |
---|
| 472 | ! revision history before 2012 removed, |
---|
| 473 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 474 | ! all variable declaration statements |
---|
| 475 | ! |
---|
[1317] | 476 | ! 1316 2014-03-17 07:44:59Z heinze |
---|
| 477 | ! Bugfix: allocation of w_subs |
---|
| 478 | ! |
---|
[1300] | 479 | ! 1299 2014-03-06 13:15:21Z heinze |
---|
| 480 | ! Allocate w_subs due to extension of large scale subsidence in combination |
---|
| 481 | ! with large scale forcing data (LSF_DATA) |
---|
| 482 | ! |
---|
[1242] | 483 | ! 1241 2013-10-30 11:36:58Z heinze |
---|
| 484 | ! Overwrite initial profiles in case of nudging |
---|
| 485 | ! Inititialize shf and qsws in case of large_scale_forcing |
---|
| 486 | ! |
---|
[1222] | 487 | ! 1221 2013-09-10 08:59:13Z raasch |
---|
| 488 | ! +rflags_s_inner in copyin statement, use copyin for most arrays instead of |
---|
| 489 | ! copy |
---|
| 490 | ! |
---|
[1213] | 491 | ! 1212 2013-08-15 08:46:27Z raasch |
---|
| 492 | ! array tri is allocated and included in data copy statement |
---|
| 493 | ! |
---|
[1196] | 494 | ! 1195 2013-07-01 12:27:57Z heinze |
---|
| 495 | ! Bugfix: move allocation of ref_state to parin.f90 and read_var_list.f90 |
---|
| 496 | ! |
---|
[1182] | 497 | ! 1179 2013-06-14 05:57:58Z raasch |
---|
| 498 | ! allocate and set ref_state to be used in buoyancy terms |
---|
| 499 | ! |
---|
[1172] | 500 | ! 1171 2013-05-30 11:27:45Z raasch |
---|
| 501 | ! diss array is allocated with full size if accelerator boards are used |
---|
| 502 | ! |
---|
[1160] | 503 | ! 1159 2013-05-21 11:58:22Z fricke |
---|
| 504 | ! -bc_lr_dirneu, bc_lr_neudir, bc_ns_dirneu, bc_ns_neudir |
---|
| 505 | ! |
---|
[1154] | 506 | ! 1153 2013-05-10 14:33:08Z raasch |
---|
| 507 | ! diss array is allocated with dummy elements even if it is not needed |
---|
[1171] | 508 | ! (required by PGI 13.4 / CUDA 5.0) |
---|
[1154] | 509 | ! |
---|
[1116] | 510 | ! 1115 2013-03-26 18:16:16Z hoffmann |
---|
| 511 | ! unused variables removed |
---|
| 512 | ! |
---|
[1114] | 513 | ! 1113 2013-03-10 02:48:14Z raasch |
---|
| 514 | ! openACC directive modified |
---|
| 515 | ! |
---|
[1112] | 516 | ! 1111 2013-03-08 23:54:10Z raasch |
---|
| 517 | ! openACC directives added for pres |
---|
| 518 | ! array diss allocated only if required |
---|
| 519 | ! |
---|
[1093] | 520 | ! 1092 2013-02-02 11:24:22Z raasch |
---|
| 521 | ! unused variables removed |
---|
| 522 | ! |
---|
[1066] | 523 | ! 1065 2012-11-22 17:42:36Z hoffmann |
---|
| 524 | ! allocation of diss (dissipation rate) in case of turbulence = .TRUE. added |
---|
| 525 | ! |
---|
[1054] | 526 | ! 1053 2012-11-13 17:11:03Z hoffmann |
---|
[1053] | 527 | ! allocation and initialisation of necessary data arrays for the two-moment |
---|
| 528 | ! cloud physics scheme the two new prognostic equations (nr, qr): |
---|
| 529 | ! +dr, lambda_r, mu_r, sed_*, xr, *s, *sws, *swst, *, *_p, t*_m, *_1, *_2, *_3, |
---|
| 530 | ! +tend_*, prr |
---|
[979] | 531 | ! |
---|
[1037] | 532 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 533 | ! code put under GPL (PALM 3.9) |
---|
| 534 | ! |
---|
[1033] | 535 | ! 1032 2012-10-21 13:03:21Z letzel |
---|
| 536 | ! save memory by not allocating pt_2 in case of neutral = .T. |
---|
| 537 | ! |
---|
[1026] | 538 | ! 1025 2012-10-07 16:04:41Z letzel |
---|
| 539 | ! bugfix: swap indices of mask for ghost boundaries |
---|
| 540 | ! |
---|
[1017] | 541 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
| 542 | ! mask is set to zero for ghost boundaries |
---|
| 543 | ! |
---|
[1011] | 544 | ! 1010 2012-09-20 07:59:54Z raasch |
---|
| 545 | ! cpp switch __nopointer added for pointer free version |
---|
| 546 | ! |
---|
[1004] | 547 | ! 1003 2012-09-14 14:35:53Z raasch |
---|
| 548 | ! nxra,nyna, nzta replaced ny nxr, nyn, nzt |
---|
| 549 | ! |
---|
[1002] | 550 | ! 1001 2012-09-13 14:08:46Z raasch |
---|
| 551 | ! all actions concerning leapfrog scheme removed |
---|
| 552 | ! |
---|
[997] | 553 | ! 996 2012-09-07 10:41:47Z raasch |
---|
| 554 | ! little reformatting |
---|
| 555 | ! |
---|
[979] | 556 | ! 978 2012-08-09 08:28:32Z fricke |
---|
[978] | 557 | ! outflow damping layer removed |
---|
| 558 | ! roughness length for scalar quantites z0h added |
---|
| 559 | ! damping zone for the potential temperatur in case of non-cyclic lateral |
---|
| 560 | ! boundaries added |
---|
| 561 | ! initialization of ptdf_x, ptdf_y |
---|
| 562 | ! initialization of c_u_m, c_u_m_l, c_v_m, c_v_m_l, c_w_m, c_w_m_l |
---|
[708] | 563 | ! |
---|
[850] | 564 | ! 849 2012-03-15 10:35:09Z raasch |
---|
| 565 | ! init_particles renamed lpm_init |
---|
| 566 | ! |
---|
[826] | 567 | ! 825 2012-02-19 03:03:44Z raasch |
---|
| 568 | ! wang_collision_kernel renamed wang_kernel |
---|
| 569 | ! |
---|
[1] | 570 | ! Revision 1.1 1998/03/09 16:22:22 raasch |
---|
| 571 | ! Initial revision |
---|
| 572 | ! |
---|
| 573 | ! |
---|
| 574 | ! Description: |
---|
| 575 | ! ------------ |
---|
[1682] | 576 | !> Allocation of arrays and initialization of the 3D model via |
---|
| 577 | !> a) pre-run the 1D model |
---|
| 578 | !> or |
---|
| 579 | !> b) pre-set constant linear profiles |
---|
| 580 | !> or |
---|
| 581 | !> c) read values of a previous run |
---|
[1] | 582 | !------------------------------------------------------------------------------! |
---|
[1682] | 583 | SUBROUTINE init_3d_model |
---|
[1] | 584 | |
---|
[3298] | 585 | |
---|
[667] | 586 | USE advec_ws |
---|
[1320] | 587 | |
---|
[1] | 588 | USE arrays_3d |
---|
[1849] | 589 | |
---|
[3274] | 590 | USE basic_constants_and_equations_mod, & |
---|
| 591 | ONLY: c_p, g, l_v, pi, r_d, exner_function, exner_function_invers, & |
---|
| 592 | ideal_gas_law_rho, ideal_gas_law_rho_pt, barometric_formula |
---|
| 593 | |
---|
| 594 | USE bulk_cloud_model_mod, & |
---|
[3685] | 595 | ONLY: bulk_cloud_model |
---|
[3274] | 596 | |
---|
[3298] | 597 | USE chem_modules, & |
---|
[3685] | 598 | ONLY: max_pr_cs ! ToDo: this dependency needs to be removed cause it is ugly #new_dom |
---|
[3298] | 599 | |
---|
[1] | 600 | USE control_parameters |
---|
[3298] | 601 | |
---|
[1320] | 602 | USE grid_variables, & |
---|
[2037] | 603 | ONLY: dx, dy, ddx2_mg, ddy2_mg |
---|
[2817] | 604 | |
---|
[1] | 605 | USE indices |
---|
[3469] | 606 | |
---|
[1320] | 607 | USE kinds |
---|
[1496] | 608 | |
---|
[3159] | 609 | USE lpm_init_mod, & |
---|
| 610 | ONLY: lpm_init |
---|
[1496] | 611 | |
---|
[2320] | 612 | USE lsf_nudging_mod, & |
---|
[3685] | 613 | ONLY: ls_forcing_surf |
---|
[1849] | 614 | |
---|
[2338] | 615 | USE model_1d_mod, & |
---|
[3241] | 616 | ONLY: init_1d_model, l1d, u1d, v1d |
---|
[2338] | 617 | |
---|
[3685] | 618 | USE module_interface, & |
---|
[3711] | 619 | ONLY: module_interface_init_arrays, & |
---|
| 620 | module_interface_init, & |
---|
| 621 | module_interface_init_checks |
---|
[3685] | 622 | |
---|
[3159] | 623 | USE multi_agent_system_mod, & |
---|
| 624 | ONLY: agents_active, mas_init |
---|
| 625 | |
---|
[1783] | 626 | USE netcdf_interface, & |
---|
[3700] | 627 | ONLY: dots_max |
---|
[2696] | 628 | |
---|
[2906] | 629 | USE netcdf_data_input_mod, & |
---|
[3761] | 630 | ONLY: init_3d, & |
---|
[3298] | 631 | netcdf_data_input_init_3d, netcdf_data_input_interpolate |
---|
[3448] | 632 | |
---|
[3347] | 633 | USE nesting_offl_mod, & |
---|
| 634 | ONLY: nesting_offl_init |
---|
[3294] | 635 | |
---|
[1320] | 636 | USE particle_attributes, & |
---|
[3241] | 637 | ONLY: particle_advection |
---|
[3298] | 638 | |
---|
[1] | 639 | USE pegrid |
---|
[3298] | 640 | |
---|
[3524] | 641 | #if defined( __parallel ) |
---|
[2934] | 642 | USE pmc_interface, & |
---|
| 643 | ONLY: nested_run |
---|
[3524] | 644 | #endif |
---|
[2934] | 645 | |
---|
[1320] | 646 | USE random_function_mod |
---|
[3685] | 647 | |
---|
[1400] | 648 | USE random_generator_parallel, & |
---|
[2172] | 649 | ONLY: init_parallel_random_generator |
---|
[3685] | 650 | |
---|
[2894] | 651 | USE read_restart_data_mod, & |
---|
[3685] | 652 | ONLY: rrd_read_parts_of_global, rrd_local |
---|
| 653 | |
---|
[1320] | 654 | USE statistics, & |
---|
[1738] | 655 | ONLY: hom, hom_sum, mean_surface_level_height, pr_palm, rmask, & |
---|
[1833] | 656 | statistic_regions, sums, sums_divnew_l, sums_divold_l, sums_l, & |
---|
[2277] | 657 | sums_l_l, sums_wsts_bc_l, ts_value, & |
---|
[1833] | 658 | weight_pres, weight_substep |
---|
[2259] | 659 | |
---|
| 660 | USE synthetic_turbulence_generator_mod, & |
---|
[3347] | 661 | ONLY: parametrize_inflow_turbulence, stg_adjust, stg_init, & |
---|
| 662 | use_syn_turb_gen |
---|
[3685] | 663 | |
---|
[1691] | 664 | USE surface_layer_fluxes_mod, & |
---|
| 665 | ONLY: init_surface_layer_fluxes |
---|
[2232] | 666 | |
---|
| 667 | USE surface_mod, & |
---|
| 668 | ONLY : init_surface_arrays, init_surfaces, surf_def_h, surf_lsm_h, & |
---|
[3761] | 669 | surf_usm_h, get_topography_top_index_ji |
---|
[3685] | 670 | |
---|
[3648] | 671 | USE surface_data_output_mod, & |
---|
| 672 | ONLY: surface_data_output_init |
---|
[3685] | 673 | |
---|
[2007] | 674 | USE transpose_indices |
---|
[1] | 675 | |
---|
[2696] | 676 | USE turbulence_closure_mod, & |
---|
| 677 | ONLY: tcm_init_arrays, tcm_init |
---|
| 678 | |
---|
[1] | 679 | IMPLICIT NONE |
---|
| 680 | |
---|
[3547] | 681 | INTEGER(iwp) :: i !< grid index in x direction |
---|
| 682 | INTEGER(iwp) :: ind_array(1) !< dummy used to determine start index for external pressure forcing |
---|
| 683 | INTEGER(iwp) :: j !< grid index in y direction |
---|
| 684 | INTEGER(iwp) :: k !< grid index in z direction |
---|
[2232] | 685 | INTEGER(iwp) :: k_surf !< surface level index |
---|
| 686 | INTEGER(iwp) :: m !< index of surface element in surface data type |
---|
| 687 | INTEGER(iwp) :: sr !< index of statistic region |
---|
[1] | 688 | |
---|
[3547] | 689 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: ngp_2dh_l !< toal number of horizontal grid points in statistical region on subdomain |
---|
[1] | 690 | |
---|
[3547] | 691 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: ngp_2dh_outer_l !< number of horizontal non-wall bounded grid points on subdomain |
---|
| 692 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: ngp_2dh_s_inner_l !< number of horizontal non-topography grid points on subdomain |
---|
[1] | 693 | |
---|
[2037] | 694 | REAL(wp) :: t_surface !< air temperature at the surface |
---|
| 695 | |
---|
[3182] | 696 | REAL(wp), DIMENSION(:), ALLOCATABLE :: init_l !< dummy array used for averaging 3D data to obtain inital profiles |
---|
[2037] | 697 | REAL(wp), DIMENSION(:), ALLOCATABLE :: p_hydrostatic !< hydrostatic pressure |
---|
| 698 | |
---|
| 699 | INTEGER(iwp) :: l !< loop variable |
---|
| 700 | INTEGER(iwp) :: nzt_l !< index of top PE boundary for multigrid level |
---|
| 701 | REAL(wp) :: dx_l !< grid spacing along x on different multigrid level |
---|
| 702 | REAL(wp) :: dy_l !< grid spacing along y on different multigrid level |
---|
| 703 | |
---|
[3547] | 704 | REAL(wp), DIMENSION(1:3) :: volume_flow_area_l !< area of lateral and top model domain surface on local subdomain |
---|
| 705 | REAL(wp), DIMENSION(1:3) :: volume_flow_initial_l !< initial volume flow into model domain |
---|
[1] | 706 | |
---|
[3547] | 707 | REAL(wp), DIMENSION(:), ALLOCATABLE :: mean_surface_level_height_l !< mean surface level height on subdomain |
---|
| 708 | REAL(wp), DIMENSION(:), ALLOCATABLE :: ngp_3d_inner_l !< total number of non-topography grid points on subdomain |
---|
| 709 | REAL(wp), DIMENSION(:), ALLOCATABLE :: ngp_3d_inner_tmp !< total number of non-topography grid points |
---|
[1] | 710 | |
---|
[3547] | 711 | INTEGER(iwp) :: nz_u_shift !< topography-top index on u-grid, used to vertically shift initial profiles |
---|
| 712 | INTEGER(iwp) :: nz_v_shift !< topography-top index on v-grid, used to vertically shift initial profiles |
---|
| 713 | INTEGER(iwp) :: nz_w_shift !< topography-top index on w-grid, used to vertically shift initial profiles |
---|
| 714 | INTEGER(iwp) :: nz_s_shift !< topography-top index on scalar-grid, used to vertically shift initial profiles |
---|
| 715 | INTEGER(iwp) :: nz_u_shift_l !< topography-top index on u-grid, used to vertically shift initial profiles |
---|
| 716 | INTEGER(iwp) :: nz_v_shift_l !< topography-top index on v-grid, used to vertically shift initial profiles |
---|
| 717 | INTEGER(iwp) :: nz_w_shift_l !< topography-top index on w-grid, used to vertically shift initial profiles |
---|
| 718 | INTEGER(iwp) :: nz_s_shift_l !< topography-top index on scalar-grid, used to vertically shift initial profiles |
---|
[485] | 719 | |
---|
[1402] | 720 | CALL location_message( 'allocating arrays', .FALSE. ) |
---|
[1] | 721 | ! |
---|
| 722 | !-- Allocate arrays |
---|
[1788] | 723 | ALLOCATE( mean_surface_level_height(0:statistic_regions), & |
---|
| 724 | mean_surface_level_height_l(0:statistic_regions), & |
---|
| 725 | ngp_2dh(0:statistic_regions), ngp_2dh_l(0:statistic_regions), & |
---|
| 726 | ngp_3d(0:statistic_regions), & |
---|
| 727 | ngp_3d_inner(0:statistic_regions), & |
---|
| 728 | ngp_3d_inner_l(0:statistic_regions), & |
---|
| 729 | ngp_3d_inner_tmp(0:statistic_regions), & |
---|
| 730 | sums_divnew_l(0:statistic_regions), & |
---|
[1] | 731 | sums_divold_l(0:statistic_regions) ) |
---|
[1195] | 732 | ALLOCATE( dp_smooth_factor(nzb:nzt), rdf(nzb+1:nzt), rdf_sc(nzb+1:nzt) ) |
---|
[1788] | 733 | ALLOCATE( ngp_2dh_outer(nzb:nzt+1,0:statistic_regions), & |
---|
| 734 | ngp_2dh_outer_l(nzb:nzt+1,0:statistic_regions), & |
---|
| 735 | ngp_2dh_s_inner(nzb:nzt+1,0:statistic_regions), & |
---|
| 736 | ngp_2dh_s_inner_l(nzb:nzt+1,0:statistic_regions), & |
---|
| 737 | rmask(nysg:nyng,nxlg:nxrg,0:statistic_regions), & |
---|
[3458] | 738 | sums(nzb:nzt+1,pr_palm+max_pr_user+max_pr_cs), & |
---|
| 739 | sums_l(nzb:nzt+1,pr_palm+max_pr_user+max_pr_cs,0:threads_per_task-1), & |
---|
[1788] | 740 | sums_l_l(nzb:nzt+1,0:statistic_regions,0:threads_per_task-1), & |
---|
[3700] | 741 | sums_wsts_bc_l(nzb:nzt+1,0:statistic_regions) ) |
---|
| 742 | ALLOCATE( ts_value(dots_max,0:statistic_regions) ) |
---|
[978] | 743 | ALLOCATE( ptdf_x(nxlg:nxrg), ptdf_y(nysg:nyng) ) |
---|
[1] | 744 | |
---|
[1788] | 745 | ALLOCATE( d(nzb+1:nzt,nys:nyn,nxl:nxr), & |
---|
| 746 | p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
[1010] | 747 | tend(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 748 | |
---|
[2696] | 749 | ALLOCATE( pt_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
[1788] | 750 | pt_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 751 | u_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 752 | u_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 753 | u_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 754 | v_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 755 | v_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 756 | v_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 757 | w_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 758 | w_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
[667] | 759 | w_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
[1788] | 760 | IF ( .NOT. neutral ) THEN |
---|
[1032] | 761 | ALLOCATE( pt_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 762 | ENDIF |
---|
[673] | 763 | ! |
---|
[3747] | 764 | !-- Pre-set masks for regional statistics. Default is the total model domain. |
---|
| 765 | !-- Ghost points are excluded because counting values at the ghost boundaries |
---|
| 766 | !-- would bias the statistics |
---|
| 767 | rmask = 1.0_wp |
---|
| 768 | rmask(:,nxlg:nxl-1,:) = 0.0_wp; rmask(:,nxr+1:nxrg,:) = 0.0_wp |
---|
| 769 | rmask(nysg:nys-1,:,:) = 0.0_wp; rmask(nyn+1:nyng,:,:) = 0.0_wp |
---|
| 770 | ! |
---|
[707] | 771 | !-- Following array is required for perturbation pressure within the iterative |
---|
| 772 | !-- pressure solvers. For the multistep schemes (Runge-Kutta), array p holds |
---|
| 773 | !-- the weighted average of the substeps and cannot be used in the Poisson |
---|
| 774 | !-- solver. |
---|
| 775 | IF ( psolver == 'sor' ) THEN |
---|
| 776 | ALLOCATE( p_loc(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
[1575] | 777 | ELSEIF ( psolver(1:9) == 'multigrid' ) THEN |
---|
[707] | 778 | ! |
---|
| 779 | !-- For performance reasons, multigrid is using one ghost layer only |
---|
| 780 | ALLOCATE( p_loc(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
[673] | 781 | ENDIF |
---|
[1] | 782 | |
---|
[1111] | 783 | ! |
---|
| 784 | !-- Array for storing constant coeffficients of the tridiagonal solver |
---|
| 785 | IF ( psolver == 'poisfft' ) THEN |
---|
[1212] | 786 | ALLOCATE( tri(nxl_z:nxr_z,nys_z:nyn_z,0:nz-1,2) ) |
---|
[1111] | 787 | ALLOCATE( tric(nxl_z:nxr_z,nys_z:nyn_z,0:nz-1) ) |
---|
| 788 | ENDIF |
---|
| 789 | |
---|
[1960] | 790 | IF ( humidity ) THEN |
---|
[1] | 791 | ! |
---|
[1960] | 792 | !-- 3D-humidity |
---|
[1788] | 793 | ALLOCATE( q_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 794 | q_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
[3011] | 795 | q_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 796 | vpt_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
[1] | 797 | |
---|
[3011] | 798 | IF ( cloud_droplets ) THEN |
---|
[1] | 799 | ! |
---|
[3011] | 800 | !-- Liquid water content, change in liquid water content |
---|
| 801 | ALLOCATE ( ql_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 802 | ql_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
[1010] | 803 | ! |
---|
[3011] | 804 | !-- Real volume of particles (with weighting), volume of particles |
---|
| 805 | ALLOCATE ( ql_v(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 806 | ql_vp(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
[1] | 807 | ENDIF |
---|
| 808 | |
---|
[3011] | 809 | ENDIF |
---|
[1960] | 810 | |
---|
| 811 | IF ( passive_scalar ) THEN |
---|
[1] | 812 | |
---|
[1960] | 813 | ! |
---|
| 814 | !-- 3D scalar arrays |
---|
| 815 | ALLOCATE( s_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 816 | s_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
| 817 | s_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
[3636] | 818 | |
---|
[1960] | 819 | ENDIF |
---|
| 820 | |
---|
[1] | 821 | ! |
---|
[3302] | 822 | !-- Allocate and set 1d-profiles for Stokes drift velocity. It may be set to |
---|
| 823 | !-- non-zero values later in ocean_init |
---|
| 824 | ALLOCATE( u_stokes_zu(nzb:nzt+1), u_stokes_zw(nzb:nzt+1), & |
---|
| 825 | v_stokes_zu(nzb:nzt+1), v_stokes_zw(nzb:nzt+1) ) |
---|
| 826 | u_stokes_zu(:) = 0.0_wp |
---|
| 827 | u_stokes_zw(:) = 0.0_wp |
---|
| 828 | v_stokes_zu(:) = 0.0_wp |
---|
| 829 | v_stokes_zw(:) = 0.0_wp |
---|
| 830 | |
---|
| 831 | ! |
---|
[2037] | 832 | !-- Allocation of anelastic and Boussinesq approximation specific arrays |
---|
| 833 | ALLOCATE( p_hydrostatic(nzb:nzt+1) ) |
---|
| 834 | ALLOCATE( rho_air(nzb:nzt+1) ) |
---|
| 835 | ALLOCATE( rho_air_zw(nzb:nzt+1) ) |
---|
| 836 | ALLOCATE( drho_air(nzb:nzt+1) ) |
---|
| 837 | ALLOCATE( drho_air_zw(nzb:nzt+1) ) |
---|
| 838 | ! |
---|
| 839 | !-- Density profile calculation for anelastic approximation |
---|
[3274] | 840 | t_surface = pt_surface * ( surface_pressure / 1000.0_wp )**( r_d / c_p ) |
---|
[2037] | 841 | IF ( TRIM( approximation ) == 'anelastic' ) THEN |
---|
| 842 | DO k = nzb, nzt+1 |
---|
| 843 | p_hydrostatic(k) = surface_pressure * 100.0_wp * & |
---|
[3274] | 844 | ( 1 - ( g * zu(k) ) / ( c_p * t_surface ) & |
---|
| 845 | )**( c_p / r_d ) |
---|
[2037] | 846 | rho_air(k) = ( p_hydrostatic(k) * & |
---|
| 847 | ( 100000.0_wp / p_hydrostatic(k) & |
---|
[3274] | 848 | )**( r_d / c_p ) & |
---|
[2037] | 849 | ) / ( r_d * pt_init(k) ) |
---|
| 850 | ENDDO |
---|
| 851 | DO k = nzb, nzt |
---|
| 852 | rho_air_zw(k) = 0.5_wp * ( rho_air(k) + rho_air(k+1) ) |
---|
| 853 | ENDDO |
---|
| 854 | rho_air_zw(nzt+1) = rho_air_zw(nzt) & |
---|
| 855 | + 2.0_wp * ( rho_air(nzt+1) - rho_air_zw(nzt) ) |
---|
| 856 | ELSE |
---|
[2252] | 857 | DO k = nzb, nzt+1 |
---|
| 858 | p_hydrostatic(k) = surface_pressure * 100.0_wp * & |
---|
[3274] | 859 | ( 1 - ( g * zu(nzb) ) / ( c_p * t_surface ) & |
---|
| 860 | )**( c_p / r_d ) |
---|
[2252] | 861 | rho_air(k) = ( p_hydrostatic(k) * & |
---|
| 862 | ( 100000.0_wp / p_hydrostatic(k) & |
---|
[3274] | 863 | )**( r_d / c_p ) & |
---|
[2252] | 864 | ) / ( r_d * pt_init(nzb) ) |
---|
| 865 | ENDDO |
---|
| 866 | DO k = nzb, nzt |
---|
| 867 | rho_air_zw(k) = 0.5_wp * ( rho_air(k) + rho_air(k+1) ) |
---|
| 868 | ENDDO |
---|
| 869 | rho_air_zw(nzt+1) = rho_air_zw(nzt) & |
---|
| 870 | + 2.0_wp * ( rho_air(nzt+1) - rho_air_zw(nzt) ) |
---|
[2037] | 871 | ENDIF |
---|
[2696] | 872 | ! |
---|
[2037] | 873 | !-- compute the inverse density array in order to avoid expencive divisions |
---|
| 874 | drho_air = 1.0_wp / rho_air |
---|
| 875 | drho_air_zw = 1.0_wp / rho_air_zw |
---|
| 876 | |
---|
| 877 | ! |
---|
| 878 | !-- Allocation of flux conversion arrays |
---|
| 879 | ALLOCATE( heatflux_input_conversion(nzb:nzt+1) ) |
---|
| 880 | ALLOCATE( waterflux_input_conversion(nzb:nzt+1) ) |
---|
| 881 | ALLOCATE( momentumflux_input_conversion(nzb:nzt+1) ) |
---|
| 882 | ALLOCATE( heatflux_output_conversion(nzb:nzt+1) ) |
---|
| 883 | ALLOCATE( waterflux_output_conversion(nzb:nzt+1) ) |
---|
| 884 | ALLOCATE( momentumflux_output_conversion(nzb:nzt+1) ) |
---|
| 885 | |
---|
| 886 | ! |
---|
| 887 | !-- calculate flux conversion factors according to approximation and in-/output mode |
---|
| 888 | DO k = nzb, nzt+1 |
---|
| 889 | |
---|
| 890 | IF ( TRIM( flux_input_mode ) == 'kinematic' ) THEN |
---|
| 891 | heatflux_input_conversion(k) = rho_air_zw(k) |
---|
| 892 | waterflux_input_conversion(k) = rho_air_zw(k) |
---|
| 893 | momentumflux_input_conversion(k) = rho_air_zw(k) |
---|
| 894 | ELSEIF ( TRIM( flux_input_mode ) == 'dynamic' ) THEN |
---|
[3274] | 895 | heatflux_input_conversion(k) = 1.0_wp / c_p |
---|
[2037] | 896 | waterflux_input_conversion(k) = 1.0_wp / l_v |
---|
| 897 | momentumflux_input_conversion(k) = 1.0_wp |
---|
| 898 | ENDIF |
---|
| 899 | |
---|
| 900 | IF ( TRIM( flux_output_mode ) == 'kinematic' ) THEN |
---|
| 901 | heatflux_output_conversion(k) = drho_air_zw(k) |
---|
| 902 | waterflux_output_conversion(k) = drho_air_zw(k) |
---|
| 903 | momentumflux_output_conversion(k) = drho_air_zw(k) |
---|
| 904 | ELSEIF ( TRIM( flux_output_mode ) == 'dynamic' ) THEN |
---|
[3274] | 905 | heatflux_output_conversion(k) = c_p |
---|
[2037] | 906 | waterflux_output_conversion(k) = l_v |
---|
| 907 | momentumflux_output_conversion(k) = 1.0_wp |
---|
| 908 | ENDIF |
---|
| 909 | |
---|
| 910 | IF ( .NOT. humidity ) THEN |
---|
| 911 | waterflux_input_conversion(k) = 1.0_wp |
---|
| 912 | waterflux_output_conversion(k) = 1.0_wp |
---|
| 913 | ENDIF |
---|
| 914 | |
---|
| 915 | ENDDO |
---|
| 916 | |
---|
| 917 | ! |
---|
| 918 | !-- In case of multigrid method, compute grid lengths and grid factors for the |
---|
| 919 | !-- grid levels with respective density on each grid |
---|
| 920 | IF ( psolver(1:9) == 'multigrid' ) THEN |
---|
| 921 | |
---|
| 922 | ALLOCATE( ddx2_mg(maximum_grid_level) ) |
---|
| 923 | ALLOCATE( ddy2_mg(maximum_grid_level) ) |
---|
| 924 | ALLOCATE( dzu_mg(nzb+1:nzt+1,maximum_grid_level) ) |
---|
| 925 | ALLOCATE( dzw_mg(nzb+1:nzt+1,maximum_grid_level) ) |
---|
| 926 | ALLOCATE( f1_mg(nzb+1:nzt,maximum_grid_level) ) |
---|
| 927 | ALLOCATE( f2_mg(nzb+1:nzt,maximum_grid_level) ) |
---|
| 928 | ALLOCATE( f3_mg(nzb+1:nzt,maximum_grid_level) ) |
---|
| 929 | ALLOCATE( rho_air_mg(nzb:nzt+1,maximum_grid_level) ) |
---|
| 930 | ALLOCATE( rho_air_zw_mg(nzb:nzt+1,maximum_grid_level) ) |
---|
| 931 | |
---|
| 932 | dzu_mg(:,maximum_grid_level) = dzu |
---|
| 933 | rho_air_mg(:,maximum_grid_level) = rho_air |
---|
| 934 | ! |
---|
| 935 | !-- Next line to ensure an equally spaced grid. |
---|
| 936 | dzu_mg(1,maximum_grid_level) = dzu(2) |
---|
| 937 | rho_air_mg(nzb,maximum_grid_level) = rho_air(nzb) + & |
---|
| 938 | (rho_air(nzb) - rho_air(nzb+1)) |
---|
| 939 | |
---|
| 940 | dzw_mg(:,maximum_grid_level) = dzw |
---|
| 941 | rho_air_zw_mg(:,maximum_grid_level) = rho_air_zw |
---|
| 942 | nzt_l = nzt |
---|
| 943 | DO l = maximum_grid_level-1, 1, -1 |
---|
| 944 | dzu_mg(nzb+1,l) = 2.0_wp * dzu_mg(nzb+1,l+1) |
---|
| 945 | dzw_mg(nzb+1,l) = 2.0_wp * dzw_mg(nzb+1,l+1) |
---|
| 946 | rho_air_mg(nzb,l) = rho_air_mg(nzb,l+1) + (rho_air_mg(nzb,l+1) - rho_air_mg(nzb+1,l+1)) |
---|
| 947 | rho_air_zw_mg(nzb,l) = rho_air_zw_mg(nzb,l+1) + (rho_air_zw_mg(nzb,l+1) - rho_air_zw_mg(nzb+1,l+1)) |
---|
| 948 | rho_air_mg(nzb+1,l) = rho_air_mg(nzb+1,l+1) |
---|
| 949 | rho_air_zw_mg(nzb+1,l) = rho_air_zw_mg(nzb+1,l+1) |
---|
| 950 | nzt_l = nzt_l / 2 |
---|
| 951 | DO k = 2, nzt_l+1 |
---|
| 952 | dzu_mg(k,l) = dzu_mg(2*k-2,l+1) + dzu_mg(2*k-1,l+1) |
---|
| 953 | dzw_mg(k,l) = dzw_mg(2*k-2,l+1) + dzw_mg(2*k-1,l+1) |
---|
| 954 | rho_air_mg(k,l) = rho_air_mg(2*k-1,l+1) |
---|
| 955 | rho_air_zw_mg(k,l) = rho_air_zw_mg(2*k-1,l+1) |
---|
| 956 | ENDDO |
---|
| 957 | ENDDO |
---|
| 958 | |
---|
| 959 | nzt_l = nzt |
---|
| 960 | dx_l = dx |
---|
| 961 | dy_l = dy |
---|
| 962 | DO l = maximum_grid_level, 1, -1 |
---|
| 963 | ddx2_mg(l) = 1.0_wp / dx_l**2 |
---|
| 964 | ddy2_mg(l) = 1.0_wp / dy_l**2 |
---|
| 965 | DO k = nzb+1, nzt_l |
---|
| 966 | f2_mg(k,l) = rho_air_zw_mg(k,l) / ( dzu_mg(k+1,l) * dzw_mg(k,l) ) |
---|
| 967 | f3_mg(k,l) = rho_air_zw_mg(k-1,l) / ( dzu_mg(k,l) * dzw_mg(k,l) ) |
---|
| 968 | f1_mg(k,l) = 2.0_wp * ( ddx2_mg(l) + ddy2_mg(l) ) & |
---|
| 969 | * rho_air_mg(k,l) + f2_mg(k,l) + f3_mg(k,l) |
---|
| 970 | ENDDO |
---|
| 971 | nzt_l = nzt_l / 2 |
---|
| 972 | dx_l = dx_l * 2.0_wp |
---|
| 973 | dy_l = dy_l * 2.0_wp |
---|
| 974 | ENDDO |
---|
| 975 | |
---|
| 976 | ENDIF |
---|
| 977 | |
---|
| 978 | ! |
---|
[1299] | 979 | !-- 1D-array for large scale subsidence velocity |
---|
[1361] | 980 | IF ( .NOT. ALLOCATED( w_subs ) ) THEN |
---|
| 981 | ALLOCATE ( w_subs(nzb:nzt+1) ) |
---|
| 982 | w_subs = 0.0_wp |
---|
| 983 | ENDIF |
---|
[1299] | 984 | |
---|
| 985 | ! |
---|
[106] | 986 | !-- Arrays to store velocity data from t-dt and the phase speeds which |
---|
| 987 | !-- are needed for radiation boundary conditions |
---|
[3182] | 988 | IF ( bc_radiation_l ) THEN |
---|
[1788] | 989 | ALLOCATE( u_m_l(nzb:nzt+1,nysg:nyng,1:2), & |
---|
| 990 | v_m_l(nzb:nzt+1,nysg:nyng,0:1), & |
---|
[667] | 991 | w_m_l(nzb:nzt+1,nysg:nyng,0:1) ) |
---|
[73] | 992 | ENDIF |
---|
[3182] | 993 | IF ( bc_radiation_r ) THEN |
---|
[1788] | 994 | ALLOCATE( u_m_r(nzb:nzt+1,nysg:nyng,nx-1:nx), & |
---|
| 995 | v_m_r(nzb:nzt+1,nysg:nyng,nx-1:nx), & |
---|
[667] | 996 | w_m_r(nzb:nzt+1,nysg:nyng,nx-1:nx) ) |
---|
[73] | 997 | ENDIF |
---|
[3182] | 998 | IF ( bc_radiation_l .OR. bc_radiation_r ) THEN |
---|
[1788] | 999 | ALLOCATE( c_u(nzb:nzt+1,nysg:nyng), c_v(nzb:nzt+1,nysg:nyng), & |
---|
[667] | 1000 | c_w(nzb:nzt+1,nysg:nyng) ) |
---|
[106] | 1001 | ENDIF |
---|
[3182] | 1002 | IF ( bc_radiation_s ) THEN |
---|
[1788] | 1003 | ALLOCATE( u_m_s(nzb:nzt+1,0:1,nxlg:nxrg), & |
---|
| 1004 | v_m_s(nzb:nzt+1,1:2,nxlg:nxrg), & |
---|
[667] | 1005 | w_m_s(nzb:nzt+1,0:1,nxlg:nxrg) ) |
---|
[73] | 1006 | ENDIF |
---|
[3182] | 1007 | IF ( bc_radiation_n ) THEN |
---|
[1788] | 1008 | ALLOCATE( u_m_n(nzb:nzt+1,ny-1:ny,nxlg:nxrg), & |
---|
| 1009 | v_m_n(nzb:nzt+1,ny-1:ny,nxlg:nxrg), & |
---|
[667] | 1010 | w_m_n(nzb:nzt+1,ny-1:ny,nxlg:nxrg) ) |
---|
[73] | 1011 | ENDIF |
---|
[3182] | 1012 | IF ( bc_radiation_s .OR. bc_radiation_n ) THEN |
---|
[1788] | 1013 | ALLOCATE( c_u(nzb:nzt+1,nxlg:nxrg), c_v(nzb:nzt+1,nxlg:nxrg), & |
---|
[667] | 1014 | c_w(nzb:nzt+1,nxlg:nxrg) ) |
---|
[106] | 1015 | ENDIF |
---|
[3182] | 1016 | IF ( bc_radiation_l .OR. bc_radiation_r .OR. bc_radiation_s .OR. & |
---|
| 1017 | bc_radiation_n ) THEN |
---|
[978] | 1018 | ALLOCATE( c_u_m_l(nzb:nzt+1), c_v_m_l(nzb:nzt+1), c_w_m_l(nzb:nzt+1) ) |
---|
| 1019 | ALLOCATE( c_u_m(nzb:nzt+1), c_v_m(nzb:nzt+1), c_w_m(nzb:nzt+1) ) |
---|
| 1020 | ENDIF |
---|
[73] | 1021 | |
---|
| 1022 | ! |
---|
[1] | 1023 | !-- Initial assignment of the pointers |
---|
[1032] | 1024 | IF ( .NOT. neutral ) THEN |
---|
| 1025 | pt => pt_1; pt_p => pt_2; tpt_m => pt_3 |
---|
| 1026 | ELSE |
---|
| 1027 | pt => pt_1; pt_p => pt_1; tpt_m => pt_3 |
---|
| 1028 | ENDIF |
---|
[1001] | 1029 | u => u_1; u_p => u_2; tu_m => u_3 |
---|
| 1030 | v => v_1; v_p => v_2; tv_m => v_3 |
---|
| 1031 | w => w_1; w_p => w_2; tw_m => w_3 |
---|
[1] | 1032 | |
---|
[1960] | 1033 | IF ( humidity ) THEN |
---|
[1001] | 1034 | q => q_1; q_p => q_2; tq_m => q_3 |
---|
[3274] | 1035 | vpt => vpt_1 |
---|
[1001] | 1036 | IF ( cloud_droplets ) THEN |
---|
| 1037 | ql => ql_1 |
---|
| 1038 | ql_c => ql_2 |
---|
[1] | 1039 | ENDIF |
---|
[1001] | 1040 | ENDIF |
---|
[1960] | 1041 | |
---|
| 1042 | IF ( passive_scalar ) THEN |
---|
| 1043 | s => s_1; s_p => s_2; ts_m => s_3 |
---|
| 1044 | ENDIF |
---|
[1] | 1045 | |
---|
| 1046 | ! |
---|
[2696] | 1047 | !-- Initialize arrays for turbulence closure |
---|
| 1048 | CALL tcm_init_arrays |
---|
| 1049 | ! |
---|
| 1050 | !-- Initialize surface arrays |
---|
[2232] | 1051 | CALL init_surface_arrays |
---|
| 1052 | ! |
---|
[3294] | 1053 | !-- Allocate arrays for other modules |
---|
[3685] | 1054 | CALL module_interface_init_arrays |
---|
[1551] | 1055 | |
---|
[1914] | 1056 | |
---|
[2320] | 1057 | ! |
---|
[709] | 1058 | !-- Allocate arrays containing the RK coefficient for calculation of |
---|
| 1059 | !-- perturbation pressure and turbulent fluxes. At this point values are |
---|
| 1060 | !-- set for pressure calculation during initialization (where no timestep |
---|
| 1061 | !-- is done). Further below the values needed within the timestep scheme |
---|
| 1062 | !-- will be set. |
---|
[1788] | 1063 | ALLOCATE( weight_substep(1:intermediate_timestep_count_max), & |
---|
[1878] | 1064 | weight_pres(1:intermediate_timestep_count_max) ) |
---|
[1340] | 1065 | weight_substep = 1.0_wp |
---|
| 1066 | weight_pres = 1.0_wp |
---|
[1918] | 1067 | intermediate_timestep_count = 0 ! needed when simulated_time = 0.0 |
---|
[673] | 1068 | |
---|
[1402] | 1069 | CALL location_message( 'finished', .TRUE. ) |
---|
[1918] | 1070 | |
---|
[673] | 1071 | ! |
---|
[3014] | 1072 | !-- Initialize time series |
---|
| 1073 | ts_value = 0.0_wp |
---|
| 1074 | |
---|
| 1075 | ! |
---|
[1918] | 1076 | !-- Initialize local summation arrays for routine flow_statistics. |
---|
| 1077 | !-- This is necessary because they may not yet have been initialized when they |
---|
| 1078 | !-- are called from flow_statistics (or - depending on the chosen model run - |
---|
| 1079 | !-- are never initialized) |
---|
| 1080 | sums_divnew_l = 0.0_wp |
---|
| 1081 | sums_divold_l = 0.0_wp |
---|
| 1082 | sums_l_l = 0.0_wp |
---|
| 1083 | sums_wsts_bc_l = 0.0_wp |
---|
[3182] | 1084 | |
---|
[1918] | 1085 | ! |
---|
[1] | 1086 | !-- Initialize model variables |
---|
[1788] | 1087 | IF ( TRIM( initializing_actions ) /= 'read_restart_data' .AND. & |
---|
[328] | 1088 | TRIM( initializing_actions ) /= 'cyclic_fill' ) THEN |
---|
[1] | 1089 | ! |
---|
[2696] | 1090 | !-- Initialization with provided input data derived from larger-scale model |
---|
| 1091 | IF ( INDEX( initializing_actions, 'inifor' ) /= 0 ) THEN |
---|
| 1092 | CALL location_message( 'initializing with INIFOR', .FALSE. ) |
---|
| 1093 | ! |
---|
[3051] | 1094 | !-- Read initial 1D profiles or 3D data from NetCDF file, depending |
---|
| 1095 | !-- on the provided level-of-detail. |
---|
[2696] | 1096 | !-- At the moment, only u, v, w, pt and q are provided. |
---|
| 1097 | CALL netcdf_data_input_init_3d |
---|
| 1098 | ! |
---|
[3182] | 1099 | !-- Please note, Inifor provides data from nzb+1 to nzt. |
---|
| 1100 | !-- Bottom and top boundary conditions for Inifor profiles are already |
---|
| 1101 | !-- set (just after reading), so that this is not necessary here. |
---|
| 1102 | !-- Depending on the provided level-of-detail, initial Inifor data is |
---|
| 1103 | !-- either stored on data type (lod=1), or directly on 3D arrays (lod=2). |
---|
| 1104 | !-- In order to obtain also initial profiles in case of lod=2 (which |
---|
| 1105 | !-- is required for e.g. damping), average over 3D data. |
---|
| 1106 | IF( init_3d%lod_u == 1 ) THEN |
---|
| 1107 | u_init = init_3d%u_init |
---|
| 1108 | ELSEIF( init_3d%lod_u == 2 ) THEN |
---|
| 1109 | ALLOCATE( init_l(nzb:nzt+1) ) |
---|
| 1110 | DO k = nzb, nzt+1 |
---|
| 1111 | init_l(k) = SUM( u(k,nys:nyn,nxl:nxr) ) |
---|
| 1112 | ENDDO |
---|
| 1113 | init_l = init_l / REAL( ( nx + 1 ) * ( ny + 1 ), KIND = wp ) |
---|
[1384] | 1114 | |
---|
[3182] | 1115 | #if defined( __parallel ) |
---|
| 1116 | CALL MPI_ALLREDUCE( init_l, u_init, nzt+1-nzb+1, & |
---|
| 1117 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
| 1118 | #else |
---|
| 1119 | u_init = init_l |
---|
| 1120 | #endif |
---|
| 1121 | DEALLOCATE( init_l ) |
---|
[3051] | 1122 | |
---|
[2696] | 1123 | ENDIF |
---|
[3182] | 1124 | |
---|
| 1125 | IF( init_3d%lod_v == 1 ) THEN |
---|
| 1126 | v_init = init_3d%v_init |
---|
| 1127 | ELSEIF( init_3d%lod_v == 2 ) THEN |
---|
| 1128 | ALLOCATE( init_l(nzb:nzt+1) ) |
---|
| 1129 | DO k = nzb, nzt+1 |
---|
| 1130 | init_l(k) = SUM( v(k,nys:nyn,nxl:nxr) ) |
---|
| 1131 | ENDDO |
---|
| 1132 | init_l = init_l / REAL( ( nx + 1 ) * ( ny + 1 ), KIND = wp ) |
---|
[2696] | 1133 | |
---|
[3182] | 1134 | #if defined( __parallel ) |
---|
| 1135 | CALL MPI_ALLREDUCE( init_l, v_init, nzt+1-nzb+1, & |
---|
| 1136 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
| 1137 | #else |
---|
| 1138 | v_init = init_l |
---|
| 1139 | #endif |
---|
| 1140 | DEALLOCATE( init_l ) |
---|
| 1141 | ENDIF |
---|
| 1142 | IF( .NOT. neutral ) THEN |
---|
| 1143 | IF( init_3d%lod_pt == 1 ) THEN |
---|
| 1144 | pt_init = init_3d%pt_init |
---|
| 1145 | ELSEIF( init_3d%lod_pt == 2 ) THEN |
---|
| 1146 | ALLOCATE( init_l(nzb:nzt+1) ) |
---|
| 1147 | DO k = nzb, nzt+1 |
---|
| 1148 | init_l(k) = SUM( pt(k,nys:nyn,nxl:nxr) ) |
---|
| 1149 | ENDDO |
---|
| 1150 | init_l = init_l / REAL( ( nx + 1 ) * ( ny + 1 ), KIND = wp ) |
---|
| 1151 | |
---|
| 1152 | #if defined( __parallel ) |
---|
| 1153 | CALL MPI_ALLREDUCE( init_l, pt_init, nzt+1-nzb+1, & |
---|
| 1154 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
| 1155 | #else |
---|
| 1156 | pt_init = init_l |
---|
| 1157 | #endif |
---|
| 1158 | DEALLOCATE( init_l ) |
---|
| 1159 | ENDIF |
---|
| 1160 | ENDIF |
---|
| 1161 | |
---|
| 1162 | |
---|
| 1163 | IF( humidity ) THEN |
---|
| 1164 | IF( init_3d%lod_q == 1 ) THEN |
---|
| 1165 | q_init = init_3d%q_init |
---|
| 1166 | ELSEIF( init_3d%lod_q == 2 ) THEN |
---|
| 1167 | ALLOCATE( init_l(nzb:nzt+1) ) |
---|
| 1168 | DO k = nzb, nzt+1 |
---|
| 1169 | init_l(k) = SUM( q(k,nys:nyn,nxl:nxr) ) |
---|
| 1170 | ENDDO |
---|
| 1171 | init_l = init_l / REAL( ( nx + 1 ) * ( ny + 1 ), KIND = wp ) |
---|
| 1172 | |
---|
| 1173 | #if defined( __parallel ) |
---|
| 1174 | CALL MPI_ALLREDUCE( init_l, q_init, nzt+1-nzb+1, & |
---|
| 1175 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
| 1176 | #else |
---|
| 1177 | q_init = init_l |
---|
| 1178 | #endif |
---|
| 1179 | DEALLOCATE( init_l ) |
---|
| 1180 | ENDIF |
---|
| 1181 | ENDIF |
---|
| 1182 | |
---|
[2696] | 1183 | ! |
---|
[3182] | 1184 | !-- Write initial profiles onto 3D arrays. Note, only in case of lod = 1, |
---|
| 1185 | !-- for lod = 2 data is already on 3D arrays. |
---|
[2696] | 1186 | DO i = nxlg, nxrg |
---|
| 1187 | DO j = nysg, nyng |
---|
[3051] | 1188 | IF( init_3d%lod_u == 1 ) u(:,j,i) = u_init(:) |
---|
| 1189 | IF( init_3d%lod_v == 1 ) v(:,j,i) = v_init(:) |
---|
| 1190 | IF( .NOT. neutral .AND. init_3d%lod_pt == 1 ) & |
---|
| 1191 | pt(:,j,i) = pt_init(:) |
---|
[3182] | 1192 | IF( humidity .AND. init_3d%lod_q == 1 ) q(:,j,i) = q_init(:) |
---|
[2696] | 1193 | ENDDO |
---|
| 1194 | ENDDO |
---|
| 1195 | ! |
---|
[3182] | 1196 | !-- Exchange ghost points in case of level-of-detail = 2 |
---|
| 1197 | IF( init_3d%lod_u == 2 ) CALL exchange_horiz( u, nbgp ) |
---|
| 1198 | IF( init_3d%lod_v == 2 ) CALL exchange_horiz( v, nbgp ) |
---|
| 1199 | IF( init_3d%lod_w == 2 ) CALL exchange_horiz( w, nbgp ) |
---|
| 1200 | IF( .NOT. neutral .AND. init_3d%lod_pt == 2 ) & |
---|
| 1201 | CALL exchange_horiz( pt, nbgp ) |
---|
| 1202 | IF( humidity .AND. init_3d%lod_q == 2 ) & |
---|
| 1203 | CALL exchange_horiz( q, nbgp ) |
---|
| 1204 | ! |
---|
| 1205 | !-- Set geostrophic wind components. |
---|
[2938] | 1206 | IF ( init_3d%from_file_ug ) THEN |
---|
| 1207 | ug(:) = init_3d%ug_init(:) |
---|
| 1208 | ENDIF |
---|
| 1209 | IF ( init_3d%from_file_vg ) THEN |
---|
| 1210 | vg(:) = init_3d%vg_init(:) |
---|
| 1211 | ENDIF |
---|
[3404] | 1212 | ! |
---|
| 1213 | !-- Set bottom and top boundary condition for geostrophic wind |
---|
[2938] | 1214 | ug(nzt+1) = ug(nzt) |
---|
| 1215 | vg(nzt+1) = vg(nzt) |
---|
[3404] | 1216 | ug(nzb) = ug(nzb+1) |
---|
| 1217 | vg(nzb) = vg(nzb+1) |
---|
[2696] | 1218 | ! |
---|
| 1219 | !-- Set inital w to 0 |
---|
| 1220 | w = 0.0_wp |
---|
| 1221 | |
---|
| 1222 | IF ( passive_scalar ) THEN |
---|
| 1223 | DO i = nxlg, nxrg |
---|
| 1224 | DO j = nysg, nyng |
---|
| 1225 | s(:,j,i) = s_init |
---|
| 1226 | ENDDO |
---|
| 1227 | ENDDO |
---|
| 1228 | ENDIF |
---|
| 1229 | |
---|
| 1230 | ! |
---|
| 1231 | !-- Set velocity components at non-atmospheric / oceanic grid points to |
---|
| 1232 | !-- zero. |
---|
| 1233 | u = MERGE( u, 0.0_wp, BTEST( wall_flags_0, 1 ) ) |
---|
| 1234 | v = MERGE( v, 0.0_wp, BTEST( wall_flags_0, 2 ) ) |
---|
| 1235 | w = MERGE( w, 0.0_wp, BTEST( wall_flags_0, 3 ) ) |
---|
[2700] | 1236 | ! |
---|
| 1237 | !-- Initialize surface variables, e.g. friction velocity, momentum |
---|
| 1238 | !-- fluxes, etc. |
---|
| 1239 | CALL init_surfaces |
---|
[2938] | 1240 | ! |
---|
| 1241 | !-- Initialize turbulence generator |
---|
| 1242 | IF( use_syn_turb_gen ) CALL stg_init |
---|
[2696] | 1243 | |
---|
| 1244 | CALL location_message( 'finished', .TRUE. ) |
---|
| 1245 | ! |
---|
| 1246 | !-- Initialization via computed 1D-model profiles |
---|
| 1247 | ELSEIF ( INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 ) THEN |
---|
| 1248 | |
---|
[1402] | 1249 | CALL location_message( 'initializing with 1D model profiles', .FALSE. ) |
---|
[1] | 1250 | ! |
---|
| 1251 | !-- Use solutions of the 1D model as initial profiles, |
---|
| 1252 | !-- start 1D model |
---|
| 1253 | CALL init_1d_model |
---|
| 1254 | ! |
---|
| 1255 | !-- Transfer initial profiles to the arrays of the 3D model |
---|
[667] | 1256 | DO i = nxlg, nxrg |
---|
| 1257 | DO j = nysg, nyng |
---|
[1] | 1258 | pt(:,j,i) = pt_init |
---|
| 1259 | u(:,j,i) = u1d |
---|
| 1260 | v(:,j,i) = v1d |
---|
| 1261 | ENDDO |
---|
| 1262 | ENDDO |
---|
| 1263 | |
---|
[1960] | 1264 | IF ( humidity ) THEN |
---|
[667] | 1265 | DO i = nxlg, nxrg |
---|
| 1266 | DO j = nysg, nyng |
---|
[1] | 1267 | q(:,j,i) = q_init |
---|
| 1268 | ENDDO |
---|
| 1269 | ENDDO |
---|
| 1270 | ENDIF |
---|
[2292] | 1271 | |
---|
[1960] | 1272 | IF ( passive_scalar ) THEN |
---|
| 1273 | DO i = nxlg, nxrg |
---|
| 1274 | DO j = nysg, nyng |
---|
| 1275 | s(:,j,i) = s_init |
---|
| 1276 | ENDDO |
---|
| 1277 | ENDDO |
---|
| 1278 | ENDIF |
---|
[1] | 1279 | ! |
---|
| 1280 | !-- Store initial profiles for output purposes etc. |
---|
[2696] | 1281 | IF ( .NOT. constant_diffusion ) THEN |
---|
[1] | 1282 | hom(:,1,25,:) = SPREAD( l1d, 2, statistic_regions+1 ) |
---|
| 1283 | ENDIF |
---|
| 1284 | ! |
---|
[2696] | 1285 | !-- Set velocities back to zero |
---|
[2758] | 1286 | u = MERGE( u, 0.0_wp, BTEST( wall_flags_0, 1 ) ) |
---|
| 1287 | v = MERGE( v, 0.0_wp, BTEST( wall_flags_0, 2 ) ) |
---|
[1] | 1288 | ! |
---|
[2696] | 1289 | !-- WARNING: The extra boundary conditions set after running the |
---|
| 1290 | !-- ------- 1D model impose an error on the divergence one layer |
---|
| 1291 | !-- below the topography; need to correct later |
---|
| 1292 | !-- ATTENTION: Provisional correction for Piacsek & Williams |
---|
| 1293 | !-- --------- advection scheme: keep u and v zero one layer below |
---|
| 1294 | !-- the topography. |
---|
| 1295 | IF ( ibc_uv_b == 1 ) THEN |
---|
[667] | 1296 | ! |
---|
[2696] | 1297 | !-- Neumann condition |
---|
| 1298 | DO i = nxl-1, nxr+1 |
---|
| 1299 | DO j = nys-1, nyn+1 |
---|
| 1300 | u(nzb,j,i) = u(nzb+1,j,i) |
---|
| 1301 | v(nzb,j,i) = v(nzb+1,j,i) |
---|
[1] | 1302 | ENDDO |
---|
[2696] | 1303 | ENDDO |
---|
[1] | 1304 | |
---|
| 1305 | ENDIF |
---|
[2618] | 1306 | ! |
---|
| 1307 | !-- Initialize surface variables, e.g. friction velocity, momentum |
---|
| 1308 | !-- fluxes, etc. |
---|
| 1309 | CALL init_surfaces |
---|
[3579] | 1310 | ! |
---|
| 1311 | !-- Initialize synthetic turbulence generator if required |
---|
| 1312 | IF( use_syn_turb_gen ) CALL stg_init |
---|
[1] | 1313 | |
---|
[1402] | 1314 | CALL location_message( 'finished', .TRUE. ) |
---|
[1384] | 1315 | |
---|
[1788] | 1316 | ELSEIF ( INDEX(initializing_actions, 'set_constant_profiles') /= 0 ) & |
---|
[1] | 1317 | THEN |
---|
[1241] | 1318 | |
---|
[1402] | 1319 | CALL location_message( 'initializing with constant profiles', .FALSE. ) |
---|
[2259] | 1320 | |
---|
| 1321 | ! |
---|
[1] | 1322 | !-- Use constructed initial profiles (velocity constant with height, |
---|
| 1323 | !-- temperature profile with constant gradient) |
---|
[667] | 1324 | DO i = nxlg, nxrg |
---|
| 1325 | DO j = nysg, nyng |
---|
[1] | 1326 | pt(:,j,i) = pt_init |
---|
| 1327 | u(:,j,i) = u_init |
---|
| 1328 | v(:,j,i) = v_init |
---|
| 1329 | ENDDO |
---|
| 1330 | ENDDO |
---|
| 1331 | ! |
---|
[2758] | 1332 | !-- Mask topography |
---|
| 1333 | u = MERGE( u, 0.0_wp, BTEST( wall_flags_0, 1 ) ) |
---|
| 1334 | v = MERGE( v, 0.0_wp, BTEST( wall_flags_0, 2 ) ) |
---|
| 1335 | ! |
---|
[292] | 1336 | !-- Set initial horizontal velocities at the lowest computational grid |
---|
| 1337 | !-- levels to zero in order to avoid too small time steps caused by the |
---|
| 1338 | !-- diffusion limit in the initial phase of a run (at k=1, dz/2 occurs |
---|
[2758] | 1339 | !-- in the limiting formula!). |
---|
| 1340 | !-- Please note, in case land- or urban-surface model is used and a |
---|
| 1341 | !-- spinup is applied, masking the lowest computational level is not |
---|
| 1342 | !-- possible as MOST as well as energy-balance parametrizations will not |
---|
| 1343 | !-- work with zero wind velocity. |
---|
| 1344 | IF ( ibc_uv_b /= 1 .AND. .NOT. spinup ) THEN |
---|
[1815] | 1345 | DO i = nxlg, nxrg |
---|
| 1346 | DO j = nysg, nyng |
---|
[2232] | 1347 | DO k = nzb, nzt |
---|
| 1348 | u(k,j,i) = MERGE( u(k,j,i), 0.0_wp, & |
---|
| 1349 | BTEST( wall_flags_0(k,j,i), 20 ) ) |
---|
| 1350 | v(k,j,i) = MERGE( v(k,j,i), 0.0_wp, & |
---|
| 1351 | BTEST( wall_flags_0(k,j,i), 21 ) ) |
---|
| 1352 | ENDDO |
---|
[1815] | 1353 | ENDDO |
---|
| 1354 | ENDDO |
---|
| 1355 | ENDIF |
---|
[1] | 1356 | |
---|
[1960] | 1357 | IF ( humidity ) THEN |
---|
[667] | 1358 | DO i = nxlg, nxrg |
---|
| 1359 | DO j = nysg, nyng |
---|
[1] | 1360 | q(:,j,i) = q_init |
---|
| 1361 | ENDDO |
---|
| 1362 | ENDDO |
---|
| 1363 | ENDIF |
---|
[1960] | 1364 | |
---|
| 1365 | IF ( passive_scalar ) THEN |
---|
| 1366 | DO i = nxlg, nxrg |
---|
| 1367 | DO j = nysg, nyng |
---|
| 1368 | s(:,j,i) = s_init |
---|
| 1369 | ENDDO |
---|
| 1370 | ENDDO |
---|
| 1371 | ENDIF |
---|
[1] | 1372 | |
---|
[1920] | 1373 | ! |
---|
[1] | 1374 | !-- Compute initial temperature field and other constants used in case |
---|
| 1375 | !-- of a sloping surface |
---|
| 1376 | IF ( sloping_surface ) CALL init_slope |
---|
[2618] | 1377 | ! |
---|
| 1378 | !-- Initialize surface variables, e.g. friction velocity, momentum |
---|
| 1379 | !-- fluxes, etc. |
---|
| 1380 | CALL init_surfaces |
---|
[3579] | 1381 | ! |
---|
| 1382 | !-- Initialize synthetic turbulence generator if required |
---|
| 1383 | IF( use_syn_turb_gen ) CALL stg_init |
---|
| 1384 | |
---|
[1402] | 1385 | CALL location_message( 'finished', .TRUE. ) |
---|
[1384] | 1386 | |
---|
[1788] | 1387 | ELSEIF ( INDEX(initializing_actions, 'by_user') /= 0 ) & |
---|
[46] | 1388 | THEN |
---|
[1384] | 1389 | |
---|
[1402] | 1390 | CALL location_message( 'initializing by user', .FALSE. ) |
---|
[46] | 1391 | ! |
---|
[2618] | 1392 | !-- Pre-initialize surface variables, i.e. setting start- and end-indices |
---|
| 1393 | !-- at each (j,i)-location. Please note, this does not supersede |
---|
| 1394 | !-- user-defined initialization of surface quantities. |
---|
| 1395 | CALL init_surfaces |
---|
| 1396 | ! |
---|
[46] | 1397 | !-- Initialization will completely be done by the user |
---|
| 1398 | CALL user_init_3d_model |
---|
| 1399 | |
---|
[1402] | 1400 | CALL location_message( 'finished', .TRUE. ) |
---|
[1384] | 1401 | |
---|
[1] | 1402 | ENDIF |
---|
[1384] | 1403 | |
---|
[1402] | 1404 | CALL location_message( 'initializing statistics, boundary conditions, etc.', & |
---|
| 1405 | .FALSE. ) |
---|
[1384] | 1406 | |
---|
[667] | 1407 | ! |
---|
| 1408 | !-- Bottom boundary |
---|
| 1409 | IF ( ibc_uv_b == 0 .OR. ibc_uv_b == 2 ) THEN |
---|
[1340] | 1410 | u(nzb,:,:) = 0.0_wp |
---|
| 1411 | v(nzb,:,:) = 0.0_wp |
---|
[667] | 1412 | ENDIF |
---|
[1] | 1413 | |
---|
| 1414 | ! |
---|
[151] | 1415 | !-- Apply channel flow boundary condition |
---|
[132] | 1416 | IF ( TRIM( bc_uv_t ) == 'dirichlet_0' ) THEN |
---|
[1340] | 1417 | u(nzt+1,:,:) = 0.0_wp |
---|
| 1418 | v(nzt+1,:,:) = 0.0_wp |
---|
[132] | 1419 | ENDIF |
---|
| 1420 | |
---|
| 1421 | ! |
---|
[1] | 1422 | !-- Calculate virtual potential temperature |
---|
[1960] | 1423 | IF ( humidity ) vpt = pt * ( 1.0_wp + 0.61_wp * q ) |
---|
[1] | 1424 | |
---|
| 1425 | ! |
---|
[2696] | 1426 | !-- Store initial profiles for output purposes etc.. Please note, in case of |
---|
| 1427 | !-- initialization of u, v, w, pt, and q via output data derived from larger |
---|
| 1428 | !-- scale models, data will not be horizontally homogeneous. Actually, a mean |
---|
| 1429 | !-- profile should be calculated before. |
---|
[1] | 1430 | hom(:,1,5,:) = SPREAD( u(:,nys,nxl), 2, statistic_regions+1 ) |
---|
| 1431 | hom(:,1,6,:) = SPREAD( v(:,nys,nxl), 2, statistic_regions+1 ) |
---|
[667] | 1432 | IF ( ibc_uv_b == 0 .OR. ibc_uv_b == 2) THEN |
---|
[1340] | 1433 | hom(nzb,1,5,:) = 0.0_wp |
---|
| 1434 | hom(nzb,1,6,:) = 0.0_wp |
---|
[1] | 1435 | ENDIF |
---|
| 1436 | hom(:,1,7,:) = SPREAD( pt(:,nys,nxl), 2, statistic_regions+1 ) |
---|
| 1437 | |
---|
[75] | 1438 | IF ( humidity ) THEN |
---|
[1] | 1439 | ! |
---|
| 1440 | !-- Store initial profile of total water content, virtual potential |
---|
| 1441 | !-- temperature |
---|
| 1442 | hom(:,1,26,:) = SPREAD( q(:,nys,nxl), 2, statistic_regions+1 ) |
---|
| 1443 | hom(:,1,29,:) = SPREAD( vpt(:,nys,nxl), 2, statistic_regions+1 ) |
---|
[2696] | 1444 | ! |
---|
[3040] | 1445 | !-- Store initial profile of mixing ratio and potential |
---|
[2696] | 1446 | !-- temperature |
---|
[3274] | 1447 | IF ( bulk_cloud_model .OR. cloud_droplets ) THEN |
---|
[1] | 1448 | hom(:,1,27,:) = SPREAD( q(:,nys,nxl), 2, statistic_regions+1 ) |
---|
| 1449 | hom(:,1,28,:) = SPREAD( pt(:,nys,nxl), 2, statistic_regions+1 ) |
---|
| 1450 | ENDIF |
---|
| 1451 | ENDIF |
---|
| 1452 | |
---|
[2696] | 1453 | ! |
---|
| 1454 | !-- Store initial scalar profile |
---|
[1] | 1455 | IF ( passive_scalar ) THEN |
---|
[2513] | 1456 | hom(:,1,121,:) = SPREAD( s(:,nys,nxl), 2, statistic_regions+1 ) |
---|
[1] | 1457 | ENDIF |
---|
| 1458 | |
---|
| 1459 | ! |
---|
[1400] | 1460 | !-- Initialize the random number generators (from numerical recipes) |
---|
| 1461 | CALL random_function_ini |
---|
[1429] | 1462 | |
---|
[1400] | 1463 | IF ( random_generator == 'random-parallel' ) THEN |
---|
[3241] | 1464 | CALL init_parallel_random_generator( nx, nys, nyn, nxl, nxr ) |
---|
[1400] | 1465 | ENDIF |
---|
| 1466 | ! |
---|
[1179] | 1467 | !-- Set the reference state to be used in the buoyancy terms (for ocean runs |
---|
| 1468 | !-- the reference state will be set (overwritten) in init_ocean) |
---|
| 1469 | IF ( use_single_reference_value ) THEN |
---|
[1788] | 1470 | IF ( .NOT. humidity ) THEN |
---|
[1179] | 1471 | ref_state(:) = pt_reference |
---|
| 1472 | ELSE |
---|
| 1473 | ref_state(:) = vpt_reference |
---|
| 1474 | ENDIF |
---|
| 1475 | ELSE |
---|
[1788] | 1476 | IF ( .NOT. humidity ) THEN |
---|
[1179] | 1477 | ref_state(:) = pt_init(:) |
---|
| 1478 | ELSE |
---|
| 1479 | ref_state(:) = vpt(:,nys,nxl) |
---|
| 1480 | ENDIF |
---|
| 1481 | ENDIF |
---|
[152] | 1482 | |
---|
| 1483 | ! |
---|
[707] | 1484 | !-- For the moment, vertical velocity is zero |
---|
[1340] | 1485 | w = 0.0_wp |
---|
[1] | 1486 | |
---|
| 1487 | ! |
---|
| 1488 | !-- Initialize array sums (must be defined in first call of pres) |
---|
[1340] | 1489 | sums = 0.0_wp |
---|
[1] | 1490 | |
---|
| 1491 | ! |
---|
[707] | 1492 | !-- In case of iterative solvers, p must get an initial value |
---|
[1575] | 1493 | IF ( psolver(1:9) == 'multigrid' .OR. psolver == 'sor' ) p = 0.0_wp |
---|
[707] | 1494 | ! |
---|
[1] | 1495 | !-- Impose vortex with vertical axis on the initial velocity profile |
---|
| 1496 | IF ( INDEX( initializing_actions, 'initialize_vortex' ) /= 0 ) THEN |
---|
| 1497 | CALL init_rankine |
---|
| 1498 | ENDIF |
---|
| 1499 | |
---|
| 1500 | ! |
---|
[3035] | 1501 | !-- Impose temperature anomaly (advection test only) or warm air bubble |
---|
| 1502 | !-- close to surface |
---|
| 1503 | IF ( INDEX( initializing_actions, 'initialize_ptanom' ) /= 0 .OR. & |
---|
| 1504 | INDEX( initializing_actions, 'initialize_bubble' ) /= 0 ) THEN |
---|
[1] | 1505 | CALL init_pt_anomaly |
---|
| 1506 | ENDIF |
---|
[3035] | 1507 | |
---|
[1] | 1508 | ! |
---|
| 1509 | !-- If required, change the surface temperature at the start of the 3D run |
---|
[1340] | 1510 | IF ( pt_surface_initial_change /= 0.0_wp ) THEN |
---|
[1] | 1511 | pt(nzb,:,:) = pt(nzb,:,:) + pt_surface_initial_change |
---|
| 1512 | ENDIF |
---|
| 1513 | |
---|
| 1514 | ! |
---|
| 1515 | !-- If required, change the surface humidity/scalar at the start of the 3D |
---|
| 1516 | !-- run |
---|
[1960] | 1517 | IF ( humidity .AND. q_surface_initial_change /= 0.0_wp ) & |
---|
[1] | 1518 | q(nzb,:,:) = q(nzb,:,:) + q_surface_initial_change |
---|
[1960] | 1519 | |
---|
| 1520 | IF ( passive_scalar .AND. s_surface_initial_change /= 0.0_wp ) & |
---|
| 1521 | s(nzb,:,:) = s(nzb,:,:) + s_surface_initial_change |
---|
| 1522 | |
---|
[1] | 1523 | |
---|
| 1524 | ! |
---|
| 1525 | !-- Initialize old and new time levels. |
---|
[2696] | 1526 | tpt_m = 0.0_wp; tu_m = 0.0_wp; tv_m = 0.0_wp; tw_m = 0.0_wp |
---|
| 1527 | pt_p = pt; u_p = u; v_p = v; w_p = w |
---|
[1] | 1528 | |
---|
[1960] | 1529 | IF ( humidity ) THEN |
---|
[1340] | 1530 | tq_m = 0.0_wp |
---|
[1] | 1531 | q_p = q |
---|
| 1532 | ENDIF |
---|
[1960] | 1533 | |
---|
| 1534 | IF ( passive_scalar ) THEN |
---|
| 1535 | ts_m = 0.0_wp |
---|
| 1536 | s_p = s |
---|
| 1537 | ENDIF |
---|
[1] | 1538 | |
---|
[1402] | 1539 | CALL location_message( 'finished', .TRUE. ) |
---|
[94] | 1540 | |
---|
[1788] | 1541 | ELSEIF ( TRIM( initializing_actions ) == 'read_restart_data' .OR. & |
---|
[2232] | 1542 | TRIM( initializing_actions ) == 'cyclic_fill' ) & |
---|
[1] | 1543 | THEN |
---|
[1384] | 1544 | |
---|
[1402] | 1545 | CALL location_message( 'initializing in case of restart / cyclic_fill', & |
---|
| 1546 | .FALSE. ) |
---|
[1] | 1547 | ! |
---|
[3609] | 1548 | !-- Initialize surface elements and its attributes, e.g. heat- and |
---|
| 1549 | !-- momentumfluxes, roughness, scaling parameters. As number of surface |
---|
| 1550 | !-- elements might be different between runs, e.g. in case of cyclic fill, |
---|
| 1551 | !-- and not all surface elements are read, surface elements need to be |
---|
| 1552 | !-- initialized before. |
---|
| 1553 | !-- Please note, in case of cyclic fill, surfaces should be initialized |
---|
| 1554 | !-- after restart data is read, else, individual settings of surface |
---|
| 1555 | !-- parameters will be overwritten from data of precursor run, hence, |
---|
| 1556 | !-- init_surfaces is called a second time after reading the restart data. |
---|
| 1557 | CALL init_surfaces |
---|
| 1558 | ! |
---|
[767] | 1559 | !-- When reading data for cyclic fill of 3D prerun data files, read |
---|
| 1560 | !-- some of the global variables from the restart file which are required |
---|
| 1561 | !-- for initializing the inflow |
---|
[328] | 1562 | IF ( TRIM( initializing_actions ) == 'cyclic_fill' ) THEN |
---|
[559] | 1563 | |
---|
[759] | 1564 | DO i = 0, io_blocks-1 |
---|
| 1565 | IF ( i == io_group ) THEN |
---|
[2894] | 1566 | CALL rrd_read_parts_of_global |
---|
[759] | 1567 | ENDIF |
---|
| 1568 | #if defined( __parallel ) |
---|
| 1569 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 1570 | #endif |
---|
| 1571 | ENDDO |
---|
[328] | 1572 | |
---|
[767] | 1573 | ENDIF |
---|
| 1574 | |
---|
[151] | 1575 | ! |
---|
[2894] | 1576 | !-- Read processor specific binary data from restart file |
---|
[767] | 1577 | DO i = 0, io_blocks-1 |
---|
| 1578 | IF ( i == io_group ) THEN |
---|
[2894] | 1579 | CALL rrd_local |
---|
[767] | 1580 | ENDIF |
---|
| 1581 | #if defined( __parallel ) |
---|
| 1582 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 1583 | #endif |
---|
| 1584 | ENDDO |
---|
[3608] | 1585 | ! |
---|
[3609] | 1586 | !-- In case of cyclic fill, call init_surfaces a second time, so that |
---|
| 1587 | !-- surface properties such as heat fluxes are initialized as prescribed. |
---|
| 1588 | IF ( TRIM( initializing_actions ) == 'cyclic_fill' ) & |
---|
| 1589 | CALL init_surfaces |
---|
[767] | 1590 | |
---|
[328] | 1591 | ! |
---|
[2550] | 1592 | !-- In case of complex terrain and cyclic fill method as initialization, |
---|
| 1593 | !-- shift initial data in the vertical direction for each point in the |
---|
| 1594 | !-- x-y-plane depending on local surface height |
---|
| 1595 | IF ( complex_terrain .AND. & |
---|
| 1596 | TRIM( initializing_actions ) == 'cyclic_fill' ) THEN |
---|
| 1597 | DO i = nxlg, nxrg |
---|
| 1598 | DO j = nysg, nyng |
---|
[2698] | 1599 | nz_u_shift = get_topography_top_index_ji( j, i, 'u' ) |
---|
| 1600 | nz_v_shift = get_topography_top_index_ji( j, i, 'v' ) |
---|
| 1601 | nz_w_shift = get_topography_top_index_ji( j, i, 'w' ) |
---|
| 1602 | nz_s_shift = get_topography_top_index_ji( j, i, 's' ) |
---|
[2550] | 1603 | |
---|
| 1604 | u(nz_u_shift:nzt+1,j,i) = u(0:nzt+1-nz_u_shift,j,i) |
---|
| 1605 | |
---|
| 1606 | v(nz_v_shift:nzt+1,j,i) = v(0:nzt+1-nz_v_shift,j,i) |
---|
| 1607 | |
---|
| 1608 | w(nz_w_shift:nzt+1,j,i) = w(0:nzt+1-nz_w_shift,j,i) |
---|
| 1609 | |
---|
| 1610 | p(nz_s_shift:nzt+1,j,i) = p(0:nzt+1-nz_s_shift,j,i) |
---|
| 1611 | pt(nz_s_shift:nzt+1,j,i) = pt(0:nzt+1-nz_s_shift,j,i) |
---|
| 1612 | ENDDO |
---|
| 1613 | ENDDO |
---|
| 1614 | ENDIF |
---|
| 1615 | |
---|
| 1616 | ! |
---|
[767] | 1617 | !-- Initialization of the turbulence recycling method |
---|
[1788] | 1618 | IF ( TRIM( initializing_actions ) == 'cyclic_fill' .AND. & |
---|
[767] | 1619 | turbulent_inflow ) THEN |
---|
| 1620 | ! |
---|
| 1621 | !-- First store the profiles to be used at the inflow. |
---|
| 1622 | !-- These profiles are the (temporally) and horizontally averaged vertical |
---|
| 1623 | !-- profiles from the prerun. Alternatively, prescribed profiles |
---|
| 1624 | !-- for u,v-components can be used. |
---|
[3288] | 1625 | ALLOCATE( mean_inflow_profiles(nzb:nzt+1,1:num_mean_inflow_profiles) ) |
---|
[151] | 1626 | |
---|
[767] | 1627 | IF ( use_prescribed_profile_data ) THEN |
---|
| 1628 | mean_inflow_profiles(:,1) = u_init ! u |
---|
| 1629 | mean_inflow_profiles(:,2) = v_init ! v |
---|
| 1630 | ELSE |
---|
[328] | 1631 | mean_inflow_profiles(:,1) = hom_sum(:,1,0) ! u |
---|
| 1632 | mean_inflow_profiles(:,2) = hom_sum(:,2,0) ! v |
---|
[767] | 1633 | ENDIF |
---|
| 1634 | mean_inflow_profiles(:,4) = hom_sum(:,4,0) ! pt |
---|
[1960] | 1635 | IF ( humidity ) & |
---|
| 1636 | mean_inflow_profiles(:,6) = hom_sum(:,41,0) ! q |
---|
| 1637 | IF ( passive_scalar ) & |
---|
| 1638 | mean_inflow_profiles(:,7) = hom_sum(:,115,0) ! s |
---|
[2550] | 1639 | ! |
---|
| 1640 | !-- In case of complex terrain, determine vertical displacement at inflow |
---|
| 1641 | !-- boundary and adjust mean inflow profiles |
---|
| 1642 | IF ( complex_terrain ) THEN |
---|
| 1643 | IF ( nxlg <= 0 .AND. nxrg >= 0 .AND. nysg <= 0 .AND. nyng >= 0 ) THEN |
---|
[2698] | 1644 | nz_u_shift_l = get_topography_top_index_ji( 0, 0, 'u' ) |
---|
| 1645 | nz_v_shift_l = get_topography_top_index_ji( 0, 0, 'v' ) |
---|
| 1646 | nz_w_shift_l = get_topography_top_index_ji( 0, 0, 'w' ) |
---|
| 1647 | nz_s_shift_l = get_topography_top_index_ji( 0, 0, 's' ) |
---|
[2550] | 1648 | ELSE |
---|
| 1649 | nz_u_shift_l = 0 |
---|
| 1650 | nz_v_shift_l = 0 |
---|
| 1651 | nz_w_shift_l = 0 |
---|
| 1652 | nz_s_shift_l = 0 |
---|
| 1653 | ENDIF |
---|
[151] | 1654 | |
---|
[2550] | 1655 | #if defined( __parallel ) |
---|
| 1656 | CALL MPI_ALLREDUCE(nz_u_shift_l, nz_u_shift, 1, MPI_INTEGER, & |
---|
| 1657 | MPI_MAX, comm2d, ierr) |
---|
| 1658 | CALL MPI_ALLREDUCE(nz_v_shift_l, nz_v_shift, 1, MPI_INTEGER, & |
---|
| 1659 | MPI_MAX, comm2d, ierr) |
---|
| 1660 | CALL MPI_ALLREDUCE(nz_w_shift_l, nz_w_shift, 1, MPI_INTEGER, & |
---|
| 1661 | MPI_MAX, comm2d, ierr) |
---|
| 1662 | CALL MPI_ALLREDUCE(nz_s_shift_l, nz_s_shift, 1, MPI_INTEGER, & |
---|
| 1663 | MPI_MAX, comm2d, ierr) |
---|
| 1664 | #else |
---|
| 1665 | nz_u_shift = nz_u_shift_l |
---|
| 1666 | nz_v_shift = nz_v_shift_l |
---|
| 1667 | nz_w_shift = nz_w_shift_l |
---|
| 1668 | nz_s_shift = nz_s_shift_l |
---|
| 1669 | #endif |
---|
| 1670 | |
---|
| 1671 | mean_inflow_profiles(:,1) = 0.0_wp |
---|
| 1672 | mean_inflow_profiles(nz_u_shift:nzt+1,1) = hom_sum(0:nzt+1-nz_u_shift,1,0) ! u |
---|
| 1673 | |
---|
| 1674 | mean_inflow_profiles(:,2) = 0.0_wp |
---|
| 1675 | mean_inflow_profiles(nz_v_shift:nzt+1,2) = hom_sum(0:nzt+1-nz_v_shift,2,0) ! v |
---|
| 1676 | |
---|
| 1677 | mean_inflow_profiles(nz_s_shift:nzt+1,4) = hom_sum(0:nzt+1-nz_s_shift,4,0) ! pt |
---|
| 1678 | |
---|
| 1679 | ENDIF |
---|
| 1680 | |
---|
[151] | 1681 | ! |
---|
[767] | 1682 | !-- If necessary, adjust the horizontal flow field to the prescribed |
---|
| 1683 | !-- profiles |
---|
| 1684 | IF ( use_prescribed_profile_data ) THEN |
---|
| 1685 | DO i = nxlg, nxrg |
---|
[667] | 1686 | DO j = nysg, nyng |
---|
[328] | 1687 | DO k = nzb, nzt+1 |
---|
[767] | 1688 | u(k,j,i) = u(k,j,i) - hom_sum(k,1,0) + u_init(k) |
---|
| 1689 | v(k,j,i) = v(k,j,i) - hom_sum(k,2,0) + v_init(k) |
---|
[328] | 1690 | ENDDO |
---|
[151] | 1691 | ENDDO |
---|
[767] | 1692 | ENDDO |
---|
| 1693 | ENDIF |
---|
[151] | 1694 | |
---|
| 1695 | ! |
---|
[767] | 1696 | !-- Use these mean profiles at the inflow (provided that Dirichlet |
---|
| 1697 | !-- conditions are used) |
---|
[3182] | 1698 | IF ( bc_dirichlet_l ) THEN |
---|
[767] | 1699 | DO j = nysg, nyng |
---|
| 1700 | DO k = nzb, nzt+1 |
---|
| 1701 | u(k,j,nxlg:-1) = mean_inflow_profiles(k,1) |
---|
| 1702 | v(k,j,nxlg:-1) = mean_inflow_profiles(k,2) |
---|
[1340] | 1703 | w(k,j,nxlg:-1) = 0.0_wp |
---|
[767] | 1704 | pt(k,j,nxlg:-1) = mean_inflow_profiles(k,4) |
---|
[1960] | 1705 | IF ( humidity ) & |
---|
[1615] | 1706 | q(k,j,nxlg:-1) = mean_inflow_profiles(k,6) |
---|
[1960] | 1707 | IF ( passive_scalar ) & |
---|
| 1708 | s(k,j,nxlg:-1) = mean_inflow_profiles(k,7) |
---|
[767] | 1709 | ENDDO |
---|
| 1710 | ENDDO |
---|
| 1711 | ENDIF |
---|
| 1712 | |
---|
[151] | 1713 | ! |
---|
[767] | 1714 | !-- Calculate the damping factors to be used at the inflow. For a |
---|
| 1715 | !-- turbulent inflow the turbulent fluctuations have to be limited |
---|
| 1716 | !-- vertically because otherwise the turbulent inflow layer will grow |
---|
| 1717 | !-- in time. |
---|
[1340] | 1718 | IF ( inflow_damping_height == 9999999.9_wp ) THEN |
---|
[767] | 1719 | ! |
---|
| 1720 | !-- Default: use the inversion height calculated by the prerun; if |
---|
| 1721 | !-- this is zero, inflow_damping_height must be explicitly |
---|
| 1722 | !-- specified. |
---|
[1340] | 1723 | IF ( hom_sum(nzb+6,pr_palm,0) /= 0.0_wp ) THEN |
---|
[767] | 1724 | inflow_damping_height = hom_sum(nzb+6,pr_palm,0) |
---|
| 1725 | ELSE |
---|
[1788] | 1726 | WRITE( message_string, * ) 'inflow_damping_height must be ', & |
---|
| 1727 | 'explicitly specified because&the inversion height ', & |
---|
[767] | 1728 | 'calculated by the prerun is zero.' |
---|
| 1729 | CALL message( 'init_3d_model', 'PA0318', 1, 2, 0, 6, 0 ) |
---|
[292] | 1730 | ENDIF |
---|
[151] | 1731 | |
---|
[767] | 1732 | ENDIF |
---|
| 1733 | |
---|
[1340] | 1734 | IF ( inflow_damping_width == 9999999.9_wp ) THEN |
---|
[151] | 1735 | ! |
---|
[767] | 1736 | !-- Default for the transition range: one tenth of the undamped |
---|
| 1737 | !-- layer |
---|
[1340] | 1738 | inflow_damping_width = 0.1_wp * inflow_damping_height |
---|
[151] | 1739 | |
---|
[767] | 1740 | ENDIF |
---|
[151] | 1741 | |
---|
[767] | 1742 | ALLOCATE( inflow_damping_factor(nzb:nzt+1) ) |
---|
[151] | 1743 | |
---|
[767] | 1744 | DO k = nzb, nzt+1 |
---|
[151] | 1745 | |
---|
[767] | 1746 | IF ( zu(k) <= inflow_damping_height ) THEN |
---|
[1340] | 1747 | inflow_damping_factor(k) = 1.0_wp |
---|
[996] | 1748 | ELSEIF ( zu(k) <= ( inflow_damping_height + inflow_damping_width ) ) THEN |
---|
[1340] | 1749 | inflow_damping_factor(k) = 1.0_wp - & |
---|
[996] | 1750 | ( zu(k) - inflow_damping_height ) / & |
---|
| 1751 | inflow_damping_width |
---|
[767] | 1752 | ELSE |
---|
[1340] | 1753 | inflow_damping_factor(k) = 0.0_wp |
---|
[767] | 1754 | ENDIF |
---|
[151] | 1755 | |
---|
[767] | 1756 | ENDDO |
---|
[151] | 1757 | |
---|
[147] | 1758 | ENDIF |
---|
| 1759 | |
---|
[152] | 1760 | ! |
---|
[2696] | 1761 | !-- Inside buildings set velocities back to zero |
---|
[1788] | 1762 | IF ( TRIM( initializing_actions ) == 'cyclic_fill' .AND. & |
---|
[359] | 1763 | topography /= 'flat' ) THEN |
---|
| 1764 | ! |
---|
[2696] | 1765 | !-- Inside buildings set velocities back to zero. |
---|
| 1766 | !-- Other scalars (pt, q, s, p, sa, ...) are ignored at present, |
---|
[359] | 1767 | !-- maybe revise later. |
---|
[1001] | 1768 | DO i = nxlg, nxrg |
---|
| 1769 | DO j = nysg, nyng |
---|
[2232] | 1770 | DO k = nzb, nzt |
---|
| 1771 | u(k,j,i) = MERGE( u(k,j,i), 0.0_wp, & |
---|
| 1772 | BTEST( wall_flags_0(k,j,i), 1 ) ) |
---|
| 1773 | v(k,j,i) = MERGE( v(k,j,i), 0.0_wp, & |
---|
| 1774 | BTEST( wall_flags_0(k,j,i), 2 ) ) |
---|
| 1775 | w(k,j,i) = MERGE( w(k,j,i), 0.0_wp, & |
---|
| 1776 | BTEST( wall_flags_0(k,j,i), 3 ) ) |
---|
| 1777 | ENDDO |
---|
[359] | 1778 | ENDDO |
---|
[1001] | 1779 | ENDDO |
---|
[359] | 1780 | |
---|
| 1781 | ENDIF |
---|
| 1782 | |
---|
| 1783 | ! |
---|
[1] | 1784 | !-- Calculate initial temperature field and other constants used in case |
---|
| 1785 | !-- of a sloping surface |
---|
| 1786 | IF ( sloping_surface ) CALL init_slope |
---|
| 1787 | |
---|
| 1788 | ! |
---|
| 1789 | !-- Initialize new time levels (only done in order to set boundary values |
---|
| 1790 | !-- including ghost points) |
---|
[2696] | 1791 | pt_p = pt; u_p = u; v_p = v; w_p = w |
---|
[1960] | 1792 | IF ( humidity ) THEN |
---|
[1053] | 1793 | q_p = q |
---|
| 1794 | ENDIF |
---|
[1960] | 1795 | IF ( passive_scalar ) s_p = s |
---|
[181] | 1796 | ! |
---|
| 1797 | !-- Allthough tendency arrays are set in prognostic_equations, they have |
---|
| 1798 | !-- have to be predefined here because they are used (but multiplied with 0) |
---|
| 1799 | !-- there before they are set. |
---|
[2696] | 1800 | tpt_m = 0.0_wp; tu_m = 0.0_wp; tv_m = 0.0_wp; tw_m = 0.0_wp |
---|
[1960] | 1801 | IF ( humidity ) THEN |
---|
[1340] | 1802 | tq_m = 0.0_wp |
---|
[1053] | 1803 | ENDIF |
---|
[1960] | 1804 | IF ( passive_scalar ) ts_m = 0.0_wp |
---|
[2259] | 1805 | ! |
---|
| 1806 | !-- Initialize synthetic turbulence generator in case of restart. |
---|
| 1807 | IF ( TRIM( initializing_actions ) == 'read_restart_data' .AND. & |
---|
[2776] | 1808 | use_syn_turb_gen ) CALL stg_init |
---|
[181] | 1809 | |
---|
[1402] | 1810 | CALL location_message( 'finished', .TRUE. ) |
---|
[1384] | 1811 | |
---|
[1] | 1812 | ELSE |
---|
| 1813 | ! |
---|
| 1814 | !-- Actually this part of the programm should not be reached |
---|
[254] | 1815 | message_string = 'unknown initializing problem' |
---|
| 1816 | CALL message( 'init_3d_model', 'PA0193', 1, 2, 0, 6, 0 ) |
---|
[1] | 1817 | ENDIF |
---|
| 1818 | |
---|
[2696] | 1819 | ! |
---|
| 1820 | !-- Initialize TKE, Kh and Km |
---|
| 1821 | CALL tcm_init |
---|
[151] | 1822 | |
---|
[2696] | 1823 | |
---|
[151] | 1824 | IF ( TRIM( initializing_actions ) /= 'read_restart_data' ) THEN |
---|
[1] | 1825 | ! |
---|
[151] | 1826 | !-- Initialize old timelevels needed for radiation boundary conditions |
---|
[3182] | 1827 | IF ( bc_radiation_l ) THEN |
---|
[151] | 1828 | u_m_l(:,:,:) = u(:,:,1:2) |
---|
| 1829 | v_m_l(:,:,:) = v(:,:,0:1) |
---|
| 1830 | w_m_l(:,:,:) = w(:,:,0:1) |
---|
| 1831 | ENDIF |
---|
[3182] | 1832 | IF ( bc_radiation_r ) THEN |
---|
[151] | 1833 | u_m_r(:,:,:) = u(:,:,nx-1:nx) |
---|
| 1834 | v_m_r(:,:,:) = v(:,:,nx-1:nx) |
---|
| 1835 | w_m_r(:,:,:) = w(:,:,nx-1:nx) |
---|
| 1836 | ENDIF |
---|
[3182] | 1837 | IF ( bc_radiation_s ) THEN |
---|
[151] | 1838 | u_m_s(:,:,:) = u(:,0:1,:) |
---|
| 1839 | v_m_s(:,:,:) = v(:,1:2,:) |
---|
| 1840 | w_m_s(:,:,:) = w(:,0:1,:) |
---|
| 1841 | ENDIF |
---|
[3182] | 1842 | IF ( bc_radiation_n ) THEN |
---|
[151] | 1843 | u_m_n(:,:,:) = u(:,ny-1:ny,:) |
---|
| 1844 | v_m_n(:,:,:) = v(:,ny-1:ny,:) |
---|
| 1845 | w_m_n(:,:,:) = w(:,ny-1:ny,:) |
---|
| 1846 | ENDIF |
---|
[667] | 1847 | |
---|
[151] | 1848 | ENDIF |
---|
[680] | 1849 | |
---|
[667] | 1850 | ! |
---|
| 1851 | !-- Calculate the initial volume flow at the right and north boundary |
---|
[709] | 1852 | IF ( conserve_volume_flow ) THEN |
---|
[151] | 1853 | |
---|
[767] | 1854 | IF ( use_prescribed_profile_data ) THEN |
---|
[667] | 1855 | |
---|
[1340] | 1856 | volume_flow_initial_l = 0.0_wp |
---|
| 1857 | volume_flow_area_l = 0.0_wp |
---|
[732] | 1858 | |
---|
[667] | 1859 | IF ( nxr == nx ) THEN |
---|
| 1860 | DO j = nys, nyn |
---|
[2232] | 1861 | DO k = nzb+1, nzt |
---|
[1788] | 1862 | volume_flow_initial_l(1) = volume_flow_initial_l(1) + & |
---|
[2232] | 1863 | u_init(k) * dzw(k) & |
---|
| 1864 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 1865 | BTEST( wall_flags_0(k,j,nxr), 1 )& |
---|
| 1866 | ) |
---|
| 1867 | |
---|
| 1868 | volume_flow_area_l(1) = volume_flow_area_l(1) + dzw(k) & |
---|
| 1869 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 1870 | BTEST( wall_flags_0(k,j,nxr), 1 )& |
---|
| 1871 | ) |
---|
[767] | 1872 | ENDDO |
---|
| 1873 | ENDDO |
---|
| 1874 | ENDIF |
---|
| 1875 | |
---|
| 1876 | IF ( nyn == ny ) THEN |
---|
| 1877 | DO i = nxl, nxr |
---|
[2232] | 1878 | DO k = nzb+1, nzt |
---|
| 1879 | volume_flow_initial_l(2) = volume_flow_initial_l(2) + & |
---|
| 1880 | v_init(k) * dzw(k) & |
---|
| 1881 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 1882 | BTEST( wall_flags_0(k,nyn,i), 2 )& |
---|
| 1883 | ) |
---|
| 1884 | volume_flow_area_l(2) = volume_flow_area_l(2) + dzw(k) & |
---|
| 1885 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 1886 | BTEST( wall_flags_0(k,nyn,i), 2 )& |
---|
| 1887 | ) |
---|
[767] | 1888 | ENDDO |
---|
| 1889 | ENDDO |
---|
| 1890 | ENDIF |
---|
| 1891 | |
---|
| 1892 | #if defined( __parallel ) |
---|
| 1893 | CALL MPI_ALLREDUCE( volume_flow_initial_l(1), volume_flow_initial(1),& |
---|
| 1894 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
| 1895 | CALL MPI_ALLREDUCE( volume_flow_area_l(1), volume_flow_area(1), & |
---|
| 1896 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
| 1897 | |
---|
| 1898 | #else |
---|
| 1899 | volume_flow_initial = volume_flow_initial_l |
---|
| 1900 | volume_flow_area = volume_flow_area_l |
---|
| 1901 | #endif |
---|
| 1902 | |
---|
| 1903 | ELSEIF ( TRIM( initializing_actions ) == 'cyclic_fill' ) THEN |
---|
| 1904 | |
---|
[1340] | 1905 | volume_flow_initial_l = 0.0_wp |
---|
| 1906 | volume_flow_area_l = 0.0_wp |
---|
[767] | 1907 | |
---|
| 1908 | IF ( nxr == nx ) THEN |
---|
| 1909 | DO j = nys, nyn |
---|
[2232] | 1910 | DO k = nzb+1, nzt |
---|
[1788] | 1911 | volume_flow_initial_l(1) = volume_flow_initial_l(1) + & |
---|
[2232] | 1912 | hom_sum(k,1,0) * dzw(k) & |
---|
| 1913 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 1914 | BTEST( wall_flags_0(k,j,nx), 1 ) & |
---|
| 1915 | ) |
---|
| 1916 | volume_flow_area_l(1) = volume_flow_area_l(1) + dzw(k) & |
---|
| 1917 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 1918 | BTEST( wall_flags_0(k,j,nx), 1 ) & |
---|
| 1919 | ) |
---|
[667] | 1920 | ENDDO |
---|
| 1921 | ENDDO |
---|
| 1922 | ENDIF |
---|
| 1923 | |
---|
| 1924 | IF ( nyn == ny ) THEN |
---|
| 1925 | DO i = nxl, nxr |
---|
[2232] | 1926 | DO k = nzb+1, nzt |
---|
[1788] | 1927 | volume_flow_initial_l(2) = volume_flow_initial_l(2) + & |
---|
[2232] | 1928 | hom_sum(k,2,0) * dzw(k) & |
---|
| 1929 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 1930 | BTEST( wall_flags_0(k,ny,i), 2 ) & |
---|
| 1931 | ) |
---|
| 1932 | volume_flow_area_l(2) = volume_flow_area_l(2) + dzw(k) & |
---|
| 1933 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 1934 | BTEST( wall_flags_0(k,ny,i), 2 ) & |
---|
| 1935 | ) |
---|
[667] | 1936 | ENDDO |
---|
| 1937 | ENDDO |
---|
| 1938 | ENDIF |
---|
| 1939 | |
---|
[732] | 1940 | #if defined( __parallel ) |
---|
| 1941 | CALL MPI_ALLREDUCE( volume_flow_initial_l(1), volume_flow_initial(1),& |
---|
| 1942 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
| 1943 | CALL MPI_ALLREDUCE( volume_flow_area_l(1), volume_flow_area(1), & |
---|
| 1944 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
| 1945 | |
---|
| 1946 | #else |
---|
| 1947 | volume_flow_initial = volume_flow_initial_l |
---|
| 1948 | volume_flow_area = volume_flow_area_l |
---|
| 1949 | #endif |
---|
| 1950 | |
---|
[667] | 1951 | ELSEIF ( TRIM( initializing_actions ) /= 'read_restart_data' ) THEN |
---|
| 1952 | |
---|
[1340] | 1953 | volume_flow_initial_l = 0.0_wp |
---|
| 1954 | volume_flow_area_l = 0.0_wp |
---|
[732] | 1955 | |
---|
[667] | 1956 | IF ( nxr == nx ) THEN |
---|
| 1957 | DO j = nys, nyn |
---|
[2232] | 1958 | DO k = nzb+1, nzt |
---|
| 1959 | volume_flow_initial_l(1) = volume_flow_initial_l(1) + & |
---|
| 1960 | u(k,j,nx) * dzw(k) & |
---|
| 1961 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 1962 | BTEST( wall_flags_0(k,j,nx), 1 ) & |
---|
| 1963 | ) |
---|
| 1964 | volume_flow_area_l(1) = volume_flow_area_l(1) + dzw(k) & |
---|
| 1965 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 1966 | BTEST( wall_flags_0(k,j,nx), 1 ) & |
---|
| 1967 | ) |
---|
[667] | 1968 | ENDDO |
---|
| 1969 | ENDDO |
---|
| 1970 | ENDIF |
---|
| 1971 | |
---|
| 1972 | IF ( nyn == ny ) THEN |
---|
| 1973 | DO i = nxl, nxr |
---|
[2232] | 1974 | DO k = nzb+1, nzt |
---|
[1788] | 1975 | volume_flow_initial_l(2) = volume_flow_initial_l(2) + & |
---|
[2232] | 1976 | v(k,ny,i) * dzw(k) & |
---|
| 1977 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 1978 | BTEST( wall_flags_0(k,ny,i), 2 ) & |
---|
| 1979 | ) |
---|
| 1980 | volume_flow_area_l(2) = volume_flow_area_l(2) + dzw(k) & |
---|
| 1981 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 1982 | BTEST( wall_flags_0(k,ny,i), 2 ) & |
---|
| 1983 | ) |
---|
[667] | 1984 | ENDDO |
---|
| 1985 | ENDDO |
---|
| 1986 | ENDIF |
---|
| 1987 | |
---|
| 1988 | #if defined( __parallel ) |
---|
[732] | 1989 | CALL MPI_ALLREDUCE( volume_flow_initial_l(1), volume_flow_initial(1),& |
---|
| 1990 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
| 1991 | CALL MPI_ALLREDUCE( volume_flow_area_l(1), volume_flow_area(1), & |
---|
| 1992 | 2, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
[667] | 1993 | |
---|
| 1994 | #else |
---|
[732] | 1995 | volume_flow_initial = volume_flow_initial_l |
---|
| 1996 | volume_flow_area = volume_flow_area_l |
---|
[667] | 1997 | #endif |
---|
| 1998 | |
---|
[732] | 1999 | ENDIF |
---|
| 2000 | |
---|
[151] | 2001 | ! |
---|
[709] | 2002 | !-- In case of 'bulk_velocity' mode, volume_flow_initial is calculated |
---|
| 2003 | !-- from u|v_bulk instead |
---|
[680] | 2004 | IF ( TRIM( conserve_volume_flow_mode ) == 'bulk_velocity' ) THEN |
---|
| 2005 | volume_flow_initial(1) = u_bulk * volume_flow_area(1) |
---|
| 2006 | volume_flow_initial(2) = v_bulk * volume_flow_area(2) |
---|
| 2007 | ENDIF |
---|
[667] | 2008 | |
---|
[680] | 2009 | ENDIF |
---|
[2232] | 2010 | ! |
---|
[2618] | 2011 | !-- Finally, if random_heatflux is set, disturb shf at horizontal |
---|
| 2012 | !-- surfaces. Actually, this should be done in surface_mod, where all other |
---|
| 2013 | !-- initializations of surface quantities are done. However, this |
---|
| 2014 | !-- would create a ring dependency, hence, it is done here. Maybe delete |
---|
| 2015 | !-- disturb_heatflux and tranfer the respective code directly into the |
---|
| 2016 | !-- initialization in surface_mod. |
---|
[2232] | 2017 | IF ( TRIM( initializing_actions ) /= 'read_restart_data' .AND. & |
---|
| 2018 | TRIM( initializing_actions ) /= 'cyclic_fill' ) THEN |
---|
[2618] | 2019 | |
---|
[2232] | 2020 | IF ( use_surface_fluxes .AND. constant_heatflux .AND. & |
---|
| 2021 | random_heatflux ) THEN |
---|
| 2022 | IF ( surf_def_h(0)%ns >= 1 ) CALL disturb_heatflux( surf_def_h(0) ) |
---|
| 2023 | IF ( surf_lsm_h%ns >= 1 ) CALL disturb_heatflux( surf_lsm_h ) |
---|
| 2024 | IF ( surf_usm_h%ns >= 1 ) CALL disturb_heatflux( surf_usm_h ) |
---|
| 2025 | ENDIF |
---|
| 2026 | ENDIF |
---|
[680] | 2027 | |
---|
[787] | 2028 | ! |
---|
[3747] | 2029 | !-- Compute total sum of grid points and the mean surface level height for each |
---|
| 2030 | !-- statistic region. These are mainly used for horizontal averaging of |
---|
| 2031 | !-- turbulence statistics. |
---|
[2696] | 2032 | !-- ngp_2dh: number of grid points of a horizontal cross section through the |
---|
[3747] | 2033 | !-- respective statistic region |
---|
| 2034 | !-- ngp_3d: number of grid points of the respective statistic region |
---|
[2696] | 2035 | ngp_2dh_outer_l = 0 |
---|
| 2036 | ngp_2dh_outer = 0 |
---|
| 2037 | ngp_2dh_s_inner_l = 0 |
---|
| 2038 | ngp_2dh_s_inner = 0 |
---|
| 2039 | ngp_2dh_l = 0 |
---|
| 2040 | ngp_2dh = 0 |
---|
| 2041 | ngp_3d_inner_l = 0.0_wp |
---|
| 2042 | ngp_3d_inner = 0 |
---|
| 2043 | ngp_3d = 0 |
---|
| 2044 | ngp_sums = ( nz + 2 ) * ( pr_palm + max_pr_user ) |
---|
| 2045 | |
---|
| 2046 | mean_surface_level_height = 0.0_wp |
---|
| 2047 | mean_surface_level_height_l = 0.0_wp |
---|
| 2048 | ! |
---|
| 2049 | !-- To do: New concept for these non-topography grid points! |
---|
| 2050 | DO sr = 0, statistic_regions |
---|
| 2051 | DO i = nxl, nxr |
---|
| 2052 | DO j = nys, nyn |
---|
| 2053 | IF ( rmask(j,i,sr) == 1.0_wp ) THEN |
---|
| 2054 | ! |
---|
| 2055 | !-- All xy-grid points |
---|
| 2056 | ngp_2dh_l(sr) = ngp_2dh_l(sr) + 1 |
---|
| 2057 | ! |
---|
| 2058 | !-- Determine mean surface-level height. In case of downward- |
---|
| 2059 | !-- facing walls are present, more than one surface level exist. |
---|
| 2060 | !-- In this case, use the lowest surface-level height. |
---|
| 2061 | IF ( surf_def_h(0)%start_index(j,i) <= & |
---|
| 2062 | surf_def_h(0)%end_index(j,i) ) THEN |
---|
| 2063 | m = surf_def_h(0)%start_index(j,i) |
---|
| 2064 | k = surf_def_h(0)%k(m) |
---|
| 2065 | mean_surface_level_height_l(sr) = & |
---|
| 2066 | mean_surface_level_height_l(sr) + zw(k-1) |
---|
| 2067 | ENDIF |
---|
| 2068 | IF ( surf_lsm_h%start_index(j,i) <= & |
---|
| 2069 | surf_lsm_h%end_index(j,i) ) THEN |
---|
| 2070 | m = surf_lsm_h%start_index(j,i) |
---|
| 2071 | k = surf_lsm_h%k(m) |
---|
| 2072 | mean_surface_level_height_l(sr) = & |
---|
| 2073 | mean_surface_level_height_l(sr) + zw(k-1) |
---|
| 2074 | ENDIF |
---|
| 2075 | IF ( surf_usm_h%start_index(j,i) <= & |
---|
| 2076 | surf_usm_h%end_index(j,i) ) THEN |
---|
| 2077 | m = surf_usm_h%start_index(j,i) |
---|
| 2078 | k = surf_usm_h%k(m) |
---|
| 2079 | mean_surface_level_height_l(sr) = & |
---|
| 2080 | mean_surface_level_height_l(sr) + zw(k-1) |
---|
| 2081 | ENDIF |
---|
| 2082 | |
---|
| 2083 | k_surf = k - 1 |
---|
| 2084 | |
---|
| 2085 | DO k = nzb, nzt+1 |
---|
| 2086 | ! |
---|
| 2087 | !-- xy-grid points above topography |
---|
| 2088 | ngp_2dh_outer_l(k,sr) = ngp_2dh_outer_l(k,sr) + & |
---|
| 2089 | MERGE( 1, 0, BTEST( wall_flags_0(k,j,i), 24 ) ) |
---|
| 2090 | |
---|
| 2091 | ngp_2dh_s_inner_l(k,sr) = ngp_2dh_s_inner_l(k,sr) + & |
---|
| 2092 | MERGE( 1, 0, BTEST( wall_flags_0(k,j,i), 22 ) ) |
---|
| 2093 | |
---|
| 2094 | ENDDO |
---|
| 2095 | ! |
---|
| 2096 | !-- All grid points of the total domain above topography |
---|
| 2097 | ngp_3d_inner_l(sr) = ngp_3d_inner_l(sr) + ( nz - k_surf + 2 ) |
---|
| 2098 | |
---|
| 2099 | |
---|
| 2100 | |
---|
| 2101 | ENDIF |
---|
| 2102 | ENDDO |
---|
| 2103 | ENDDO |
---|
| 2104 | ENDDO |
---|
[3747] | 2105 | |
---|
[2696] | 2106 | sr = statistic_regions + 1 |
---|
| 2107 | #if defined( __parallel ) |
---|
| 2108 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 2109 | CALL MPI_ALLREDUCE( ngp_2dh_l(0), ngp_2dh(0), sr, MPI_INTEGER, MPI_SUM, & |
---|
| 2110 | comm2d, ierr ) |
---|
| 2111 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 2112 | CALL MPI_ALLREDUCE( ngp_2dh_outer_l(0,0), ngp_2dh_outer(0,0), (nz+2)*sr, & |
---|
| 2113 | MPI_INTEGER, MPI_SUM, comm2d, ierr ) |
---|
| 2114 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 2115 | CALL MPI_ALLREDUCE( ngp_2dh_s_inner_l(0,0), ngp_2dh_s_inner(0,0), & |
---|
| 2116 | (nz+2)*sr, MPI_INTEGER, MPI_SUM, comm2d, ierr ) |
---|
| 2117 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 2118 | CALL MPI_ALLREDUCE( ngp_3d_inner_l(0), ngp_3d_inner_tmp(0), sr, MPI_REAL, & |
---|
| 2119 | MPI_SUM, comm2d, ierr ) |
---|
| 2120 | ngp_3d_inner = INT( ngp_3d_inner_tmp, KIND = SELECTED_INT_KIND( 18 ) ) |
---|
| 2121 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 2122 | CALL MPI_ALLREDUCE( mean_surface_level_height_l(0), & |
---|
| 2123 | mean_surface_level_height(0), sr, MPI_REAL, & |
---|
| 2124 | MPI_SUM, comm2d, ierr ) |
---|
| 2125 | mean_surface_level_height = mean_surface_level_height / REAL( ngp_2dh ) |
---|
| 2126 | #else |
---|
| 2127 | ngp_2dh = ngp_2dh_l |
---|
| 2128 | ngp_2dh_outer = ngp_2dh_outer_l |
---|
| 2129 | ngp_2dh_s_inner = ngp_2dh_s_inner_l |
---|
| 2130 | ngp_3d_inner = INT( ngp_3d_inner_l, KIND = SELECTED_INT_KIND( 18 ) ) |
---|
| 2131 | mean_surface_level_height = mean_surface_level_height_l / REAL( ngp_2dh_l ) |
---|
| 2132 | #endif |
---|
| 2133 | |
---|
| 2134 | ngp_3d = INT ( ngp_2dh, KIND = SELECTED_INT_KIND( 18 ) ) * & |
---|
| 2135 | INT ( (nz + 2 ), KIND = SELECTED_INT_KIND( 18 ) ) |
---|
| 2136 | |
---|
| 2137 | ! |
---|
| 2138 | !-- Set a lower limit of 1 in order to avoid zero divisions in flow_statistics, |
---|
| 2139 | !-- buoyancy, etc. A zero value will occur for cases where all grid points of |
---|
| 2140 | !-- the respective subdomain lie below the surface topography |
---|
| 2141 | ngp_2dh_outer = MAX( 1, ngp_2dh_outer(:,:) ) |
---|
| 2142 | ngp_3d_inner = MAX( INT(1, KIND = SELECTED_INT_KIND( 18 )), & |
---|
| 2143 | ngp_3d_inner(:) ) |
---|
| 2144 | ngp_2dh_s_inner = MAX( 1, ngp_2dh_s_inner(:,:) ) |
---|
| 2145 | |
---|
| 2146 | DEALLOCATE( mean_surface_level_height_l, ngp_2dh_l, ngp_2dh_outer_l, & |
---|
| 2147 | ngp_3d_inner_l, ngp_3d_inner_tmp ) |
---|
| 2148 | ! |
---|
[2232] | 2149 | !-- Initialize surface forcing corresponding to large-scale forcing. Therein, |
---|
| 2150 | !-- initialize heat-fluxes, etc. via datatype. Revise it later! |
---|
| 2151 | IF ( large_scale_forcing .AND. lsf_surf ) THEN |
---|
| 2152 | IF ( use_surface_fluxes .AND. constant_heatflux ) THEN |
---|
| 2153 | CALL ls_forcing_surf ( simulated_time ) |
---|
| 2154 | ENDIF |
---|
| 2155 | ENDIF |
---|
| 2156 | ! |
---|
[3347] | 2157 | !-- Initializae 3D offline nesting in COSMO model and read data from |
---|
| 2158 | !-- external NetCDF file. |
---|
| 2159 | IF ( nesting_offline ) CALL nesting_offl_init |
---|
| 2160 | ! |
---|
[787] | 2161 | !-- Initialize quantities for special advections schemes |
---|
| 2162 | CALL init_advec |
---|
[680] | 2163 | |
---|
[667] | 2164 | ! |
---|
[680] | 2165 | !-- Impose random perturbation on the horizontal velocity field and then |
---|
| 2166 | !-- remove the divergences from the velocity field at the initial stage |
---|
[1788] | 2167 | IF ( create_disturbances .AND. disturbance_energy_limit /= 0.0_wp .AND. & |
---|
| 2168 | TRIM( initializing_actions ) /= 'read_restart_data' .AND. & |
---|
[680] | 2169 | TRIM( initializing_actions ) /= 'cyclic_fill' ) THEN |
---|
| 2170 | |
---|
[1402] | 2171 | CALL location_message( 'creating initial disturbances', .FALSE. ) |
---|
[2232] | 2172 | CALL disturb_field( 'u', tend, u ) |
---|
| 2173 | CALL disturb_field( 'v', tend, v ) |
---|
[1402] | 2174 | CALL location_message( 'finished', .TRUE. ) |
---|
[1384] | 2175 | |
---|
[1402] | 2176 | CALL location_message( 'calling pressure solver', .FALSE. ) |
---|
[680] | 2177 | n_sor = nsor_ini |
---|
| 2178 | CALL pres |
---|
| 2179 | n_sor = nsor |
---|
[1402] | 2180 | CALL location_message( 'finished', .TRUE. ) |
---|
[1384] | 2181 | |
---|
[680] | 2182 | ENDIF |
---|
| 2183 | |
---|
| 2184 | ! |
---|
[1] | 2185 | !-- If required, initialize dvrp-software |
---|
[1340] | 2186 | IF ( dt_dvrp /= 9999999.9_wp ) CALL init_dvrp |
---|
[1] | 2187 | |
---|
| 2188 | ! |
---|
[3294] | 2189 | !-- Initialize quantities for handling cloud physics. |
---|
| 2190 | !-- This routine must be called before lpm_init, becaus otherwise, |
---|
| 2191 | !-- array d_exner, needed in data_output_dvrp (called by lpm_init) is not defined. |
---|
| 2192 | IF ( .NOT. ocean_mode ) THEN |
---|
[3274] | 2193 | |
---|
| 2194 | ALLOCATE( hyp(nzb:nzt+1) ) |
---|
| 2195 | ALLOCATE( d_exner(nzb:nzt+1) ) |
---|
| 2196 | ALLOCATE( exner(nzb:nzt+1) ) |
---|
| 2197 | ALLOCATE( hyrho(nzb:nzt+1) ) |
---|
[1849] | 2198 | ! |
---|
[3274] | 2199 | !-- Check temperature in case of too large domain height |
---|
| 2200 | DO k = nzb, nzt+1 |
---|
| 2201 | IF ( ( pt_surface * exner_function(surface_pressure * 100.0_wp) - g/c_p * zu(k) ) < 0.0_wp ) THEN |
---|
| 2202 | WRITE( message_string, * ) 'absolute temperature < 0.0 at zu(', k, & |
---|
| 2203 | ') = ', zu(k) |
---|
[3685] | 2204 | CALL message( 'init_3d_model', 'PA0142', 1, 2, 0, 6, 0 ) |
---|
[3274] | 2205 | ENDIF |
---|
| 2206 | ENDDO |
---|
| 2207 | |
---|
| 2208 | ! |
---|
| 2209 | !-- Calculate vertical profile of the hydrostatic pressure (hyp) |
---|
| 2210 | hyp = barometric_formula(zu, pt_surface * exner_function(surface_pressure * 100.0_wp), surface_pressure * 100.0_wp) |
---|
| 2211 | d_exner = exner_function_invers(hyp) |
---|
| 2212 | exner = 1.0_wp / exner_function_invers(hyp) |
---|
| 2213 | hyrho = ideal_gas_law_rho_pt(hyp, pt_init) |
---|
| 2214 | ! |
---|
| 2215 | !-- Compute reference density |
---|
| 2216 | rho_surface = ideal_gas_law_rho(surface_pressure * 100.0_wp, pt_surface * exner_function(surface_pressure * 100.0_wp)) |
---|
| 2217 | |
---|
[96] | 2218 | ENDIF |
---|
[1] | 2219 | |
---|
| 2220 | ! |
---|
| 2221 | !-- If required, initialize particles |
---|
[849] | 2222 | IF ( particle_advection ) CALL lpm_init |
---|
[1585] | 2223 | ! |
---|
[3159] | 2224 | !-- If required, initialize particles |
---|
| 2225 | IF ( agents_active ) CALL mas_init |
---|
| 2226 | ! |
---|
[3347] | 2227 | !-- In case the synthetic turbulence generator does not have any information |
---|
| 2228 | !-- about the inflow turbulence, these information will be parametrized |
---|
| 2229 | !-- depending on the initial atmospheric conditions and surface properties. |
---|
| 2230 | !-- Please note, within pre-determined time intervals these turbulence |
---|
| 2231 | !-- information can be updated if desired. |
---|
[3685] | 2232 | IF ( use_syn_turb_gen .AND. parametrize_inflow_turbulence ) THEN |
---|
[3347] | 2233 | CALL stg_adjust |
---|
[2696] | 2234 | ENDIF |
---|
| 2235 | ! |
---|
[3685] | 2236 | !-- Initializing actions for all other modules |
---|
| 2237 | CALL module_interface_init |
---|
[2696] | 2238 | ! |
---|
[3685] | 2239 | !-- Initialize surface layer (done after LSM as roughness length are required |
---|
| 2240 | !-- for initialization |
---|
| 2241 | IF ( constant_flux_layer ) CALL init_surface_layer_fluxes |
---|
[2977] | 2242 | ! |
---|
[3421] | 2243 | !-- Initialize surface data output |
---|
[3685] | 2244 | IF ( surface_output ) CALL surface_data_output_init |
---|
[3472] | 2245 | ! |
---|
[673] | 2246 | !-- Initialize the ws-scheme. |
---|
[3448] | 2247 | IF ( ws_scheme_sca .OR. ws_scheme_mom ) CALL ws_init |
---|
[3711] | 2248 | ! |
---|
| 2249 | !-- Perform post-initializing checks for all other modules |
---|
| 2250 | CALL module_interface_init_checks |
---|
[1] | 2251 | |
---|
| 2252 | ! |
---|
[709] | 2253 | !-- Setting weighting factors for calculation of perturbation pressure |
---|
[1762] | 2254 | !-- and turbulent quantities from the RK substeps |
---|
[709] | 2255 | IF ( TRIM(timestep_scheme) == 'runge-kutta-3' ) THEN ! for RK3-method |
---|
| 2256 | |
---|
[1322] | 2257 | weight_substep(1) = 1._wp/6._wp |
---|
| 2258 | weight_substep(2) = 3._wp/10._wp |
---|
| 2259 | weight_substep(3) = 8._wp/15._wp |
---|
[709] | 2260 | |
---|
[1322] | 2261 | weight_pres(1) = 1._wp/3._wp |
---|
| 2262 | weight_pres(2) = 5._wp/12._wp |
---|
| 2263 | weight_pres(3) = 1._wp/4._wp |
---|
[709] | 2264 | |
---|
| 2265 | ELSEIF ( TRIM(timestep_scheme) == 'runge-kutta-2' ) THEN ! for RK2-method |
---|
| 2266 | |
---|
[1322] | 2267 | weight_substep(1) = 1._wp/2._wp |
---|
| 2268 | weight_substep(2) = 1._wp/2._wp |
---|
[673] | 2269 | |
---|
[1322] | 2270 | weight_pres(1) = 1._wp/2._wp |
---|
| 2271 | weight_pres(2) = 1._wp/2._wp |
---|
[709] | 2272 | |
---|
[1001] | 2273 | ELSE ! for Euler-method |
---|
[709] | 2274 | |
---|
[1340] | 2275 | weight_substep(1) = 1.0_wp |
---|
| 2276 | weight_pres(1) = 1.0_wp |
---|
[709] | 2277 | |
---|
[673] | 2278 | ENDIF |
---|
| 2279 | |
---|
| 2280 | ! |
---|
[1] | 2281 | !-- Initialize Rayleigh damping factors |
---|
[1340] | 2282 | rdf = 0.0_wp |
---|
| 2283 | rdf_sc = 0.0_wp |
---|
| 2284 | IF ( rayleigh_damping_factor /= 0.0_wp ) THEN |
---|
[3294] | 2285 | |
---|
| 2286 | IF ( .NOT. ocean_mode ) THEN |
---|
[108] | 2287 | DO k = nzb+1, nzt |
---|
| 2288 | IF ( zu(k) >= rayleigh_damping_height ) THEN |
---|
[1788] | 2289 | rdf(k) = rayleigh_damping_factor * & |
---|
[1340] | 2290 | ( SIN( pi * 0.5_wp * ( zu(k) - rayleigh_damping_height ) & |
---|
[1788] | 2291 | / ( zu(nzt) - rayleigh_damping_height ) ) & |
---|
[1] | 2292 | )**2 |
---|
[108] | 2293 | ENDIF |
---|
| 2294 | ENDDO |
---|
| 2295 | ELSE |
---|
[3294] | 2296 | ! |
---|
| 2297 | !-- In ocean mode, rayleigh damping is applied in the lower part of the |
---|
| 2298 | !-- model domain |
---|
[108] | 2299 | DO k = nzt, nzb+1, -1 |
---|
| 2300 | IF ( zu(k) <= rayleigh_damping_height ) THEN |
---|
[1788] | 2301 | rdf(k) = rayleigh_damping_factor * & |
---|
[1340] | 2302 | ( SIN( pi * 0.5_wp * ( rayleigh_damping_height - zu(k) ) & |
---|
[1788] | 2303 | / ( rayleigh_damping_height - zu(nzb+1) ) ) & |
---|
[108] | 2304 | )**2 |
---|
| 2305 | ENDIF |
---|
| 2306 | ENDDO |
---|
| 2307 | ENDIF |
---|
[3294] | 2308 | |
---|
[1] | 2309 | ENDIF |
---|
[785] | 2310 | IF ( scalar_rayleigh_damping ) rdf_sc = rdf |
---|
[1] | 2311 | |
---|
| 2312 | ! |
---|
[240] | 2313 | !-- Initialize the starting level and the vertical smoothing factor used for |
---|
| 2314 | !-- the external pressure gradient |
---|
[1340] | 2315 | dp_smooth_factor = 1.0_wp |
---|
[240] | 2316 | IF ( dp_external ) THEN |
---|
| 2317 | ! |
---|
| 2318 | !-- Set the starting level dp_level_ind_b only if it has not been set before |
---|
| 2319 | !-- (e.g. in init_grid). |
---|
| 2320 | IF ( dp_level_ind_b == 0 ) THEN |
---|
| 2321 | ind_array = MINLOC( ABS( dp_level_b - zu ) ) |
---|
| 2322 | dp_level_ind_b = ind_array(1) - 1 + nzb |
---|
| 2323 | ! MINLOC uses lower array bound 1 |
---|
| 2324 | ENDIF |
---|
| 2325 | IF ( dp_smooth ) THEN |
---|
[1340] | 2326 | dp_smooth_factor(:dp_level_ind_b) = 0.0_wp |
---|
[240] | 2327 | DO k = dp_level_ind_b+1, nzt |
---|
[1340] | 2328 | dp_smooth_factor(k) = 0.5_wp * ( 1.0_wp + SIN( pi * & |
---|
| 2329 | ( REAL( k - dp_level_ind_b, KIND=wp ) / & |
---|
| 2330 | REAL( nzt - dp_level_ind_b, KIND=wp ) - 0.5_wp ) ) ) |
---|
[240] | 2331 | ENDDO |
---|
| 2332 | ENDIF |
---|
| 2333 | ENDIF |
---|
| 2334 | |
---|
| 2335 | ! |
---|
[978] | 2336 | !-- Initialize damping zone for the potential temperature in case of |
---|
| 2337 | !-- non-cyclic lateral boundaries. The damping zone has the maximum value |
---|
| 2338 | !-- at the inflow boundary and decreases to zero at pt_damping_width. |
---|
[1340] | 2339 | ptdf_x = 0.0_wp |
---|
| 2340 | ptdf_y = 0.0_wp |
---|
[1159] | 2341 | IF ( bc_lr_dirrad ) THEN |
---|
[996] | 2342 | DO i = nxl, nxr |
---|
[978] | 2343 | IF ( ( i * dx ) < pt_damping_width ) THEN |
---|
[1340] | 2344 | ptdf_x(i) = pt_damping_factor * ( SIN( pi * 0.5_wp * & |
---|
| 2345 | REAL( pt_damping_width - i * dx, KIND=wp ) / ( & |
---|
[1788] | 2346 | REAL( pt_damping_width, KIND=wp ) ) ) )**2 |
---|
[73] | 2347 | ENDIF |
---|
| 2348 | ENDDO |
---|
[1159] | 2349 | ELSEIF ( bc_lr_raddir ) THEN |
---|
[996] | 2350 | DO i = nxl, nxr |
---|
[978] | 2351 | IF ( ( i * dx ) > ( nx * dx - pt_damping_width ) ) THEN |
---|
[1322] | 2352 | ptdf_x(i) = pt_damping_factor * & |
---|
[1340] | 2353 | SIN( pi * 0.5_wp * & |
---|
| 2354 | ( ( i - nx ) * dx + pt_damping_width ) / & |
---|
| 2355 | REAL( pt_damping_width, KIND=wp ) )**2 |
---|
[73] | 2356 | ENDIF |
---|
[978] | 2357 | ENDDO |
---|
[1159] | 2358 | ELSEIF ( bc_ns_dirrad ) THEN |
---|
[996] | 2359 | DO j = nys, nyn |
---|
[978] | 2360 | IF ( ( j * dy ) > ( ny * dy - pt_damping_width ) ) THEN |
---|
[1322] | 2361 | ptdf_y(j) = pt_damping_factor * & |
---|
[1340] | 2362 | SIN( pi * 0.5_wp * & |
---|
| 2363 | ( ( j - ny ) * dy + pt_damping_width ) / & |
---|
| 2364 | REAL( pt_damping_width, KIND=wp ) )**2 |
---|
[1] | 2365 | ENDIF |
---|
[978] | 2366 | ENDDO |
---|
[1159] | 2367 | ELSEIF ( bc_ns_raddir ) THEN |
---|
[996] | 2368 | DO j = nys, nyn |
---|
[978] | 2369 | IF ( ( j * dy ) < pt_damping_width ) THEN |
---|
[1322] | 2370 | ptdf_y(j) = pt_damping_factor * & |
---|
[1340] | 2371 | SIN( pi * 0.5_wp * & |
---|
| 2372 | ( pt_damping_width - j * dy ) / & |
---|
| 2373 | REAL( pt_damping_width, KIND=wp ) )**2 |
---|
[1] | 2374 | ENDIF |
---|
[73] | 2375 | ENDDO |
---|
[1] | 2376 | ENDIF |
---|
[51] | 2377 | |
---|
[1] | 2378 | ! |
---|
| 2379 | !-- Input binary data file is not needed anymore. This line must be placed |
---|
| 2380 | !-- after call of user_init! |
---|
| 2381 | CALL close_file( 13 ) |
---|
[2934] | 2382 | ! |
---|
| 2383 | !-- In case of nesting, put an barrier to assure that all parent and child |
---|
| 2384 | !-- domains finished initialization. |
---|
| 2385 | #if defined( __parallel ) |
---|
| 2386 | IF ( nested_run ) CALL MPI_BARRIER( MPI_COMM_WORLD, ierr ) |
---|
| 2387 | #endif |
---|
[1] | 2388 | |
---|
[2934] | 2389 | |
---|
[1402] | 2390 | CALL location_message( 'leaving init_3d_model', .TRUE. ) |
---|
[1] | 2391 | |
---|
| 2392 | END SUBROUTINE init_3d_model |
---|