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