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