[2586] | 1 | !> @file netcdf_data_input_mod.f90 |
---|
| 2 | !------------------------------------------------------------------------------! |
---|
[2696] | 3 | ! This file is part of the PALM model system. |
---|
[2586] | 4 | ! |
---|
| 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. |
---|
| 9 | ! |
---|
| 10 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
| 11 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
| 12 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
| 13 | ! |
---|
| 14 | ! You should have received a copy of the GNU General Public License along with |
---|
| 15 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
| 16 | ! |
---|
[2718] | 17 | ! Copyright 1997-2018 Leibniz Universitaet Hannover |
---|
[2586] | 18 | !------------------------------------------------------------------------------! |
---|
| 19 | ! |
---|
| 20 | ! Current revisions: |
---|
| 21 | ! ----------------- |
---|
| 22 | ! |
---|
[2591] | 23 | ! |
---|
[2586] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
[2696] | 26 | ! $Id: netcdf_data_input_mod.f90 2963 2018-04-12 14:47:44Z suehring $ |
---|
[2963] | 27 | ! - Revise checks for static input variables. |
---|
| 28 | ! - Introduce index for vegetation/wall, pavement/green-wall and water/window |
---|
| 29 | ! surfaces, for clearer access of surface fraction, albedo, emissivity, etc. . |
---|
| 30 | ! |
---|
| 31 | ! 2958 2018-04-11 15:38:13Z suehring |
---|
[2958] | 32 | ! Synchronize longitude and latitude between nested model domains, values are |
---|
| 33 | ! taken from the root model. |
---|
| 34 | ! |
---|
| 35 | ! 2955 2018-04-09 15:14:01Z suehring |
---|
[2955] | 36 | ! Extend checks for consistent setting of buildings, its ID and type. |
---|
| 37 | ! Add log-points to measure CPU time of NetCDF data input. |
---|
| 38 | ! |
---|
| 39 | ! 2953 2018-04-09 11:26:02Z suehring |
---|
[2953] | 40 | ! Bugfix in checks for initialization data |
---|
| 41 | ! |
---|
| 42 | ! 2947 2018-04-04 18:01:41Z suehring |
---|
[2947] | 43 | ! Checks for dynamic input revised |
---|
| 44 | ! |
---|
| 45 | ! 2946 2018-04-04 17:01:23Z suehring |
---|
[2946] | 46 | ! Bugfix for revision 2945, perform checks only if dynamic input file is |
---|
| 47 | ! available. |
---|
| 48 | ! |
---|
| 49 | ! 2945 2018-04-04 16:27:14Z suehring |
---|
[2945] | 50 | ! - Mimic for topography input slightly revised, in order to enable consistency |
---|
| 51 | ! checks |
---|
| 52 | ! - Add checks for dimensions in dynamic input file and move already existing |
---|
| 53 | ! checks |
---|
| 54 | ! |
---|
| 55 | ! 2938 2018-03-27 15:52:42Z suehring |
---|
[2938] | 56 | ! Initial read of geostrophic wind components from dynamic driver. |
---|
| 57 | ! |
---|
| 58 | ! 2773 2018-01-30 14:12:54Z suehring |
---|
[2930] | 59 | ! Revise checks for surface_fraction. |
---|
| 60 | ! |
---|
| 61 | ! 2925 2018-03-23 14:54:11Z suehring |
---|
[2925] | 62 | ! Check for further inconsistent settings of surface_fractions. |
---|
| 63 | ! Some messages slightly rephrased and error numbers renamed. |
---|
| 64 | ! |
---|
| 65 | ! 2898 2018-03-15 13:03:01Z suehring |
---|
[2898] | 66 | ! Check if each building has a type. Further, check if dimensions in static |
---|
| 67 | ! input file match the model dimensions. |
---|
| 68 | ! |
---|
| 69 | ! 2897 2018-03-15 11:47:16Z suehring |
---|
[2897] | 70 | ! Relax restrictions for topography input, terrain and building heights can be |
---|
| 71 | ! input separately and are not mandatory any more. |
---|
| 72 | ! |
---|
| 73 | ! 2874 2018-03-13 10:55:42Z knoop |
---|
[2874] | 74 | ! Bugfix: wrong placement of netcdf cpp-macros fixed |
---|
| 75 | ! |
---|
| 76 | ! 2794 2018-02-07 14:09:43Z knoop |
---|
[2787] | 77 | ! Check if 3D building input is consistent to numeric grid. |
---|
| 78 | ! |
---|
| 79 | ! 2773 2018-01-30 14:12:54Z suehring |
---|
[2773] | 80 | ! - Enable initialization with 3D topography. |
---|
| 81 | ! - Move check for correct initialization in nesting mode to check_parameters. |
---|
| 82 | ! |
---|
| 83 | ! 2772 2018-01-29 13:10:35Z suehring |
---|
[2772] | 84 | ! Initialization of simulation independent on land-surface model. |
---|
| 85 | ! |
---|
| 86 | ! 2746 2018-01-15 12:06:04Z suehring |
---|
[2746] | 87 | ! Read plant-canopy variables independently on land-surface model usage |
---|
| 88 | ! |
---|
| 89 | ! 2718 2018-01-02 08:49:38Z maronga |
---|
[2716] | 90 | ! Corrected "Former revisions" section |
---|
| 91 | ! |
---|
| 92 | ! 2711 2017-12-20 17:04:49Z suehring |
---|
[2711] | 93 | ! Rename subroutine close_file to avoid double-naming. |
---|
| 94 | ! |
---|
| 95 | ! 2700 2017-12-15 14:12:35Z suehring |
---|
[2716] | 96 | ! |
---|
| 97 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
| 98 | ! Initial revision (suehring) |
---|
[2591] | 99 | ! |
---|
| 100 | ! |
---|
[2696] | 101 | ! |
---|
| 102 | ! |
---|
| 103 | ! Authors: |
---|
| 104 | ! -------- |
---|
| 105 | ! @author Matthias Suehring |
---|
| 106 | ! |
---|
[2586] | 107 | ! Description: |
---|
| 108 | ! ------------ |
---|
| 109 | !> Modulue contains routines to input data according to Palm input data |
---|
| 110 | !> standart using dynamic and static input files. |
---|
| 111 | !> |
---|
| 112 | !> @todo - Order input alphabetically |
---|
| 113 | !> @todo - Revise error messages and error numbers |
---|
| 114 | !> @todo - Input of missing quantities (chemical species, emission rates) |
---|
| 115 | !> @todo - Defninition and input of still missing variable attributes |
---|
| 116 | !> @todo - Input of initial geostrophic wind profiles with cyclic conditions. |
---|
| 117 | !------------------------------------------------------------------------------! |
---|
| 118 | MODULE netcdf_data_input_mod |
---|
| 119 | |
---|
| 120 | USE control_parameters, & |
---|
[2589] | 121 | ONLY: coupling_char, io_blocks, io_group |
---|
[2586] | 122 | |
---|
[2955] | 123 | USE cpulog, & |
---|
| 124 | ONLY: cpu_log, log_point_s |
---|
| 125 | |
---|
[2586] | 126 | USE kinds |
---|
| 127 | |
---|
| 128 | #if defined ( __netcdf ) |
---|
| 129 | USE NETCDF |
---|
| 130 | #endif |
---|
| 131 | |
---|
| 132 | USE pegrid |
---|
[2963] | 133 | |
---|
| 134 | USE surface_mod, & |
---|
| 135 | ONLY: ind_pav_green, ind_veg_wall, ind_wat_win |
---|
[2586] | 136 | ! |
---|
[2898] | 137 | !-- Define type for dimensions. |
---|
| 138 | TYPE dims_xy |
---|
| 139 | INTEGER(iwp) :: nx !< dimension length in x |
---|
| 140 | INTEGER(iwp) :: ny !< dimension length in y |
---|
[2945] | 141 | INTEGER(iwp) :: nz !< dimension length in z |
---|
[2898] | 142 | REAL(wp), DIMENSION(:), ALLOCATABLE :: x !< dimension array in x |
---|
| 143 | REAL(wp), DIMENSION(:), ALLOCATABLE :: y !< dimension array in y |
---|
[2945] | 144 | REAL(wp), DIMENSION(:), ALLOCATABLE :: z !< dimension array in z |
---|
[2898] | 145 | END TYPE dims_xy |
---|
| 146 | ! |
---|
[2586] | 147 | !-- Define data type for nesting in larger-scale models like COSMO. |
---|
| 148 | !-- Data type comprises u, v, w, pt, and q at lateral and top boundaries. |
---|
| 149 | TYPE force_type |
---|
| 150 | |
---|
| 151 | CHARACTER(LEN=100), DIMENSION(:), ALLOCATABLE :: var_names |
---|
| 152 | |
---|
| 153 | INTEGER(iwp) :: nt !< number of time levels in dynamic input file |
---|
| 154 | INTEGER(iwp) :: nzu !< number of vertical levels on scalar grid in dynamic input file |
---|
| 155 | INTEGER(iwp) :: nzw !< number of vertical levels on w grid in dynamic input file |
---|
| 156 | INTEGER(iwp) :: tind !< time index for reference time in large-scale forcing data |
---|
| 157 | INTEGER(iwp) :: tind_p !< time index for following time in large-scale forcing data |
---|
| 158 | |
---|
| 159 | LOGICAL :: init = .FALSE. |
---|
| 160 | LOGICAL :: interpolated = .FALSE. |
---|
| 161 | LOGICAL :: from_file = .FALSE. |
---|
| 162 | |
---|
| 163 | REAL(wp), DIMENSION(:), ALLOCATABLE :: surface_pressure !< time dependent surface pressure |
---|
| 164 | REAL(wp), DIMENSION(:), ALLOCATABLE :: time !< time levels in dynamic input file |
---|
| 165 | REAL(wp), DIMENSION(:), ALLOCATABLE :: zu_atmos !< vertical levels at scalar grid in dynamic input file |
---|
| 166 | REAL(wp), DIMENSION(:), ALLOCATABLE :: zw_atmos !< vertical levels at w grid in dynamic input file |
---|
| 167 | |
---|
[2938] | 168 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: ug !< domain-averaged geostrophic component |
---|
| 169 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: vg !< domain-averaged geostrophic component |
---|
| 170 | |
---|
[2586] | 171 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: u_left !< u-component at left boundary |
---|
| 172 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: v_left !< v-component at left boundary |
---|
| 173 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: w_left !< w-component at left boundary |
---|
| 174 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: q_left !< mixing ratio at left boundary |
---|
| 175 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: pt_left !< potentital temperautre at left boundary |
---|
| 176 | |
---|
| 177 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: u_north !< u-component at north boundary |
---|
| 178 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: v_north !< v-component at north boundary |
---|
| 179 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: w_north !< w-component at north boundary |
---|
| 180 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: q_north !< mixing ratio at north boundary |
---|
| 181 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: pt_north !< potentital temperautre at north boundary |
---|
| 182 | |
---|
| 183 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: u_right !< u-component at right boundary |
---|
| 184 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: v_right !< v-component at right boundary |
---|
| 185 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: w_right !< w-component at right boundary |
---|
| 186 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: q_right !< mixing ratio at right boundary |
---|
| 187 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: pt_right !< potentital temperautre at right boundary |
---|
| 188 | |
---|
| 189 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: u_south !< u-component at south boundary |
---|
| 190 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: v_south !< v-component at south boundary |
---|
| 191 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: w_south !< w-component at south boundary |
---|
| 192 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: q_south !< mixing ratio at south boundary |
---|
| 193 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: pt_south !< potentital temperautre at south boundary |
---|
| 194 | |
---|
| 195 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: u_top !< u-component at top boundary |
---|
| 196 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: v_top !< v-component at top boundary |
---|
| 197 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: w_top !< w-component at top boundary |
---|
| 198 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: q_top !< mixing ratio at top boundary |
---|
| 199 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: pt_top !< potentital temperautre at top boundary |
---|
| 200 | |
---|
| 201 | END TYPE force_type |
---|
| 202 | |
---|
| 203 | TYPE init_type |
---|
| 204 | |
---|
| 205 | INTEGER(iwp) :: lod_msoil !< level of detail - soil moisture |
---|
| 206 | INTEGER(iwp) :: lod_pt !< level of detail - pt |
---|
| 207 | INTEGER(iwp) :: lod_q !< level of detail - q |
---|
| 208 | INTEGER(iwp) :: lod_tsoil !< level of detail - soil temperature |
---|
| 209 | INTEGER(iwp) :: lod_u !< level of detail - u-component |
---|
| 210 | INTEGER(iwp) :: lod_v !< level of detail - v-component |
---|
| 211 | INTEGER(iwp) :: lod_w !< level of detail - w-component |
---|
| 212 | INTEGER(iwp) :: nx !< number of scalar grid points along x in dynamic input file |
---|
| 213 | INTEGER(iwp) :: nxu !< number of u grid points along x in dynamic input file |
---|
| 214 | INTEGER(iwp) :: ny !< number of scalar grid points along y in dynamic input file |
---|
| 215 | INTEGER(iwp) :: nyv !< number of v grid points along y in dynamic input file |
---|
| 216 | INTEGER(iwp) :: nzs !< number of vertical soil levels in dynamic input file |
---|
| 217 | INTEGER(iwp) :: nzu !< number of vertical levels on scalar grid in dynamic input file |
---|
| 218 | INTEGER(iwp) :: nzw !< number of vertical levels on w grid in dynamic input file |
---|
| 219 | |
---|
| 220 | LOGICAL :: from_file_msoil = .FALSE. !< flag indicating whether soil moisture is already initialized from file |
---|
| 221 | LOGICAL :: from_file_pt = .FALSE. !< flag indicating whether pt is already initialized from file |
---|
| 222 | LOGICAL :: from_file_q = .FALSE. !< flag indicating whether q is already initialized from file |
---|
| 223 | LOGICAL :: from_file_tsoil = .FALSE. !< flag indicating whether soil temperature is already initialized from file |
---|
| 224 | LOGICAL :: from_file_u = .FALSE. !< flag indicating whether u is already initialized from file |
---|
[2938] | 225 | LOGICAL :: from_file_ug = .FALSE. !< flag indicating whether ug is already initialized from file |
---|
[2586] | 226 | LOGICAL :: from_file_v = .FALSE. !< flag indicating whether v is already initialized from file |
---|
[2938] | 227 | LOGICAL :: from_file_vg = .FALSE. !< flag indicating whether ug is already initialized from file |
---|
| 228 | LOGICAL :: from_file_w = .FALSE. !< flag indicating whether w is already initialized from file |
---|
[2586] | 229 | |
---|
[2938] | 230 | |
---|
[2586] | 231 | REAL(wp) :: fill_msoil !< fill value for soil moisture |
---|
| 232 | REAL(wp) :: fill_pt !< fill value for pt |
---|
| 233 | REAL(wp) :: fill_q !< fill value for q |
---|
| 234 | REAL(wp) :: fill_tsoil !< fill value for soil temperature |
---|
| 235 | REAL(wp) :: fill_u !< fill value for u |
---|
| 236 | REAL(wp) :: fill_v !< fill value for v |
---|
| 237 | REAL(wp) :: fill_w !< fill value for w |
---|
| 238 | REAL(wp) :: latitude !< latitude of the southern model boundary |
---|
| 239 | REAL(wp) :: longitude !< longitude of the western model boundary |
---|
| 240 | |
---|
| 241 | REAL(wp), DIMENSION(:), ALLOCATABLE :: msoil_init !< initial vertical profile of soil moisture |
---|
| 242 | REAL(wp), DIMENSION(:), ALLOCATABLE :: pt_init !< initial vertical profile of pt |
---|
| 243 | REAL(wp), DIMENSION(:), ALLOCATABLE :: q_init !< initial vertical profile of q |
---|
| 244 | REAL(wp), DIMENSION(:), ALLOCATABLE :: tsoil_init !< initial vertical profile of soil temperature |
---|
| 245 | REAL(wp), DIMENSION(:), ALLOCATABLE :: u_init !< initial vertical profile of u |
---|
| 246 | REAL(wp), DIMENSION(:), ALLOCATABLE :: ug_init !< initial vertical profile of ug |
---|
| 247 | REAL(wp), DIMENSION(:), ALLOCATABLE :: v_init !< initial vertical profile of v |
---|
| 248 | REAL(wp), DIMENSION(:), ALLOCATABLE :: vg_init !< initial vertical profile of ug |
---|
| 249 | REAL(wp), DIMENSION(:), ALLOCATABLE :: w_init !< initial vertical profile of w |
---|
| 250 | REAL(wp), DIMENSION(:), ALLOCATABLE :: z_soil !< vertical levels in soil in dynamic input file, used for interpolation |
---|
| 251 | REAL(wp), DIMENSION(:), ALLOCATABLE :: zu_atmos !< vertical levels at scalar grid in dynamic input file, used for interpolation |
---|
| 252 | REAL(wp), DIMENSION(:), ALLOCATABLE :: zw_atmos !< vertical levels at w grid in dynamic input file, used for interpolation |
---|
| 253 | |
---|
| 254 | |
---|
| 255 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: msoil !< initial 3d soil moisture provide by Inifor and interpolated onto soil grid |
---|
| 256 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: tsoil !< initial 3d soil temperature provide by Inifor and interpolated onto soil grid |
---|
| 257 | |
---|
| 258 | END TYPE init_type |
---|
| 259 | |
---|
| 260 | ! |
---|
| 261 | !-- Define data structures for different input data types. |
---|
| 262 | !-- 8-bit Integer 2D |
---|
| 263 | TYPE int_2d_8bit |
---|
| 264 | INTEGER(KIND=1) :: fill = -127 !< fill value |
---|
| 265 | INTEGER(KIND=1), DIMENSION(:,:), ALLOCATABLE :: var !< respective variable |
---|
| 266 | |
---|
| 267 | LOGICAL :: from_file = .FALSE. !< flag indicating whether an input variable is available and read from file or default values are used |
---|
| 268 | END TYPE int_2d_8bit |
---|
| 269 | ! |
---|
| 270 | !-- 32-bit Integer 2D |
---|
| 271 | TYPE int_2d_32bit |
---|
| 272 | INTEGER(iwp) :: fill = -9999 !< fill value |
---|
| 273 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: var !< respective variable |
---|
| 274 | |
---|
| 275 | LOGICAL :: from_file = .FALSE. !< flag indicating whether an input variable is available and read from file or default values are used |
---|
| 276 | END TYPE int_2d_32bit |
---|
| 277 | |
---|
| 278 | ! |
---|
| 279 | !-- Define data type to read 2D real variables |
---|
| 280 | TYPE real_2d |
---|
| 281 | LOGICAL :: from_file = .FALSE. !< flag indicating whether an input variable is available and read from file or default values are used |
---|
| 282 | |
---|
| 283 | REAL(wp) :: fill = -9999.9_wp !< fill value |
---|
| 284 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: var !< respective variable |
---|
| 285 | END TYPE real_2d |
---|
| 286 | |
---|
| 287 | ! |
---|
| 288 | !-- Define data type to read 2D real variables |
---|
| 289 | TYPE real_3d |
---|
| 290 | LOGICAL :: from_file = .FALSE. !< flag indicating whether an input variable is available and read from file or default values are used |
---|
| 291 | |
---|
| 292 | INTEGER(iwp) :: nz !< number of grid points along vertical dimension |
---|
| 293 | |
---|
| 294 | REAL(wp) :: fill = -9999.9_wp !< fill value |
---|
| 295 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: var !< respective variable |
---|
| 296 | END TYPE real_3d |
---|
| 297 | ! |
---|
| 298 | !-- Define data structure where the dimension and type of the input depends |
---|
| 299 | !-- on the given level of detail. |
---|
| 300 | !-- For buildings, the input is either 2D float, or 3d byte. |
---|
| 301 | TYPE build_in |
---|
| 302 | INTEGER(iwp) :: lod = 1 !< level of detail |
---|
| 303 | INTEGER(KIND=1) :: fill2 = -127 !< fill value for lod = 2 |
---|
[2665] | 304 | INTEGER(iwp) :: nz !< number of vertical layers in file |
---|
[2586] | 305 | INTEGER(KIND=1), DIMENSION(:,:,:), ALLOCATABLE :: var_3d !< 3d variable (lod = 2) |
---|
| 306 | |
---|
[2787] | 307 | REAL(wp), DIMENSION(:), ALLOCATABLE :: z !< vertical coordinate for 3D building, used for consistency check |
---|
| 308 | |
---|
[2586] | 309 | LOGICAL :: from_file = .FALSE. !< flag indicating whether an input variable is available and read from file or default values are used |
---|
| 310 | |
---|
| 311 | REAL(wp) :: fill1 = -9999.9_wp !< fill values for lod = 1 |
---|
| 312 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: var_2d !< 2d variable (lod = 1) |
---|
| 313 | END TYPE build_in |
---|
| 314 | |
---|
| 315 | ! |
---|
| 316 | !-- For soil_type, the input is either 2D or 3D one-byte integer. |
---|
| 317 | TYPE soil_in |
---|
| 318 | INTEGER(iwp) :: lod = 1 !< level of detail |
---|
| 319 | INTEGER(KIND=1) :: fill = -127 !< fill value for lod = 2 |
---|
| 320 | INTEGER(KIND=1), DIMENSION(:,:), ALLOCATABLE :: var_2d !< 2d variable (lod = 1) |
---|
| 321 | INTEGER(KIND=1), DIMENSION(:,:,:), ALLOCATABLE :: var_3d !< 3d variable (lod = 2) |
---|
| 322 | |
---|
| 323 | LOGICAL :: from_file = .FALSE. !< flag indicating whether an input variable is available and read from file or default values are used |
---|
| 324 | END TYPE soil_in |
---|
| 325 | |
---|
| 326 | ! |
---|
| 327 | !-- Define data type for fractions between surface types |
---|
| 328 | TYPE fracs |
---|
| 329 | INTEGER(iwp) :: nf !< total number of fractions |
---|
| 330 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: nfracs !< dimension array for fraction |
---|
| 331 | |
---|
| 332 | LOGICAL :: from_file = .FALSE. !< flag indicating whether an input variable is available and read from file or default values are used |
---|
| 333 | |
---|
| 334 | REAL(wp) :: fill = -9999.9_wp !< fill value |
---|
| 335 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: frac !< respective fraction between different surface types |
---|
| 336 | END TYPE fracs |
---|
| 337 | ! |
---|
| 338 | !-- Data type for parameter lists, Depending on the given level of detail, |
---|
| 339 | !-- the input is 3D or 4D |
---|
| 340 | TYPE pars |
---|
| 341 | INTEGER(iwp) :: lod = 1 !< level of detail |
---|
| 342 | INTEGER(iwp) :: np !< total number of parameters |
---|
| 343 | INTEGER(iwp) :: nz !< vertical dimension - number of soil layers |
---|
| 344 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: layers !< dimension array for soil layers |
---|
| 345 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: pars !< dimension array for parameters |
---|
| 346 | |
---|
| 347 | LOGICAL :: from_file = .FALSE. !< flag indicating whether an input variable is available and read from file or default values are used |
---|
| 348 | |
---|
| 349 | REAL(wp) :: fill = -9999.9_wp !< fill value |
---|
| 350 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: pars_xy !< respective parameters, level of detail = 1 |
---|
| 351 | REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE :: pars_xyz !< respective parameters, level of detail = 2 |
---|
| 352 | END TYPE pars |
---|
[2898] | 353 | ! |
---|
| 354 | !-- Define variables |
---|
[2945] | 355 | TYPE(dims_xy) :: dim_static !< data structure for x, y-dimension in static input file |
---|
[2586] | 356 | |
---|
[2898] | 357 | TYPE(force_type) :: force !< data structure for data input at lateral and top boundaries (provided by Inifor) |
---|
[2586] | 358 | |
---|
| 359 | TYPE(init_type) :: init_3d !< data structure for the initialization of the 3D flow and soil fields |
---|
| 360 | TYPE(init_type) :: init_model !< data structure for the initialization of the model |
---|
| 361 | |
---|
| 362 | ! |
---|
| 363 | !-- Define 2D variables of type NC_BYTE |
---|
| 364 | TYPE(int_2d_8bit) :: albedo_type_f !< input variable for albedo type |
---|
| 365 | TYPE(int_2d_8bit) :: building_type_f !< input variable for building type |
---|
| 366 | TYPE(int_2d_8bit) :: pavement_type_f !< input variable for pavenment type |
---|
[2664] | 367 | TYPE(int_2d_8bit) :: street_crossing_f !< input variable for water type |
---|
| 368 | TYPE(int_2d_8bit) :: street_type_f !< input variable for water type |
---|
[2586] | 369 | TYPE(int_2d_8bit) :: vegetation_type_f !< input variable for vegetation type |
---|
| 370 | TYPE(int_2d_8bit) :: water_type_f !< input variable for water type |
---|
| 371 | |
---|
| 372 | ! |
---|
| 373 | !-- Define 2D variables of type NC_INT |
---|
| 374 | TYPE(int_2d_32bit) :: building_id_f !< input variable for building ID |
---|
| 375 | ! |
---|
| 376 | !-- Define 2D variables of type NC_FLOAT |
---|
| 377 | TYPE(real_2d) :: terrain_height_f !< input variable for terrain height |
---|
| 378 | ! |
---|
| 379 | !-- Define 3D variables of type NC_FLOAT |
---|
| 380 | TYPE(real_3d) :: basal_area_density_f !< input variable for basal area density - resolved vegetation |
---|
| 381 | TYPE(real_3d) :: leaf_area_density_f !< input variable for leaf area density - resolved vegetation |
---|
| 382 | TYPE(real_3d) :: root_area_density_lad_f !< input variable for root area density - resolved vegetation |
---|
| 383 | TYPE(real_3d) :: root_area_density_lsm_f !< input variable for root area density - parametrized vegetation |
---|
| 384 | |
---|
| 385 | ! |
---|
| 386 | !-- Define input variable for buildings |
---|
| 387 | TYPE(build_in) :: buildings_f !< input variable for buildings |
---|
| 388 | ! |
---|
| 389 | !-- Define input variables for soil_type |
---|
| 390 | TYPE(soil_in) :: soil_type_f !< input variable for soil type |
---|
| 391 | |
---|
| 392 | TYPE(fracs) :: surface_fraction_f !< input variable for surface fraction |
---|
| 393 | |
---|
| 394 | TYPE(pars) :: albedo_pars_f !< input variable for albedo parameters |
---|
| 395 | TYPE(pars) :: building_pars_f !< input variable for building parameters |
---|
| 396 | TYPE(pars) :: pavement_pars_f !< input variable for pavement parameters |
---|
| 397 | TYPE(pars) :: pavement_subsurface_pars_f !< input variable for pavement parameters |
---|
| 398 | TYPE(pars) :: soil_pars_f !< input variable for soil parameters |
---|
| 399 | TYPE(pars) :: vegetation_pars_f !< input variable for vegetation parameters |
---|
| 400 | TYPE(pars) :: water_pars_f !< input variable for water parameters |
---|
| 401 | |
---|
| 402 | |
---|
| 403 | CHARACTER(LEN=3) :: char_lod = 'lod' !< name of level-of-detail attribute in NetCDF file |
---|
| 404 | |
---|
| 405 | CHARACTER(LEN=10) :: char_fill = '_FillValue' !< name of fill value attribute in NetCDF file |
---|
| 406 | CHARACTER(LEN=10) :: char_lon = 'origin_lon' !< name of global attribute for longitude in NetCDF file |
---|
| 407 | CHARACTER(LEN=10) :: char_lat = 'origin_lat' !< name of global attribute for latitude in NetCDF file |
---|
| 408 | |
---|
| 409 | CHARACTER(LEN=100) :: input_file_static = 'PIDS_STATIC' !< Name of file which comprises static input data |
---|
| 410 | CHARACTER(LEN=100) :: input_file_dynamic = 'PIDS_DYNAMIC' !< Name of file which comprises dynamic input data |
---|
| 411 | |
---|
| 412 | INTEGER(iwp) :: nc_stat !< return value of nf90 function call |
---|
| 413 | |
---|
| 414 | LOGICAL :: input_pids_static = .FALSE. !< Flag indicating whether Palm-input-data-standard file containing static information exists |
---|
| 415 | LOGICAL :: input_pids_dynamic = .FALSE. !< Flag indicating whether Palm-input-data-standard file containing dynamic information exists |
---|
| 416 | |
---|
| 417 | SAVE |
---|
| 418 | |
---|
| 419 | PRIVATE |
---|
| 420 | |
---|
| 421 | INTERFACE netcdf_data_input_interpolate |
---|
| 422 | MODULE PROCEDURE netcdf_data_input_interpolate_1d |
---|
| 423 | MODULE PROCEDURE netcdf_data_input_interpolate_1d_soil |
---|
| 424 | MODULE PROCEDURE netcdf_data_input_interpolate_2d |
---|
| 425 | MODULE PROCEDURE netcdf_data_input_interpolate_3d |
---|
| 426 | END INTERFACE netcdf_data_input_interpolate |
---|
| 427 | |
---|
[2637] | 428 | INTERFACE netcdf_data_input_check_dynamic |
---|
| 429 | MODULE PROCEDURE netcdf_data_input_check_dynamic |
---|
| 430 | END INTERFACE netcdf_data_input_check_dynamic |
---|
| 431 | |
---|
[2586] | 432 | INTERFACE netcdf_data_input_check_static |
---|
| 433 | MODULE PROCEDURE netcdf_data_input_check_static |
---|
| 434 | END INTERFACE netcdf_data_input_check_static |
---|
| 435 | |
---|
| 436 | INTERFACE netcdf_data_input_inquire_file |
---|
| 437 | MODULE PROCEDURE netcdf_data_input_inquire_file |
---|
| 438 | END INTERFACE netcdf_data_input_inquire_file |
---|
| 439 | |
---|
| 440 | INTERFACE netcdf_data_input_init |
---|
| 441 | MODULE PROCEDURE netcdf_data_input_init |
---|
| 442 | END INTERFACE netcdf_data_input_init |
---|
| 443 | |
---|
| 444 | INTERFACE netcdf_data_input_init_3d |
---|
| 445 | MODULE PROCEDURE netcdf_data_input_init_3d |
---|
| 446 | END INTERFACE netcdf_data_input_init_3d |
---|
| 447 | |
---|
| 448 | INTERFACE netcdf_data_input_lsf |
---|
| 449 | MODULE PROCEDURE netcdf_data_input_lsf |
---|
| 450 | END INTERFACE netcdf_data_input_lsf |
---|
| 451 | |
---|
| 452 | INTERFACE netcdf_data_input_surface_data |
---|
| 453 | MODULE PROCEDURE netcdf_data_input_surface_data |
---|
| 454 | END INTERFACE netcdf_data_input_surface_data |
---|
| 455 | |
---|
| 456 | INTERFACE netcdf_data_input_topo |
---|
| 457 | MODULE PROCEDURE netcdf_data_input_topo |
---|
| 458 | END INTERFACE netcdf_data_input_topo |
---|
| 459 | |
---|
| 460 | INTERFACE get_variable |
---|
| 461 | MODULE PROCEDURE get_variable_1d_int |
---|
| 462 | MODULE PROCEDURE get_variable_1d_real |
---|
| 463 | MODULE PROCEDURE get_variable_2d_int8 |
---|
| 464 | MODULE PROCEDURE get_variable_2d_int32 |
---|
| 465 | MODULE PROCEDURE get_variable_2d_real |
---|
| 466 | MODULE PROCEDURE get_variable_3d_int8 |
---|
| 467 | MODULE PROCEDURE get_variable_3d_real |
---|
| 468 | MODULE PROCEDURE get_variable_4d_real |
---|
| 469 | END INTERFACE get_variable |
---|
| 470 | |
---|
[2938] | 471 | INTERFACE get_variable_pr |
---|
| 472 | MODULE PROCEDURE get_variable_pr |
---|
| 473 | END INTERFACE get_variable_pr |
---|
| 474 | |
---|
[2586] | 475 | INTERFACE get_attribute |
---|
| 476 | MODULE PROCEDURE get_attribute_real |
---|
| 477 | MODULE PROCEDURE get_attribute_int8 |
---|
| 478 | MODULE PROCEDURE get_attribute_int32 |
---|
| 479 | MODULE PROCEDURE get_attribute_string |
---|
| 480 | END INTERFACE get_attribute |
---|
| 481 | |
---|
| 482 | ! |
---|
| 483 | !-- Public variables |
---|
| 484 | PUBLIC albedo_pars_f, albedo_type_f, basal_area_density_f, buildings_f, & |
---|
| 485 | building_id_f, building_pars_f, building_type_f, force, init_3d, & |
---|
[2640] | 486 | init_model, input_file_static, input_pids_static, & |
---|
| 487 | input_pids_dynamic, leaf_area_density_f, & |
---|
[2586] | 488 | pavement_pars_f, pavement_subsurface_pars_f, pavement_type_f, & |
---|
| 489 | root_area_density_lad_f, root_area_density_lsm_f, soil_pars_f, & |
---|
[2664] | 490 | soil_type_f, street_crossing_f, street_type_f, surface_fraction_f, & |
---|
| 491 | terrain_height_f, vegetation_pars_f, vegetation_type_f, & |
---|
| 492 | water_pars_f, water_type_f |
---|
[2586] | 493 | |
---|
| 494 | ! |
---|
| 495 | !-- Public subroutines |
---|
[2637] | 496 | PUBLIC netcdf_data_input_check_dynamic, netcdf_data_input_check_static, & |
---|
| 497 | netcdf_data_input_inquire_file, & |
---|
[2586] | 498 | netcdf_data_input_init, netcdf_data_input_init_3d, & |
---|
| 499 | netcdf_data_input_interpolate, netcdf_data_input_lsf, & |
---|
| 500 | netcdf_data_input_surface_data, netcdf_data_input_topo |
---|
| 501 | |
---|
| 502 | CONTAINS |
---|
| 503 | |
---|
| 504 | !------------------------------------------------------------------------------! |
---|
| 505 | ! Description: |
---|
| 506 | ! ------------ |
---|
[2589] | 507 | !> Inquires whether NetCDF input files according to Palm-input-data standard |
---|
[2637] | 508 | !> exist. Moreover, basic checks are performed. |
---|
[2586] | 509 | !------------------------------------------------------------------------------! |
---|
| 510 | SUBROUTINE netcdf_data_input_inquire_file |
---|
| 511 | |
---|
| 512 | USE control_parameters, & |
---|
[2659] | 513 | ONLY: land_surface, message_string, topo_no_distinct, urban_surface |
---|
[2586] | 514 | |
---|
| 515 | IMPLICIT NONE |
---|
| 516 | |
---|
[2637] | 517 | LOGICAL :: check_nest !< flag indicating whether a check passed or not |
---|
| 518 | |
---|
[2586] | 519 | #if defined ( __netcdf ) |
---|
[2589] | 520 | INQUIRE( FILE = TRIM( input_file_static ) // TRIM( coupling_char ), & |
---|
| 521 | EXIST = input_pids_static ) |
---|
| 522 | INQUIRE( FILE = TRIM( input_file_dynamic ) // TRIM( coupling_char ), & |
---|
| 523 | EXIST = input_pids_dynamic ) |
---|
[2586] | 524 | #endif |
---|
| 525 | |
---|
[2794] | 526 | ! |
---|
| 527 | !-- As long as topography can be input via ASCII format, no distinction |
---|
| 528 | !-- between building and terrain can be made. This case, classify all |
---|
| 529 | !-- surfaces as default type. Same in case land-surface and urban-surface |
---|
| 530 | !-- model are not applied. |
---|
[2586] | 531 | IF ( .NOT. input_pids_static ) THEN |
---|
| 532 | topo_no_distinct = .TRUE. |
---|
| 533 | ENDIF |
---|
| 534 | |
---|
| 535 | END SUBROUTINE netcdf_data_input_inquire_file |
---|
| 536 | |
---|
| 537 | !------------------------------------------------------------------------------! |
---|
| 538 | ! Description: |
---|
| 539 | ! ------------ |
---|
| 540 | !> Reads global attributes required for initialization of the model. |
---|
| 541 | !------------------------------------------------------------------------------! |
---|
| 542 | SUBROUTINE netcdf_data_input_init |
---|
| 543 | |
---|
| 544 | IMPLICIT NONE |
---|
| 545 | |
---|
| 546 | INTEGER(iwp) :: id_mod !< NetCDF id of input file |
---|
[2646] | 547 | INTEGER(iwp) :: ii !< running index for IO blocks |
---|
[2586] | 548 | |
---|
| 549 | IF ( .NOT. input_pids_static ) RETURN |
---|
| 550 | |
---|
| 551 | DO ii = 0, io_blocks-1 |
---|
| 552 | IF ( ii == io_group ) THEN |
---|
| 553 | #if defined ( __netcdf ) |
---|
| 554 | ! |
---|
| 555 | !-- Open file in read-only mode |
---|
[2589] | 556 | CALL open_read_file( TRIM( input_file_static ) // & |
---|
| 557 | TRIM( coupling_char ), id_mod ) |
---|
[2586] | 558 | ! |
---|
| 559 | !-- Read global attribute for latitude and longitude |
---|
| 560 | CALL get_attribute( id_mod, char_lat, & |
---|
| 561 | init_model%latitude, .TRUE. ) |
---|
| 562 | |
---|
| 563 | CALL get_attribute( id_mod, char_lon, & |
---|
| 564 | init_model%longitude, .TRUE. ) |
---|
| 565 | ! |
---|
| 566 | !-- Finally, close input file |
---|
[2711] | 567 | CALL close_input_file( id_mod ) |
---|
[2586] | 568 | #endif |
---|
| 569 | ENDIF |
---|
| 570 | #if defined( __parallel ) |
---|
| 571 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 572 | #endif |
---|
| 573 | ENDDO |
---|
[2958] | 574 | ! |
---|
| 575 | !-- In case of nested runs, each model domain might have different longitude |
---|
| 576 | !-- and latitude, which would result in different Coriolis parameters and |
---|
| 577 | !-- sun-zenith angles. To avoid this, longitude and latitude in each model |
---|
| 578 | !-- domain will be set to the values of the root model. Please note, this |
---|
| 579 | !-- synchronization is required already here. |
---|
| 580 | #if defined( __parallel ) |
---|
| 581 | CALL MPI_BCAST( init_model%latitude, 1, MPI_REAL, 0, & |
---|
| 582 | MPI_COMM_WORLD, ierr ) |
---|
| 583 | CALL MPI_BCAST( init_model%longitude, 1, MPI_REAL, 0, & |
---|
| 584 | MPI_COMM_WORLD, ierr ) |
---|
| 585 | #endif |
---|
[2586] | 586 | |
---|
[2958] | 587 | |
---|
[2586] | 588 | END SUBROUTINE netcdf_data_input_init |
---|
| 589 | |
---|
| 590 | !------------------------------------------------------------------------------! |
---|
| 591 | ! Description: |
---|
| 592 | ! ------------ |
---|
| 593 | !> Reads surface classification data, such as vegetation and soil type, etc. . |
---|
| 594 | !------------------------------------------------------------------------------! |
---|
| 595 | SUBROUTINE netcdf_data_input_surface_data |
---|
| 596 | |
---|
| 597 | USE control_parameters, & |
---|
[2659] | 598 | ONLY: bc_lr_cyc, bc_ns_cyc, land_surface, message_string, & |
---|
[2746] | 599 | plant_canopy, urban_surface |
---|
[2586] | 600 | |
---|
| 601 | USE indices, & |
---|
[2646] | 602 | ONLY: nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg |
---|
[2586] | 603 | |
---|
[2746] | 604 | |
---|
[2586] | 605 | IMPLICIT NONE |
---|
| 606 | |
---|
| 607 | CHARACTER(LEN=100), DIMENSION(:), ALLOCATABLE :: var_names !< variable names in static input file |
---|
| 608 | |
---|
| 609 | INTEGER(iwp) :: i !< running index along x-direction |
---|
| 610 | INTEGER(iwp) :: ii !< running index for IO blocks |
---|
| 611 | INTEGER(iwp) :: id_surf !< NetCDF id of input file |
---|
| 612 | INTEGER(iwp) :: j !< running index along y-direction |
---|
| 613 | INTEGER(iwp) :: k !< running index along z-direction |
---|
[2646] | 614 | INTEGER(iwp) :: k2 !< running index |
---|
[2586] | 615 | INTEGER(iwp) :: num_vars !< number of variables in input file |
---|
| 616 | INTEGER(iwp) :: nz_soil !< number of soil layers in file |
---|
| 617 | |
---|
[2646] | 618 | INTEGER(iwp), DIMENSION(nysg:nyng,nxlg:nxrg) :: var_exchange_int !< dummy variables used to exchange 32-bit Integer arrays |
---|
| 619 | INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE :: var_dum_int_3d !< dummy variables used to exchange real arrays |
---|
| 620 | |
---|
| 621 | REAL(wp), DIMENSION(nysg:nyng,nxlg:nxrg) :: var_exchange_real !< dummy variables used to exchange real arrays |
---|
| 622 | |
---|
| 623 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: var_dum_real_3d !< dummy variables used to exchange real arrays |
---|
| 624 | REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE :: var_dum_real_4d !< dummy variables used to exchange real arrays |
---|
| 625 | |
---|
[2659] | 626 | ! |
---|
| 627 | !-- If not static input file is available, skip this routine |
---|
[2746] | 628 | IF ( .NOT. input_pids_static ) RETURN |
---|
[2646] | 629 | ! |
---|
[2955] | 630 | !-- Measure CPU time |
---|
| 631 | CALL cpu_log( log_point_s(82), 'NetCDF input', 'start' ) |
---|
| 632 | ! |
---|
[2746] | 633 | !-- Read plant canopy variables. |
---|
| 634 | IF ( plant_canopy ) THEN |
---|
| 635 | DO ii = 0, io_blocks-1 |
---|
| 636 | IF ( ii == io_group ) THEN |
---|
| 637 | #if defined ( __netcdf ) |
---|
| 638 | ! |
---|
| 639 | !-- Open file in read-only mode |
---|
| 640 | CALL open_read_file( TRIM( input_file_static ) // & |
---|
| 641 | TRIM( coupling_char ) , id_surf ) |
---|
| 642 | ! |
---|
| 643 | !-- At first, inquire all variable names. |
---|
| 644 | !-- This will be used to check whether an optional input variable |
---|
| 645 | !-- exist or not. |
---|
| 646 | CALL inquire_num_variables( id_surf, num_vars ) |
---|
| 647 | |
---|
| 648 | ALLOCATE( var_names(1:num_vars) ) |
---|
| 649 | CALL inquire_variable_names( id_surf, var_names ) |
---|
| 650 | |
---|
| 651 | ! |
---|
| 652 | !-- Read leaf area density - resolved vegetation |
---|
| 653 | IF ( check_existence( var_names, 'leaf_area_density' ) ) THEN |
---|
| 654 | leaf_area_density_f%from_file = .TRUE. |
---|
| 655 | CALL get_attribute( id_surf, char_fill, & |
---|
| 656 | leaf_area_density_f%fill, & |
---|
| 657 | .FALSE., 'leaf_area_density' ) |
---|
| 658 | ! |
---|
| 659 | !-- Inquire number of vertical vegetation layer |
---|
| 660 | CALL get_dimension_length( id_surf, leaf_area_density_f%nz, & |
---|
| 661 | 'zlad' ) |
---|
| 662 | ! |
---|
| 663 | !-- Allocate variable for leaf-area density |
---|
| 664 | ALLOCATE( leaf_area_density_f%var( & |
---|
| 665 | 0:leaf_area_density_f%nz-1, & |
---|
| 666 | nys:nyn,nxl:nxr) ) |
---|
| 667 | |
---|
[2772] | 668 | DO i = nxl, nxr |
---|
| 669 | DO j = nys, nyn |
---|
| 670 | CALL get_variable( id_surf, 'leaf_area_density', & |
---|
| 671 | i, j, & |
---|
| 672 | leaf_area_density_f%var(:,j,i) ) |
---|
[2746] | 673 | ENDDO |
---|
[2772] | 674 | ENDDO |
---|
[2746] | 675 | ELSE |
---|
| 676 | leaf_area_density_f%from_file = .FALSE. |
---|
| 677 | ENDIF |
---|
| 678 | |
---|
| 679 | ! |
---|
| 680 | !-- Read basal area density - resolved vegetation |
---|
| 681 | IF ( check_existence( var_names, 'basal_area_density' ) ) THEN |
---|
| 682 | basal_area_density_f%from_file = .TRUE. |
---|
| 683 | CALL get_attribute( id_surf, char_fill, & |
---|
| 684 | basal_area_density_f%fill, & |
---|
| 685 | .FALSE., 'basal_area_density' ) |
---|
| 686 | ! |
---|
| 687 | !-- Inquire number of vertical vegetation layer |
---|
| 688 | CALL get_dimension_length( id_surf, & |
---|
| 689 | basal_area_density_f%nz, & |
---|
| 690 | 'zlad' ) |
---|
| 691 | ! |
---|
| 692 | !-- Allocate variable |
---|
| 693 | ALLOCATE( basal_area_density_f%var( & |
---|
| 694 | 0:basal_area_density_f%nz-1, & |
---|
| 695 | nys:nyn,nxl:nxr) ) |
---|
| 696 | |
---|
| 697 | DO i = nxl, nxr |
---|
| 698 | DO j = nys, nyn |
---|
| 699 | CALL get_variable( id_surf, 'basal_area_density', & |
---|
| 700 | i, j, & |
---|
| 701 | basal_area_density_f%var(:,j,i) ) |
---|
| 702 | ENDDO |
---|
| 703 | ENDDO |
---|
| 704 | ELSE |
---|
| 705 | basal_area_density_f%from_file = .FALSE. |
---|
| 706 | ENDIF |
---|
| 707 | |
---|
| 708 | ! |
---|
| 709 | !-- Read root area density - resolved vegetation |
---|
| 710 | IF ( check_existence( var_names, 'root_area_density_lad' ) ) THEN |
---|
| 711 | root_area_density_lad_f%from_file = .TRUE. |
---|
| 712 | CALL get_attribute( id_surf, char_fill, & |
---|
| 713 | root_area_density_lad_f%fill, & |
---|
| 714 | .FALSE., 'root_area_density_lad' ) |
---|
| 715 | ! |
---|
| 716 | !-- Inquire number of vertical soil layers |
---|
| 717 | CALL get_dimension_length( id_surf, & |
---|
| 718 | root_area_density_lad_f%nz, & |
---|
| 719 | 'zsoil' ) |
---|
| 720 | ! |
---|
| 721 | !-- Allocate variable |
---|
| 722 | ALLOCATE( root_area_density_lad_f%var & |
---|
| 723 | (0:root_area_density_lad_f%nz-1,& |
---|
| 724 | nys:nyn,nxl:nxr) ) |
---|
| 725 | |
---|
| 726 | DO i = nxl, nxr |
---|
| 727 | DO j = nys, nyn |
---|
| 728 | CALL get_variable( id_surf, 'root_area_density_lad', & |
---|
| 729 | i, j, & |
---|
| 730 | root_area_density_lad_f%var(:,j,i) ) |
---|
| 731 | ENDDO |
---|
| 732 | ENDDO |
---|
| 733 | ELSE |
---|
| 734 | root_area_density_lad_f%from_file = .FALSE. |
---|
| 735 | ENDIF |
---|
| 736 | ! |
---|
| 737 | !-- Finally, close input file |
---|
| 738 | CALL close_input_file( id_surf ) |
---|
| 739 | #endif |
---|
| 740 | ENDIF |
---|
| 741 | #if defined( __parallel ) |
---|
| 742 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 743 | #endif |
---|
| 744 | ENDDO |
---|
| 745 | ! |
---|
| 746 | !-- Deallocate variable list. Will be re-allocated in case further |
---|
| 747 | !-- variables are read from file. |
---|
| 748 | IF ( ALLOCATED( var_names ) ) DEALLOCATE( var_names ) |
---|
| 749 | |
---|
| 750 | ENDIF |
---|
| 751 | ! |
---|
| 752 | !-- Skip the following if no land-surface or urban-surface module are |
---|
| 753 | !-- applied. This case, no one of the following variables is used anyway. |
---|
[2659] | 754 | IF ( .NOT. land_surface .OR. .NOT. urban_surface ) RETURN |
---|
| 755 | ! |
---|
[2646] | 756 | !-- Initialize dummy arrays used for ghost-point exchange |
---|
| 757 | var_exchange_int = 0 |
---|
| 758 | var_exchange_real = 0.0_wp |
---|
[2586] | 759 | |
---|
| 760 | DO ii = 0, io_blocks-1 |
---|
| 761 | IF ( ii == io_group ) THEN |
---|
| 762 | #if defined ( __netcdf ) |
---|
| 763 | ! |
---|
| 764 | !-- Open file in read-only mode |
---|
[2589] | 765 | CALL open_read_file( TRIM( input_file_static ) // & |
---|
| 766 | TRIM( coupling_char ) , id_surf ) |
---|
[2586] | 767 | |
---|
| 768 | ! |
---|
[2746] | 769 | !-- Inquire all variable names. |
---|
[2586] | 770 | !-- This will be used to check whether an optional input variable exist |
---|
| 771 | !-- or not. |
---|
| 772 | CALL inquire_num_variables( id_surf, num_vars ) |
---|
| 773 | |
---|
| 774 | ALLOCATE( var_names(1:num_vars) ) |
---|
| 775 | CALL inquire_variable_names( id_surf, var_names ) |
---|
| 776 | |
---|
| 777 | ! |
---|
| 778 | !-- Read vegetation type and required attributes |
---|
| 779 | IF ( check_existence( var_names, 'vegetation_type' ) ) THEN |
---|
| 780 | vegetation_type_f%from_file = .TRUE. |
---|
| 781 | CALL get_attribute( id_surf, char_fill, & |
---|
| 782 | vegetation_type_f%fill, & |
---|
| 783 | .FALSE., 'vegetation_type' ) |
---|
| 784 | ! |
---|
| 785 | !-- PE-wise reading of 2D vegetation type. |
---|
| 786 | ALLOCATE ( vegetation_type_f%var(nys:nyn,nxl:nxr) ) |
---|
[2700] | 787 | |
---|
[2586] | 788 | DO i = nxl, nxr |
---|
| 789 | CALL get_variable( id_surf, 'vegetation_type', & |
---|
| 790 | i, vegetation_type_f%var(:,i) ) |
---|
| 791 | ENDDO |
---|
| 792 | ELSE |
---|
| 793 | vegetation_type_f%from_file = .FALSE. |
---|
| 794 | ENDIF |
---|
| 795 | |
---|
| 796 | ! |
---|
| 797 | !-- Read soil type and required attributes |
---|
| 798 | IF ( check_existence( var_names, 'soil_type' ) ) THEN |
---|
| 799 | soil_type_f%from_file = .TRUE. |
---|
| 800 | ! |
---|
| 801 | !-- Note, lod is currently not on file; skip for the moment |
---|
| 802 | ! CALL get_attribute( id_surf, char_lod, & |
---|
| 803 | ! soil_type_f%lod, & |
---|
| 804 | ! .FALSE., 'soil_type' ) |
---|
| 805 | CALL get_attribute( id_surf, char_fill, & |
---|
| 806 | soil_type_f%fill, & |
---|
| 807 | .FALSE., 'soil_type' ) |
---|
| 808 | |
---|
| 809 | IF ( soil_type_f%lod == 1 ) THEN |
---|
| 810 | ! |
---|
| 811 | !-- PE-wise reading of 2D soil type. |
---|
| 812 | ALLOCATE ( soil_type_f%var_2d(nys:nyn,nxl:nxr) ) |
---|
| 813 | DO i = nxl, nxr |
---|
| 814 | CALL get_variable( id_surf, 'soil_type', & |
---|
| 815 | i, soil_type_f%var_2d(:,i) ) |
---|
| 816 | ENDDO |
---|
| 817 | ELSEIF ( soil_type_f%lod == 2 ) THEN |
---|
| 818 | ! |
---|
| 819 | !-- Obtain number of soil layers from file. |
---|
| 820 | CALL get_dimension_length( id_surf, nz_soil, 'zsoil' ) |
---|
| 821 | ! |
---|
| 822 | !-- PE-wise reading of 3D soil type. |
---|
| 823 | ALLOCATE ( soil_type_f%var_3d(0:nz_soil,nys:nyn,nxl:nxr) ) |
---|
| 824 | DO i = nxl, nxr |
---|
| 825 | DO j = nys, nyn |
---|
| 826 | CALL get_variable( id_surf, 'soil_type', i, j, & |
---|
| 827 | soil_type_f%var_3d(:,j,i) ) |
---|
| 828 | ENDDO |
---|
| 829 | ENDDO |
---|
| 830 | ENDIF |
---|
| 831 | ELSE |
---|
| 832 | soil_type_f%from_file = .FALSE. |
---|
| 833 | ENDIF |
---|
| 834 | |
---|
| 835 | ! |
---|
| 836 | !-- Read pavement type and required attributes |
---|
| 837 | IF ( check_existence( var_names, 'pavement_type' ) ) THEN |
---|
| 838 | pavement_type_f%from_file = .TRUE. |
---|
| 839 | CALL get_attribute( id_surf, char_fill, & |
---|
| 840 | pavement_type_f%fill, .FALSE., & |
---|
| 841 | 'pavement_type' ) |
---|
| 842 | ! |
---|
| 843 | !-- PE-wise reading of 2D pavement type. |
---|
| 844 | ALLOCATE ( pavement_type_f%var(nys:nyn,nxl:nxr) ) |
---|
| 845 | DO i = nxl, nxr |
---|
| 846 | CALL get_variable( id_surf, 'pavement_type', & |
---|
| 847 | i, pavement_type_f%var(:,i) ) |
---|
| 848 | ENDDO |
---|
| 849 | ELSE |
---|
| 850 | pavement_type_f%from_file = .FALSE. |
---|
| 851 | ENDIF |
---|
| 852 | |
---|
| 853 | ! |
---|
| 854 | !-- Read water type and required attributes |
---|
| 855 | IF ( check_existence( var_names, 'water_type' ) ) THEN |
---|
| 856 | water_type_f%from_file = .TRUE. |
---|
| 857 | CALL get_attribute( id_surf, char_fill, water_type_f%fill, & |
---|
| 858 | .FALSE., 'water_type' ) |
---|
| 859 | ! |
---|
| 860 | !-- PE-wise reading of 2D water type. |
---|
| 861 | ALLOCATE ( water_type_f%var(nys:nyn,nxl:nxr) ) |
---|
| 862 | DO i = nxl, nxr |
---|
| 863 | CALL get_variable( id_surf, 'water_type', i, & |
---|
| 864 | water_type_f%var(:,i) ) |
---|
| 865 | ENDDO |
---|
| 866 | ELSE |
---|
| 867 | water_type_f%from_file = .FALSE. |
---|
| 868 | ENDIF |
---|
| 869 | ! |
---|
| 870 | !-- Read surface fractions and related information |
---|
| 871 | IF ( check_existence( var_names, 'surface_fraction' ) ) THEN |
---|
| 872 | surface_fraction_f%from_file = .TRUE. |
---|
| 873 | CALL get_attribute( id_surf, char_fill, & |
---|
| 874 | surface_fraction_f%fill, & |
---|
| 875 | .FALSE., 'surface_fraction' ) |
---|
| 876 | ! |
---|
| 877 | !-- Inquire number of surface fractions |
---|
| 878 | CALL get_dimension_length( id_surf, & |
---|
| 879 | surface_fraction_f%nf, & |
---|
| 880 | 'nsurface_fraction' ) |
---|
| 881 | ! |
---|
| 882 | !-- Allocate dimension array and input array for surface fractions |
---|
| 883 | ALLOCATE( surface_fraction_f%nfracs(0:surface_fraction_f%nf-1) ) |
---|
| 884 | ALLOCATE( surface_fraction_f%frac(0:surface_fraction_f%nf-1, & |
---|
| 885 | nys:nyn,nxl:nxr) ) |
---|
| 886 | ! |
---|
| 887 | !-- Get dimension of surface fractions |
---|
| 888 | CALL get_variable( id_surf, 'nsurface_fraction', & |
---|
| 889 | surface_fraction_f%nfracs ) |
---|
| 890 | ! |
---|
| 891 | !-- Read surface fractions |
---|
| 892 | DO i = nxl, nxr |
---|
| 893 | DO j = nys, nyn |
---|
| 894 | CALL get_variable( id_surf, 'surface_fraction', i, j, & |
---|
| 895 | surface_fraction_f%frac(:,j,i) ) |
---|
| 896 | ENDDO |
---|
| 897 | ENDDO |
---|
| 898 | ELSE |
---|
| 899 | surface_fraction_f%from_file = .FALSE. |
---|
| 900 | ENDIF |
---|
| 901 | ! |
---|
| 902 | !-- Read building parameters and related information |
---|
| 903 | IF ( check_existence( var_names, 'building_pars' ) ) THEN |
---|
| 904 | building_pars_f%from_file = .TRUE. |
---|
| 905 | CALL get_attribute( id_surf, char_fill, & |
---|
| 906 | building_pars_f%fill, & |
---|
| 907 | .FALSE., 'building_pars' ) |
---|
| 908 | ! |
---|
| 909 | !-- Inquire number of building parameters |
---|
| 910 | CALL get_dimension_length( id_surf, & |
---|
| 911 | building_pars_f%np, & |
---|
| 912 | 'nbuilding_pars' ) |
---|
| 913 | ! |
---|
| 914 | !-- Allocate dimension array and input array for building parameters |
---|
| 915 | ALLOCATE( building_pars_f%pars(0:building_pars_f%np-1) ) |
---|
| 916 | ALLOCATE( building_pars_f%pars_xy(0:building_pars_f%np-1, & |
---|
| 917 | nys:nyn,nxl:nxr) ) |
---|
| 918 | ! |
---|
| 919 | !-- Get dimension of building parameters |
---|
| 920 | CALL get_variable( id_surf, 'nbuilding_pars', & |
---|
| 921 | building_pars_f%pars ) |
---|
| 922 | ! |
---|
| 923 | !-- Read building_pars |
---|
| 924 | DO i = nxl, nxr |
---|
| 925 | DO j = nys, nyn |
---|
| 926 | CALL get_variable( id_surf, 'building_pars', i, j, & |
---|
| 927 | building_pars_f%pars_xy(:,j,i) ) |
---|
| 928 | ENDDO |
---|
| 929 | ENDDO |
---|
| 930 | ELSE |
---|
| 931 | building_pars_f%from_file = .FALSE. |
---|
| 932 | ENDIF |
---|
| 933 | |
---|
| 934 | ! |
---|
| 935 | !-- Read albedo type and required attributes |
---|
| 936 | IF ( check_existence( var_names, 'albedo_type' ) ) THEN |
---|
| 937 | albedo_type_f%from_file = .TRUE. |
---|
| 938 | CALL get_attribute( id_surf, char_fill, albedo_type_f%fill, & |
---|
| 939 | .FALSE., 'albedo_type' ) |
---|
| 940 | ! |
---|
| 941 | !-- PE-wise reading of 2D water type. |
---|
| 942 | ALLOCATE ( albedo_type_f%var(nys:nyn,nxl:nxr) ) |
---|
| 943 | DO i = nxl, nxr |
---|
| 944 | CALL get_variable( id_surf, 'albedo_type', & |
---|
| 945 | i, albedo_type_f%var(:,i) ) |
---|
| 946 | ENDDO |
---|
| 947 | ELSE |
---|
| 948 | albedo_type_f%from_file = .FALSE. |
---|
| 949 | ENDIF |
---|
| 950 | ! |
---|
| 951 | !-- Read albedo parameters and related information |
---|
| 952 | IF ( check_existence( var_names, 'albedo_pars' ) ) THEN |
---|
| 953 | albedo_pars_f%from_file = .TRUE. |
---|
| 954 | CALL get_attribute( id_surf, char_fill, albedo_pars_f%fill, & |
---|
| 955 | .FALSE., 'albedo_pars' ) |
---|
| 956 | ! |
---|
| 957 | !-- Inquire number of albedo parameters |
---|
| 958 | CALL get_dimension_length( id_surf, albedo_pars_f%np, & |
---|
| 959 | 'nalbedo_pars' ) |
---|
| 960 | ! |
---|
| 961 | !-- Allocate dimension array and input array for albedo parameters |
---|
| 962 | ALLOCATE( albedo_pars_f%pars(0:albedo_pars_f%np-1) ) |
---|
| 963 | ALLOCATE( albedo_pars_f%pars_xy(0:albedo_pars_f%np-1, & |
---|
| 964 | nys:nyn,nxl:nxr) ) |
---|
| 965 | ! |
---|
| 966 | !-- Get dimension of albedo parameters |
---|
| 967 | CALL get_variable( id_surf, 'nalbedo_pars', albedo_pars_f%pars ) |
---|
| 968 | |
---|
| 969 | DO i = nxl, nxr |
---|
| 970 | DO j = nys, nyn |
---|
| 971 | CALL get_variable( id_surf, 'albedo_pars', i, j, & |
---|
| 972 | albedo_pars_f%pars_xy(:,j,i) ) |
---|
| 973 | ENDDO |
---|
| 974 | ENDDO |
---|
| 975 | ELSE |
---|
| 976 | albedo_pars_f%from_file = .FALSE. |
---|
| 977 | ENDIF |
---|
| 978 | |
---|
| 979 | ! |
---|
| 980 | !-- Read pavement parameters and related information |
---|
| 981 | IF ( check_existence( var_names, 'pavement_pars' ) ) THEN |
---|
| 982 | pavement_pars_f%from_file = .TRUE. |
---|
| 983 | CALL get_attribute( id_surf, char_fill, & |
---|
| 984 | pavement_pars_f%fill, & |
---|
| 985 | .FALSE., 'pavement_pars' ) |
---|
| 986 | ! |
---|
| 987 | !-- Inquire number of pavement parameters |
---|
| 988 | CALL get_dimension_length( id_surf, pavement_pars_f%np, & |
---|
| 989 | 'npavement_pars' ) |
---|
| 990 | ! |
---|
| 991 | !-- Allocate dimension array and input array for pavement parameters |
---|
| 992 | ALLOCATE( pavement_pars_f%pars(0:pavement_pars_f%np-1) ) |
---|
| 993 | ALLOCATE( pavement_pars_f%pars_xy(0:pavement_pars_f%np-1, & |
---|
| 994 | nys:nyn,nxl:nxr) ) |
---|
| 995 | ! |
---|
| 996 | !-- Get dimension of pavement parameters |
---|
| 997 | CALL get_variable( id_surf, 'npavement_pars', & |
---|
| 998 | pavement_pars_f%pars ) |
---|
| 999 | |
---|
| 1000 | DO i = nxl, nxr |
---|
| 1001 | DO j = nys, nyn |
---|
| 1002 | CALL get_variable( id_surf, 'pavement_pars', i, j, & |
---|
| 1003 | pavement_pars_f%pars_xy(:,j,i) ) |
---|
| 1004 | ENDDO |
---|
| 1005 | ENDDO |
---|
| 1006 | ELSE |
---|
| 1007 | pavement_pars_f%from_file = .FALSE. |
---|
| 1008 | ENDIF |
---|
| 1009 | |
---|
| 1010 | ! |
---|
| 1011 | !-- Read pavement subsurface parameters and related information |
---|
| 1012 | IF ( check_existence( var_names, 'pavement_subsurface_pars' ) ) & |
---|
| 1013 | THEN |
---|
| 1014 | pavement_subsurface_pars_f%from_file = .TRUE. |
---|
| 1015 | CALL get_attribute( id_surf, char_fill, & |
---|
| 1016 | pavement_subsurface_pars_f%fill, & |
---|
| 1017 | .FALSE., 'pavement_subsurface_pars' ) |
---|
| 1018 | ! |
---|
| 1019 | !-- Inquire number of parameters |
---|
| 1020 | CALL get_dimension_length( id_surf, & |
---|
| 1021 | pavement_subsurface_pars_f%np, & |
---|
| 1022 | 'npavement_subsurface_pars' ) |
---|
| 1023 | ! |
---|
| 1024 | !-- Inquire number of soil layers |
---|
| 1025 | CALL get_dimension_length( id_surf, & |
---|
| 1026 | pavement_subsurface_pars_f%nz, & |
---|
| 1027 | 'zsoil' ) |
---|
| 1028 | ! |
---|
| 1029 | !-- Allocate dimension array and input array for pavement parameters |
---|
| 1030 | ALLOCATE( pavement_subsurface_pars_f%pars & |
---|
| 1031 | (0:pavement_subsurface_pars_f%np-1) ) |
---|
| 1032 | ALLOCATE( pavement_subsurface_pars_f%pars_xyz & |
---|
| 1033 | (0:pavement_subsurface_pars_f%np-1, & |
---|
| 1034 | 0:pavement_subsurface_pars_f%nz-1, & |
---|
| 1035 | nys:nyn,nxl:nxr) ) |
---|
| 1036 | ! |
---|
| 1037 | !-- Get dimension of pavement parameters |
---|
| 1038 | CALL get_variable( id_surf, 'npavement_subsurface_pars', & |
---|
| 1039 | pavement_subsurface_pars_f%pars ) |
---|
| 1040 | |
---|
| 1041 | DO i = nxl, nxr |
---|
| 1042 | DO j = nys, nyn |
---|
| 1043 | CALL get_variable( & |
---|
| 1044 | id_surf, 'pavement_subsurface_pars', & |
---|
| 1045 | i, j, & |
---|
| 1046 | pavement_subsurface_pars_f%pars_xyz(:,:,j,i),& |
---|
| 1047 | pavement_subsurface_pars_f%nz, & |
---|
| 1048 | pavement_subsurface_pars_f%np ) |
---|
| 1049 | ENDDO |
---|
| 1050 | ENDDO |
---|
| 1051 | ELSE |
---|
| 1052 | pavement_subsurface_pars_f%from_file = .FALSE. |
---|
| 1053 | ENDIF |
---|
| 1054 | |
---|
| 1055 | |
---|
| 1056 | ! |
---|
| 1057 | !-- Read vegetation parameters and related information |
---|
| 1058 | IF ( check_existence( var_names, 'vegetation_pars' ) ) THEN |
---|
| 1059 | vegetation_pars_f%from_file = .TRUE. |
---|
| 1060 | CALL get_attribute( id_surf, char_fill, & |
---|
| 1061 | vegetation_pars_f%fill, & |
---|
| 1062 | .FALSE., 'vegetation_pars' ) |
---|
| 1063 | ! |
---|
| 1064 | !-- Inquire number of vegetation parameters |
---|
| 1065 | CALL get_dimension_length( id_surf, vegetation_pars_f%np, & |
---|
| 1066 | 'nvegetation_pars' ) |
---|
| 1067 | ! |
---|
| 1068 | !-- Allocate dimension array and input array for surface fractions |
---|
| 1069 | ALLOCATE( vegetation_pars_f%pars(0:vegetation_pars_f%np-1) ) |
---|
| 1070 | ALLOCATE( vegetation_pars_f%pars_xy(0:vegetation_pars_f%np-1, & |
---|
| 1071 | nys:nyn,nxl:nxr) ) |
---|
| 1072 | ! |
---|
| 1073 | !-- Get dimension of the parameters |
---|
| 1074 | CALL get_variable( id_surf, 'nvegetation_pars', & |
---|
| 1075 | vegetation_pars_f%pars ) |
---|
| 1076 | |
---|
| 1077 | DO i = nxl, nxr |
---|
| 1078 | DO j = nys, nyn |
---|
| 1079 | CALL get_variable( id_surf, 'vegetation_pars', i, j, & |
---|
| 1080 | vegetation_pars_f%pars_xy(:,j,i) ) |
---|
| 1081 | ENDDO |
---|
| 1082 | ENDDO |
---|
| 1083 | ELSE |
---|
| 1084 | vegetation_pars_f%from_file = .FALSE. |
---|
| 1085 | ENDIF |
---|
| 1086 | |
---|
| 1087 | ! |
---|
| 1088 | !-- Read root parameters/distribution and related information |
---|
| 1089 | IF ( check_existence( var_names, 'soil_pars' ) ) THEN |
---|
| 1090 | soil_pars_f%from_file = .TRUE. |
---|
| 1091 | CALL get_attribute( id_surf, char_fill, & |
---|
| 1092 | soil_pars_f%fill, & |
---|
| 1093 | .FALSE., 'soil_pars' ) |
---|
| 1094 | |
---|
| 1095 | CALL get_attribute( id_surf, char_lod, & |
---|
| 1096 | soil_pars_f%lod, & |
---|
| 1097 | .FALSE., 'soil_pars' ) |
---|
| 1098 | |
---|
| 1099 | ! |
---|
| 1100 | !-- Inquire number of soil parameters |
---|
| 1101 | CALL get_dimension_length( id_surf, & |
---|
| 1102 | soil_pars_f%np, & |
---|
| 1103 | 'nsoil_pars' ) |
---|
| 1104 | ! |
---|
| 1105 | !-- Read parameters array |
---|
| 1106 | ALLOCATE( soil_pars_f%pars(0:soil_pars_f%np-1) ) |
---|
| 1107 | CALL get_variable( id_surf, 'nsoil_pars', soil_pars_f%pars ) |
---|
| 1108 | |
---|
| 1109 | ! |
---|
| 1110 | !-- In case of level of detail 2, also inquire number of vertical |
---|
| 1111 | !-- soil layers, allocate memory and read the respective dimension |
---|
| 1112 | IF ( soil_pars_f%lod == 2 ) THEN |
---|
| 1113 | CALL get_dimension_length( id_surf, soil_pars_f%nz, 'zsoil' ) |
---|
| 1114 | |
---|
| 1115 | ALLOCATE( soil_pars_f%layers(0:soil_pars_f%nz-1) ) |
---|
| 1116 | CALL get_variable( id_surf, 'zsoil', soil_pars_f%layers ) |
---|
| 1117 | |
---|
| 1118 | ENDIF |
---|
| 1119 | |
---|
| 1120 | ! |
---|
| 1121 | !-- Read soil parameters, depending on level of detail |
---|
| 1122 | IF ( soil_pars_f%lod == 1 ) THEN |
---|
[2646] | 1123 | ALLOCATE( soil_pars_f%pars_xy(0:soil_pars_f%np-1, & |
---|
| 1124 | nys:nyn,nxl:nxr) ) |
---|
[2586] | 1125 | DO i = nxl, nxr |
---|
| 1126 | DO j = nys, nyn |
---|
| 1127 | CALL get_variable( id_surf, 'soil_pars', i, j, & |
---|
| 1128 | soil_pars_f%pars_xy(:,j,i) ) |
---|
| 1129 | ENDDO |
---|
| 1130 | ENDDO |
---|
| 1131 | |
---|
| 1132 | ELSEIF ( soil_pars_f%lod == 2 ) THEN |
---|
| 1133 | ALLOCATE( soil_pars_f%pars_xyz(0:soil_pars_f%np-1, & |
---|
| 1134 | 0:soil_pars_f%nz-1, & |
---|
| 1135 | nys:nyn,nxl:nxr) ) |
---|
| 1136 | DO i = nxl, nxr |
---|
| 1137 | DO j = nys, nyn |
---|
| 1138 | CALL get_variable( id_surf, 'soil_pars', i, j, & |
---|
| 1139 | soil_pars_f%pars_xyz(:,:,j,i), & |
---|
| 1140 | soil_pars_f%nz, soil_pars_f%np ) |
---|
| 1141 | ENDDO |
---|
| 1142 | ENDDO |
---|
| 1143 | ENDIF |
---|
| 1144 | ELSE |
---|
| 1145 | soil_pars_f%from_file = .FALSE. |
---|
| 1146 | ENDIF |
---|
| 1147 | |
---|
| 1148 | ! |
---|
| 1149 | !-- Read water parameters and related information |
---|
| 1150 | IF ( check_existence( var_names, 'water_pars' ) ) THEN |
---|
| 1151 | water_pars_f%from_file = .TRUE. |
---|
| 1152 | CALL get_attribute( id_surf, char_fill, & |
---|
| 1153 | water_pars_f%fill, & |
---|
| 1154 | .FALSE., 'water_pars' ) |
---|
| 1155 | ! |
---|
| 1156 | !-- Inquire number of water parameters |
---|
| 1157 | CALL get_dimension_length( id_surf, & |
---|
| 1158 | water_pars_f%np, & |
---|
| 1159 | 'nwater_pars' ) |
---|
| 1160 | ! |
---|
| 1161 | !-- Allocate dimension array and input array for water parameters |
---|
| 1162 | ALLOCATE( water_pars_f%pars(0:water_pars_f%np-1) ) |
---|
| 1163 | ALLOCATE( water_pars_f%pars_xy(0:water_pars_f%np-1, & |
---|
| 1164 | nys:nyn,nxl:nxr) ) |
---|
| 1165 | ! |
---|
| 1166 | !-- Get dimension of water parameters |
---|
| 1167 | CALL get_variable( id_surf, 'nwater_pars', water_pars_f%pars ) |
---|
| 1168 | |
---|
| 1169 | DO i = nxl, nxr |
---|
| 1170 | DO j = nys, nyn |
---|
| 1171 | CALL get_variable( id_surf, 'water_pars', i, j, & |
---|
| 1172 | water_pars_f%pars_xy(:,j,i) ) |
---|
| 1173 | ENDDO |
---|
| 1174 | ENDDO |
---|
| 1175 | ELSE |
---|
| 1176 | water_pars_f%from_file = .FALSE. |
---|
| 1177 | ENDIF |
---|
| 1178 | ! |
---|
| 1179 | !-- Read root area density - parametrized vegetation |
---|
| 1180 | IF ( check_existence( var_names, 'root_area_density_lsm' ) ) THEN |
---|
| 1181 | root_area_density_lsm_f%from_file = .TRUE. |
---|
| 1182 | CALL get_attribute( id_surf, char_fill, & |
---|
| 1183 | root_area_density_lsm_f%fill, & |
---|
| 1184 | .FALSE., 'root_area_density_lsm' ) |
---|
| 1185 | ! |
---|
| 1186 | !-- Obtain number of soil layers from file and allocate variable |
---|
| 1187 | CALL get_dimension_length( id_surf, root_area_density_lsm_f%nz,& |
---|
| 1188 | 'zsoil' ) |
---|
| 1189 | ALLOCATE( root_area_density_lsm_f%var & |
---|
| 1190 | (0:root_area_density_lsm_f%nz-1, & |
---|
| 1191 | nys:nyn,nxl:nxr) ) |
---|
| 1192 | |
---|
| 1193 | ! |
---|
| 1194 | !-- Read root-area density |
---|
| 1195 | DO i = nxl, nxr |
---|
| 1196 | DO j = nys, nyn |
---|
| 1197 | CALL get_variable( id_surf, 'root_area_density_lsm', & |
---|
| 1198 | i, j, & |
---|
| 1199 | root_area_density_lsm_f%var(:,j,i) ) |
---|
| 1200 | ENDDO |
---|
| 1201 | ENDDO |
---|
| 1202 | |
---|
| 1203 | ELSE |
---|
| 1204 | root_area_density_lsm_f%from_file = .FALSE. |
---|
| 1205 | ENDIF |
---|
[2664] | 1206 | ! |
---|
| 1207 | !-- Read street type and street crossing |
---|
| 1208 | IF ( check_existence( var_names, 'street_type' ) ) THEN |
---|
| 1209 | street_type_f%from_file = .TRUE. |
---|
| 1210 | CALL get_attribute( id_surf, char_fill, & |
---|
| 1211 | street_type_f%fill, .FALSE., & |
---|
| 1212 | 'street_type' ) |
---|
| 1213 | ! |
---|
| 1214 | !-- PE-wise reading of 2D pavement type. |
---|
| 1215 | ALLOCATE ( street_type_f%var(nys:nyn,nxl:nxr) ) |
---|
| 1216 | DO i = nxl, nxr |
---|
| 1217 | CALL get_variable( id_surf, 'street_type', & |
---|
| 1218 | i, street_type_f%var(:,i) ) |
---|
| 1219 | ENDDO |
---|
| 1220 | ELSE |
---|
| 1221 | street_type_f%from_file = .FALSE. |
---|
| 1222 | ENDIF |
---|
[2586] | 1223 | |
---|
[2664] | 1224 | IF ( check_existence( var_names, 'street_crossing' ) ) THEN |
---|
| 1225 | street_crossing_f%from_file = .TRUE. |
---|
| 1226 | CALL get_attribute( id_surf, char_fill, & |
---|
| 1227 | street_crossing_f%fill, .FALSE., & |
---|
| 1228 | 'street_crossing' ) |
---|
[2586] | 1229 | ! |
---|
[2664] | 1230 | !-- PE-wise reading of 2D pavement type. |
---|
| 1231 | ALLOCATE ( street_crossing_f%var(nys:nyn,nxl:nxr) ) |
---|
| 1232 | DO i = nxl, nxr |
---|
| 1233 | CALL get_variable( id_surf, 'street_crossing', & |
---|
| 1234 | i, street_crossing_f%var(:,i) ) |
---|
| 1235 | ENDDO |
---|
| 1236 | ELSE |
---|
| 1237 | street_crossing_f%from_file = .FALSE. |
---|
| 1238 | ENDIF |
---|
| 1239 | ! |
---|
[2586] | 1240 | !-- Still missing: root_resolved and building_surface_pars. |
---|
| 1241 | !-- Will be implemented as soon as they are available. |
---|
| 1242 | |
---|
| 1243 | ! |
---|
| 1244 | !-- Finally, close input file |
---|
[2711] | 1245 | CALL close_input_file( id_surf ) |
---|
[2586] | 1246 | #endif |
---|
| 1247 | ENDIF |
---|
| 1248 | #if defined( __parallel ) |
---|
| 1249 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 1250 | #endif |
---|
| 1251 | ENDDO |
---|
[2646] | 1252 | ! |
---|
[2955] | 1253 | !-- End of CPU measurement |
---|
| 1254 | CALL cpu_log( log_point_s(82), 'NetCDF input', 'stop' ) |
---|
| 1255 | ! |
---|
[2646] | 1256 | !-- Exchange 1 ghost points for surface variables. Please note, ghost point |
---|
| 1257 | !-- exchange for 3D parameter lists should be revised by using additional |
---|
| 1258 | !-- MPI datatypes or rewriting exchange_horiz. |
---|
| 1259 | !-- Moreover, varialbes will be resized in the following, including ghost |
---|
| 1260 | !-- points. |
---|
| 1261 | !-- Start with 2D Integer variables. Please note, for 8-bit integer |
---|
| 1262 | !-- variables must be swapt to 32-bit integer before calling exchange_horiz. |
---|
| 1263 | IF ( albedo_type_f%from_file ) THEN |
---|
| 1264 | var_exchange_int = INT( albedo_type_f%fill, KIND = 1 ) |
---|
| 1265 | var_exchange_int(nys:nyn,nxl:nxr) = & |
---|
| 1266 | INT( albedo_type_f%var(nys:nyn,nxl:nxr), KIND = 4 ) |
---|
| 1267 | CALL exchange_horiz_2d_int( var_exchange_int, nys, nyn, nxl, nxr, nbgp ) |
---|
| 1268 | DEALLOCATE( albedo_type_f%var ) |
---|
| 1269 | ALLOCATE( albedo_type_f%var(nysg:nyng,nxlg:nxrg) ) |
---|
| 1270 | albedo_type_f%var = INT( var_exchange_int, KIND = 1 ) |
---|
| 1271 | ENDIF |
---|
| 1272 | IF ( pavement_type_f%from_file ) THEN |
---|
| 1273 | var_exchange_int = INT( pavement_type_f%fill, KIND = 1 ) |
---|
| 1274 | var_exchange_int(nys:nyn,nxl:nxr) = & |
---|
| 1275 | INT( pavement_type_f%var(nys:nyn,nxl:nxr), KIND = 4 ) |
---|
| 1276 | CALL exchange_horiz_2d_int( var_exchange_int, nys, nyn, nxl, nxr, nbgp ) |
---|
| 1277 | DEALLOCATE( pavement_type_f%var ) |
---|
| 1278 | ALLOCATE( pavement_type_f%var(nysg:nyng,nxlg:nxrg) ) |
---|
| 1279 | pavement_type_f%var = INT( var_exchange_int, KIND = 1 ) |
---|
| 1280 | ENDIF |
---|
| 1281 | IF ( soil_type_f%from_file .AND. ALLOCATED( soil_type_f%var_2d ) ) THEN |
---|
| 1282 | var_exchange_int = INT( soil_type_f%fill, KIND = 1 ) |
---|
| 1283 | var_exchange_int(nys:nyn,nxl:nxr) = & |
---|
| 1284 | INT( soil_type_f%var_2d(nys:nyn,nxl:nxr), KIND = 4 ) |
---|
| 1285 | CALL exchange_horiz_2d_int( var_exchange_int, nys, nyn, nxl, nxr, nbgp ) |
---|
| 1286 | DEALLOCATE( soil_type_f%var_2d ) |
---|
| 1287 | ALLOCATE( soil_type_f%var_2d(nysg:nyng,nxlg:nxrg) ) |
---|
| 1288 | soil_type_f%var_2d = INT( var_exchange_int, KIND = 1 ) |
---|
| 1289 | ENDIF |
---|
| 1290 | IF ( vegetation_type_f%from_file ) THEN |
---|
| 1291 | var_exchange_int = INT( vegetation_type_f%fill, KIND = 1 ) |
---|
| 1292 | var_exchange_int(nys:nyn,nxl:nxr) = & |
---|
| 1293 | INT( vegetation_type_f%var(nys:nyn,nxl:nxr), KIND = 4 ) |
---|
| 1294 | CALL exchange_horiz_2d_int( var_exchange_int, nys, nyn, nxl, nxr, nbgp ) |
---|
| 1295 | DEALLOCATE( vegetation_type_f%var ) |
---|
| 1296 | ALLOCATE( vegetation_type_f%var(nysg:nyng,nxlg:nxrg) ) |
---|
| 1297 | vegetation_type_f%var = INT( var_exchange_int, KIND = 1 ) |
---|
| 1298 | ENDIF |
---|
| 1299 | IF ( water_type_f%from_file ) THEN |
---|
| 1300 | var_exchange_int = INT( water_type_f%fill, KIND = 1 ) |
---|
| 1301 | var_exchange_int(nys:nyn,nxl:nxr) = & |
---|
| 1302 | INT( water_type_f%var(nys:nyn,nxl:nxr), KIND = 4 ) |
---|
| 1303 | CALL exchange_horiz_2d_int( var_exchange_int, nys, nyn, nxl, nxr, nbgp ) |
---|
| 1304 | DEALLOCATE( water_type_f%var ) |
---|
| 1305 | ALLOCATE( water_type_f%var(nysg:nyng,nxlg:nxrg) ) |
---|
| 1306 | water_type_f%var = INT( var_exchange_int, KIND = 1 ) |
---|
| 1307 | ENDIF |
---|
| 1308 | ! |
---|
| 1309 | !-- Exchange 1 ghost point for 3/4-D variables. For the sake of simplicity, |
---|
| 1310 | !-- loop further dimensions to use 2D exchange routines. |
---|
| 1311 | !-- This should be revised later by introducing new MPI datatypes. |
---|
| 1312 | IF ( soil_type_f%from_file .AND. ALLOCATED( soil_type_f%var_3d ) ) & |
---|
| 1313 | THEN |
---|
| 1314 | ALLOCATE( var_dum_int_3d(0:nz_soil,nys:nyn,nxl:nxr) ) |
---|
| 1315 | var_dum_int_3d = soil_type_f%var_3d |
---|
| 1316 | DEALLOCATE( soil_type_f%var_3d ) |
---|
| 1317 | ALLOCATE( soil_type_f%var_3d(0:nz_soil,nysg:nyng,nxlg:nxrg) ) |
---|
| 1318 | soil_type_f%var_3d = soil_type_f%fill |
---|
[2586] | 1319 | |
---|
[2646] | 1320 | DO k = 0, nz_soil |
---|
| 1321 | var_exchange_int(nys:nyn,nxl:nxr) = var_dum_int_3d(k,nys:nyn,nxl:nxr) |
---|
| 1322 | CALL exchange_horiz_2d_int( var_exchange_int, nys, nyn, nxl, nxr, nbgp ) |
---|
| 1323 | soil_type_f%var_3d(k,:,:) = INT( var_exchange_int(:,:), KIND = 1 ) |
---|
| 1324 | ENDDO |
---|
| 1325 | DEALLOCATE( var_dum_int_3d ) |
---|
| 1326 | ENDIF |
---|
| 1327 | |
---|
| 1328 | IF ( surface_fraction_f%from_file ) THEN |
---|
| 1329 | ALLOCATE( var_dum_real_3d(0:surface_fraction_f%nf-1,nys:nyn,nxl:nxr) ) |
---|
| 1330 | var_dum_real_3d = surface_fraction_f%frac |
---|
| 1331 | DEALLOCATE( surface_fraction_f%frac ) |
---|
| 1332 | ALLOCATE( surface_fraction_f%frac(0:surface_fraction_f%nf-1, & |
---|
| 1333 | nysg:nyng,nxlg:nxrg) ) |
---|
| 1334 | surface_fraction_f%frac = surface_fraction_f%fill |
---|
| 1335 | |
---|
| 1336 | DO k = 0, surface_fraction_f%nf-1 |
---|
| 1337 | var_exchange_real(nys:nyn,nxl:nxr) = var_dum_real_3d(k,nys:nyn,nxl:nxr) |
---|
| 1338 | CALL exchange_horiz_2d( var_exchange_real, nbgp ) |
---|
| 1339 | surface_fraction_f%frac(k,:,:) = var_exchange_real(:,:) |
---|
| 1340 | ENDDO |
---|
| 1341 | DEALLOCATE( var_dum_real_3d ) |
---|
| 1342 | ENDIF |
---|
| 1343 | |
---|
| 1344 | IF ( building_pars_f%from_file ) THEN |
---|
| 1345 | ALLOCATE( var_dum_real_3d(0:building_pars_f%np-1,nys:nyn,nxl:nxr) ) |
---|
| 1346 | var_dum_real_3d = building_pars_f%pars_xy |
---|
| 1347 | DEALLOCATE( building_pars_f%pars_xy ) |
---|
| 1348 | ALLOCATE( building_pars_f%pars_xy(0:building_pars_f%np-1, & |
---|
| 1349 | nysg:nyng,nxlg:nxrg) ) |
---|
| 1350 | building_pars_f%pars_xy = building_pars_f%fill |
---|
| 1351 | DO k = 0, building_pars_f%np-1 |
---|
| 1352 | var_exchange_real(nys:nyn,nxl:nxr) = & |
---|
| 1353 | var_dum_real_3d(k,nys:nyn,nxl:nxr) |
---|
| 1354 | CALL exchange_horiz_2d( var_exchange_real, nbgp ) |
---|
| 1355 | building_pars_f%pars_xy(k,:,:) = var_exchange_real(:,:) |
---|
| 1356 | ENDDO |
---|
| 1357 | DEALLOCATE( var_dum_real_3d ) |
---|
| 1358 | ENDIF |
---|
| 1359 | |
---|
| 1360 | IF ( albedo_pars_f%from_file ) THEN |
---|
| 1361 | ALLOCATE( var_dum_real_3d(0:albedo_pars_f%np-1,nys:nyn,nxl:nxr) ) |
---|
| 1362 | var_dum_real_3d = albedo_pars_f%pars_xy |
---|
| 1363 | DEALLOCATE( albedo_pars_f%pars_xy ) |
---|
| 1364 | ALLOCATE( albedo_pars_f%pars_xy(0:albedo_pars_f%np-1, & |
---|
| 1365 | nysg:nyng,nxlg:nxrg) ) |
---|
| 1366 | albedo_pars_f%pars_xy = albedo_pars_f%fill |
---|
| 1367 | DO k = 0, albedo_pars_f%np-1 |
---|
| 1368 | var_exchange_real(nys:nyn,nxl:nxr) = & |
---|
| 1369 | var_dum_real_3d(k,nys:nyn,nxl:nxr) |
---|
| 1370 | CALL exchange_horiz_2d( var_exchange_real, nbgp ) |
---|
| 1371 | albedo_pars_f%pars_xy(k,:,:) = var_exchange_real(:,:) |
---|
| 1372 | ENDDO |
---|
| 1373 | DEALLOCATE( var_dum_real_3d ) |
---|
| 1374 | ENDIF |
---|
| 1375 | |
---|
| 1376 | IF ( pavement_pars_f%from_file ) THEN |
---|
| 1377 | ALLOCATE( var_dum_real_3d(0:pavement_pars_f%np-1,nys:nyn,nxl:nxr) ) |
---|
| 1378 | var_dum_real_3d = pavement_pars_f%pars_xy |
---|
| 1379 | DEALLOCATE( pavement_pars_f%pars_xy ) |
---|
| 1380 | ALLOCATE( pavement_pars_f%pars_xy(0:pavement_pars_f%np-1, & |
---|
| 1381 | nysg:nyng,nxlg:nxrg) ) |
---|
| 1382 | pavement_pars_f%pars_xy = pavement_pars_f%fill |
---|
| 1383 | DO k = 0, pavement_pars_f%np-1 |
---|
| 1384 | var_exchange_real(nys:nyn,nxl:nxr) = & |
---|
| 1385 | var_dum_real_3d(k,nys:nyn,nxl:nxr) |
---|
| 1386 | CALL exchange_horiz_2d( var_exchange_real, nbgp ) |
---|
| 1387 | pavement_pars_f%pars_xy(k,:,:) = var_exchange_real(:,:) |
---|
| 1388 | ENDDO |
---|
| 1389 | DEALLOCATE( var_dum_real_3d ) |
---|
| 1390 | ENDIF |
---|
| 1391 | |
---|
| 1392 | IF ( vegetation_pars_f%from_file ) THEN |
---|
| 1393 | ALLOCATE( var_dum_real_3d(0:vegetation_pars_f%np-1,nys:nyn,nxl:nxr) ) |
---|
| 1394 | var_dum_real_3d = vegetation_pars_f%pars_xy |
---|
| 1395 | DEALLOCATE( vegetation_pars_f%pars_xy ) |
---|
| 1396 | ALLOCATE( vegetation_pars_f%pars_xy(0:vegetation_pars_f%np-1, & |
---|
| 1397 | nysg:nyng,nxlg:nxrg) ) |
---|
| 1398 | vegetation_pars_f%pars_xy = vegetation_pars_f%fill |
---|
| 1399 | DO k = 0, vegetation_pars_f%np-1 |
---|
| 1400 | var_exchange_real(nys:nyn,nxl:nxr) = & |
---|
| 1401 | var_dum_real_3d(k,nys:nyn,nxl:nxr) |
---|
| 1402 | CALL exchange_horiz_2d( var_exchange_real, nbgp ) |
---|
| 1403 | vegetation_pars_f%pars_xy(k,:,:) = var_exchange_real(:,:) |
---|
| 1404 | ENDDO |
---|
| 1405 | DEALLOCATE( var_dum_real_3d ) |
---|
| 1406 | ENDIF |
---|
| 1407 | |
---|
| 1408 | IF ( water_pars_f%from_file ) THEN |
---|
| 1409 | ALLOCATE( var_dum_real_3d(0:water_pars_f%np-1,nys:nyn,nxl:nxr) ) |
---|
| 1410 | var_dum_real_3d = water_pars_f%pars_xy |
---|
| 1411 | DEALLOCATE( water_pars_f%pars_xy ) |
---|
| 1412 | ALLOCATE( water_pars_f%pars_xy(0:water_pars_f%np-1, & |
---|
| 1413 | nysg:nyng,nxlg:nxrg) ) |
---|
| 1414 | water_pars_f%pars_xy = water_pars_f%fill |
---|
| 1415 | DO k = 0, water_pars_f%np-1 |
---|
| 1416 | var_exchange_real(nys:nyn,nxl:nxr) = & |
---|
| 1417 | var_dum_real_3d(k,nys:nyn,nxl:nxr) |
---|
| 1418 | CALL exchange_horiz_2d( var_exchange_real, nbgp ) |
---|
| 1419 | water_pars_f%pars_xy(k,:,:) = var_exchange_real(:,:) |
---|
| 1420 | ENDDO |
---|
| 1421 | DEALLOCATE( var_dum_real_3d ) |
---|
| 1422 | ENDIF |
---|
| 1423 | |
---|
| 1424 | IF ( root_area_density_lsm_f%from_file ) THEN |
---|
| 1425 | ALLOCATE( var_dum_real_3d(0:root_area_density_lsm_f%nz-1,nys:nyn,nxl:nxr) ) |
---|
| 1426 | var_dum_real_3d = root_area_density_lsm_f%var |
---|
| 1427 | DEALLOCATE( root_area_density_lsm_f%var ) |
---|
| 1428 | ALLOCATE( root_area_density_lsm_f%var(0:root_area_density_lsm_f%nz-1,& |
---|
| 1429 | nysg:nyng,nxlg:nxrg) ) |
---|
| 1430 | root_area_density_lsm_f%var = root_area_density_lsm_f%fill |
---|
| 1431 | |
---|
| 1432 | DO k = 0, root_area_density_lsm_f%nz-1 |
---|
| 1433 | var_exchange_real(nys:nyn,nxl:nxr) = & |
---|
| 1434 | var_dum_real_3d(k,nys:nyn,nxl:nxr) |
---|
| 1435 | CALL exchange_horiz_2d( var_exchange_real, nbgp ) |
---|
| 1436 | root_area_density_lsm_f%var(k,:,:) = var_exchange_real(:,:) |
---|
| 1437 | ENDDO |
---|
| 1438 | DEALLOCATE( var_dum_real_3d ) |
---|
| 1439 | ENDIF |
---|
| 1440 | |
---|
| 1441 | IF ( soil_pars_f%from_file ) THEN |
---|
| 1442 | IF ( soil_pars_f%lod == 1 ) THEN |
---|
| 1443 | |
---|
| 1444 | ALLOCATE( var_dum_real_3d(0:soil_pars_f%np-1,nys:nyn,nxl:nxr) ) |
---|
| 1445 | var_dum_real_3d = soil_pars_f%pars_xy |
---|
| 1446 | DEALLOCATE( soil_pars_f%pars_xy ) |
---|
| 1447 | ALLOCATE( soil_pars_f%pars_xy(0:soil_pars_f%np-1, & |
---|
| 1448 | nysg:nyng,nxlg:nxrg) ) |
---|
| 1449 | soil_pars_f%pars_xy = soil_pars_f%fill |
---|
| 1450 | |
---|
| 1451 | DO k = 0, soil_pars_f%np-1 |
---|
| 1452 | var_exchange_real(nys:nyn,nxl:nxr) = & |
---|
| 1453 | var_dum_real_3d(k,nys:nyn,nxl:nxr) |
---|
| 1454 | CALL exchange_horiz_2d( var_exchange_real, nbgp ) |
---|
| 1455 | soil_pars_f%pars_xy(k,:,:) = var_exchange_real(:,:) |
---|
| 1456 | ENDDO |
---|
| 1457 | DEALLOCATE( var_dum_real_3d ) |
---|
| 1458 | ELSEIF ( soil_pars_f%lod == 2 ) THEN |
---|
| 1459 | ALLOCATE( var_dum_real_4d(0:soil_pars_f%np-1, & |
---|
| 1460 | 0:soil_pars_f%nz-1, & |
---|
| 1461 | nys:nyn,nxl:nxr) ) |
---|
| 1462 | var_dum_real_4d = soil_pars_f%pars_xyz |
---|
| 1463 | DEALLOCATE( soil_pars_f%pars_xyz ) |
---|
| 1464 | ALLOCATE( soil_pars_f%pars_xyz(0:soil_pars_f%np-1, & |
---|
| 1465 | 0:soil_pars_f%nz-1, & |
---|
| 1466 | nysg:nyng,nxlg:nxrg) ) |
---|
| 1467 | soil_pars_f%pars_xyz = soil_pars_f%fill |
---|
| 1468 | |
---|
| 1469 | DO k2 = 0, soil_pars_f%nz-1 |
---|
| 1470 | DO k = 0, soil_pars_f%np-1 |
---|
| 1471 | var_exchange_real(nys:nyn,nxl:nxr) = & |
---|
| 1472 | var_dum_real_4d(k,k2,nys:nyn,nxl:nxr) |
---|
| 1473 | CALL exchange_horiz_2d( var_exchange_real, nbgp ) |
---|
| 1474 | |
---|
| 1475 | soil_pars_f%pars_xyz(k,k2,:,:) = var_exchange_real(:,:) |
---|
| 1476 | ENDDO |
---|
| 1477 | ENDDO |
---|
| 1478 | DEALLOCATE( var_dum_real_4d ) |
---|
| 1479 | ENDIF |
---|
| 1480 | ENDIF |
---|
| 1481 | |
---|
| 1482 | IF ( pavement_subsurface_pars_f%from_file ) THEN |
---|
| 1483 | ALLOCATE( var_dum_real_4d(0:pavement_subsurface_pars_f%np-1, & |
---|
| 1484 | 0:pavement_subsurface_pars_f%nz-1, & |
---|
| 1485 | nys:nyn,nxl:nxr) ) |
---|
| 1486 | var_dum_real_4d = pavement_subsurface_pars_f%pars_xyz |
---|
| 1487 | DEALLOCATE( pavement_subsurface_pars_f%pars_xyz ) |
---|
| 1488 | ALLOCATE( pavement_subsurface_pars_f%pars_xyz & |
---|
| 1489 | (0:pavement_subsurface_pars_f%np-1, & |
---|
| 1490 | 0:pavement_subsurface_pars_f%nz-1, & |
---|
| 1491 | nysg:nyng,nxlg:nxrg) ) |
---|
| 1492 | pavement_subsurface_pars_f%pars_xyz = pavement_subsurface_pars_f%fill |
---|
| 1493 | |
---|
| 1494 | DO k2 = 0, pavement_subsurface_pars_f%nz-1 |
---|
| 1495 | DO k = 0, pavement_subsurface_pars_f%np-1 |
---|
| 1496 | var_exchange_real(nys:nyn,nxl:nxr) = & |
---|
| 1497 | var_dum_real_4d(k,k2,nys:nyn,nxl:nxr) |
---|
| 1498 | CALL exchange_horiz_2d( var_exchange_real, nbgp ) |
---|
| 1499 | pavement_subsurface_pars_f%pars_xyz(k,k2,:,:) = & |
---|
| 1500 | var_exchange_real(:,:) |
---|
| 1501 | ENDDO |
---|
| 1502 | ENDDO |
---|
| 1503 | DEALLOCATE( var_dum_real_4d ) |
---|
| 1504 | ENDIF |
---|
| 1505 | |
---|
| 1506 | ! |
---|
| 1507 | !-- In case of non-cyclic boundary conditions, set Neumann conditions at the |
---|
| 1508 | !-- lateral boundaries. |
---|
| 1509 | IF ( .NOT. bc_ns_cyc ) THEN |
---|
| 1510 | IF ( nys == 0 ) THEN |
---|
| 1511 | IF ( albedo_type_f%from_file ) & |
---|
| 1512 | albedo_type_f%var(-1,:) = albedo_type_f%var(0,:) |
---|
| 1513 | IF ( pavement_type_f%from_file ) & |
---|
| 1514 | pavement_type_f%var(-1,:) = pavement_type_f%var(0,:) |
---|
| 1515 | IF ( soil_type_f%from_file ) THEN |
---|
| 1516 | IF ( ALLOCATED( soil_type_f%var_2d ) ) THEN |
---|
| 1517 | soil_type_f%var_2d(-1,:) = soil_type_f%var_2d(0,:) |
---|
| 1518 | ELSE |
---|
| 1519 | soil_type_f%var_3d(:,-1,:) = soil_type_f%var_3d(:,0,:) |
---|
| 1520 | ENDIF |
---|
| 1521 | ENDIF |
---|
| 1522 | IF ( vegetation_type_f%from_file ) & |
---|
| 1523 | vegetation_type_f%var(-1,:) = vegetation_type_f%var(0,:) |
---|
| 1524 | IF ( water_type_f%from_file ) & |
---|
| 1525 | water_type_f%var(-1,:) = water_type_f%var(0,:) |
---|
| 1526 | IF ( surface_fraction_f%from_file ) & |
---|
| 1527 | surface_fraction_f%frac(:,-1,:) = surface_fraction_f%frac(:,0,:) |
---|
| 1528 | IF ( building_pars_f%from_file ) & |
---|
| 1529 | building_pars_f%pars_xy(:,-1,:) = building_pars_f%pars_xy(:,0,:) |
---|
| 1530 | IF ( albedo_pars_f%from_file ) & |
---|
| 1531 | albedo_pars_f%pars_xy(:,-1,:) = albedo_pars_f%pars_xy(:,0,:) |
---|
| 1532 | IF ( pavement_pars_f%from_file ) & |
---|
| 1533 | pavement_pars_f%pars_xy(:,-1,:) = pavement_pars_f%pars_xy(:,0,:) |
---|
| 1534 | IF ( vegetation_pars_f%from_file ) & |
---|
| 1535 | vegetation_pars_f%pars_xy(:,-1,:) = & |
---|
| 1536 | vegetation_pars_f%pars_xy(:,0,:) |
---|
| 1537 | IF ( water_pars_f%from_file ) & |
---|
| 1538 | water_pars_f%pars_xy(:,-1,:) = water_pars_f%pars_xy(:,0,:) |
---|
| 1539 | IF ( root_area_density_lsm_f%from_file ) & |
---|
| 1540 | root_area_density_lsm_f%var(:,-1,:) = & |
---|
| 1541 | root_area_density_lsm_f%var(:,0,:) |
---|
| 1542 | IF ( soil_pars_f%from_file ) THEN |
---|
| 1543 | IF ( soil_pars_f%lod == 1 ) THEN |
---|
| 1544 | soil_pars_f%pars_xy(:,-1,:) = soil_pars_f%pars_xy(:,0,:) |
---|
| 1545 | ELSE |
---|
| 1546 | soil_pars_f%pars_xyz(:,:,-1,:) = soil_pars_f%pars_xyz(:,:,0,:) |
---|
| 1547 | ENDIF |
---|
| 1548 | ENDIF |
---|
| 1549 | IF ( pavement_subsurface_pars_f%from_file ) & |
---|
| 1550 | pavement_subsurface_pars_f%pars_xyz(:,:,-1,:) = & |
---|
| 1551 | pavement_subsurface_pars_f%pars_xyz(:,:,0,:) |
---|
| 1552 | ENDIF |
---|
| 1553 | |
---|
| 1554 | IF ( nyn == ny ) THEN |
---|
| 1555 | IF ( albedo_type_f%from_file ) & |
---|
| 1556 | albedo_type_f%var(ny+1,:) = albedo_type_f%var(ny,:) |
---|
| 1557 | IF ( pavement_type_f%from_file ) & |
---|
| 1558 | pavement_type_f%var(ny+1,:) = pavement_type_f%var(ny,:) |
---|
| 1559 | IF ( soil_type_f%from_file ) THEN |
---|
| 1560 | IF ( ALLOCATED( soil_type_f%var_2d ) ) THEN |
---|
| 1561 | soil_type_f%var_2d(ny+1,:) = soil_type_f%var_2d(ny,:) |
---|
| 1562 | ELSE |
---|
| 1563 | soil_type_f%var_3d(:,ny+1,:) = soil_type_f%var_3d(:,ny,:) |
---|
| 1564 | ENDIF |
---|
| 1565 | ENDIF |
---|
| 1566 | IF ( vegetation_type_f%from_file ) & |
---|
| 1567 | vegetation_type_f%var(ny+1,:) = vegetation_type_f%var(ny,:) |
---|
| 1568 | IF ( water_type_f%from_file ) & |
---|
| 1569 | water_type_f%var(ny+1,:) = water_type_f%var(ny,:) |
---|
| 1570 | IF ( surface_fraction_f%from_file ) & |
---|
| 1571 | surface_fraction_f%frac(:,ny+1,:) = & |
---|
| 1572 | surface_fraction_f%frac(:,ny,:) |
---|
| 1573 | IF ( building_pars_f%from_file ) & |
---|
| 1574 | building_pars_f%pars_xy(:,ny+1,:) = & |
---|
| 1575 | building_pars_f%pars_xy(:,ny,:) |
---|
| 1576 | IF ( albedo_pars_f%from_file ) & |
---|
| 1577 | albedo_pars_f%pars_xy(:,ny+1,:) = albedo_pars_f%pars_xy(:,ny,:) |
---|
| 1578 | IF ( pavement_pars_f%from_file ) & |
---|
| 1579 | pavement_pars_f%pars_xy(:,ny+1,:) = & |
---|
| 1580 | pavement_pars_f%pars_xy(:,ny,:) |
---|
| 1581 | IF ( vegetation_pars_f%from_file ) & |
---|
| 1582 | vegetation_pars_f%pars_xy(:,ny+1,:) = & |
---|
| 1583 | vegetation_pars_f%pars_xy(:,ny,:) |
---|
| 1584 | IF ( water_pars_f%from_file ) & |
---|
| 1585 | water_pars_f%pars_xy(:,ny+1,:) = water_pars_f%pars_xy(:,ny,:) |
---|
| 1586 | IF ( root_area_density_lsm_f%from_file ) & |
---|
| 1587 | root_area_density_lsm_f%var(:,ny+1,:) = & |
---|
| 1588 | root_area_density_lsm_f%var(:,ny,:) |
---|
| 1589 | IF ( soil_pars_f%from_file ) THEN |
---|
| 1590 | IF ( soil_pars_f%lod == 1 ) THEN |
---|
| 1591 | soil_pars_f%pars_xy(:,ny+1,:) = soil_pars_f%pars_xy(:,ny,:) |
---|
| 1592 | ELSE |
---|
| 1593 | soil_pars_f%pars_xyz(:,:,ny+1,:) = & |
---|
| 1594 | soil_pars_f%pars_xyz(:,:,ny,:) |
---|
| 1595 | ENDIF |
---|
| 1596 | ENDIF |
---|
| 1597 | IF ( pavement_subsurface_pars_f%from_file ) & |
---|
| 1598 | pavement_subsurface_pars_f%pars_xyz(:,:,ny+1,:) = & |
---|
| 1599 | pavement_subsurface_pars_f%pars_xyz(:,:,ny,:) |
---|
| 1600 | ENDIF |
---|
| 1601 | ENDIF |
---|
| 1602 | |
---|
| 1603 | IF ( .NOT. bc_lr_cyc ) THEN |
---|
| 1604 | IF ( nxl == 0 ) THEN |
---|
| 1605 | IF ( albedo_type_f%from_file ) & |
---|
| 1606 | albedo_type_f%var(:,-1) = albedo_type_f%var(:,0) |
---|
| 1607 | IF ( pavement_type_f%from_file ) & |
---|
| 1608 | pavement_type_f%var(:,-1) = pavement_type_f%var(:,0) |
---|
| 1609 | IF ( soil_type_f%from_file ) THEN |
---|
| 1610 | IF ( ALLOCATED( soil_type_f%var_2d ) ) THEN |
---|
| 1611 | soil_type_f%var_2d(:,-1) = soil_type_f%var_2d(:,0) |
---|
| 1612 | ELSE |
---|
| 1613 | soil_type_f%var_3d(:,:,-1) = soil_type_f%var_3d(:,:,0) |
---|
| 1614 | ENDIF |
---|
| 1615 | ENDIF |
---|
| 1616 | IF ( vegetation_type_f%from_file ) & |
---|
| 1617 | vegetation_type_f%var(:,-1) = vegetation_type_f%var(:,0) |
---|
| 1618 | IF ( water_type_f%from_file ) & |
---|
| 1619 | water_type_f%var(:,-1) = water_type_f%var(:,0) |
---|
| 1620 | IF ( surface_fraction_f%from_file ) & |
---|
| 1621 | surface_fraction_f%frac(:,:,-1) = surface_fraction_f%frac(:,:,0) |
---|
| 1622 | IF ( building_pars_f%from_file ) & |
---|
| 1623 | building_pars_f%pars_xy(:,:,-1) = building_pars_f%pars_xy(:,:,0) |
---|
| 1624 | IF ( albedo_pars_f%from_file ) & |
---|
| 1625 | albedo_pars_f%pars_xy(:,:,-1) = albedo_pars_f%pars_xy(:,:,0) |
---|
| 1626 | IF ( pavement_pars_f%from_file ) & |
---|
| 1627 | pavement_pars_f%pars_xy(:,:,-1) = pavement_pars_f%pars_xy(:,:,0) |
---|
| 1628 | IF ( vegetation_pars_f%from_file ) & |
---|
| 1629 | vegetation_pars_f%pars_xy(:,:,-1) = & |
---|
| 1630 | vegetation_pars_f%pars_xy(:,:,0) |
---|
| 1631 | IF ( water_pars_f%from_file ) & |
---|
| 1632 | water_pars_f%pars_xy(:,:,-1) = water_pars_f%pars_xy(:,:,0) |
---|
| 1633 | IF ( root_area_density_lsm_f%from_file ) & |
---|
| 1634 | root_area_density_lsm_f%var(:,:,-1) = & |
---|
| 1635 | root_area_density_lsm_f%var(:,:,0) |
---|
| 1636 | IF ( soil_pars_f%from_file ) THEN |
---|
| 1637 | IF ( soil_pars_f%lod == 1 ) THEN |
---|
| 1638 | soil_pars_f%pars_xy(:,:,-1) = soil_pars_f%pars_xy(:,:,0) |
---|
| 1639 | ELSE |
---|
| 1640 | soil_pars_f%pars_xyz(:,:,:,-1) = soil_pars_f%pars_xyz(:,:,:,0) |
---|
| 1641 | ENDIF |
---|
| 1642 | ENDIF |
---|
| 1643 | IF ( pavement_subsurface_pars_f%from_file ) & |
---|
| 1644 | pavement_subsurface_pars_f%pars_xyz(:,:,:,-1) = & |
---|
| 1645 | pavement_subsurface_pars_f%pars_xyz(:,:,:,0) |
---|
| 1646 | ENDIF |
---|
| 1647 | |
---|
| 1648 | IF ( nxr == nx ) THEN |
---|
| 1649 | IF ( albedo_type_f%from_file ) & |
---|
| 1650 | albedo_type_f%var(:,nx+1) = albedo_type_f%var(:,nx) |
---|
| 1651 | IF ( pavement_type_f%from_file ) & |
---|
| 1652 | pavement_type_f%var(:,nx+1) = pavement_type_f%var(:,nx) |
---|
| 1653 | IF ( soil_type_f%from_file ) THEN |
---|
| 1654 | IF ( ALLOCATED( soil_type_f%var_2d ) ) THEN |
---|
| 1655 | soil_type_f%var_2d(:,nx+1) = soil_type_f%var_2d(:,nx) |
---|
| 1656 | ELSE |
---|
| 1657 | soil_type_f%var_3d(:,:,nx+1) = soil_type_f%var_3d(:,:,nx) |
---|
| 1658 | ENDIF |
---|
| 1659 | ENDIF |
---|
| 1660 | IF ( vegetation_type_f%from_file ) & |
---|
| 1661 | vegetation_type_f%var(:,nx+1) = vegetation_type_f%var(:,nx) |
---|
| 1662 | IF ( water_type_f%from_file ) & |
---|
| 1663 | water_type_f%var(:,nx+1) = water_type_f%var(:,nx) |
---|
| 1664 | IF ( surface_fraction_f%from_file ) & |
---|
| 1665 | surface_fraction_f%frac(:,:,nx+1) = & |
---|
| 1666 | surface_fraction_f%frac(:,:,nx) |
---|
| 1667 | IF ( building_pars_f%from_file ) & |
---|
| 1668 | building_pars_f%pars_xy(:,:,nx+1) = & |
---|
| 1669 | building_pars_f%pars_xy(:,:,nx) |
---|
| 1670 | IF ( albedo_pars_f%from_file ) & |
---|
| 1671 | albedo_pars_f%pars_xy(:,:,nx+1) = albedo_pars_f%pars_xy(:,:,nx) |
---|
| 1672 | IF ( pavement_pars_f%from_file ) & |
---|
| 1673 | pavement_pars_f%pars_xy(:,:,nx+1) = & |
---|
| 1674 | pavement_pars_f%pars_xy(:,:,nx) |
---|
| 1675 | IF ( vegetation_pars_f%from_file ) & |
---|
| 1676 | vegetation_pars_f%pars_xy(:,:,nx+1) = & |
---|
| 1677 | vegetation_pars_f%pars_xy(:,:,nx) |
---|
| 1678 | IF ( water_pars_f%from_file ) & |
---|
| 1679 | water_pars_f%pars_xy(:,:,nx+1) = water_pars_f%pars_xy(:,:,nx) |
---|
| 1680 | IF ( root_area_density_lsm_f%from_file ) & |
---|
| 1681 | root_area_density_lsm_f%var(:,:,nx+1) = & |
---|
| 1682 | root_area_density_lsm_f%var(:,:,nx) |
---|
| 1683 | IF ( soil_pars_f%from_file ) THEN |
---|
| 1684 | IF ( soil_pars_f%lod == 1 ) THEN |
---|
| 1685 | soil_pars_f%pars_xy(:,:,nx+1) = soil_pars_f%pars_xy(:,:,nx) |
---|
| 1686 | ELSE |
---|
| 1687 | soil_pars_f%pars_xyz(:,:,:,nx+1) = & |
---|
| 1688 | soil_pars_f%pars_xyz(:,:,:,nx) |
---|
| 1689 | ENDIF |
---|
| 1690 | ENDIF |
---|
| 1691 | IF ( pavement_subsurface_pars_f%from_file ) & |
---|
| 1692 | pavement_subsurface_pars_f%pars_xyz(:,:,:,nx+1) = & |
---|
| 1693 | pavement_subsurface_pars_f%pars_xyz(:,:,:,nx) |
---|
| 1694 | ENDIF |
---|
| 1695 | ENDIF |
---|
| 1696 | |
---|
[2586] | 1697 | END SUBROUTINE netcdf_data_input_surface_data |
---|
| 1698 | |
---|
| 1699 | !------------------------------------------------------------------------------! |
---|
| 1700 | ! Description: |
---|
| 1701 | ! ------------ |
---|
| 1702 | !> Reads orography and building information. |
---|
| 1703 | !------------------------------------------------------------------------------! |
---|
| 1704 | SUBROUTINE netcdf_data_input_topo |
---|
| 1705 | |
---|
| 1706 | USE control_parameters, & |
---|
[2646] | 1707 | ONLY: bc_lr_cyc, bc_ns_cyc, message_string, topography |
---|
[2586] | 1708 | |
---|
| 1709 | USE indices, & |
---|
[2646] | 1710 | ONLY: nbgp, nx, nxl, nxr, ny, nyn, nys, nzb, nzt |
---|
| 1711 | |
---|
[2586] | 1712 | |
---|
| 1713 | IMPLICIT NONE |
---|
| 1714 | |
---|
| 1715 | CHARACTER(LEN=100), DIMENSION(:), ALLOCATABLE :: var_names !< variable names in static input file |
---|
| 1716 | |
---|
| 1717 | |
---|
[2646] | 1718 | INTEGER(iwp) :: i !< running index along x-direction |
---|
| 1719 | INTEGER(iwp) :: ii !< running index for IO blocks |
---|
| 1720 | INTEGER(iwp) :: id_topo !< NetCDF id of topograhy input file |
---|
| 1721 | INTEGER(iwp) :: j !< running index along y-direction |
---|
| 1722 | INTEGER(iwp) :: k !< running index along z-direction |
---|
| 1723 | INTEGER(iwp) :: num_vars !< number of variables in netcdf input file |
---|
| 1724 | INTEGER(iwp) :: skip_n_rows !< counting variable to skip rows while reading topography file |
---|
[2586] | 1725 | |
---|
[2646] | 1726 | INTEGER(iwp), DIMENSION(nys-nbgp:nyn+nbgp,nxl-nbgp:nxr+nbgp) :: var_exchange_int !< dummy variables used to exchange 32-bit Integer arrays |
---|
[2586] | 1727 | |
---|
| 1728 | REAL(wp) :: dum !< dummy variable to skip columns while reading topography file |
---|
[2955] | 1729 | ! |
---|
| 1730 | !-- CPU measurement |
---|
| 1731 | CALL cpu_log( log_point_s(83), 'NetCDF/ASCII input topo', 'start' ) |
---|
[2586] | 1732 | |
---|
| 1733 | DO ii = 0, io_blocks-1 |
---|
| 1734 | IF ( ii == io_group ) THEN |
---|
| 1735 | ! |
---|
| 1736 | !-- Input via palm-input data standard |
---|
| 1737 | IF ( input_pids_static ) THEN |
---|
[2874] | 1738 | #if defined ( __netcdf ) |
---|
[2586] | 1739 | ! |
---|
| 1740 | !-- Open file in read-only mode |
---|
[2589] | 1741 | CALL open_read_file( TRIM( input_file_static ) // & |
---|
| 1742 | TRIM( coupling_char ), id_topo ) |
---|
[2586] | 1743 | |
---|
| 1744 | ! |
---|
| 1745 | !-- At first, inquire all variable names. |
---|
| 1746 | !-- This will be used to check whether an input variable exist |
---|
| 1747 | !-- or not. |
---|
| 1748 | CALL inquire_num_variables( id_topo, num_vars ) |
---|
| 1749 | ! |
---|
| 1750 | !-- Allocate memory to store variable names and inquire them. |
---|
| 1751 | ALLOCATE( var_names(1:num_vars) ) |
---|
| 1752 | CALL inquire_variable_names( id_topo, var_names ) |
---|
| 1753 | ! |
---|
[2945] | 1754 | !-- Read x, y - dimensions. Only required for consistency checks. |
---|
[2898] | 1755 | CALL get_dimension_length( id_topo, dim_static%nx, 'x' ) |
---|
| 1756 | CALL get_dimension_length( id_topo, dim_static%ny, 'y' ) |
---|
| 1757 | ALLOCATE( dim_static%x(0:dim_static%nx-1) ) |
---|
| 1758 | ALLOCATE( dim_static%y(0:dim_static%ny-1) ) |
---|
| 1759 | CALL get_variable( id_topo, 'x', dim_static%x ) |
---|
| 1760 | CALL get_variable( id_topo, 'y', dim_static%y ) |
---|
| 1761 | ! |
---|
[2586] | 1762 | !-- Terrain height. First, get variable-related _FillValue attribute |
---|
| 1763 | IF ( check_existence( var_names, 'orography_2D' ) ) THEN |
---|
| 1764 | terrain_height_f%from_file = .TRUE. |
---|
| 1765 | CALL get_attribute( id_topo, char_fill, & |
---|
| 1766 | terrain_height_f%fill, & |
---|
| 1767 | .FALSE., 'orography_2D' ) |
---|
| 1768 | ! |
---|
| 1769 | !-- PE-wise reading of 2D terrain height. |
---|
| 1770 | ALLOCATE ( terrain_height_f%var(nys:nyn,nxl:nxr) ) |
---|
| 1771 | DO i = nxl, nxr |
---|
| 1772 | CALL get_variable( id_topo, 'orography_2D', & |
---|
| 1773 | i, terrain_height_f%var(:,i) ) |
---|
| 1774 | ENDDO |
---|
| 1775 | ELSE |
---|
| 1776 | terrain_height_f%from_file = .FALSE. |
---|
| 1777 | ENDIF |
---|
| 1778 | |
---|
| 1779 | ! |
---|
| 1780 | !-- Read building height. First, read its _FillValue attribute, |
---|
| 1781 | !-- as well as lod attribute |
---|
[2637] | 1782 | buildings_f%from_file = .FALSE. |
---|
[2586] | 1783 | IF ( check_existence( var_names, 'buildings_2D' ) ) THEN |
---|
| 1784 | buildings_f%from_file = .TRUE. |
---|
| 1785 | CALL get_attribute( id_topo, char_lod, buildings_f%lod, & |
---|
| 1786 | .FALSE., 'buildings_2D' ) |
---|
| 1787 | |
---|
[2637] | 1788 | CALL get_attribute( id_topo, char_fill, & |
---|
[2642] | 1789 | buildings_f%fill1, & |
---|
| 1790 | .FALSE., 'buildings_2D' ) |
---|
[2586] | 1791 | |
---|
| 1792 | ! |
---|
[2637] | 1793 | !-- Read 2D topography |
---|
[2586] | 1794 | IF ( buildings_f%lod == 1 ) THEN |
---|
| 1795 | ALLOCATE ( buildings_f%var_2d(nys:nyn,nxl:nxr) ) |
---|
| 1796 | DO i = nxl, nxr |
---|
| 1797 | CALL get_variable( id_topo, 'buildings_2D', & |
---|
| 1798 | i, buildings_f%var_2d(:,i) ) |
---|
| 1799 | ENDDO |
---|
| 1800 | ELSE |
---|
| 1801 | message_string = 'NetCDF attribute lod ' // & |
---|
[2925] | 1802 | '(level of detail) is not set ' // & |
---|
| 1803 | 'properly for buildings_2D.' |
---|
| 1804 | CALL message( 'netcdf_data_input_mod', 'NDI000', & |
---|
[2586] | 1805 | 1, 2, 0, 6, 0 ) |
---|
| 1806 | ENDIF |
---|
| 1807 | ENDIF |
---|
| 1808 | ! |
---|
[2637] | 1809 | !-- If available, also read 3D building information. If both are |
---|
| 1810 | !-- available, use 3D information. |
---|
[2773] | 1811 | IF ( check_existence( var_names, 'buildings_3D' ) ) THEN |
---|
| 1812 | buildings_f%from_file = .TRUE. |
---|
| 1813 | CALL get_attribute( id_topo, char_lod, buildings_f%lod, & |
---|
| 1814 | .FALSE., 'buildings_3D' ) |
---|
| 1815 | |
---|
| 1816 | CALL get_attribute( id_topo, char_fill, & |
---|
| 1817 | buildings_f%fill2, & |
---|
| 1818 | .FALSE., 'buildings_3D' ) |
---|
| 1819 | |
---|
| 1820 | CALL get_dimension_length( id_topo, buildings_f%nz, 'z' ) |
---|
| 1821 | |
---|
| 1822 | IF ( buildings_f%lod == 2 ) THEN |
---|
[2787] | 1823 | ALLOCATE( buildings_f%z(nzb:buildings_f%nz-1) ) |
---|
| 1824 | CALL get_variable( id_topo, 'z', buildings_f%z ) |
---|
| 1825 | |
---|
| 1826 | ALLOCATE( buildings_f%var_3d(nzb:buildings_f%nz-1, & |
---|
[2773] | 1827 | nys:nyn,nxl:nxr) ) |
---|
| 1828 | buildings_f%var_3d = 0 |
---|
[2637] | 1829 | ! |
---|
[2773] | 1830 | !-- Read data PE-wise. Read yz-slices. |
---|
| 1831 | DO i = nxl, nxr |
---|
| 1832 | DO j = nys, nyn |
---|
| 1833 | CALL get_variable( id_topo, 'buildings_3D', & |
---|
| 1834 | i, j, & |
---|
| 1835 | buildings_f%var_3d(:,j,i) ) |
---|
| 1836 | ENDDO |
---|
| 1837 | ENDDO |
---|
| 1838 | ELSE |
---|
| 1839 | message_string = 'NetCDF attribute lod ' // & |
---|
[2925] | 1840 | '(level of detail) is not set ' // & |
---|
| 1841 | 'properly for buildings_3D.' |
---|
| 1842 | CALL message( 'netcdf_data_input_mod', 'NDI001', & |
---|
[2773] | 1843 | 1, 2, 0, 6, 0 ) |
---|
| 1844 | ENDIF |
---|
| 1845 | ENDIF |
---|
| 1846 | ! |
---|
[2586] | 1847 | !-- Read building IDs and its FillValue attribute. Further required |
---|
| 1848 | !-- for mapping buildings on top of orography. |
---|
[2614] | 1849 | IF ( check_existence( var_names, 'building_id' ) ) THEN |
---|
[2586] | 1850 | building_id_f%from_file = .TRUE. |
---|
| 1851 | CALL get_attribute( id_topo, char_fill, & |
---|
| 1852 | building_id_f%fill, .FALSE., & |
---|
| 1853 | 'building_id' ) |
---|
| 1854 | |
---|
| 1855 | |
---|
| 1856 | ALLOCATE ( building_id_f%var(nys:nyn,nxl:nxr) ) |
---|
| 1857 | DO i = nxl, nxr |
---|
| 1858 | CALL get_variable( id_topo, 'building_id', & |
---|
| 1859 | i, building_id_f%var(:,i) ) |
---|
| 1860 | ENDDO |
---|
| 1861 | ELSE |
---|
| 1862 | building_id_f%from_file = .FALSE. |
---|
| 1863 | ENDIF |
---|
[2642] | 1864 | ! |
---|
| 1865 | !-- Read building_type and required attributes. |
---|
| 1866 | IF ( check_existence( var_names, 'building_type' ) ) THEN |
---|
| 1867 | building_type_f%from_file = .TRUE. |
---|
| 1868 | CALL get_attribute( id_topo, char_fill, & |
---|
| 1869 | building_type_f%fill, .FALSE., & |
---|
| 1870 | 'building_type' ) |
---|
| 1871 | |
---|
| 1872 | ALLOCATE ( building_type_f%var(nys:nyn,nxl:nxr) ) |
---|
| 1873 | DO i = nxl, nxr |
---|
| 1874 | CALL get_variable( id_topo, 'building_type', & |
---|
| 1875 | i, building_type_f%var(:,i) ) |
---|
| 1876 | ENDDO |
---|
| 1877 | ELSE |
---|
| 1878 | building_type_f%from_file = .FALSE. |
---|
| 1879 | ENDIF |
---|
[2586] | 1880 | |
---|
| 1881 | ! |
---|
| 1882 | !-- Close topography input file |
---|
[2711] | 1883 | CALL close_input_file( id_topo ) |
---|
[2874] | 1884 | #else |
---|
| 1885 | CONTINUE |
---|
[2586] | 1886 | #endif |
---|
| 1887 | ! |
---|
| 1888 | !-- ASCII input |
---|
[2945] | 1889 | ELSEIF ( TRIM( topography ) == 'read_from_file' ) THEN |
---|
[2586] | 1890 | |
---|
| 1891 | OPEN( 90, FILE='TOPOGRAPHY_DATA'//TRIM( coupling_char ), & |
---|
| 1892 | STATUS='OLD', FORM='FORMATTED', ERR=10 ) |
---|
| 1893 | ! |
---|
| 1894 | !-- Read topography PE-wise. Rows are read from nyn to nys, columns |
---|
| 1895 | !-- are read from nxl to nxr. At first, ny-nyn rows need to be skipped. |
---|
| 1896 | skip_n_rows = 0 |
---|
| 1897 | DO WHILE ( skip_n_rows < ny - nyn ) |
---|
| 1898 | READ( 90, * ) |
---|
| 1899 | skip_n_rows = skip_n_rows + 1 |
---|
| 1900 | ENDDO |
---|
| 1901 | ! |
---|
| 1902 | !-- Read data from nyn to nys and nxl to nxr. Therefore, skip |
---|
| 1903 | !-- column until nxl-1 is reached |
---|
| 1904 | ALLOCATE ( buildings_f%var_2d(nys:nyn,nxl:nxr) ) |
---|
| 1905 | DO j = nyn, nys, -1 |
---|
| 1906 | READ( 90, *, ERR=11, END=11 ) & |
---|
| 1907 | ( dum, i = 0, nxl-1 ), & |
---|
| 1908 | ( buildings_f%var_2d(j,i), i = nxl, nxr ) |
---|
| 1909 | ENDDO |
---|
| 1910 | |
---|
| 1911 | GOTO 12 |
---|
| 1912 | |
---|
| 1913 | 10 message_string = 'file TOPOGRAPHY'//TRIM( coupling_char )// & |
---|
| 1914 | ' does not exist' |
---|
| 1915 | CALL message( 'netcdf_data_input_mod', 'PA0208', 1, 2, 0, 6, 0 ) |
---|
| 1916 | |
---|
| 1917 | 11 message_string = 'errors in file TOPOGRAPHY_DATA'// & |
---|
| 1918 | TRIM( coupling_char ) |
---|
| 1919 | CALL message( 'netcdf_data_input_mod', 'PA0209', 1, 2, 0, 6, 0 ) |
---|
| 1920 | |
---|
| 1921 | 12 CLOSE( 90 ) |
---|
| 1922 | buildings_f%from_file = .TRUE. |
---|
| 1923 | |
---|
| 1924 | ENDIF |
---|
| 1925 | |
---|
| 1926 | ENDIF |
---|
| 1927 | #if defined( __parallel ) |
---|
| 1928 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 1929 | #endif |
---|
| 1930 | ENDDO |
---|
[2637] | 1931 | ! |
---|
[2955] | 1932 | !-- End of CPU measurement |
---|
| 1933 | CALL cpu_log( log_point_s(83), 'NetCDF/ASCII input topo', 'stop' ) |
---|
| 1934 | ! |
---|
[2897] | 1935 | !-- Check for minimum requirement to setup building topography. If buildings |
---|
| 1936 | !-- are provided, also an ID and a type are required. |
---|
| 1937 | !-- Note, doing this check in check_parameters |
---|
[2637] | 1938 | !-- will be too late (data will be used for grid inititialization before). |
---|
| 1939 | IF ( input_pids_static ) THEN |
---|
[2897] | 1940 | IF ( buildings_f%from_file .AND. & |
---|
| 1941 | .NOT. building_id_f%from_file ) THEN |
---|
| 1942 | message_string = 'If building heigths are prescribed in ' // & |
---|
| 1943 | 'static input file, also an ID is required.' |
---|
[2925] | 1944 | CALL message( 'netcdf_data_input_mod', 'NDI002', 1, 2, 0, 6, 0 ) |
---|
[2637] | 1945 | ENDIF |
---|
| 1946 | ENDIF |
---|
[2646] | 1947 | ! |
---|
[2897] | 1948 | !-- In case no terrain height is provided by static input file, allocate |
---|
| 1949 | !-- array nevertheless and set terrain height to 0, which simplifies |
---|
| 1950 | !-- topography initialization. |
---|
| 1951 | IF ( .NOT. terrain_height_f%from_file ) THEN |
---|
| 1952 | ALLOCATE ( terrain_height_f%var(nys:nyn,nxl:nxr) ) |
---|
| 1953 | terrain_height_f%var = 0.0_wp |
---|
| 1954 | ENDIF |
---|
| 1955 | ! |
---|
[2646] | 1956 | !-- Finally, exchange 1 ghost point for building ID and type. |
---|
| 1957 | !-- In case of non-cyclic boundary conditions set Neumann conditions at the |
---|
| 1958 | !-- lateral boundaries. |
---|
| 1959 | IF ( building_id_f%from_file ) THEN |
---|
| 1960 | var_exchange_int = building_id_f%fill |
---|
| 1961 | var_exchange_int(nys:nyn,nxl:nxr) = building_id_f%var(nys:nyn,nxl:nxr) |
---|
| 1962 | CALL exchange_horiz_2d_int( var_exchange_int, nys, nyn, nxl, nxr, nbgp ) |
---|
| 1963 | DEALLOCATE( building_id_f%var ) |
---|
| 1964 | ALLOCATE( building_id_f%var(nys-nbgp:nyn+nbgp,nxl-nbgp:nxr+nbgp) ) |
---|
| 1965 | building_id_f%var = var_exchange_int |
---|
[2586] | 1966 | |
---|
[2646] | 1967 | IF ( .NOT. bc_ns_cyc ) THEN |
---|
| 1968 | IF ( nys == 0 ) building_id_f%var(-1,:) = building_id_f%var(0,:) |
---|
| 1969 | IF ( nyn == ny ) building_id_f%var(ny+1,:) = building_id_f%var(ny,:) |
---|
| 1970 | ENDIF |
---|
| 1971 | IF ( .NOT. bc_lr_cyc ) THEN |
---|
| 1972 | IF ( nxl == 0 ) building_id_f%var(:,-1) = building_id_f%var(:,0) |
---|
| 1973 | IF ( nxr == nx ) building_id_f%var(:,nx+1) = building_id_f%var(:,nx) |
---|
| 1974 | ENDIF |
---|
| 1975 | ENDIF |
---|
[2637] | 1976 | |
---|
[2646] | 1977 | IF ( building_type_f%from_file ) THEN |
---|
| 1978 | var_exchange_int = INT( building_type_f%fill, KIND = 4 ) |
---|
| 1979 | var_exchange_int(nys:nyn,nxl:nxr) = & |
---|
| 1980 | INT( building_type_f%var(nys:nyn,nxl:nxr), KIND = 4 ) |
---|
| 1981 | CALL exchange_horiz_2d_int( var_exchange_int, nys, nyn, nxl, nxr, nbgp ) |
---|
| 1982 | DEALLOCATE( building_type_f%var ) |
---|
| 1983 | ALLOCATE( building_type_f%var(nys-nbgp:nyn+nbgp,nxl-nbgp:nxr+nbgp) ) |
---|
| 1984 | building_type_f%var = INT( var_exchange_int, KIND = 1 ) |
---|
| 1985 | |
---|
| 1986 | IF ( .NOT. bc_ns_cyc ) THEN |
---|
| 1987 | IF ( nys == 0 ) building_type_f%var(-1,:) = building_type_f%var(0,:) |
---|
| 1988 | IF ( nyn == ny ) building_type_f%var(ny+1,:) = building_type_f%var(ny,:) |
---|
| 1989 | ENDIF |
---|
| 1990 | IF ( .NOT. bc_lr_cyc ) THEN |
---|
| 1991 | IF ( nxl == 0 ) building_type_f%var(:,-1) = building_type_f%var(:,0) |
---|
| 1992 | IF ( nxr == nx ) building_type_f%var(:,nx+1) = building_type_f%var(:,nx) |
---|
| 1993 | ENDIF |
---|
| 1994 | ENDIF |
---|
| 1995 | |
---|
[2586] | 1996 | END SUBROUTINE netcdf_data_input_topo |
---|
| 1997 | |
---|
| 1998 | !------------------------------------------------------------------------------! |
---|
| 1999 | ! Description: |
---|
| 2000 | ! ------------ |
---|
| 2001 | !> Reads initialization data of u, v, w, pt, q, geostrophic wind components, |
---|
| 2002 | !> as well as soil moisture and soil temperature, derived from larger-scale |
---|
| 2003 | !> model (COSMO) by Inifor. |
---|
| 2004 | !------------------------------------------------------------------------------! |
---|
| 2005 | SUBROUTINE netcdf_data_input_init_3d |
---|
| 2006 | |
---|
| 2007 | USE arrays_3d, & |
---|
| 2008 | ONLY: q, pt, u, v, w |
---|
| 2009 | |
---|
| 2010 | USE control_parameters, & |
---|
[2772] | 2011 | ONLY: bc_lr_cyc, bc_ns_cyc, forcing, humidity, land_surface, & |
---|
| 2012 | message_string, neutral, surface_pressure |
---|
[2586] | 2013 | |
---|
| 2014 | USE indices, & |
---|
[2947] | 2015 | ONLY: nx, nxl, nxlu, nxr, ny, nyn, nys, nysv, nzb, nz, nzt |
---|
[2586] | 2016 | |
---|
| 2017 | IMPLICIT NONE |
---|
| 2018 | |
---|
| 2019 | CHARACTER(LEN=100), DIMENSION(:), ALLOCATABLE :: var_names |
---|
| 2020 | |
---|
| 2021 | INTEGER(iwp) :: i !< running index along x-direction |
---|
| 2022 | INTEGER(iwp) :: ii !< running index for IO blocks |
---|
| 2023 | INTEGER(iwp) :: id_dynamic !< NetCDF id of dynamic input file |
---|
| 2024 | INTEGER(iwp) :: j !< running index along y-direction |
---|
| 2025 | INTEGER(iwp) :: k !< running index along z-direction |
---|
| 2026 | INTEGER(iwp) :: num_vars !< number of variables in netcdf input file |
---|
| 2027 | INTEGER(iwp) :: off_i !< offset in x-direction used for reading the u-component |
---|
| 2028 | INTEGER(iwp) :: off_j !< offset in y-direction used for reading the v-component |
---|
| 2029 | |
---|
[2953] | 2030 | LOGICAL :: check_passed !< flag indicating if a check passed |
---|
| 2031 | |
---|
[2586] | 2032 | ! |
---|
| 2033 | !-- Skip routine if no input file with dynamic input data is available. |
---|
| 2034 | IF ( .NOT. input_pids_dynamic ) RETURN |
---|
| 2035 | ! |
---|
| 2036 | !-- Please note, Inifor is designed to provide initial data for u and v for |
---|
| 2037 | !-- the prognostic grid points in case of lateral Dirichlet conditions. |
---|
| 2038 | !-- This means that Inifor provides data from nxlu:nxr (for u) and |
---|
| 2039 | !-- from nysv:nyn (for v) at the left and south domain boundary, respectively. |
---|
| 2040 | !-- However, as work-around for the moment, PALM will run with cyclic |
---|
| 2041 | !-- conditions and will be initialized with data provided by Inifor |
---|
| 2042 | !-- boundaries in case of Dirichlet. |
---|
| 2043 | !-- Hence, simply set set nxlu/nysv to 1 (will be reset to its original value |
---|
| 2044 | !-- at the end of this routine. |
---|
| 2045 | IF ( bc_lr_cyc .AND. nxl == 0 ) nxlu = 1 |
---|
| 2046 | IF ( bc_ns_cyc .AND. nys == 0 ) nysv = 1 |
---|
| 2047 | |
---|
[2955] | 2048 | ! |
---|
| 2049 | !-- CPU measurement |
---|
| 2050 | CALL cpu_log( log_point_s(85), 'NetCDF input init', 'start' ) |
---|
| 2051 | |
---|
[2586] | 2052 | DO ii = 0, io_blocks-1 |
---|
| 2053 | IF ( ii == io_group ) THEN |
---|
| 2054 | #if defined ( __netcdf ) |
---|
| 2055 | ! |
---|
| 2056 | !-- Open file in read-only mode |
---|
[2589] | 2057 | CALL open_read_file( TRIM( input_file_dynamic ) // & |
---|
| 2058 | TRIM( coupling_char ), id_dynamic ) |
---|
[2586] | 2059 | |
---|
| 2060 | ! |
---|
| 2061 | !-- At first, inquire all variable names. |
---|
| 2062 | CALL inquire_num_variables( id_dynamic, num_vars ) |
---|
| 2063 | ! |
---|
| 2064 | !-- Allocate memory to store variable names. |
---|
| 2065 | ALLOCATE( var_names(1:num_vars) ) |
---|
| 2066 | CALL inquire_variable_names( id_dynamic, var_names ) |
---|
| 2067 | ! |
---|
| 2068 | !-- Read vertical dimension of scalar und w grid. Will be used for |
---|
| 2069 | !-- inter- and extrapolation in case of stretched numeric grid. |
---|
| 2070 | !-- This will be removed when Inifor is able to handle stretched grids. |
---|
| 2071 | CALL get_dimension_length( id_dynamic, init_3d%nzu, 'z' ) |
---|
| 2072 | CALL get_dimension_length( id_dynamic, init_3d%nzw, 'zw' ) |
---|
| 2073 | CALL get_dimension_length( id_dynamic, init_3d%nzs, 'depth' ) |
---|
| 2074 | ! |
---|
| 2075 | !-- Read also the horizontal dimensions. These are used just used fo |
---|
| 2076 | !-- checking the compatibility with the PALM grid before reading. |
---|
| 2077 | CALL get_dimension_length( id_dynamic, init_3d%nx, 'x' ) |
---|
| 2078 | CALL get_dimension_length( id_dynamic, init_3d%nxu, 'xu' ) |
---|
| 2079 | CALL get_dimension_length( id_dynamic, init_3d%ny, 'y' ) |
---|
| 2080 | CALL get_dimension_length( id_dynamic, init_3d%nyv, 'yv' ) |
---|
[2947] | 2081 | |
---|
[2586] | 2082 | ! |
---|
[2947] | 2083 | !-- Check for correct horizontal and vertical dimension. Please note, |
---|
| 2084 | !-- checks are performed directly here and not called from |
---|
| 2085 | !-- check_parameters as some varialbes are still not allocated there. |
---|
| 2086 | !-- Moreover, please note, u- and v-grid has 1 grid point less on |
---|
| 2087 | !-- Inifor grid. |
---|
| 2088 | IF ( init_3d%nx-1 /= nx .OR. init_3d%nxu-1 /= nx - 1 .OR. & |
---|
| 2089 | init_3d%ny-1 /= ny .OR. init_3d%nyv-1 /= ny - 1 ) THEN |
---|
| 2090 | message_string = 'Number of inifor horizontal grid points '// & |
---|
| 2091 | 'does not match the number of numeric grid '//& |
---|
| 2092 | 'points.' |
---|
| 2093 | CALL message( 'netcdf_data_input_mod', 'NDI003', 1, 2, 0, 6, 0 ) |
---|
| 2094 | ENDIF |
---|
| 2095 | |
---|
| 2096 | IF ( init_3d%nzu-1 /= nz ) THEN |
---|
| 2097 | message_string = 'Number of inifor vertical grid points ' // & |
---|
| 2098 | 'does not match the number of numeric grid '//& |
---|
| 2099 | 'points.' |
---|
| 2100 | CALL message( 'netcdf_data_input_mod', 'NDI003', 1, 2, 0, 6, 0 ) |
---|
| 2101 | ENDIF |
---|
| 2102 | ! |
---|
[2586] | 2103 | !-- Read vertical dimensions. Later, these are required for eventual |
---|
| 2104 | !-- inter- and extrapolations of the initialization data. |
---|
| 2105 | IF ( check_existence( var_names, 'z' ) ) THEN |
---|
| 2106 | ALLOCATE( init_3d%zu_atmos(1:init_3d%nzu) ) |
---|
| 2107 | CALL get_variable( id_dynamic, 'z', init_3d%zu_atmos ) |
---|
| 2108 | ENDIF |
---|
| 2109 | IF ( check_existence( var_names, 'zw' ) ) THEN |
---|
| 2110 | ALLOCATE( init_3d%zw_atmos(1:init_3d%nzw) ) |
---|
| 2111 | CALL get_variable( id_dynamic, 'zw', init_3d%zw_atmos ) |
---|
| 2112 | ENDIF |
---|
| 2113 | IF ( check_existence( var_names, 'depth' ) ) THEN |
---|
| 2114 | ALLOCATE( init_3d%z_soil(1:init_3d%nzs) ) |
---|
| 2115 | CALL get_variable( id_dynamic, 'depth', init_3d%z_soil ) |
---|
| 2116 | ENDIF |
---|
| 2117 | ! |
---|
[2938] | 2118 | !-- Read initial geostrophic wind components at |
---|
| 2119 | !-- t = 0 (index 1 in file). |
---|
| 2120 | IF ( check_existence( var_names, 'ls_forcing_ug' ) ) THEN |
---|
| 2121 | ALLOCATE( init_3d%ug_init(nzb:nzt+1) ) |
---|
| 2122 | CALL get_variable_pr( id_dynamic, 'ls_forcing_ug', 1, & |
---|
| 2123 | init_3d%ug_init ) |
---|
| 2124 | init_3d%from_file_ug = .TRUE. |
---|
| 2125 | ELSE |
---|
| 2126 | init_3d%from_file_ug = .FALSE. |
---|
| 2127 | ENDIF |
---|
| 2128 | IF ( check_existence( var_names, 'ls_forcing_vg' ) ) THEN |
---|
| 2129 | ALLOCATE( init_3d%vg_init(nzb:nzt+1) ) |
---|
| 2130 | CALL get_variable_pr( id_dynamic, 'ls_forcing_vg', 1, & |
---|
| 2131 | init_3d%vg_init ) |
---|
| 2132 | init_3d%from_file_vg = .TRUE. |
---|
| 2133 | ELSE |
---|
| 2134 | init_3d%from_file_vg = .FALSE. |
---|
| 2135 | ENDIF |
---|
[2586] | 2136 | ! |
---|
| 2137 | !-- Read inital 3D data of u, v, w, pt and q, |
---|
| 2138 | !-- derived from COSMO model. Read PE-wise yz-slices. |
---|
| 2139 | !-- Please note, the u-, v- and w-component are defined on different |
---|
| 2140 | !-- grids with one element less in the x-, y-, |
---|
| 2141 | !-- and z-direction, respectively. Hence, reading is subdivided |
---|
| 2142 | !-- into separate loops. Moreover, i and j are used |
---|
| 2143 | !-- as start index in the NF90 interface. |
---|
| 2144 | !-- The passed arguments for u, and v are (i,j)-1, respectively, |
---|
| 2145 | !-- in contrast to the remaining quantities. This is because in case |
---|
| 2146 | !-- of forcing is applied, the input data for u and v has one |
---|
| 2147 | !-- element less along the x- and y-direction respectively. |
---|
| 2148 | !-- Read u-component |
---|
| 2149 | IF ( check_existence( var_names, 'init_u' ) ) THEN |
---|
| 2150 | ! |
---|
| 2151 | !-- Read attributes for the fill value and level-of-detail |
---|
| 2152 | CALL get_attribute( id_dynamic, char_fill, init_3d%fill_u, & |
---|
| 2153 | .FALSE., 'init_u' ) |
---|
| 2154 | CALL get_attribute( id_dynamic, char_lod, init_3d%lod_u, & |
---|
| 2155 | .FALSE., 'init_u' ) |
---|
| 2156 | ! |
---|
| 2157 | !-- level-of-detail 1 - read initialization profile |
---|
| 2158 | IF ( init_3d%lod_u == 1 ) THEN |
---|
| 2159 | ALLOCATE( init_3d%u_init(nzb:nzt+1) ) |
---|
| 2160 | init_3d%u_init = 0.0_wp |
---|
| 2161 | |
---|
| 2162 | CALL get_variable( id_dynamic, 'init_u', & |
---|
| 2163 | init_3d%u_init(nzb+1:nzt+1) ) |
---|
| 2164 | ! |
---|
| 2165 | !-- level-of-detail 2 - read 3D initialization data |
---|
| 2166 | ELSEIF ( init_3d%lod_u == 2 ) THEN |
---|
| 2167 | ! |
---|
| 2168 | !-- Set offset value. In case of Dirichlet conditions at the left |
---|
| 2169 | !-- domain boundary, the u component starts at nxl+1. This case, |
---|
| 2170 | !-- the passed start-index for reading the NetCDF data is shifted |
---|
| 2171 | !-- by -1. |
---|
| 2172 | off_i = 1 !MERGE( 1, 0, forcing ) |
---|
| 2173 | |
---|
| 2174 | DO i = nxlu, nxr |
---|
| 2175 | DO j = nys, nyn |
---|
| 2176 | CALL get_variable( id_dynamic, 'init_u', i-off_i, j, & |
---|
| 2177 | u(nzb+1:nzt+1,j,i) ) |
---|
| 2178 | ENDDO |
---|
| 2179 | ENDDO |
---|
| 2180 | |
---|
| 2181 | ENDIF |
---|
| 2182 | init_3d%from_file_u = .TRUE. |
---|
| 2183 | ENDIF |
---|
| 2184 | ! |
---|
| 2185 | !-- Read v-component |
---|
| 2186 | IF ( check_existence( var_names, 'init_v' ) ) THEN |
---|
| 2187 | ! |
---|
| 2188 | !-- Read attributes for the fill value and level-of-detail |
---|
| 2189 | CALL get_attribute( id_dynamic, char_fill, init_3d%fill_v, & |
---|
| 2190 | .FALSE., 'init_v' ) |
---|
| 2191 | CALL get_attribute( id_dynamic, char_lod, init_3d%lod_v, & |
---|
| 2192 | .FALSE., 'init_v' ) |
---|
| 2193 | ! |
---|
| 2194 | !-- level-of-detail 1 - read initialization profile |
---|
| 2195 | IF ( init_3d%lod_v == 1 ) THEN |
---|
| 2196 | ALLOCATE( init_3d%v_init(nzb:nzt+1) ) |
---|
| 2197 | init_3d%v_init = 0.0_wp |
---|
| 2198 | |
---|
| 2199 | CALL get_variable( id_dynamic, 'init_v', & |
---|
| 2200 | init_3d%v_init(nzb+1:nzt+1) ) |
---|
| 2201 | |
---|
| 2202 | ! |
---|
| 2203 | !-- level-of-detail 2 - read 3D initialization data |
---|
| 2204 | ELSEIF ( init_3d%lod_v == 2 ) THEN |
---|
| 2205 | ! |
---|
| 2206 | !-- Set offset value. In case of Dirichlet conditions at the south |
---|
| 2207 | !-- domain boundary, the v component starts at nys+1. This case, |
---|
| 2208 | !-- the passed start-index for reading the NetCDF data is shifted |
---|
| 2209 | !-- by -1. |
---|
| 2210 | off_j = 1 !MERGE( 1, 0, forcing ) |
---|
| 2211 | |
---|
| 2212 | DO i = nxl, nxr |
---|
| 2213 | DO j = nysv, nyn |
---|
| 2214 | CALL get_variable( id_dynamic, 'init_v', i, j-off_j, & |
---|
| 2215 | v(nzb+1:nzt+1,j,i) ) |
---|
| 2216 | ENDDO |
---|
| 2217 | ENDDO |
---|
| 2218 | |
---|
| 2219 | ENDIF |
---|
| 2220 | init_3d%from_file_v = .TRUE. |
---|
| 2221 | ENDIF |
---|
| 2222 | ! |
---|
| 2223 | !-- Read w-component |
---|
| 2224 | IF ( check_existence( var_names, 'init_w' ) ) THEN |
---|
| 2225 | ! |
---|
| 2226 | !-- Read attributes for the fill value and level-of-detail |
---|
| 2227 | CALL get_attribute( id_dynamic, char_fill, init_3d%fill_w, & |
---|
| 2228 | .FALSE., 'init_w' ) |
---|
| 2229 | CALL get_attribute( id_dynamic, char_lod, init_3d%lod_w, & |
---|
| 2230 | .FALSE., 'init_w' ) |
---|
| 2231 | ! |
---|
| 2232 | !-- level-of-detail 1 - read initialization profile |
---|
| 2233 | IF ( init_3d%lod_w == 1 ) THEN |
---|
| 2234 | ALLOCATE( init_3d%w_init(nzb:nzt+1) ) |
---|
| 2235 | init_3d%w_init = 0.0_wp |
---|
| 2236 | |
---|
| 2237 | CALL get_variable( id_dynamic, 'init_w', & |
---|
| 2238 | init_3d%w_init(nzb+1:nzt) ) |
---|
| 2239 | |
---|
| 2240 | ! |
---|
| 2241 | !-- level-of-detail 2 - read 3D initialization data |
---|
| 2242 | ELSEIF ( init_3d%lod_w == 2 ) THEN |
---|
| 2243 | DO i = nxl, nxr |
---|
| 2244 | DO j = nys, nyn |
---|
| 2245 | CALL get_variable( id_dynamic, 'init_w', i, j, & |
---|
| 2246 | w(nzb+1:nzt,j,i) ) |
---|
| 2247 | ENDDO |
---|
| 2248 | ENDDO |
---|
| 2249 | |
---|
| 2250 | ENDIF |
---|
| 2251 | init_3d%from_file_w = .TRUE. |
---|
| 2252 | ENDIF |
---|
| 2253 | ! |
---|
| 2254 | !-- Read potential temperature |
---|
| 2255 | IF ( .NOT. neutral ) THEN |
---|
| 2256 | IF ( check_existence( var_names, 'init_pt' ) ) THEN |
---|
| 2257 | ! |
---|
| 2258 | !-- Read attributes for the fill value and level-of-detail |
---|
| 2259 | CALL get_attribute( id_dynamic, char_fill, init_3d%fill_pt, & |
---|
| 2260 | .FALSE., 'init_pt' ) |
---|
| 2261 | CALL get_attribute( id_dynamic, char_lod, init_3d%lod_pt, & |
---|
| 2262 | .FALSE., 'init_pt' ) |
---|
| 2263 | ! |
---|
| 2264 | !-- level-of-detail 1 - read initialization profile |
---|
| 2265 | IF ( init_3d%lod_pt == 1 ) THEN |
---|
| 2266 | ALLOCATE( init_3d%pt_init(nzb:nzt+1) ) |
---|
| 2267 | |
---|
| 2268 | CALL get_variable( id_dynamic, 'init_pt', & |
---|
| 2269 | init_3d%pt_init(nzb+1:nzt+1) ) |
---|
| 2270 | ! |
---|
| 2271 | !-- Set Neumann surface boundary condition for initial profil |
---|
| 2272 | init_3d%pt_init(nzb) = init_3d%pt_init(nzb+1) |
---|
| 2273 | ! |
---|
| 2274 | !-- level-of-detail 2 - read 3D initialization data |
---|
| 2275 | ELSEIF ( init_3d%lod_pt == 2 ) THEN |
---|
| 2276 | DO i = nxl, nxr |
---|
| 2277 | DO j = nys, nyn |
---|
| 2278 | CALL get_variable( id_dynamic, 'init_pt', i, j, & |
---|
| 2279 | pt(nzb+1:nzt+1,j,i) ) |
---|
| 2280 | ENDDO |
---|
| 2281 | ENDDO |
---|
| 2282 | |
---|
| 2283 | ENDIF |
---|
| 2284 | init_3d%from_file_pt = .TRUE. |
---|
| 2285 | ENDIF |
---|
| 2286 | ENDIF |
---|
| 2287 | ! |
---|
| 2288 | !-- Read mixing ratio |
---|
| 2289 | IF ( humidity ) THEN |
---|
| 2290 | IF ( check_existence( var_names, 'init_qv' ) ) THEN |
---|
| 2291 | ! |
---|
| 2292 | !-- Read attributes for the fill value and level-of-detail |
---|
| 2293 | CALL get_attribute( id_dynamic, char_fill, init_3d%fill_q, & |
---|
| 2294 | .FALSE., 'init_qv' ) |
---|
| 2295 | CALL get_attribute( id_dynamic, char_lod, init_3d%lod_q, & |
---|
| 2296 | .FALSE., 'init_qv' ) |
---|
| 2297 | ! |
---|
| 2298 | !-- level-of-detail 1 - read initialization profile |
---|
| 2299 | IF ( init_3d%lod_q == 1 ) THEN |
---|
| 2300 | ALLOCATE( init_3d%q_init(nzb:nzt+1) ) |
---|
| 2301 | |
---|
[2589] | 2302 | CALL get_variable( id_dynamic, 'init_qv', & |
---|
[2586] | 2303 | init_3d%q_init(nzb+1:nzt+1) ) |
---|
| 2304 | ! |
---|
| 2305 | !-- Set Neumann surface boundary condition for initial profil |
---|
| 2306 | init_3d%q_init(nzb) = init_3d%q_init(nzb+1) |
---|
| 2307 | |
---|
| 2308 | ! |
---|
| 2309 | !-- level-of-detail 2 - read 3D initialization data |
---|
| 2310 | ELSEIF ( init_3d%lod_q == 2 ) THEN |
---|
| 2311 | DO i = nxl, nxr |
---|
| 2312 | DO j = nys, nyn |
---|
| 2313 | CALL get_variable( id_dynamic, 'init_qv', i, j, & |
---|
| 2314 | q(nzb+1:nzt+1,j,i) ) |
---|
| 2315 | ENDDO |
---|
| 2316 | ENDDO |
---|
| 2317 | |
---|
| 2318 | ENDIF |
---|
| 2319 | init_3d%from_file_q = .TRUE. |
---|
| 2320 | ENDIF |
---|
| 2321 | ENDIF |
---|
| 2322 | ! |
---|
| 2323 | !-- Read soil moisture |
---|
[2772] | 2324 | IF ( land_surface ) THEN |
---|
[2938] | 2325 | |
---|
[2772] | 2326 | IF ( check_existence( var_names, 'init_soil_m' ) ) THEN |
---|
[2586] | 2327 | ! |
---|
[2772] | 2328 | !-- Read attributes for the fill value and level-of-detail |
---|
| 2329 | CALL get_attribute( id_dynamic, char_fill, & |
---|
| 2330 | init_3d%fill_msoil, & |
---|
| 2331 | .FALSE., 'init_soil_m' ) |
---|
| 2332 | CALL get_attribute( id_dynamic, char_lod, & |
---|
| 2333 | init_3d%lod_msoil, & |
---|
| 2334 | .FALSE., 'init_soil_m' ) |
---|
[2586] | 2335 | ! |
---|
[2772] | 2336 | !-- level-of-detail 1 - read initialization profile |
---|
| 2337 | IF ( init_3d%lod_msoil == 1 ) THEN |
---|
| 2338 | ALLOCATE( init_3d%msoil_init(0:init_3d%nzs-1) ) |
---|
[2586] | 2339 | |
---|
[2772] | 2340 | CALL get_variable( id_dynamic, 'init_soil_m', & |
---|
| 2341 | init_3d%msoil_init(0:init_3d%nzs-1) ) |
---|
[2586] | 2342 | ! |
---|
[2772] | 2343 | !-- level-of-detail 2 - read 3D initialization data |
---|
[2938] | 2344 | ELSEIF ( init_3d%lod_msoil == 2 ) THEN |
---|
[2772] | 2345 | ALLOCATE ( init_3d%msoil(0:init_3d%nzs-1,nys:nyn,nxl:nxr) ) |
---|
| 2346 | DO i = nxl, nxr |
---|
| 2347 | DO j = nys, nyn |
---|
| 2348 | CALL get_variable( id_dynamic, 'init_soil_m', i, j,& |
---|
| 2349 | init_3d%msoil(0:init_3d%nzs-1,j,i) ) |
---|
| 2350 | ENDDO |
---|
[2586] | 2351 | ENDDO |
---|
[2772] | 2352 | ENDIF |
---|
| 2353 | init_3d%from_file_msoil = .TRUE. |
---|
[2586] | 2354 | ENDIF |
---|
| 2355 | ! |
---|
[2772] | 2356 | !-- Read soil temperature |
---|
| 2357 | IF ( check_existence( var_names, 'init_soil_t' ) ) THEN |
---|
[2586] | 2358 | ! |
---|
[2772] | 2359 | !-- Read attributes for the fill value and level-of-detail |
---|
| 2360 | CALL get_attribute( id_dynamic, char_fill, & |
---|
| 2361 | init_3d%fill_tsoil, & |
---|
| 2362 | .FALSE., 'init_soil_t' ) |
---|
| 2363 | CALL get_attribute( id_dynamic, char_lod, & |
---|
| 2364 | init_3d%lod_tsoil, & |
---|
| 2365 | .FALSE., 'init_soil_t' ) |
---|
[2586] | 2366 | ! |
---|
[2772] | 2367 | !-- level-of-detail 1 - read initialization profile |
---|
| 2368 | IF ( init_3d%lod_tsoil == 1 ) THEN |
---|
| 2369 | ALLOCATE( init_3d%tsoil_init(0:init_3d%nzs-1) ) |
---|
[2586] | 2370 | |
---|
[2772] | 2371 | CALL get_variable( id_dynamic, 'init_soil_t', & |
---|
| 2372 | init_3d%tsoil_init(0:init_3d%nzs-1) ) |
---|
[2586] | 2373 | |
---|
| 2374 | ! |
---|
[2772] | 2375 | !-- level-of-detail 2 - read 3D initialization data |
---|
[2938] | 2376 | ELSEIF ( init_3d%lod_tsoil == 2 ) THEN |
---|
[2772] | 2377 | ALLOCATE ( init_3d%tsoil(0:init_3d%nzs-1,nys:nyn,nxl:nxr) ) |
---|
| 2378 | DO i = nxl, nxr |
---|
| 2379 | DO j = nys, nyn |
---|
| 2380 | CALL get_variable( id_dynamic, 'init_soil_t', i, j,& |
---|
| 2381 | init_3d%tsoil(0:init_3d%nzs-1,j,i) ) |
---|
| 2382 | ENDDO |
---|
[2586] | 2383 | ENDDO |
---|
[2772] | 2384 | ENDIF |
---|
| 2385 | init_3d%from_file_tsoil = .TRUE. |
---|
[2586] | 2386 | ENDIF |
---|
| 2387 | ENDIF |
---|
| 2388 | ! |
---|
| 2389 | !-- Close input file |
---|
[2711] | 2390 | CALL close_input_file( id_dynamic ) |
---|
[2586] | 2391 | #endif |
---|
| 2392 | ENDIF |
---|
| 2393 | #if defined( __parallel ) |
---|
| 2394 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 2395 | #endif |
---|
| 2396 | ENDDO |
---|
| 2397 | ! |
---|
[2955] | 2398 | !-- End of CPU measurement |
---|
| 2399 | CALL cpu_log( log_point_s(85), 'NetCDF input init', 'stop' ) |
---|
| 2400 | ! |
---|
[2953] | 2401 | !-- Finally, check if the input data has any fill values. Please note, |
---|
| 2402 | !-- checks depend on the LOD of the input data. |
---|
[2586] | 2403 | IF ( init_3d%from_file_u ) THEN |
---|
[2953] | 2404 | check_passed = .TRUE. |
---|
| 2405 | IF ( init_3d%lod_u == 1 ) THEN |
---|
| 2406 | IF ( ANY( init_3d%u_init(nzb+1:nzt+1) == init_3d%fill_u ) ) & |
---|
| 2407 | check_passed = .FALSE. |
---|
| 2408 | ELSEIF ( init_3d%lod_u == 2 ) THEN |
---|
| 2409 | IF ( ANY( u(nzb+1:nzt+1,nys:nyn,nxlu:nxr) == init_3d%fill_u ) ) & |
---|
| 2410 | check_passed = .FALSE. |
---|
| 2411 | ENDIF |
---|
| 2412 | IF ( .NOT. check_passed ) THEN |
---|
[2586] | 2413 | message_string = 'NetCDF input for u_init must not contain ' // & |
---|
| 2414 | 'any _FillValues' |
---|
[2925] | 2415 | CALL message( 'netcdf_data_input_mod', 'NDI004', 2, 2, 0, 6, 0 ) |
---|
[2586] | 2416 | ENDIF |
---|
| 2417 | ENDIF |
---|
[2953] | 2418 | |
---|
[2586] | 2419 | IF ( init_3d%from_file_v ) THEN |
---|
[2953] | 2420 | check_passed = .TRUE. |
---|
| 2421 | IF ( init_3d%lod_v == 1 ) THEN |
---|
| 2422 | IF ( ANY( init_3d%v_init(nzb+1:nzt+1) == init_3d%fill_v ) ) & |
---|
| 2423 | check_passed = .FALSE. |
---|
| 2424 | ELSEIF ( init_3d%lod_v == 2 ) THEN |
---|
| 2425 | IF ( ANY( v(nzb+1:nzt+1,nysv:nyn,nxl:nxr) == init_3d%fill_v ) ) & |
---|
| 2426 | check_passed = .FALSE. |
---|
| 2427 | ENDIF |
---|
| 2428 | IF ( .NOT. check_passed ) THEN |
---|
[2586] | 2429 | message_string = 'NetCDF input for v_init must not contain ' // & |
---|
| 2430 | 'any _FillValues' |
---|
[2925] | 2431 | CALL message( 'netcdf_data_input_mod', 'NDI005', 2, 2, 0, 6, 0 ) |
---|
[2586] | 2432 | ENDIF |
---|
| 2433 | ENDIF |
---|
[2953] | 2434 | |
---|
[2586] | 2435 | IF ( init_3d%from_file_w ) THEN |
---|
[2953] | 2436 | check_passed = .TRUE. |
---|
| 2437 | IF ( init_3d%lod_w == 1 ) THEN |
---|
| 2438 | IF ( ANY( init_3d%w_init(nzb+1:nzt) == init_3d%fill_w ) ) & |
---|
| 2439 | check_passed = .FALSE. |
---|
| 2440 | ELSEIF ( init_3d%lod_w == 2 ) THEN |
---|
| 2441 | IF ( ANY( w(nzb+1:nzt,nys:nyn,nxl:nxr) == init_3d%fill_w ) ) & |
---|
| 2442 | check_passed = .FALSE. |
---|
| 2443 | ENDIF |
---|
| 2444 | IF ( .NOT. check_passed ) THEN |
---|
[2586] | 2445 | message_string = 'NetCDF input for w_init must not contain ' // & |
---|
| 2446 | 'any _FillValues' |
---|
[2925] | 2447 | CALL message( 'netcdf_data_input_mod', 'NDI006', 2, 2, 0, 6, 0 ) |
---|
[2586] | 2448 | ENDIF |
---|
| 2449 | ENDIF |
---|
[2953] | 2450 | |
---|
[2586] | 2451 | IF ( init_3d%from_file_pt ) THEN |
---|
[2953] | 2452 | check_passed = .TRUE. |
---|
| 2453 | IF ( init_3d%lod_pt == 1 ) THEN |
---|
| 2454 | IF ( ANY( init_3d%pt_init(nzb+1:nzt+1) == init_3d%fill_pt ) ) & |
---|
| 2455 | check_passed = .FALSE. |
---|
| 2456 | ELSEIF ( init_3d%lod_pt == 2 ) THEN |
---|
| 2457 | IF ( ANY( pt(nzb+1:nzt+1,nys:nyn,nxl:nxr) == init_3d%fill_pt ) ) & |
---|
| 2458 | check_passed = .FALSE. |
---|
| 2459 | ENDIF |
---|
| 2460 | IF ( .NOT. check_passed ) THEN |
---|
[2586] | 2461 | message_string = 'NetCDF input for pt_init must not contain ' // & |
---|
| 2462 | 'any _FillValues' |
---|
[2925] | 2463 | CALL message( 'netcdf_data_input_mod', 'NDI007', 2, 2, 0, 6, 0 ) |
---|
[2586] | 2464 | ENDIF |
---|
| 2465 | ENDIF |
---|
[2953] | 2466 | |
---|
[2586] | 2467 | IF ( init_3d%from_file_q ) THEN |
---|
[2953] | 2468 | check_passed = .TRUE. |
---|
| 2469 | IF ( init_3d%lod_q == 1 ) THEN |
---|
| 2470 | IF ( ANY( init_3d%q_init(nzb+1:nzt+1) == init_3d%fill_q ) ) & |
---|
| 2471 | check_passed = .FALSE. |
---|
| 2472 | ELSEIF ( init_3d%lod_q == 2 ) THEN |
---|
| 2473 | IF ( ANY( q(nzb+1:nzt+1,nys:nyn,nxl:nxr) == init_3d%fill_q ) ) & |
---|
| 2474 | check_passed = .FALSE. |
---|
| 2475 | ENDIF |
---|
| 2476 | IF ( .NOT. check_passed ) THEN |
---|
[2586] | 2477 | message_string = 'NetCDF input for q_init must not contain ' // & |
---|
| 2478 | 'any _FillValues' |
---|
[2925] | 2479 | CALL message( 'netcdf_data_input_mod', 'NDI008', 2, 2, 0, 6, 0 ) |
---|
[2586] | 2480 | ENDIF |
---|
| 2481 | ENDIF |
---|
[2614] | 2482 | ! |
---|
| 2483 | !-- Workaround for cyclic conditions. Please see above for further explanation. |
---|
| 2484 | IF ( bc_lr_cyc .AND. nxl == 0 ) nxlu = nxl |
---|
| 2485 | IF ( bc_ns_cyc .AND. nys == 0 ) nysv = nys |
---|
[2586] | 2486 | |
---|
| 2487 | END SUBROUTINE netcdf_data_input_init_3d |
---|
| 2488 | |
---|
| 2489 | !------------------------------------------------------------------------------! |
---|
| 2490 | ! Description: |
---|
| 2491 | ! ------------ |
---|
| 2492 | !> Reads data at lateral and top boundaries derived from larger-scale model |
---|
| 2493 | !> (COSMO) by Inifor. |
---|
| 2494 | !------------------------------------------------------------------------------! |
---|
| 2495 | SUBROUTINE netcdf_data_input_lsf |
---|
| 2496 | |
---|
| 2497 | USE control_parameters, & |
---|
[2938] | 2498 | ONLY: bc_lr_cyc, bc_ns_cyc, force_bound_l, force_bound_n, & |
---|
| 2499 | force_bound_r, force_bound_s, & |
---|
[2586] | 2500 | forcing, humidity, message_string, neutral, simulated_time |
---|
| 2501 | |
---|
[2938] | 2502 | |
---|
[2586] | 2503 | USE indices, & |
---|
[2945] | 2504 | ONLY: nxl, nxlu, nxr, nyn, nys, nysv, nzb, nzt |
---|
[2586] | 2505 | |
---|
| 2506 | IMPLICIT NONE |
---|
| 2507 | |
---|
| 2508 | |
---|
| 2509 | INTEGER(iwp) :: i !< running index along x-direction |
---|
| 2510 | INTEGER(iwp) :: ii !< running index for IO blocks |
---|
| 2511 | INTEGER(iwp) :: id_dynamic !< NetCDF id of dynamic input file |
---|
| 2512 | INTEGER(iwp) :: j !< running index along y-direction |
---|
| 2513 | INTEGER(iwp) :: k !< running index along z-direction |
---|
| 2514 | INTEGER(iwp) :: num_vars !< number of variables in netcdf input file |
---|
| 2515 | INTEGER(iwp) :: t !< running index time dimension |
---|
| 2516 | |
---|
| 2517 | REAL(wp) :: dum !< dummy variable to skip columns while reading topography file |
---|
| 2518 | |
---|
| 2519 | force%from_file = MERGE( .TRUE., .FALSE., input_pids_dynamic ) |
---|
| 2520 | ! |
---|
| 2521 | !-- Skip input if no forcing from larger-scale models is applied. |
---|
| 2522 | IF ( .NOT. forcing ) RETURN |
---|
| 2523 | |
---|
[2955] | 2524 | ! |
---|
| 2525 | !-- CPU measurement |
---|
| 2526 | CALL cpu_log( log_point_s(86), 'NetCDF input forcing', 'start' ) |
---|
| 2527 | |
---|
[2586] | 2528 | DO ii = 0, io_blocks-1 |
---|
| 2529 | IF ( ii == io_group ) THEN |
---|
| 2530 | #if defined ( __netcdf ) |
---|
| 2531 | ! |
---|
| 2532 | !-- Open file in read-only mode |
---|
[2589] | 2533 | CALL open_read_file( TRIM( input_file_dynamic ) // & |
---|
| 2534 | TRIM( coupling_char ), id_dynamic ) |
---|
[2586] | 2535 | ! |
---|
| 2536 | !-- Initialize INIFOR forcing. |
---|
| 2537 | IF ( .NOT. force%init ) THEN |
---|
| 2538 | ! |
---|
| 2539 | !-- At first, inquire all variable names. |
---|
| 2540 | CALL inquire_num_variables( id_dynamic, num_vars ) |
---|
| 2541 | ! |
---|
| 2542 | !-- Allocate memory to store variable names. |
---|
| 2543 | ALLOCATE( force%var_names(1:num_vars) ) |
---|
| 2544 | CALL inquire_variable_names( id_dynamic, force%var_names ) |
---|
| 2545 | ! |
---|
| 2546 | !-- Read time dimension, allocate memory and finally read time array |
---|
| 2547 | CALL get_dimension_length( id_dynamic, force%nt, 'time' ) |
---|
| 2548 | |
---|
| 2549 | IF ( check_existence( force%var_names, 'time' ) ) THEN |
---|
| 2550 | ALLOCATE( force%time(0:force%nt-1) ) |
---|
| 2551 | CALL get_variable( id_dynamic, 'time', force%time ) |
---|
| 2552 | ENDIF |
---|
| 2553 | ! |
---|
| 2554 | !-- Read vertical dimension of scalar und w grid |
---|
| 2555 | CALL get_dimension_length( id_dynamic, force%nzu, 'z' ) |
---|
| 2556 | CALL get_dimension_length( id_dynamic, force%nzw, 'zw' ) |
---|
| 2557 | |
---|
| 2558 | IF ( check_existence( force%var_names, 'z' ) ) THEN |
---|
| 2559 | ALLOCATE( force%zu_atmos(1:force%nzu) ) |
---|
| 2560 | CALL get_variable( id_dynamic, 'z', force%zu_atmos ) |
---|
| 2561 | ENDIF |
---|
| 2562 | IF ( check_existence( force%var_names, 'zw' ) ) THEN |
---|
| 2563 | ALLOCATE( force%zw_atmos(1:force%nzw) ) |
---|
| 2564 | CALL get_variable( id_dynamic, 'zw', force%zw_atmos ) |
---|
| 2565 | ENDIF |
---|
| 2566 | |
---|
| 2567 | ! |
---|
| 2568 | !-- Read surface pressure |
---|
| 2569 | IF ( check_existence( force%var_names, & |
---|
| 2570 | 'surface_forcing_surface_pressure' ) ) THEN |
---|
| 2571 | ALLOCATE( force%surface_pressure(0:force%nt-1) ) |
---|
| 2572 | CALL get_variable( id_dynamic, & |
---|
| 2573 | 'surface_forcing_surface_pressure', & |
---|
| 2574 | force%surface_pressure ) |
---|
| 2575 | ENDIF |
---|
| 2576 | ! |
---|
| 2577 | !-- Set control flag to indicate that initialization is already done |
---|
| 2578 | force%init = .TRUE. |
---|
| 2579 | |
---|
| 2580 | ENDIF |
---|
| 2581 | |
---|
| 2582 | ! |
---|
| 2583 | !-- Obtain time index for current input starting at 0. |
---|
| 2584 | !-- @todo: At the moment time, in INIFOR and simulated time correspond |
---|
| 2585 | !-- to each other. If required, adjust to daytime. |
---|
| 2586 | force%tind = MINLOC( ABS( force%time - simulated_time ), DIM = 1 )& |
---|
| 2587 | - 1 |
---|
[2938] | 2588 | force%tind_p = force%tind + 1 |
---|
[2586] | 2589 | ! |
---|
[2938] | 2590 | !-- Read geostrophic wind components. In case of forcing, this is only |
---|
| 2591 | !-- required if cyclic boundary conditions are applied. |
---|
| 2592 | IF ( bc_lr_cyc .AND. bc_ns_cyc ) THEN |
---|
| 2593 | DO t = force%tind, force%tind_p |
---|
| 2594 | CALL get_variable_pr( id_dynamic, 'ls_forcing_ug', t+1, & |
---|
| 2595 | force%ug(t-force%tind,:) ) |
---|
| 2596 | CALL get_variable_pr( id_dynamic, 'ls_forcing_vg', t+1, & |
---|
| 2597 | force%ug(t-force%tind,:) ) |
---|
| 2598 | ENDDO |
---|
| 2599 | ENDIF |
---|
| 2600 | ! |
---|
[2586] | 2601 | !-- Read data at lateral and top boundaries. Please note, at left and |
---|
| 2602 | !-- right domain boundary, yz-layers are read for u, v, w, pt and q. |
---|
| 2603 | !-- For the v-component, the data starts at nysv, while for the other |
---|
| 2604 | !-- quantities the data starts at nys. This is equivalent at the north |
---|
| 2605 | !-- and south domain boundary for the u-component. |
---|
| 2606 | !-- The function get_variable_bc assumes the start indices with respect |
---|
| 2607 | !-- to the netcdf file convention (data starts at index 1). For this |
---|
| 2608 | !-- reason, nys+1 / nxl+1 are passed instead of nys / nxl. For the |
---|
| 2609 | !-- the u- and v-component at the north/south, and left/right boundary, |
---|
| 2610 | !-- nxlu and nysv are passed, respectively, since these always starts |
---|
| 2611 | !-- at index 1 in case of forcing. |
---|
| 2612 | |
---|
| 2613 | IF ( force_bound_l ) THEN |
---|
| 2614 | DO j = nys, nyn |
---|
| 2615 | DO t = force%tind, force%tind_p |
---|
| 2616 | CALL get_variable_bc( id_dynamic, 'ls_forcing_left_u', & |
---|
| 2617 | t+1, & |
---|
| 2618 | nzb+1, nzt+1-(nzb+1)+1, & |
---|
| 2619 | j+1, 1, & |
---|
| 2620 | force%u_left(t-force%tind,nzb+1:nzt+1,j) ) |
---|
| 2621 | ENDDO |
---|
| 2622 | ENDDO |
---|
| 2623 | |
---|
| 2624 | DO j = nysv, nyn |
---|
| 2625 | DO t = force%tind, force%tind_p |
---|
| 2626 | CALL get_variable_bc( id_dynamic, 'ls_forcing_left_v', & |
---|
| 2627 | t+1, & |
---|
| 2628 | nzb+1, nzt+1-(nzb+1)+1, & |
---|
| 2629 | j, 1, & |
---|
| 2630 | force%v_left(t-force%tind,nzb+1:nzt+1,j) ) |
---|
| 2631 | ENDDO |
---|
| 2632 | ENDDO |
---|
| 2633 | DO j = nys, nyn |
---|
| 2634 | DO t = force%tind, force%tind_p |
---|
| 2635 | CALL get_variable_bc( id_dynamic, & |
---|
| 2636 | 'ls_forcing_left_w', & |
---|
| 2637 | t+1, & |
---|
| 2638 | nzb+1, nzt-(nzb+1) + 1, & |
---|
| 2639 | j+1, 1, & |
---|
| 2640 | force%w_left(t-force%tind,nzb+1:nzt,j) ) |
---|
| 2641 | ENDDO |
---|
| 2642 | ENDDO |
---|
| 2643 | IF ( .NOT. neutral ) THEN |
---|
| 2644 | DO j = nys, nyn |
---|
| 2645 | DO t = force%tind, force%tind_p |
---|
| 2646 | CALL get_variable_bc( id_dynamic, & |
---|
| 2647 | 'ls_forcing_left_pt', & |
---|
| 2648 | t+1, & |
---|
| 2649 | nzb+1, nzt+1-(nzb+1)+1, & |
---|
| 2650 | j+1, 1, & |
---|
| 2651 | force%pt_left(t-force%tind,nzb+1:nzt+1,j) ) |
---|
| 2652 | ENDDO |
---|
| 2653 | ENDDO |
---|
| 2654 | ENDIF |
---|
| 2655 | IF ( humidity ) THEN |
---|
| 2656 | DO j = nys, nyn |
---|
| 2657 | DO t = force%tind, force%tind_p |
---|
| 2658 | CALL get_variable_bc( id_dynamic, & |
---|
| 2659 | 'ls_forcing_left_qv', & |
---|
| 2660 | t+1, & |
---|
| 2661 | nzb+1, nzt+1-(nzb+1)+1, & |
---|
| 2662 | j+1, 1, & |
---|
| 2663 | force%q_left(t-force%tind,nzb+1:nzt+1,j) ) |
---|
| 2664 | ENDDO |
---|
| 2665 | ENDDO |
---|
| 2666 | ENDIF |
---|
| 2667 | ENDIF |
---|
| 2668 | |
---|
| 2669 | IF ( force_bound_r ) THEN |
---|
| 2670 | DO j = nys, nyn |
---|
| 2671 | DO t = force%tind, force%tind_p |
---|
| 2672 | CALL get_variable_bc( id_dynamic, 'ls_forcing_right_u', & |
---|
| 2673 | t+1, & |
---|
| 2674 | nzb+1, nzt+1-(nzb+1)+1, & |
---|
| 2675 | j+1, 1, & |
---|
| 2676 | force%u_right(t-force%tind,nzb+1:nzt+1,j) ) |
---|
| 2677 | ENDDO |
---|
| 2678 | ENDDO |
---|
| 2679 | DO j = nysv, nyn |
---|
| 2680 | DO t = force%tind, force%tind_p |
---|
| 2681 | CALL get_variable_bc( id_dynamic, 'ls_forcing_right_v', & |
---|
| 2682 | t+1, & |
---|
| 2683 | nzb+1, nzt+1-(nzb+1)+1, & |
---|
| 2684 | j, 1, & |
---|
| 2685 | force%v_right(t-force%tind,nzb+1:nzt+1,j) ) |
---|
| 2686 | ENDDO |
---|
| 2687 | ENDDO |
---|
| 2688 | DO j = nys, nyn |
---|
| 2689 | DO t = force%tind, force%tind_p |
---|
| 2690 | CALL get_variable_bc( id_dynamic, 'ls_forcing_right_w', & |
---|
| 2691 | t+1, & |
---|
| 2692 | nzb+1, nzt-(nzb+1)+1, & |
---|
| 2693 | j+1, 1, & |
---|
| 2694 | force%w_right(t-force%tind,nzb+1:nzt,j) ) |
---|
| 2695 | ENDDO |
---|
| 2696 | ENDDO |
---|
| 2697 | IF ( .NOT. neutral ) THEN |
---|
| 2698 | DO j = nys, nyn |
---|
| 2699 | DO t = force%tind, force%tind_p |
---|
| 2700 | CALL get_variable_bc( id_dynamic, & |
---|
| 2701 | 'ls_forcing_right_pt', & |
---|
| 2702 | t+1, & |
---|
| 2703 | nzb+1, nzt+1-(nzb+1)+1, & |
---|
| 2704 | j+1, 1, & |
---|
| 2705 | force%pt_right(t-force%tind,nzb+1:nzt+1,j) ) |
---|
| 2706 | ENDDO |
---|
| 2707 | ENDDO |
---|
| 2708 | ENDIF |
---|
| 2709 | IF ( humidity ) THEN |
---|
| 2710 | DO j = nys, nyn |
---|
| 2711 | DO t = force%tind, force%tind_p |
---|
| 2712 | CALL get_variable_bc( id_dynamic, & |
---|
| 2713 | 'ls_forcing_right_qv', & |
---|
| 2714 | t+1, & |
---|
| 2715 | nzb+1, nzt+1-(nzb+1)+1, & |
---|
| 2716 | j+1, 1, & |
---|
| 2717 | force%q_right(t-force%tind,nzb+1:nzt+1,j) ) |
---|
| 2718 | ENDDO |
---|
| 2719 | ENDDO |
---|
| 2720 | ENDIF |
---|
| 2721 | ENDIF |
---|
| 2722 | |
---|
| 2723 | IF ( force_bound_n ) THEN |
---|
| 2724 | DO i = nxlu, nxr |
---|
| 2725 | DO t = force%tind, force%tind_p |
---|
| 2726 | CALL get_variable_bc( id_dynamic, 'ls_forcing_north_u', & |
---|
| 2727 | t+1, & |
---|
| 2728 | nzb+1, nzt+1-(nzb+1)+1, & |
---|
| 2729 | i, 1, & |
---|
| 2730 | force%u_north(t-force%tind,nzb+1:nzt+1,i) ) |
---|
| 2731 | ENDDO |
---|
| 2732 | ENDDO |
---|
| 2733 | DO i = nxl, nxr |
---|
| 2734 | DO t = force%tind, force%tind_p |
---|
| 2735 | CALL get_variable_bc( id_dynamic, 'ls_forcing_north_v', & |
---|
| 2736 | t+1, & |
---|
| 2737 | nzb+1, nzt+1-(nzb+1)+1, & |
---|
| 2738 | i+1, 1, & |
---|
| 2739 | force%v_north(t-force%tind,nzb+1:nzt+1,i) ) |
---|
| 2740 | ENDDO |
---|
| 2741 | ENDDO |
---|
| 2742 | DO i = nxl, nxr |
---|
| 2743 | DO t = force%tind, force%tind_p |
---|
| 2744 | CALL get_variable_bc( id_dynamic, 'ls_forcing_north_w', & |
---|
| 2745 | t+1, & |
---|
| 2746 | nzb+1, nzt-(nzb+1)+1, & |
---|
| 2747 | i+1, 1, & |
---|
| 2748 | force%w_north(t-force%tind,nzb+1:nzt,i) ) |
---|
| 2749 | ENDDO |
---|
| 2750 | ENDDO |
---|
| 2751 | IF ( .NOT. neutral ) THEN |
---|
| 2752 | DO i = nxl, nxr |
---|
| 2753 | DO t = force%tind, force%tind_p |
---|
| 2754 | CALL get_variable_bc( id_dynamic, & |
---|
| 2755 | 'ls_forcing_north_pt', & |
---|
| 2756 | t+1, & |
---|
| 2757 | nzb+1, nzt+1-(nzb+1)+1, & |
---|
| 2758 | i+1, 1, & |
---|
| 2759 | force%pt_north(t-force%tind,nzb+1:nzt+1,i) ) |
---|
| 2760 | ENDDO |
---|
| 2761 | ENDDO |
---|
| 2762 | ENDIF |
---|
| 2763 | IF ( humidity ) THEN |
---|
| 2764 | DO i = nxl, nxr |
---|
| 2765 | DO t = force%tind, force%tind_p |
---|
| 2766 | CALL get_variable_bc( id_dynamic, & |
---|
| 2767 | 'ls_forcing_north_qv', & |
---|
| 2768 | t+1, & |
---|
| 2769 | nzb+1, nzt+1-(nzb+1)+1, & |
---|
| 2770 | i+1, 1, & |
---|
| 2771 | force%q_north(t-force%tind,nzb+1:nzt+1,i) ) |
---|
| 2772 | ENDDO |
---|
| 2773 | ENDDO |
---|
| 2774 | ENDIF |
---|
| 2775 | ENDIF |
---|
| 2776 | |
---|
| 2777 | IF ( force_bound_s ) THEN |
---|
| 2778 | DO i = nxlu, nxr |
---|
| 2779 | DO t = force%tind, force%tind_p |
---|
| 2780 | CALL get_variable_bc( id_dynamic, 'ls_forcing_south_u', & |
---|
| 2781 | t+1, & |
---|
| 2782 | nzb+1, nzt+1-(nzb+1)+1, & |
---|
| 2783 | i, 1, & |
---|
| 2784 | force%u_south(t-force%tind,nzb+1:nzt+1,i) ) |
---|
| 2785 | ENDDO |
---|
| 2786 | ENDDO |
---|
| 2787 | DO i = nxl, nxr |
---|
| 2788 | DO t = force%tind, force%tind_p |
---|
| 2789 | CALL get_variable_bc( id_dynamic, 'ls_forcing_south_v', & |
---|
| 2790 | t+1, & |
---|
| 2791 | nzb+1, nzt+1-(nzb+1)+1, & |
---|
| 2792 | i+1, 1, & |
---|
| 2793 | force%v_south(t-force%tind,nzb+1:nzt+1,i) ) |
---|
| 2794 | ENDDO |
---|
| 2795 | ENDDO |
---|
| 2796 | DO i = nxl, nxr |
---|
| 2797 | DO t = force%tind, force%tind_p |
---|
| 2798 | CALL get_variable_bc( id_dynamic, 'ls_forcing_south_w', & |
---|
| 2799 | t+1, & |
---|
| 2800 | nzb+1, nzt-(nzb+1)+1, & |
---|
| 2801 | i+1, 1, & |
---|
| 2802 | force%w_south(t-force%tind,nzb+1:nzt,i) ) |
---|
| 2803 | ENDDO |
---|
| 2804 | ENDDO |
---|
| 2805 | IF ( .NOT. neutral ) THEN |
---|
| 2806 | DO i = nxl, nxr |
---|
| 2807 | DO t = force%tind, force%tind_p |
---|
| 2808 | CALL get_variable_bc( id_dynamic, & |
---|
| 2809 | 'ls_forcing_south_pt', & |
---|
| 2810 | t+1, & |
---|
| 2811 | nzb+1, nzt+1-(nzb+1)+1, & |
---|
| 2812 | i+1, 1, & |
---|
| 2813 | force%pt_south(t-force%tind,nzb+1:nzt+1,i) ) |
---|
| 2814 | ENDDO |
---|
| 2815 | ENDDO |
---|
| 2816 | ENDIF |
---|
| 2817 | IF ( humidity ) THEN |
---|
| 2818 | DO i = nxl, nxr |
---|
| 2819 | DO t = force%tind, force%tind_p |
---|
| 2820 | CALL get_variable_bc( id_dynamic, & |
---|
| 2821 | 'ls_forcing_south_qv', & |
---|
| 2822 | t+1, & |
---|
| 2823 | nzb+1, nzt+1-(nzb+1)+1, & |
---|
| 2824 | i+1, 1, & |
---|
| 2825 | force%q_south(t-force%tind,nzb+1:nzt+1,i) ) |
---|
| 2826 | ENDDO |
---|
| 2827 | ENDDO |
---|
| 2828 | ENDIF |
---|
| 2829 | ENDIF |
---|
| 2830 | ! |
---|
| 2831 | !-- Top boundary |
---|
| 2832 | DO i = nxlu, nxr |
---|
| 2833 | DO t = force%tind, force%tind_p |
---|
| 2834 | CALL get_variable_bc( id_dynamic, 'ls_forcing_top_u', & |
---|
| 2835 | t+1, & |
---|
| 2836 | nys+1, nyn-nys+1, & |
---|
| 2837 | i, 1, & |
---|
| 2838 | force%u_top(t-force%tind,nys:nyn,i) ) |
---|
| 2839 | ENDDO |
---|
| 2840 | ENDDO |
---|
| 2841 | DO i = nxl, nxr |
---|
| 2842 | DO t = force%tind, force%tind_p |
---|
| 2843 | CALL get_variable_bc( id_dynamic, 'ls_forcing_top_v', & |
---|
| 2844 | t+1, & |
---|
| 2845 | nysv, nyn-nysv+1, & |
---|
| 2846 | i+1, 1, & |
---|
| 2847 | force%v_top(t-force%tind,nysv:nyn,i) ) |
---|
| 2848 | ENDDO |
---|
| 2849 | ENDDO |
---|
| 2850 | DO i = nxl, nxr |
---|
| 2851 | DO t = force%tind, force%tind_p |
---|
| 2852 | CALL get_variable_bc( id_dynamic, 'ls_forcing_top_w', & |
---|
| 2853 | t+1, & |
---|
| 2854 | nys+1, nyn-nys+1, & |
---|
| 2855 | i+1, 1, & |
---|
| 2856 | force%w_top(t-force%tind,nys:nyn,i) ) |
---|
| 2857 | ENDDO |
---|
| 2858 | ENDDO |
---|
| 2859 | IF ( .NOT. neutral ) THEN |
---|
| 2860 | DO i = nxl, nxr |
---|
| 2861 | DO t = force%tind, force%tind_p |
---|
| 2862 | CALL get_variable_bc( id_dynamic, 'ls_forcing_top_pt', & |
---|
| 2863 | t+1, & |
---|
| 2864 | nys+1, nyn-nys+1, & |
---|
| 2865 | i+1, 1, & |
---|
| 2866 | force%pt_top(t-force%tind,nys:nyn,i) ) |
---|
| 2867 | ENDDO |
---|
| 2868 | ENDDO |
---|
| 2869 | ENDIF |
---|
| 2870 | IF ( humidity ) THEN |
---|
| 2871 | DO i = nxl, nxr |
---|
| 2872 | DO t = force%tind, force%tind_p |
---|
| 2873 | CALL get_variable_bc( id_dynamic, 'ls_forcing_top_qv', & |
---|
| 2874 | t+1, & |
---|
| 2875 | nys+1, nyn-nys+1, & |
---|
| 2876 | i+1, 1, & |
---|
| 2877 | force%q_top(t-force%tind,nys:nyn,i) ) |
---|
| 2878 | ENDDO |
---|
| 2879 | ENDDO |
---|
| 2880 | ENDIF |
---|
| 2881 | |
---|
| 2882 | ! |
---|
| 2883 | !-- Close input file |
---|
[2711] | 2884 | CALL close_input_file( id_dynamic ) |
---|
[2586] | 2885 | #endif |
---|
| 2886 | ENDIF |
---|
| 2887 | #if defined( __parallel ) |
---|
| 2888 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 2889 | #endif |
---|
| 2890 | ENDDO |
---|
| 2891 | |
---|
| 2892 | ! |
---|
[2955] | 2893 | !-- End of CPU measurement |
---|
| 2894 | CALL cpu_log( log_point_s(86), 'NetCDF input forcing', 'stop' ) |
---|
| 2895 | |
---|
| 2896 | ! |
---|
[2586] | 2897 | !-- Finally, after data input set control flag indicating that vertical |
---|
| 2898 | !-- inter- and/or extrapolation is required. |
---|
| 2899 | !-- Please note, inter/extrapolation of INIFOR data is only a workaroud, |
---|
| 2900 | !-- as long as INIFOR delivers vertically equidistant data. |
---|
| 2901 | force%interpolated = .FALSE. |
---|
| 2902 | |
---|
| 2903 | END SUBROUTINE netcdf_data_input_lsf |
---|
| 2904 | |
---|
| 2905 | |
---|
| 2906 | !------------------------------------------------------------------------------! |
---|
| 2907 | ! Description: |
---|
| 2908 | ! ------------ |
---|
| 2909 | !> Checks input file for consistency and minimum requirements. |
---|
| 2910 | !------------------------------------------------------------------------------! |
---|
[2637] | 2911 | SUBROUTINE netcdf_data_input_check_dynamic |
---|
| 2912 | |
---|
| 2913 | USE control_parameters, & |
---|
| 2914 | ONLY: initializing_actions, forcing, message_string |
---|
| 2915 | |
---|
| 2916 | IMPLICIT NONE |
---|
| 2917 | |
---|
| 2918 | ! |
---|
| 2919 | !-- In case of forcing, check whether dynamic input file is present |
---|
| 2920 | IF ( .NOT. input_pids_dynamic .AND. forcing ) THEN |
---|
| 2921 | message_string = 'forcing = .TRUE. requires dynamic input file ' // & |
---|
| 2922 | TRIM( input_file_dynamic ) // TRIM( coupling_char ) |
---|
[2925] | 2923 | CALL message( 'netcdf_data_input_mod', 'NDI009', 1, 2, 0, 6, 0 ) |
---|
[2637] | 2924 | ENDIF |
---|
| 2925 | ! |
---|
| 2926 | !-- Dynamic input file must also be present if initialization via inifor is |
---|
| 2927 | !-- prescribed. |
---|
| 2928 | IF ( .NOT. input_pids_dynamic .AND. & |
---|
| 2929 | TRIM( initializing_actions ) == 'inifor' ) THEN |
---|
| 2930 | message_string = 'initializing_actions = inifor requires dynamic ' //& |
---|
| 2931 | 'input file ' // TRIM( input_file_dynamic ) // & |
---|
| 2932 | TRIM( coupling_char ) |
---|
[2925] | 2933 | CALL message( 'netcdf_data_input_mod', 'NDI010', 1, 2, 0, 6, 0 ) |
---|
[2637] | 2934 | ENDIF |
---|
| 2935 | |
---|
| 2936 | END SUBROUTINE netcdf_data_input_check_dynamic |
---|
| 2937 | |
---|
| 2938 | !------------------------------------------------------------------------------! |
---|
| 2939 | ! Description: |
---|
| 2940 | ! ------------ |
---|
| 2941 | !> Checks input file for consistency and minimum requirements. |
---|
| 2942 | !------------------------------------------------------------------------------! |
---|
[2586] | 2943 | SUBROUTINE netcdf_data_input_check_static |
---|
| 2944 | |
---|
[2787] | 2945 | USE arrays_3d, & |
---|
| 2946 | ONLY: zu |
---|
| 2947 | |
---|
[2586] | 2948 | USE control_parameters, & |
---|
[2659] | 2949 | ONLY: land_surface, message_string, urban_surface |
---|
[2586] | 2950 | |
---|
[2898] | 2951 | USE grid_variables, & |
---|
| 2952 | ONLY: dx, dy |
---|
| 2953 | |
---|
[2586] | 2954 | USE indices, & |
---|
[2898] | 2955 | ONLY: nx, nxl, nxr, ny, nyn, nys |
---|
[2586] | 2956 | |
---|
| 2957 | IMPLICIT NONE |
---|
| 2958 | |
---|
| 2959 | INTEGER(iwp) :: i !< loop index along x-direction |
---|
| 2960 | INTEGER(iwp) :: j !< loop index along y-direction |
---|
[2930] | 2961 | INTEGER(iwp) :: n_surf !< number of different surface types at given location |
---|
[2586] | 2962 | |
---|
| 2963 | LOGICAL :: check_passed !< flag indicating if a check passed |
---|
| 2964 | |
---|
| 2965 | ! |
---|
| 2966 | !-- Return if no static input file is available |
---|
[2898] | 2967 | IF ( .NOT. input_pids_static ) RETURN |
---|
[2586] | 2968 | ! |
---|
[2898] | 2969 | !-- Check whether dimension size in input file matches the model dimensions |
---|
| 2970 | IF ( dim_static%nx-1 /= nx .OR. dim_static%ny-1 /= ny ) THEN |
---|
| 2971 | message_string = 'Static input file: horizontal dimension in ' // & |
---|
| 2972 | 'x- and/or y-direction ' // & |
---|
| 2973 | 'do not match the respective model dimension' |
---|
[2925] | 2974 | CALL message( 'netcdf_data_input_mod', 'NDI011', 1, 2, 0, 6, 0 ) |
---|
[2898] | 2975 | ENDIF |
---|
| 2976 | ! |
---|
| 2977 | !-- Check if grid spacing of provided input data matches the respective |
---|
| 2978 | !-- grid spacing in the model. |
---|
| 2979 | IF ( dim_static%x(1) - dim_static%x(0) /= dx .OR. & |
---|
| 2980 | dim_static%y(1) - dim_static%y(0) /= dy ) THEN |
---|
| 2981 | message_string = 'Static input file: horizontal grid spacing ' // & |
---|
| 2982 | 'in x- and/or y-direction ' // & |
---|
| 2983 | 'do not match the respective model grid spacing.' |
---|
[2925] | 2984 | CALL message( 'netcdf_data_input_mod', 'NDI012', 1, 2, 0, 6, 0 ) |
---|
[2898] | 2985 | ENDIF |
---|
| 2986 | ! |
---|
[2659] | 2987 | !-- Check orography for fill-values. For the moment, give an error message. |
---|
| 2988 | !-- More advanced methods, e.g. a nearest neighbor algorithm as used in GIS |
---|
| 2989 | !-- systems might be implemented later. |
---|
[2963] | 2990 | !-- Please note, if no terrain height is provided, it is set to 0. |
---|
[2659] | 2991 | IF ( ANY( terrain_height_f%var == terrain_height_f%fill ) ) THEN |
---|
| 2992 | message_string = 'NetCDF variable orography_2D is not ' // & |
---|
| 2993 | 'allowed to have missing data' |
---|
[2925] | 2994 | CALL message( 'netcdf_data_input_mod', 'NDI013', 2, 2, 0, 6, 0 ) |
---|
[2659] | 2995 | ENDIF |
---|
| 2996 | ! |
---|
[2787] | 2997 | !-- If 3D buildings are read, check if building information is consistent |
---|
| 2998 | !-- to numeric grid. |
---|
| 2999 | IF ( buildings_f%from_file ) THEN |
---|
| 3000 | IF ( buildings_f%lod == 2 ) THEN |
---|
| 3001 | IF ( buildings_f%nz > SIZE( zu ) ) THEN |
---|
| 3002 | message_string = 'Reading 3D building data - too much ' // & |
---|
| 3003 | 'data points along the vertical coordinate.' |
---|
[2925] | 3004 | CALL message( 'netcdf_data_input_mod', 'NDI014', 2, 2, 0, 6, 0 ) |
---|
[2787] | 3005 | ENDIF |
---|
| 3006 | |
---|
| 3007 | IF ( ANY( buildings_f%z(0:buildings_f%nz-1) /= & |
---|
| 3008 | zu(0:buildings_f%nz-1) ) ) THEN |
---|
| 3009 | message_string = 'Reading 3D building data - vertical ' // & |
---|
| 3010 | 'coordinate do not match numeric grid.' |
---|
[2925] | 3011 | CALL message( 'netcdf_data_input_mod', 'NDI015', 2, 2, 0, 6, 0 ) |
---|
[2787] | 3012 | ENDIF |
---|
| 3013 | ENDIF |
---|
| 3014 | ENDIF |
---|
| 3015 | |
---|
| 3016 | ! |
---|
[2659] | 3017 | !-- Skip further checks concerning buildings and natural surface properties |
---|
| 3018 | !-- if no urban surface and land surface model are applied. |
---|
| 3019 | IF ( .NOT. land_surface .OR. .NOT. urban_surface ) RETURN |
---|
| 3020 | ! |
---|
[2586] | 3021 | !-- Check for minimum requirement of surface-classification data in case |
---|
| 3022 | !-- static input file is used. |
---|
[2963] | 3023 | IF ( ( .NOT. vegetation_type_f%from_file .OR. & |
---|
| 3024 | .NOT. pavement_type_f%from_file .OR. & |
---|
| 3025 | .NOT. water_type_f%from_file .OR. & |
---|
| 3026 | .NOT. soil_type_f%from_file ) .OR. & |
---|
| 3027 | ( urban_surface .AND. .NOT. building_type_f%from_file ) ) THEN |
---|
[2586] | 3028 | message_string = 'Minimum requirement for surface classification ' //& |
---|
| 3029 | 'is not fulfilled. At least ' // & |
---|
| 3030 | 'vegetation_type, pavement_type, ' // & |
---|
[2963] | 3031 | 'soil_type and water_type are '// & |
---|
| 3032 | 'required. If urban-surface model is applied, ' // & |
---|
| 3033 | 'also building_type ist required' |
---|
[2925] | 3034 | CALL message( 'netcdf_data_input_mod', 'NDI016', 1, 2, 0, 6, 0 ) |
---|
[2586] | 3035 | ENDIF |
---|
| 3036 | ! |
---|
| 3037 | !-- Check for general availability of input variables. |
---|
| 3038 | !-- If vegetation_type is 0 at any location, vegetation_pars as well as |
---|
| 3039 | !-- root_area_density_lsm are required. |
---|
| 3040 | IF ( vegetation_type_f%from_file ) THEN |
---|
| 3041 | IF ( ANY( vegetation_type_f%var == 0 ) ) THEN |
---|
| 3042 | IF ( .NOT. vegetation_pars_f%from_file ) THEN |
---|
| 3043 | message_string = 'If vegegation_type = 0 at any location, ' // & |
---|
| 3044 | 'vegetation_pars is required' |
---|
[2925] | 3045 | CALL message( 'netcdf_data_input_mod', 'NDI017', 2, 2, 0, 6, 0 ) |
---|
[2586] | 3046 | ENDIF |
---|
| 3047 | IF ( .NOT. root_area_density_lsm_f%from_file ) THEN |
---|
| 3048 | message_string = 'If vegegation_type = 0 at any location, ' // & |
---|
| 3049 | 'root_area_density_lsm is required' |
---|
[2925] | 3050 | CALL message( 'netcdf_data_input_mod', 'NDI018', 2, 2, 0, 6, 0 ) |
---|
[2586] | 3051 | ENDIF |
---|
| 3052 | ENDIF |
---|
| 3053 | ENDIF |
---|
| 3054 | ! |
---|
| 3055 | !-- If soil_type is zero at any location, soil_pars is required. |
---|
| 3056 | IF ( soil_type_f%from_file ) THEN |
---|
| 3057 | check_passed = .TRUE. |
---|
[2646] | 3058 | IF ( ALLOCATED( soil_type_f%var_2d ) ) THEN |
---|
[2586] | 3059 | IF ( ANY( soil_type_f%var_2d == 0 ) ) THEN |
---|
| 3060 | IF ( .NOT. soil_pars_f%from_file ) check_passed = .FALSE. |
---|
| 3061 | ENDIF |
---|
| 3062 | ELSE |
---|
| 3063 | IF ( ANY( soil_type_f%var_3d == 0 ) ) THEN |
---|
| 3064 | IF ( .NOT. soil_pars_f%from_file ) check_passed = .FALSE. |
---|
| 3065 | ENDIF |
---|
| 3066 | ENDIF |
---|
| 3067 | IF ( .NOT. check_passed ) THEN |
---|
| 3068 | message_string = 'If soil_type = 0 at any location, ' // & |
---|
| 3069 | 'soil_pars is required' |
---|
[2925] | 3070 | CALL message( 'netcdf_data_input_mod', 'NDI019', 2, 2, 0, 6, 0 ) |
---|
[2586] | 3071 | ENDIF |
---|
| 3072 | ENDIF |
---|
| 3073 | ! |
---|
| 3074 | !-- If building_type is zero at any location, building_pars is required. |
---|
| 3075 | IF ( building_type_f%from_file ) THEN |
---|
| 3076 | IF ( ANY( building_type_f%var == 0 ) ) THEN |
---|
| 3077 | IF ( .NOT. building_pars_f%from_file ) THEN |
---|
| 3078 | message_string = 'If building_type = 0 at any location, ' // & |
---|
| 3079 | 'building_pars is required' |
---|
[2925] | 3080 | CALL message( 'netcdf_data_input_mod', 'NDI020', 2, 2, 0, 6, 0 ) |
---|
[2586] | 3081 | ENDIF |
---|
| 3082 | ENDIF |
---|
| 3083 | ENDIF |
---|
| 3084 | ! |
---|
| 3085 | !-- If albedo_type is zero at any location, albedo_pars is required. |
---|
| 3086 | IF ( albedo_type_f%from_file ) THEN |
---|
| 3087 | IF ( ANY( albedo_type_f%var == 0 ) ) THEN |
---|
| 3088 | IF ( .NOT. albedo_pars_f%from_file ) THEN |
---|
| 3089 | message_string = 'If albedo_type = 0 at any location, ' // & |
---|
| 3090 | 'albedo_pars is required' |
---|
[2925] | 3091 | CALL message( 'netcdf_data_input_mod', 'NDI021', 2, 2, 0, 6, 0 ) |
---|
[2586] | 3092 | ENDIF |
---|
| 3093 | ENDIF |
---|
| 3094 | ENDIF |
---|
| 3095 | ! |
---|
| 3096 | !-- If pavement_type is zero at any location, pavement_pars is required. |
---|
| 3097 | IF ( pavement_type_f%from_file ) THEN |
---|
| 3098 | IF ( ANY( pavement_type_f%var == 0 ) ) THEN |
---|
| 3099 | IF ( .NOT. pavement_pars_f%from_file ) THEN |
---|
| 3100 | message_string = 'If pavement_type = 0 at any location, ' // & |
---|
| 3101 | 'pavement_pars is required' |
---|
[2925] | 3102 | CALL message( 'netcdf_data_input_mod', 'NDI022', 2, 2, 0, 6, 0 ) |
---|
[2586] | 3103 | ENDIF |
---|
| 3104 | ENDIF |
---|
| 3105 | ENDIF |
---|
| 3106 | ! |
---|
| 3107 | !-- If pavement_type is zero at any location, also pavement_subsurface_pars |
---|
| 3108 | !-- is required. |
---|
| 3109 | IF ( pavement_type_f%from_file ) THEN |
---|
| 3110 | IF ( ANY( pavement_type_f%var == 0 ) ) THEN |
---|
| 3111 | IF ( .NOT. pavement_subsurface_pars_f%from_file ) THEN |
---|
| 3112 | message_string = 'If pavement_type = 0 at any location, ' // & |
---|
| 3113 | 'pavement_subsurface_pars is required' |
---|
[2925] | 3114 | CALL message( 'netcdf_data_input_mod', 'NDI023', 2, 2, 0, 6, 0 ) |
---|
[2586] | 3115 | ENDIF |
---|
| 3116 | ENDIF |
---|
| 3117 | ENDIF |
---|
| 3118 | ! |
---|
| 3119 | !-- If water_type is zero at any location, water_pars is required. |
---|
| 3120 | IF ( water_type_f%from_file ) THEN |
---|
| 3121 | IF ( ANY( water_type_f%var == 0 ) ) THEN |
---|
| 3122 | IF ( .NOT. water_pars_f%from_file ) THEN |
---|
| 3123 | message_string = 'If water_type = 0 at any location, ' // & |
---|
| 3124 | 'water_pars is required' |
---|
[2925] | 3125 | CALL message( 'netcdf_data_input_mod', 'NDI024', 2, 2, 0, 6, 0 ) |
---|
[2586] | 3126 | ENDIF |
---|
| 3127 | ENDIF |
---|
| 3128 | ENDIF |
---|
| 3129 | ! |
---|
| 3130 | !-- Check for local consistency of the input data. |
---|
| 3131 | DO i = nxl, nxr |
---|
| 3132 | DO j = nys, nyn |
---|
| 3133 | ! |
---|
| 3134 | !-- For each (y,x)-location at least one of the parameters |
---|
| 3135 | !-- vegetation_type, pavement_type, building_type, or water_type |
---|
| 3136 | !-- must be set to a nonÂmissing value. |
---|
| 3137 | IF ( vegetation_type_f%var(j,i) == vegetation_type_f%fill .AND. & |
---|
| 3138 | pavement_type_f%var(j,i) == pavement_type_f%fill .AND. & |
---|
| 3139 | building_type_f%var(j,i) == building_type_f%fill .AND. & |
---|
| 3140 | water_type_f%var(j,i) == water_type_f%fill ) THEN |
---|
[2963] | 3141 | WRITE( message_string, * ) 'At least one of the parameters '// & |
---|
[2586] | 3142 | 'vegetation_type, pavement_type, ' // & |
---|
| 3143 | 'building_type, or water_type must be set '// & |
---|
[2963] | 3144 | 'to a non-missing value. Grid point: ', j, i |
---|
[2925] | 3145 | CALL message( 'netcdf_data_input_mod', 'NDI025', 2, 2, 0, 6, 0 ) |
---|
[2586] | 3146 | ENDIF |
---|
| 3147 | ! |
---|
| 3148 | !-- Note that a soil_type is required for each location (y,x) where |
---|
| 3149 | !-- either vegetation_type or pavement_type is a nonÂmissing value. |
---|
| 3150 | IF ( ( vegetation_type_f%var(j,i) /= vegetation_type_f%fill .OR. & |
---|
| 3151 | pavement_type_f%var(j,i) /= pavement_type_f%fill ) ) THEN |
---|
| 3152 | check_passed = .TRUE. |
---|
[2646] | 3153 | IF ( ALLOCATED( soil_type_f%var_2d ) ) THEN |
---|
[2586] | 3154 | IF ( soil_type_f%var_2d(j,i) == soil_type_f%fill ) & |
---|
| 3155 | check_passed = .FALSE. |
---|
| 3156 | ELSE |
---|
| 3157 | IF ( ANY( soil_type_f%var_3d(:,j,i) == soil_type_f%fill) ) & |
---|
| 3158 | check_passed = .FALSE. |
---|
| 3159 | ENDIF |
---|
| 3160 | |
---|
| 3161 | IF ( .NOT. check_passed ) THEN |
---|
| 3162 | message_string = 'soil_type is required for each '// & |
---|
| 3163 | 'location (y,x) where vegetation_type or ' // & |
---|
| 3164 | 'pavement_type is a non-missing value.' |
---|
[2925] | 3165 | CALL message( 'netcdf_data_input_mod', 'NDI026', & |
---|
[2589] | 3166 | 2, 2, 0, 6, 0 ) |
---|
[2586] | 3167 | ENDIF |
---|
| 3168 | ENDIF |
---|
| 3169 | ! |
---|
[2930] | 3170 | !-- Check for consistency of surface fraction. If more than one type |
---|
| 3171 | !-- is set, surface fraction need to be given and the sum must not |
---|
| 3172 | !-- be larger than 1. |
---|
| 3173 | n_surf = 0 |
---|
| 3174 | IF ( vegetation_type_f%var(j,i) /= vegetation_type_f%fill ) & |
---|
| 3175 | n_surf = n_surf + 1 |
---|
| 3176 | IF ( water_type_f%var(j,i) /= water_type_f%fill ) & |
---|
| 3177 | n_surf = n_surf + 1 |
---|
| 3178 | IF ( pavement_type_f%var(j,i) /= pavement_type_f%fill ) & |
---|
| 3179 | n_surf = n_surf + 1 |
---|
| 3180 | |
---|
| 3181 | IF ( n_surf > 1 ) THEN |
---|
| 3182 | IF ( ANY ( surface_fraction_f%frac(:,j,i) == & |
---|
| 3183 | surface_fraction_f%fill ) ) THEN |
---|
| 3184 | message_string = 'If more than one surface type is ' // & |
---|
| 3185 | 'given at a location, surface_fraction ' // & |
---|
| 3186 | 'must be provided.' |
---|
| 3187 | CALL message( 'netcdf_data_input_mod', 'NDI027', & |
---|
[2589] | 3188 | 2, 2, 0, 6, 0 ) |
---|
[2930] | 3189 | ENDIF |
---|
| 3190 | IF ( SUM ( surface_fraction_f%frac(:,j,i) ) > 1.0_wp ) THEN |
---|
| 3191 | message_string = 'surface_fraction must not exceed 1' |
---|
| 3192 | CALL message( 'netcdf_data_input_mod', 'NDI028', & |
---|
| 3193 | 2, 2, 0, 6, 0 ) |
---|
| 3194 | ENDIF |
---|
[2586] | 3195 | ENDIF |
---|
| 3196 | ! |
---|
[2925] | 3197 | !-- Check for further mismatches, e.g. vegetation_type is set but |
---|
| 3198 | !-- surface vegetation fraction is zero. |
---|
[2930] | 3199 | IF ( ( vegetation_type_f%var(j,i) /= vegetation_type_f%fill .AND.& |
---|
[2963] | 3200 | ( surface_fraction_f%frac(ind_veg_wall,j,i) == 0.0_wp .OR. & |
---|
| 3201 | surface_fraction_f%frac(ind_veg_wall,j,i) == & |
---|
| 3202 | surface_fraction_f%fill ) & |
---|
[2930] | 3203 | ) .OR. & |
---|
| 3204 | ( pavement_type_f%var(j,i) /= pavement_type_f%fill .AND. & |
---|
[2963] | 3205 | ( surface_fraction_f%frac(ind_pav_green,j,i) == 0.0_wp .OR. & |
---|
| 3206 | surface_fraction_f%frac(ind_pav_green,j,i) == & |
---|
| 3207 | surface_fraction_f%fill ) & |
---|
[2930] | 3208 | ) .OR. & |
---|
| 3209 | ( water_type_f%var(j,i) /= water_type_f%fill .AND. & |
---|
[2963] | 3210 | ( surface_fraction_f%frac(ind_wat_win,j,i) == 0.0_wp .OR. & |
---|
| 3211 | surface_fraction_f%frac(ind_wat_win,j,i) == & |
---|
| 3212 | surface_fraction_f%fill ) & |
---|
[2930] | 3213 | ) ) THEN |
---|
| 3214 | WRITE( message_string, * ) 'Mismatch in setting of ' // & |
---|
| 3215 | 'surface_fraction. Vegetation-, pavement-, or '// & |
---|
| 3216 | 'water surface is given at (i,j) = ( ', i, j, & |
---|
| 3217 | ' ), but surface fraction is 0 for the given type.' |
---|
| 3218 | CALL message( 'netcdf_data_input_mod', 'NDI029', & |
---|
[2925] | 3219 | 2, 2, 0, 6, 0 ) |
---|
| 3220 | ENDIF |
---|
| 3221 | ! |
---|
| 3222 | !-- Check for further mismatches, e.g. vegetation_type is not set |
---|
| 3223 | !-- surface vegetation fraction is non-zero. |
---|
[2930] | 3224 | IF ( ( vegetation_type_f%var(j,i) == vegetation_type_f%fill .AND.& |
---|
[2963] | 3225 | ( surface_fraction_f%frac(ind_veg_wall,j,i) /= 0.0_wp .AND. & |
---|
| 3226 | surface_fraction_f%frac(ind_veg_wall,j,i) /= & |
---|
| 3227 | surface_fraction_f%fill ) & |
---|
[2930] | 3228 | ) .OR. & |
---|
| 3229 | ( pavement_type_f%var(j,i) == pavement_type_f%fill .AND. & |
---|
[2963] | 3230 | ( surface_fraction_f%frac(ind_pav_green,j,i) /= 0.0_wp .AND. & |
---|
| 3231 | surface_fraction_f%frac(ind_pav_green,j,i) /= & |
---|
| 3232 | surface_fraction_f%fill ) & |
---|
[2930] | 3233 | ) .OR. & |
---|
| 3234 | ( water_type_f%var(j,i) == water_type_f%fill .AND. & |
---|
[2963] | 3235 | ( surface_fraction_f%frac(ind_wat_win,j,i) /= 0.0_wp .AND. & |
---|
| 3236 | surface_fraction_f%frac(ind_wat_win,j,i) /= & |
---|
| 3237 | surface_fraction_f%fill ) & |
---|
[2930] | 3238 | ) ) THEN |
---|
| 3239 | WRITE( message_string, * ) 'Mismatch in setting of ' // & |
---|
| 3240 | 'surface_fraction. Vegetation-, pavement-, or '// & |
---|
| 3241 | 'water surface is not given at (i,j) = ( ', i, j, & |
---|
| 3242 | ' ), but surface fraction is not 0 for the ' // & |
---|
| 3243 | 'given type.' |
---|
| 3244 | CALL message( 'netcdf_data_input_mod', 'NDI030', & |
---|
[2925] | 3245 | 2, 2, 0, 6, 0 ) |
---|
| 3246 | ENDIF |
---|
| 3247 | ! |
---|
[2586] | 3248 | !-- Check vegetation_pars. If vegetation_type is 0, all parameters |
---|
| 3249 | !-- need to be set, otherwise, single parameters set by |
---|
| 3250 | !-- vegetation_type can be overwritten. |
---|
| 3251 | IF ( vegetation_type_f%from_file ) THEN |
---|
| 3252 | IF ( vegetation_type_f%var(j,i) == 0 ) THEN |
---|
| 3253 | IF ( ANY( vegetation_pars_f%pars_xy(:,j,i) == & |
---|
| 3254 | vegetation_pars_f%fill ) ) THEN |
---|
| 3255 | message_string = 'If vegetation_type(y,x) = 0, all ' // & |
---|
| 3256 | 'parameters of vegetation_pars at '// & |
---|
| 3257 | 'this location must be set.' |
---|
[2925] | 3258 | CALL message( 'netcdf_data_input_mod', 'NDI031', & |
---|
[2589] | 3259 | 2, 2, 0, 6, 0 ) |
---|
[2586] | 3260 | ENDIF |
---|
| 3261 | ENDIF |
---|
| 3262 | ENDIF |
---|
| 3263 | ! |
---|
| 3264 | !-- Check root distribution. If vegetation_type is 0, all levels must |
---|
| 3265 | !-- be set. |
---|
| 3266 | IF ( vegetation_type_f%from_file ) THEN |
---|
| 3267 | IF ( vegetation_type_f%var(j,i) == 0 ) THEN |
---|
| 3268 | IF ( ANY( root_area_density_lsm_f%var(:,j,i) == & |
---|
| 3269 | root_area_density_lsm_f%fill ) ) THEN |
---|
| 3270 | message_string = 'If vegetation_type(y,x) = 0, all ' // & |
---|
| 3271 | 'levels of root_area_density_lsm ' // & |
---|
| 3272 | 'must be set at this location.' |
---|
[2925] | 3273 | CALL message( 'netcdf_data_input_mod', 'NDI032', & |
---|
[2589] | 3274 | 2, 2, 0, 6, 0 ) |
---|
[2586] | 3275 | ENDIF |
---|
| 3276 | ENDIF |
---|
| 3277 | ENDIF |
---|
| 3278 | ! |
---|
| 3279 | !-- Check soil parameters. If soil_type is 0, all parameters |
---|
| 3280 | !-- must be set. |
---|
| 3281 | IF ( soil_type_f%from_file ) THEN |
---|
| 3282 | check_passed = .TRUE. |
---|
[2646] | 3283 | IF ( ALLOCATED( soil_type_f%var_2d ) ) THEN |
---|
[2586] | 3284 | IF ( soil_type_f%var_2d(j,i) == 0 ) THEN |
---|
| 3285 | IF ( ANY( soil_pars_f%pars_xy(:,j,i) == & |
---|
| 3286 | soil_pars_f%fill ) ) check_passed = .FALSE. |
---|
| 3287 | ENDIF |
---|
| 3288 | ELSE |
---|
| 3289 | IF ( ANY( soil_type_f%var_3d(:,j,i) == 0 ) ) THEN |
---|
| 3290 | IF ( ANY( soil_pars_f%pars_xy(:,j,i) == & |
---|
| 3291 | soil_pars_f%fill ) ) check_passed = .FALSE. |
---|
| 3292 | ENDIF |
---|
| 3293 | ENDIF |
---|
| 3294 | IF ( .NOT. check_passed ) THEN |
---|
| 3295 | message_string = 'If soil_type(y,x) = 0, all levels of ' //& |
---|
| 3296 | 'soil_pars at this location must be set.' |
---|
[2925] | 3297 | CALL message( 'netcdf_data_input_mod', 'NDI033', & |
---|
[2589] | 3298 | 2, 2, 0, 6, 0 ) |
---|
[2586] | 3299 | ENDIF |
---|
| 3300 | ENDIF |
---|
| 3301 | |
---|
| 3302 | ! |
---|
| 3303 | !-- Check building parameters. If building_type is 0, all parameters |
---|
| 3304 | !-- must be set. |
---|
| 3305 | IF ( building_type_f%from_file ) THEN |
---|
| 3306 | IF ( building_type_f%var(j,i) == 0 ) THEN |
---|
| 3307 | IF ( ANY( building_pars_f%pars_xy(:,j,i) == & |
---|
| 3308 | building_pars_f%fill ) ) THEN |
---|
| 3309 | message_string = 'If building_type(y,x) = 0, all ' // & |
---|
| 3310 | 'parameters of building_pars at this '//& |
---|
| 3311 | 'location must be set.' |
---|
[2925] | 3312 | CALL message( 'netcdf_data_input_mod', 'NDI034', & |
---|
[2589] | 3313 | 2, 2, 0, 6, 0 ) |
---|
[2586] | 3314 | ENDIF |
---|
| 3315 | ENDIF |
---|
| 3316 | ENDIF |
---|
| 3317 | ! |
---|
[2955] | 3318 | !-- Check if building_type is set at each building and vice versa. |
---|
[2898] | 3319 | IF ( building_type_f%from_file .AND. buildings_f%from_file ) THEN |
---|
| 3320 | IF ( buildings_f%lod == 1 ) THEN |
---|
| 3321 | IF ( buildings_f%var_2d(j,i) /= buildings_f%fill1 .AND. & |
---|
| 3322 | building_type_f%var(j,i) == building_type_f%fill ) THEN |
---|
[2955] | 3323 | |
---|
| 3324 | WRITE( message_string, * ) 'Each location where a ' // & |
---|
| 3325 | 'building is set requires a type ' // & |
---|
| 3326 | '( and vice versa ) in case the ' // & |
---|
| 3327 | 'urban-surface model is applied. ' // & |
---|
| 3328 | 'i, j = ', i, j |
---|
[2925] | 3329 | CALL message( 'netcdf_data_input_mod', 'NDI035', & |
---|
[2898] | 3330 | 2, 2, 0, 6, 0 ) |
---|
| 3331 | ENDIF |
---|
| 3332 | ENDIF |
---|
| 3333 | IF ( buildings_f%lod == 2 ) THEN |
---|
[2955] | 3334 | IF ( ANY( buildings_f%var_3d(:,j,i) == 1 ) .AND. & |
---|
| 3335 | building_type_f%var(j,i) == building_type_f%fill ) THEN |
---|
| 3336 | WRITE( message_string, * ) 'Each location where a ' // & |
---|
| 3337 | 'building is set requires a type ' // & |
---|
| 3338 | '( and vice versa ) in case the ' // & |
---|
| 3339 | 'urban-surface model is applied. ' // & |
---|
| 3340 | 'i, j = ', i, j |
---|
| 3341 | CALL message( 'netcdf_data_input_mod', 'NDI035', & |
---|
| 3342 | 2, 2, 0, 6, 0 ) |
---|
| 3343 | ENDIF |
---|
| 3344 | ENDIF |
---|
| 3345 | ENDIF |
---|
| 3346 | ! |
---|
| 3347 | !-- Check if at each location where a building is present also an ID |
---|
| 3348 | !-- is set and vice versa. |
---|
| 3349 | IF ( buildings_f%from_file ) THEN |
---|
| 3350 | IF ( buildings_f%lod == 1 ) THEN |
---|
| 3351 | IF ( buildings_f%var_2d(j,i) /= buildings_f%fill1 .AND. & |
---|
| 3352 | building_id_f%var(j,i) == building_id_f%fill ) THEN |
---|
| 3353 | WRITE( message_string, * ) 'Each location where a ' // & |
---|
| 3354 | 'building is set requires an ID ' // & |
---|
| 3355 | '( and vice versa ). i, j = ', i, j |
---|
| 3356 | CALL message( 'netcdf_data_input_mod', 'NDI036', & |
---|
| 3357 | 2, 2, 0, 6, 0 ) |
---|
| 3358 | ENDIF |
---|
| 3359 | ELSEIF ( buildings_f%lod == 2 ) THEN |
---|
| 3360 | IF ( ANY( buildings_f%var_3d(:,j,i) == 1 ) .AND. & |
---|
| 3361 | building_id_f%var(j,i) == building_id_f%fill ) THEN |
---|
| 3362 | WRITE( message_string, * ) 'Each location where a ' // & |
---|
| 3363 | 'building is set requires an ID ' // & |
---|
| 3364 | '( and vice versa ). i, j = ', i, j |
---|
| 3365 | CALL message( 'netcdf_data_input_mod', 'NDI036', & |
---|
| 3366 | 2, 2, 0, 6, 0 ) |
---|
| 3367 | ENDIF |
---|
| 3368 | ENDIF |
---|
| 3369 | ENDIF |
---|
| 3370 | ! |
---|
| 3371 | !-- Check if at each location where a building ID or a -type is set |
---|
| 3372 | !-- also a bulding is defined. |
---|
| 3373 | IF ( buildings_f%from_file ) THEN |
---|
| 3374 | IF ( buildings_f%lod == 1 ) THEN |
---|
| 3375 | IF ( buildings_f%var_2d(j,i) /= buildings_f%fill1 .AND. & |
---|
| 3376 | building_id_f%var(j,i) == building_id_f%fill ) THEN |
---|
| 3377 | WRITE( message_string, * ) 'Each building grid point '// & |
---|
| 3378 | 'requires an ID.', i, j |
---|
| 3379 | CALL message( 'netcdf_data_input_mod', 'NDI036', & |
---|
| 3380 | 2, 2, 0, 6, 0 ) |
---|
| 3381 | ENDIF |
---|
| 3382 | ELSEIF ( buildings_f%lod == 2 ) THEN |
---|
[2898] | 3383 | IF ( ANY( buildings_f%var_3d(:,j,i) == 1 ) & |
---|
[2955] | 3384 | .AND. building_id_f%var(j,i) == building_id_f%fill ) THEN |
---|
| 3385 | WRITE( message_string, * ) 'Each building grid point '// & |
---|
| 3386 | 'requires an ID.', i, j |
---|
[2925] | 3387 | CALL message( 'netcdf_data_input_mod', 'NDI036', & |
---|
[2898] | 3388 | 2, 2, 0, 6, 0 ) |
---|
| 3389 | ENDIF |
---|
| 3390 | ENDIF |
---|
| 3391 | ENDIF |
---|
[2589] | 3392 | ! |
---|
[2586] | 3393 | !-- Check albedo parameters. If albedo_type is 0, all parameters |
---|
| 3394 | !-- must be set. |
---|
| 3395 | IF ( albedo_type_f%from_file ) THEN |
---|
| 3396 | IF ( albedo_type_f%var(j,i) == 0 ) THEN |
---|
| 3397 | IF ( ANY( albedo_pars_f%pars_xy(:,j,i) == & |
---|
| 3398 | albedo_pars_f%fill ) ) THEN |
---|
| 3399 | message_string = 'If albedo_type(y,x) = 0, all ' // & |
---|
| 3400 | 'parameters of albedo_pars at this ' // & |
---|
| 3401 | 'location must be set.' |
---|
[2925] | 3402 | CALL message( 'netcdf_data_input_mod', 'NDI037', & |
---|
[2589] | 3403 | 2, 2, 0, 6, 0 ) |
---|
[2586] | 3404 | ENDIF |
---|
| 3405 | ENDIF |
---|
| 3406 | ENDIF |
---|
| 3407 | |
---|
| 3408 | ! |
---|
| 3409 | !-- Check pavement parameters. If pavement_type is 0, all parameters |
---|
| 3410 | !-- of pavement_pars must be set at this location. |
---|
| 3411 | IF ( pavement_type_f%from_file ) THEN |
---|
| 3412 | IF ( pavement_type_f%var(j,i) == 0 ) THEN |
---|
| 3413 | IF ( ANY( pavement_pars_f%pars_xy(:,j,i) == & |
---|
| 3414 | pavement_pars_f%fill ) ) THEN |
---|
| 3415 | message_string = 'If pavement_type(y,x) = 0, all ' // & |
---|
| 3416 | 'parameters of pavement_pars at this '//& |
---|
| 3417 | 'location must be set.' |
---|
[2925] | 3418 | CALL message( 'netcdf_data_input_mod', 'NDI038', & |
---|
[2589] | 3419 | 2, 2, 0, 6, 0 ) |
---|
[2586] | 3420 | ENDIF |
---|
| 3421 | ENDIF |
---|
| 3422 | ENDIF |
---|
| 3423 | ! |
---|
| 3424 | !-- Check pavement-subsurface parameters. If pavement_type is 0, |
---|
| 3425 | !-- all parameters of pavement_subsurface_pars must be set at this |
---|
| 3426 | !-- location. |
---|
| 3427 | IF ( pavement_type_f%from_file ) THEN |
---|
| 3428 | IF ( pavement_type_f%var(j,i) == 0 ) THEN |
---|
| 3429 | IF ( ANY( pavement_subsurface_pars_f%pars_xyz(:,:,j,i) == & |
---|
| 3430 | pavement_subsurface_pars_f%fill ) ) THEN |
---|
| 3431 | message_string = 'If pavement_type(y,x) = 0, all ' // & |
---|
| 3432 | 'parameters of ' // & |
---|
| 3433 | 'pavement_subsurface_pars at this '// & |
---|
| 3434 | 'location must be set.' |
---|
[2925] | 3435 | CALL message( 'netcdf_data_input_mod', 'NDI039', & |
---|
[2589] | 3436 | 2, 2, 0, 6, 0 ) |
---|
[2586] | 3437 | ENDIF |
---|
| 3438 | ENDIF |
---|
| 3439 | ENDIF |
---|
| 3440 | |
---|
| 3441 | ! |
---|
| 3442 | !-- Check water parameters. If water_type is 0, all parameters |
---|
| 3443 | !-- must be set at this location. |
---|
| 3444 | IF ( water_type_f%from_file ) THEN |
---|
| 3445 | IF ( water_type_f%var(j,i) == 0 ) THEN |
---|
| 3446 | IF ( ANY( water_pars_f%pars_xy(:,j,i) == & |
---|
| 3447 | water_pars_f%fill ) ) THEN |
---|
| 3448 | message_string = 'If water_type(y,x) = 0, all ' // & |
---|
| 3449 | 'parameters of water_pars at this ' // & |
---|
| 3450 | 'location must be set.' |
---|
[2925] | 3451 | CALL message( 'netcdf_data_input_mod', 'NDI040', & |
---|
[2589] | 3452 | 2, 2, 0, 6, 0 ) |
---|
[2586] | 3453 | ENDIF |
---|
| 3454 | ENDIF |
---|
| 3455 | ENDIF |
---|
| 3456 | |
---|
| 3457 | ENDDO |
---|
| 3458 | ENDDO |
---|
[2646] | 3459 | |
---|
[2586] | 3460 | END SUBROUTINE netcdf_data_input_check_static |
---|
| 3461 | |
---|
| 3462 | !------------------------------------------------------------------------------! |
---|
| 3463 | ! Description: |
---|
| 3464 | ! ------------ |
---|
| 3465 | !> Vertical interpolation and extrapolation of 1D variables. |
---|
| 3466 | !------------------------------------------------------------------------------! |
---|
| 3467 | SUBROUTINE netcdf_data_input_interpolate_1d( var, z_grid, z_file) |
---|
| 3468 | |
---|
| 3469 | IMPLICIT NONE |
---|
| 3470 | |
---|
| 3471 | LOGICAL :: top !< flag indicating extrapolation at model top |
---|
| 3472 | |
---|
| 3473 | INTEGER(iwp) :: k !< running index z-direction file |
---|
| 3474 | INTEGER(iwp) :: kk !< running index z-direction stretched model grid |
---|
| 3475 | INTEGER(iwp) :: kl !< lower index bound along z-direction |
---|
| 3476 | INTEGER(iwp) :: ku !< upper index bound along z-direction |
---|
| 3477 | INTEGER(iwp) :: nz_file !< number of vertical levels on file |
---|
| 3478 | |
---|
| 3479 | |
---|
| 3480 | REAL(wp), DIMENSION(:) :: z_grid !< grid levels on numeric grid |
---|
| 3481 | REAL(wp), DIMENSION(:) :: z_file !< grid levels on file grid |
---|
| 3482 | REAL(wp), DIMENSION(:), INTENT(INOUT) :: var !< treated variable |
---|
| 3483 | REAL(wp), DIMENSION(:), ALLOCATABLE :: var_tmp !< temporary variable |
---|
| 3484 | |
---|
| 3485 | |
---|
| 3486 | kl = LBOUND(var,1) |
---|
| 3487 | ku = UBOUND(var,1) |
---|
| 3488 | ALLOCATE( var_tmp(kl:ku) ) |
---|
| 3489 | |
---|
| 3490 | DO k = kl, ku |
---|
| 3491 | |
---|
| 3492 | kk = MINLOC( ABS( z_file - z_grid(k) ), DIM = 1 ) |
---|
| 3493 | |
---|
| 3494 | IF ( kk < ku ) THEN |
---|
| 3495 | IF ( z_file(kk) - z_grid(k) <= 0.0_wp ) THEN |
---|
| 3496 | var_tmp(k) = var(kk) + & |
---|
| 3497 | ( var(kk+1) - var(kk) ) / & |
---|
| 3498 | ( z_file(kk+1) - z_file(kk) ) * & |
---|
| 3499 | ( z_grid(k) - z_file(kk) ) |
---|
| 3500 | |
---|
| 3501 | ELSEIF ( z_file(kk) - z_grid(k) > 0.0_wp ) THEN |
---|
| 3502 | var_tmp(k) = var(kk-1) + & |
---|
| 3503 | ( var(kk) - var(kk-1) ) / & |
---|
| 3504 | ( z_file(kk) - z_file(kk-1) ) * & |
---|
| 3505 | ( z_grid(k) - z_file(kk-1) ) |
---|
| 3506 | ENDIF |
---|
| 3507 | ! |
---|
| 3508 | !-- Extrapolate |
---|
| 3509 | ELSE |
---|
| 3510 | |
---|
| 3511 | var_tmp(k) = var(ku) + ( var(ku) - var(ku-1) ) / & |
---|
| 3512 | ( z_file(ku) - z_file(ku-1) ) * & |
---|
| 3513 | ( z_grid(k) - z_file(ku) ) |
---|
| 3514 | |
---|
| 3515 | ENDIF |
---|
| 3516 | |
---|
| 3517 | ENDDO |
---|
| 3518 | var(:) = var_tmp(:) |
---|
| 3519 | |
---|
| 3520 | DEALLOCATE( var_tmp ) |
---|
| 3521 | |
---|
| 3522 | |
---|
| 3523 | END SUBROUTINE netcdf_data_input_interpolate_1d |
---|
| 3524 | |
---|
| 3525 | |
---|
| 3526 | !------------------------------------------------------------------------------! |
---|
| 3527 | ! Description: |
---|
| 3528 | ! ------------ |
---|
| 3529 | !> Vertical interpolation and extrapolation of 1D variables from Inifor grid |
---|
| 3530 | !> onto Palm grid, where both have same dimension. Please note, the passed |
---|
| 3531 | !> paramter list in 1D version is different compared to 2D version. |
---|
| 3532 | !------------------------------------------------------------------------------! |
---|
| 3533 | SUBROUTINE netcdf_data_input_interpolate_1d_soil( var, var_file, & |
---|
| 3534 | z_grid, z_file, & |
---|
| 3535 | nzb_var, nzt_var, & |
---|
| 3536 | nzb_file, nzt_file ) |
---|
| 3537 | |
---|
| 3538 | IMPLICIT NONE |
---|
| 3539 | |
---|
| 3540 | INTEGER(iwp) :: i !< running index x-direction |
---|
| 3541 | INTEGER(iwp) :: j !< running index y-direction |
---|
| 3542 | INTEGER(iwp) :: k !< running index z-direction file |
---|
| 3543 | INTEGER(iwp) :: kk !< running index z-direction stretched model grid |
---|
| 3544 | INTEGER(iwp) :: ku !< upper index bound along z-direction for varialbe from file |
---|
| 3545 | INTEGER(iwp) :: nzb_var !< lower bound of final array |
---|
| 3546 | INTEGER(iwp) :: nzt_var !< upper bound of final array |
---|
| 3547 | INTEGER(iwp) :: nzb_file !< lower bound of file array |
---|
| 3548 | INTEGER(iwp) :: nzt_file !< upper bound of file array |
---|
| 3549 | |
---|
| 3550 | ! LOGICAL, OPTIONAL :: depth !< flag indicating reverse z-axis, i.e. depth instead of height, e.g. in case of ocean or soil |
---|
| 3551 | |
---|
| 3552 | REAL(wp), DIMENSION(nzb_var:nzt_var) :: z_grid !< grid levels on numeric grid |
---|
| 3553 | REAL(wp), DIMENSION(nzb_file:nzt_file) :: z_file !< grid levels on file grid |
---|
| 3554 | REAL(wp), DIMENSION(nzb_var:nzt_var) :: var !< treated variable |
---|
| 3555 | REAL(wp), DIMENSION(nzb_file:nzt_file) :: var_file !< temporary variable |
---|
| 3556 | |
---|
| 3557 | ku = nzt_file |
---|
| 3558 | |
---|
| 3559 | DO k = nzb_var, nzt_var |
---|
| 3560 | ! |
---|
| 3561 | !-- Determine index on Inifor grid which is closest to the actual height |
---|
| 3562 | kk = MINLOC( ABS( z_file - z_grid(k) ), DIM = 1 ) |
---|
| 3563 | ! |
---|
| 3564 | !-- If closest index on Inifor grid is smaller than top index, |
---|
| 3565 | !-- interpolate the data |
---|
| 3566 | IF ( kk < nzt_file ) THEN |
---|
| 3567 | IF ( z_file(kk) - z_grid(k) <= 0.0_wp ) THEN |
---|
| 3568 | var(k) = var_file(kk) + ( var_file(kk+1) - var_file(kk) ) / & |
---|
| 3569 | ( z_file(kk+1) - z_file(kk) ) * & |
---|
| 3570 | ( z_grid(k) - z_file(kk) ) |
---|
| 3571 | |
---|
| 3572 | ELSEIF ( z_file(kk) - z_grid(k) > 0.0_wp ) THEN |
---|
| 3573 | var(k) = var_file(kk-1) + ( var_file(kk) - var_file(kk-1) ) / & |
---|
| 3574 | ( z_file(kk) - z_file(kk-1) ) * & |
---|
| 3575 | ( z_grid(k) - z_file(kk-1) ) |
---|
| 3576 | ENDIF |
---|
| 3577 | ! |
---|
| 3578 | !-- Extrapolate if actual height is above the highest Inifor level |
---|
| 3579 | ELSE |
---|
| 3580 | var(k) = var_file(ku) + ( var_file(ku) - var_file(ku-1) ) / & |
---|
| 3581 | ( z_file(ku) - z_file(ku-1) ) * & |
---|
| 3582 | ( z_grid(k) - z_file(ku) ) |
---|
| 3583 | |
---|
| 3584 | ENDIF |
---|
| 3585 | |
---|
| 3586 | ENDDO |
---|
| 3587 | |
---|
| 3588 | END SUBROUTINE netcdf_data_input_interpolate_1d_soil |
---|
| 3589 | |
---|
| 3590 | !------------------------------------------------------------------------------! |
---|
| 3591 | ! Description: |
---|
| 3592 | ! ------------ |
---|
| 3593 | !> Vertical interpolation and extrapolation of 2D variables at lateral boundaries. |
---|
| 3594 | !------------------------------------------------------------------------------! |
---|
| 3595 | SUBROUTINE netcdf_data_input_interpolate_2d( var, z_grid, z_file) |
---|
| 3596 | |
---|
| 3597 | IMPLICIT NONE |
---|
| 3598 | |
---|
| 3599 | LOGICAL :: top !< flag indicating extrapolation at model top |
---|
| 3600 | |
---|
| 3601 | INTEGER(iwp) :: i !< running index x- or y -direction |
---|
| 3602 | INTEGER(iwp) :: il !< lower index bound along x- or y-direction |
---|
| 3603 | INTEGER(iwp) :: iu !< upper index bound along x- or y-direction |
---|
| 3604 | INTEGER(iwp) :: k !< running index z-direction file |
---|
| 3605 | INTEGER(iwp) :: kk !< running index z-direction stretched model grid |
---|
| 3606 | INTEGER(iwp) :: kl !< lower index bound along z-direction |
---|
| 3607 | INTEGER(iwp) :: ku !< upper index bound along z-direction |
---|
| 3608 | INTEGER(iwp) :: nz_file !< number of vertical levels on file |
---|
| 3609 | |
---|
| 3610 | |
---|
| 3611 | REAL(wp), DIMENSION(:) :: z_grid !< grid levels on numeric grid |
---|
| 3612 | REAL(wp), DIMENSION(:) :: z_file !< grid levels on file grid |
---|
| 3613 | REAL(wp), DIMENSION(:,:), INTENT(INOUT) :: var !< treated variable |
---|
| 3614 | REAL(wp), DIMENSION(:), ALLOCATABLE :: var_tmp !< temporary variable |
---|
| 3615 | |
---|
| 3616 | |
---|
| 3617 | il = LBOUND(var,2) |
---|
| 3618 | iu = UBOUND(var,2) |
---|
| 3619 | kl = LBOUND(var,1) |
---|
| 3620 | ku = UBOUND(var,1) |
---|
| 3621 | ALLOCATE( var_tmp(kl:ku) ) |
---|
| 3622 | |
---|
| 3623 | DO i = il, iu |
---|
| 3624 | DO k = kl, ku |
---|
| 3625 | |
---|
| 3626 | kk = MINLOC( ABS( z_file - z_grid(k) ), DIM = 1 ) |
---|
| 3627 | |
---|
| 3628 | IF ( kk < ku ) THEN |
---|
| 3629 | IF ( z_file(kk) - z_grid(k) <= 0.0_wp ) THEN |
---|
| 3630 | var_tmp(k) = var(kk,i) + & |
---|
| 3631 | ( var(kk+1,i) - var(kk,i) ) / & |
---|
| 3632 | ( z_file(kk+1) - z_file(kk) ) * & |
---|
| 3633 | ( z_grid(k) - z_file(kk) ) |
---|
| 3634 | |
---|
| 3635 | ELSEIF ( z_file(kk) - z_grid(k) > 0.0_wp ) THEN |
---|
| 3636 | var_tmp(k) = var(kk-1,i) + & |
---|
| 3637 | ( var(kk,i) - var(kk-1,i) ) / & |
---|
| 3638 | ( z_file(kk) - z_file(kk-1) ) * & |
---|
| 3639 | ( z_grid(k) - z_file(kk-1) ) |
---|
| 3640 | ENDIF |
---|
| 3641 | ! |
---|
| 3642 | !-- Extrapolate |
---|
| 3643 | ELSE |
---|
| 3644 | |
---|
| 3645 | var_tmp(k) = var(ku,i) + ( var(ku,i) - var(ku-1,i) ) / & |
---|
| 3646 | ( z_file(ku) - z_file(ku-1) ) * & |
---|
| 3647 | ( z_grid(k) - z_file(ku) ) |
---|
| 3648 | |
---|
| 3649 | ENDIF |
---|
| 3650 | |
---|
| 3651 | ENDDO |
---|
| 3652 | var(:,i) = var_tmp(:) |
---|
| 3653 | |
---|
| 3654 | ENDDO |
---|
| 3655 | |
---|
| 3656 | DEALLOCATE( var_tmp ) |
---|
| 3657 | |
---|
| 3658 | |
---|
| 3659 | END SUBROUTINE netcdf_data_input_interpolate_2d |
---|
| 3660 | |
---|
| 3661 | !------------------------------------------------------------------------------! |
---|
| 3662 | ! Description: |
---|
| 3663 | ! ------------ |
---|
| 3664 | !> Vertical interpolation and extrapolation of 3D variables. |
---|
| 3665 | !------------------------------------------------------------------------------! |
---|
| 3666 | SUBROUTINE netcdf_data_input_interpolate_3d( var, z_grid, z_file ) |
---|
| 3667 | |
---|
| 3668 | IMPLICIT NONE |
---|
| 3669 | |
---|
| 3670 | INTEGER(iwp) :: i !< running index x-direction |
---|
| 3671 | INTEGER(iwp) :: il !< lower index bound along x-direction |
---|
| 3672 | INTEGER(iwp) :: iu !< upper index bound along x-direction |
---|
| 3673 | INTEGER(iwp) :: j !< running index y-direction |
---|
| 3674 | INTEGER(iwp) :: jl !< lower index bound along x-direction |
---|
| 3675 | INTEGER(iwp) :: ju !< upper index bound along x-direction |
---|
| 3676 | INTEGER(iwp) :: k !< running index z-direction file |
---|
| 3677 | INTEGER(iwp) :: kk !< running index z-direction stretched model grid |
---|
| 3678 | INTEGER(iwp) :: kl !< lower index bound along z-direction |
---|
| 3679 | INTEGER(iwp) :: ku !< upper index bound along z-direction |
---|
| 3680 | INTEGER(iwp) :: nz_file !< number of vertical levels on file |
---|
| 3681 | |
---|
| 3682 | REAL(wp), DIMENSION(:) :: z_grid !< grid levels on numeric grid |
---|
| 3683 | REAL(wp), DIMENSION(:) :: z_file !< grid levels on file grid |
---|
| 3684 | REAL(wp), DIMENSION(:,:,:), INTENT(INOUT) :: var !< treated variable |
---|
| 3685 | REAL(wp), DIMENSION(:), ALLOCATABLE :: var_tmp !< temporary variable |
---|
| 3686 | |
---|
| 3687 | il = LBOUND(var,3) |
---|
| 3688 | iu = UBOUND(var,3) |
---|
| 3689 | jl = LBOUND(var,2) |
---|
| 3690 | ju = UBOUND(var,2) |
---|
| 3691 | kl = LBOUND(var,1) |
---|
| 3692 | ku = UBOUND(var,1) |
---|
| 3693 | |
---|
| 3694 | ALLOCATE( var_tmp(kl:ku) ) |
---|
| 3695 | |
---|
| 3696 | DO i = il, iu |
---|
| 3697 | DO j = jl, ju |
---|
| 3698 | DO k = kl, ku |
---|
| 3699 | |
---|
| 3700 | kk = MINLOC( ABS( z_file - z_grid(k) ), DIM = 1 ) |
---|
| 3701 | |
---|
| 3702 | IF ( kk < ku ) THEN |
---|
| 3703 | IF ( z_file(kk) - z_grid(k) <= 0.0_wp ) THEN |
---|
| 3704 | var_tmp(k) = var(kk,j,i) + & |
---|
| 3705 | ( var(kk+1,j,i) - var(kk,j,i) ) / & |
---|
| 3706 | ( z_file(kk+1) - z_file(kk) ) * & |
---|
| 3707 | ( z_grid(k) - z_file(kk) ) |
---|
| 3708 | |
---|
| 3709 | ELSEIF ( z_file(kk) - z_grid(k) > 0.0_wp ) THEN |
---|
| 3710 | var_tmp(k) = var(kk-1,j,i) + & |
---|
| 3711 | ( var(kk,j,i) - var(kk-1,j,i) ) / & |
---|
| 3712 | ( z_file(kk) - z_file(kk-1) ) * & |
---|
| 3713 | ( z_grid(k) - z_file(kk-1) ) |
---|
| 3714 | ENDIF |
---|
| 3715 | ! |
---|
| 3716 | !-- Extrapolate |
---|
| 3717 | ELSE |
---|
| 3718 | var_tmp(k) = var(ku,j,i) + & |
---|
| 3719 | ( var(ku,j,i) - var(ku-1,j,i) ) / & |
---|
| 3720 | ( z_file(ku) - z_file(ku-1) ) * & |
---|
| 3721 | ( z_grid(k) - z_file(ku) ) |
---|
| 3722 | |
---|
| 3723 | ENDIF |
---|
| 3724 | ENDDO |
---|
| 3725 | var(:,j,i) = var_tmp(:) |
---|
| 3726 | ENDDO |
---|
| 3727 | ENDDO |
---|
| 3728 | |
---|
| 3729 | DEALLOCATE( var_tmp ) |
---|
| 3730 | |
---|
| 3731 | |
---|
| 3732 | END SUBROUTINE netcdf_data_input_interpolate_3d |
---|
| 3733 | |
---|
| 3734 | !------------------------------------------------------------------------------! |
---|
| 3735 | ! Description: |
---|
| 3736 | ! ------------ |
---|
| 3737 | !> Checks if a given variables is on file |
---|
| 3738 | !------------------------------------------------------------------------------! |
---|
| 3739 | FUNCTION check_existence( vars_in_file, var_name ) |
---|
| 3740 | |
---|
| 3741 | IMPLICIT NONE |
---|
| 3742 | |
---|
| 3743 | CHARACTER(LEN=*) :: var_name !< variable to be checked |
---|
| 3744 | CHARACTER(LEN=*), DIMENSION(:) :: vars_in_file !< list of variables in file |
---|
| 3745 | |
---|
| 3746 | INTEGER(iwp) :: i !< loop variable |
---|
| 3747 | |
---|
| 3748 | LOGICAL :: check_existence !< flag indicating whether a variable exist or not - actual return value |
---|
| 3749 | |
---|
| 3750 | i = 1 |
---|
| 3751 | check_existence = .FALSE. |
---|
| 3752 | DO WHILE ( i <= SIZE( vars_in_file ) ) |
---|
| 3753 | check_existence = TRIM( vars_in_file(i) ) == TRIM( var_name ) .OR. & |
---|
| 3754 | check_existence |
---|
| 3755 | i = i + 1 |
---|
| 3756 | ENDDO |
---|
| 3757 | |
---|
| 3758 | RETURN |
---|
| 3759 | |
---|
| 3760 | END FUNCTION check_existence |
---|
| 3761 | |
---|
| 3762 | |
---|
| 3763 | !------------------------------------------------------------------------------! |
---|
| 3764 | ! Description: |
---|
| 3765 | ! ------------ |
---|
| 3766 | !> Closes an existing netCDF file. |
---|
| 3767 | !------------------------------------------------------------------------------! |
---|
[2711] | 3768 | SUBROUTINE close_input_file( id ) |
---|
[2586] | 3769 | #if defined( __netcdf ) |
---|
| 3770 | |
---|
| 3771 | USE pegrid |
---|
| 3772 | |
---|
| 3773 | IMPLICIT NONE |
---|
| 3774 | |
---|
| 3775 | INTEGER(iwp), INTENT(INOUT) :: id !< file id |
---|
| 3776 | |
---|
| 3777 | nc_stat = NF90_CLOSE( id ) |
---|
| 3778 | CALL handle_error( 'close', 537 ) |
---|
| 3779 | #endif |
---|
[2711] | 3780 | END SUBROUTINE close_input_file |
---|
[2586] | 3781 | |
---|
| 3782 | !------------------------------------------------------------------------------! |
---|
| 3783 | ! Description: |
---|
| 3784 | ! ------------ |
---|
| 3785 | !> Opens an existing netCDF file for reading only and returns its id. |
---|
| 3786 | !------------------------------------------------------------------------------! |
---|
| 3787 | SUBROUTINE open_read_file( filename, id ) |
---|
| 3788 | #if defined( __netcdf ) |
---|
| 3789 | |
---|
| 3790 | USE pegrid |
---|
| 3791 | |
---|
| 3792 | IMPLICIT NONE |
---|
| 3793 | |
---|
| 3794 | CHARACTER (LEN=*), INTENT(IN) :: filename !< filename |
---|
| 3795 | INTEGER(iwp), INTENT(INOUT) :: id !< file id |
---|
| 3796 | LOGICAL :: file_open = .FALSE. |
---|
| 3797 | |
---|
| 3798 | nc_stat = NF90_OPEN( filename, NF90_NOWRITE, id ) |
---|
| 3799 | |
---|
| 3800 | CALL handle_error( 'open_read_file', 536 ) |
---|
| 3801 | |
---|
| 3802 | #endif |
---|
| 3803 | END SUBROUTINE open_read_file |
---|
| 3804 | |
---|
| 3805 | !------------------------------------------------------------------------------! |
---|
| 3806 | ! Description: |
---|
| 3807 | ! ------------ |
---|
| 3808 | !> Reads global or variable-related attributes of type INTEGER (32-bit) |
---|
| 3809 | !------------------------------------------------------------------------------! |
---|
| 3810 | SUBROUTINE get_attribute_int32( id, attribute_name, value, global, & |
---|
| 3811 | variable_name ) |
---|
| 3812 | |
---|
| 3813 | USE pegrid |
---|
| 3814 | |
---|
| 3815 | IMPLICIT NONE |
---|
| 3816 | |
---|
| 3817 | CHARACTER(LEN=*) :: attribute_name !< attribute name |
---|
| 3818 | CHARACTER(LEN=*), OPTIONAL :: variable_name !< variable name |
---|
| 3819 | |
---|
| 3820 | INTEGER(iwp), INTENT(IN) :: id !< file id |
---|
| 3821 | INTEGER(iwp) :: id_var !< variable id |
---|
| 3822 | INTEGER(iwp), INTENT(INOUT) :: value !< read value |
---|
| 3823 | |
---|
| 3824 | LOGICAL, INTENT(IN) :: global !< flag indicating global attribute |
---|
[2874] | 3825 | #if defined( __netcdf ) |
---|
[2586] | 3826 | |
---|
| 3827 | ! |
---|
| 3828 | !-- Read global attribute |
---|
| 3829 | IF ( global ) THEN |
---|
| 3830 | nc_stat = NF90_GET_ATT( id, NF90_GLOBAL, TRIM( attribute_name ), value ) |
---|
| 3831 | CALL handle_error( 'get_attribute_int32 global', 522 ) |
---|
| 3832 | ! |
---|
| 3833 | !-- Read attributes referring to a single variable. Therefore, first inquire |
---|
| 3834 | !-- variable id |
---|
| 3835 | ELSE |
---|
| 3836 | nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var ) |
---|
| 3837 | CALL handle_error( 'get_attribute_int32', 522 ) |
---|
| 3838 | nc_stat = NF90_GET_ATT( id, id_var, TRIM( attribute_name ), value ) |
---|
| 3839 | CALL handle_error( 'get_attribute_int32', 522 ) |
---|
| 3840 | ENDIF |
---|
| 3841 | #endif |
---|
| 3842 | END SUBROUTINE get_attribute_int32 |
---|
| 3843 | |
---|
| 3844 | !------------------------------------------------------------------------------! |
---|
| 3845 | ! Description: |
---|
| 3846 | ! ------------ |
---|
| 3847 | !> Reads global or variable-related attributes of type INTEGER (8-bit) |
---|
| 3848 | !------------------------------------------------------------------------------! |
---|
| 3849 | SUBROUTINE get_attribute_int8( id, attribute_name, value, global, & |
---|
| 3850 | variable_name ) |
---|
| 3851 | |
---|
| 3852 | USE pegrid |
---|
| 3853 | |
---|
| 3854 | IMPLICIT NONE |
---|
| 3855 | |
---|
| 3856 | CHARACTER(LEN=*) :: attribute_name !< attribute name |
---|
| 3857 | CHARACTER(LEN=*), OPTIONAL :: variable_name !< variable name |
---|
| 3858 | |
---|
| 3859 | INTEGER(iwp), INTENT(IN) :: id !< file id |
---|
| 3860 | INTEGER(iwp) :: id_var !< variable id |
---|
| 3861 | INTEGER(KIND=1), INTENT(INOUT) :: value !< read value |
---|
| 3862 | |
---|
| 3863 | LOGICAL, INTENT(IN) :: global !< flag indicating global attribute |
---|
[2874] | 3864 | #if defined( __netcdf ) |
---|
[2586] | 3865 | |
---|
| 3866 | ! |
---|
| 3867 | !-- Read global attribute |
---|
| 3868 | IF ( global ) THEN |
---|
| 3869 | nc_stat = NF90_GET_ATT( id, NF90_GLOBAL, TRIM( attribute_name ), value ) |
---|
| 3870 | CALL handle_error( 'get_attribute_int8 global', 523 ) |
---|
| 3871 | ! |
---|
| 3872 | !-- Read attributes referring to a single variable. Therefore, first inquire |
---|
| 3873 | !-- variable id |
---|
| 3874 | ELSE |
---|
| 3875 | nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var ) |
---|
| 3876 | CALL handle_error( 'get_attribute_int8', 523 ) |
---|
| 3877 | nc_stat = NF90_GET_ATT( id, id_var, TRIM( attribute_name ), value ) |
---|
| 3878 | CALL handle_error( 'get_attribute_int8', 523 ) |
---|
| 3879 | ENDIF |
---|
| 3880 | #endif |
---|
| 3881 | END SUBROUTINE get_attribute_int8 |
---|
| 3882 | |
---|
| 3883 | !------------------------------------------------------------------------------! |
---|
| 3884 | ! Description: |
---|
| 3885 | ! ------------ |
---|
| 3886 | !> Reads global or variable-related attributes of type REAL |
---|
| 3887 | !------------------------------------------------------------------------------! |
---|
| 3888 | SUBROUTINE get_attribute_real( id, attribute_name, value, global, & |
---|
| 3889 | variable_name ) |
---|
| 3890 | |
---|
| 3891 | USE pegrid |
---|
| 3892 | |
---|
| 3893 | IMPLICIT NONE |
---|
| 3894 | |
---|
| 3895 | CHARACTER(LEN=*) :: attribute_name !< attribute name |
---|
| 3896 | CHARACTER(LEN=*), OPTIONAL :: variable_name !< variable name |
---|
| 3897 | |
---|
| 3898 | INTEGER(iwp), INTENT(IN) :: id !< file id |
---|
| 3899 | INTEGER(iwp) :: id_var !< variable id |
---|
| 3900 | |
---|
| 3901 | LOGICAL, INTENT(IN) :: global !< flag indicating global attribute |
---|
| 3902 | |
---|
| 3903 | REAL(wp), INTENT(INOUT) :: value !< read value |
---|
[2874] | 3904 | #if defined( __netcdf ) |
---|
[2586] | 3905 | |
---|
| 3906 | |
---|
| 3907 | ! |
---|
| 3908 | !-- Read global attribute |
---|
| 3909 | IF ( global ) THEN |
---|
| 3910 | nc_stat = NF90_GET_ATT( id, NF90_GLOBAL, TRIM( attribute_name ), value ) |
---|
| 3911 | CALL handle_error( 'get_attribute_real global', 524 ) |
---|
| 3912 | ! |
---|
| 3913 | !-- Read attributes referring to a single variable. Therefore, first inquire |
---|
| 3914 | !-- variable id |
---|
| 3915 | ELSE |
---|
| 3916 | nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var ) |
---|
| 3917 | CALL handle_error( 'get_attribute_real', 524 ) |
---|
| 3918 | nc_stat = NF90_GET_ATT( id, id_var, TRIM( attribute_name ), value ) |
---|
| 3919 | CALL handle_error( 'get_attribute_real', 524 ) |
---|
| 3920 | ENDIF |
---|
| 3921 | #endif |
---|
| 3922 | END SUBROUTINE get_attribute_real |
---|
| 3923 | |
---|
| 3924 | !------------------------------------------------------------------------------! |
---|
| 3925 | ! Description: |
---|
| 3926 | ! ------------ |
---|
| 3927 | !> Reads global or variable-related attributes of type CHARACTER |
---|
| 3928 | !> Remark: reading attributes of type NF_STRING return an error code 56 - |
---|
| 3929 | !> Attempt to convert between text & numbers. |
---|
| 3930 | !------------------------------------------------------------------------------! |
---|
| 3931 | SUBROUTINE get_attribute_string( id, attribute_name, value, global, & |
---|
| 3932 | variable_name ) |
---|
| 3933 | |
---|
| 3934 | USE pegrid |
---|
| 3935 | |
---|
| 3936 | IMPLICIT NONE |
---|
| 3937 | |
---|
| 3938 | CHARACTER(LEN=*) :: attribute_name !< attribute name |
---|
| 3939 | CHARACTER(LEN=*), OPTIONAL :: variable_name !< variable name |
---|
| 3940 | CHARACTER(LEN=*), INTENT(INOUT) :: value !< read value |
---|
| 3941 | |
---|
| 3942 | INTEGER(iwp), INTENT(IN) :: id !< file id |
---|
| 3943 | INTEGER(iwp) :: id_var !< variable id |
---|
| 3944 | |
---|
| 3945 | LOGICAL, INTENT(IN) :: global !< flag indicating global attribute |
---|
[2874] | 3946 | #if defined( __netcdf ) |
---|
[2586] | 3947 | |
---|
| 3948 | ! |
---|
| 3949 | !-- Read global attribute |
---|
| 3950 | IF ( global ) THEN |
---|
| 3951 | nc_stat = NF90_GET_ATT( id, NF90_GLOBAL, TRIM( attribute_name ), value ) |
---|
| 3952 | CALL handle_error( 'get_attribute_string global', 525 ) |
---|
| 3953 | ! |
---|
| 3954 | !-- Read attributes referring to a single variable. Therefore, first inquire |
---|
| 3955 | !-- variable id |
---|
| 3956 | ELSE |
---|
| 3957 | nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var ) |
---|
| 3958 | CALL handle_error( 'get_attribute_string', 525 ) |
---|
| 3959 | |
---|
| 3960 | nc_stat = NF90_GET_ATT( id, id_var, TRIM( attribute_name ), value ) |
---|
| 3961 | CALL handle_error( 'get_attribute_string',525 ) |
---|
| 3962 | |
---|
| 3963 | ENDIF |
---|
| 3964 | #endif |
---|
| 3965 | END SUBROUTINE get_attribute_string |
---|
| 3966 | |
---|
| 3967 | |
---|
| 3968 | |
---|
| 3969 | !------------------------------------------------------------------------------! |
---|
| 3970 | ! Description: |
---|
| 3971 | ! ------------ |
---|
| 3972 | !> Get dimension array for a given dimension |
---|
| 3973 | !------------------------------------------------------------------------------! |
---|
| 3974 | SUBROUTINE get_dimension_length( id, dim_len, variable_name ) |
---|
| 3975 | #if defined( __netcdf ) |
---|
| 3976 | |
---|
| 3977 | USE pegrid |
---|
| 3978 | |
---|
| 3979 | IMPLICIT NONE |
---|
| 3980 | |
---|
| 3981 | CHARACTER(LEN=*) :: variable_name !< dimension name |
---|
| 3982 | CHARACTER(LEN=100) :: dum !< dummy variable to receive return character |
---|
| 3983 | |
---|
| 3984 | INTEGER(iwp) :: dim_len !< dimension size |
---|
| 3985 | INTEGER(iwp), INTENT(IN) :: id !< file id |
---|
| 3986 | INTEGER(iwp) :: id_dim !< dimension id |
---|
| 3987 | |
---|
| 3988 | ! |
---|
| 3989 | !-- First, inquire dimension ID |
---|
| 3990 | nc_stat = NF90_INQ_DIMID( id, TRIM( variable_name ), id_dim ) |
---|
| 3991 | CALL handle_error( 'get_dimension_length', 526 ) |
---|
| 3992 | ! |
---|
| 3993 | !-- Inquire dimension length |
---|
| 3994 | nc_stat = NF90_INQUIRE_DIMENSION( id, id_dim, dum, LEN = dim_len ) |
---|
| 3995 | CALL handle_error( 'get_dimension_length', 526 ) |
---|
| 3996 | |
---|
| 3997 | #endif |
---|
| 3998 | END SUBROUTINE get_dimension_length |
---|
| 3999 | |
---|
| 4000 | !------------------------------------------------------------------------------! |
---|
| 4001 | ! Description: |
---|
| 4002 | ! ------------ |
---|
| 4003 | !> Reads a 1D integer variable from file. |
---|
| 4004 | !------------------------------------------------------------------------------! |
---|
| 4005 | SUBROUTINE get_variable_1d_int( id, variable_name, var ) |
---|
| 4006 | |
---|
| 4007 | USE pegrid |
---|
| 4008 | |
---|
| 4009 | IMPLICIT NONE |
---|
| 4010 | |
---|
| 4011 | CHARACTER(LEN=*) :: variable_name !< variable name |
---|
| 4012 | |
---|
| 4013 | INTEGER(iwp), INTENT(IN) :: id !< file id |
---|
| 4014 | INTEGER(iwp) :: id_var !< dimension id |
---|
| 4015 | |
---|
| 4016 | INTEGER(iwp), DIMENSION(:), INTENT(INOUT) :: var !< variable to be read |
---|
[2874] | 4017 | #if defined( __netcdf ) |
---|
[2586] | 4018 | |
---|
| 4019 | ! |
---|
| 4020 | !-- First, inquire variable ID |
---|
| 4021 | nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var ) |
---|
| 4022 | CALL handle_error( 'get_variable_1d_int', 527 ) |
---|
| 4023 | ! |
---|
| 4024 | !-- Inquire dimension length |
---|
| 4025 | nc_stat = NF90_GET_VAR( id, id_var, var ) |
---|
| 4026 | CALL handle_error( 'get_variable_1d_int', 527 ) |
---|
| 4027 | |
---|
| 4028 | #endif |
---|
| 4029 | END SUBROUTINE get_variable_1d_int |
---|
| 4030 | |
---|
| 4031 | !------------------------------------------------------------------------------! |
---|
| 4032 | ! Description: |
---|
| 4033 | ! ------------ |
---|
| 4034 | !> Reads a 1D float variable from file. |
---|
| 4035 | !------------------------------------------------------------------------------! |
---|
| 4036 | SUBROUTINE get_variable_1d_real( id, variable_name, var ) |
---|
| 4037 | |
---|
| 4038 | USE pegrid |
---|
| 4039 | |
---|
| 4040 | IMPLICIT NONE |
---|
| 4041 | |
---|
| 4042 | CHARACTER(LEN=*) :: variable_name !< variable name |
---|
| 4043 | |
---|
| 4044 | INTEGER(iwp), INTENT(IN) :: id !< file id |
---|
| 4045 | INTEGER(iwp) :: id_var !< dimension id |
---|
| 4046 | |
---|
| 4047 | REAL(wp), DIMENSION(:), INTENT(INOUT) :: var !< variable to be read |
---|
[2874] | 4048 | #if defined( __netcdf ) |
---|
[2586] | 4049 | |
---|
| 4050 | ! |
---|
| 4051 | !-- First, inquire variable ID |
---|
| 4052 | nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var ) |
---|
[2589] | 4053 | CALL handle_error( 'get_variable_1d_real', 527 ) |
---|
[2586] | 4054 | ! |
---|
| 4055 | !-- Inquire dimension length |
---|
| 4056 | nc_stat = NF90_GET_VAR( id, id_var, var ) |
---|
[2589] | 4057 | CALL handle_error( 'get_variable_1d_real', 527 ) |
---|
[2586] | 4058 | |
---|
| 4059 | #endif |
---|
| 4060 | END SUBROUTINE get_variable_1d_real |
---|
| 4061 | |
---|
[2938] | 4062 | |
---|
[2586] | 4063 | !------------------------------------------------------------------------------! |
---|
| 4064 | ! Description: |
---|
| 4065 | ! ------------ |
---|
[2938] | 4066 | !> Reads a time-dependent 1D float variable from file. |
---|
| 4067 | !------------------------------------------------------------------------------! |
---|
| 4068 | SUBROUTINE get_variable_pr( id, variable_name, t, var ) |
---|
| 4069 | #if defined( __netcdf ) |
---|
| 4070 | |
---|
| 4071 | USE pegrid |
---|
| 4072 | |
---|
| 4073 | IMPLICIT NONE |
---|
| 4074 | |
---|
| 4075 | CHARACTER(LEN=*) :: variable_name !< variable name |
---|
| 4076 | |
---|
| 4077 | INTEGER(iwp), INTENT(IN) :: id !< file id |
---|
| 4078 | INTEGER(iwp), DIMENSION(1:2) :: id_dim !< dimension ids |
---|
| 4079 | INTEGER(iwp) :: id_var !< dimension id |
---|
| 4080 | INTEGER(iwp) :: n_file !< number of data-points in file along z dimension |
---|
| 4081 | INTEGER(iwp), INTENT(IN) :: t !< timestep number |
---|
| 4082 | |
---|
| 4083 | REAL(wp), DIMENSION(:), INTENT(INOUT) :: var !< variable to be read |
---|
| 4084 | |
---|
| 4085 | ! |
---|
| 4086 | !-- First, inquire variable ID |
---|
| 4087 | nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var ) |
---|
| 4088 | ! |
---|
| 4089 | !-- Inquire dimension size of vertical dimension |
---|
| 4090 | nc_stat = NF90_INQUIRE_VARIABLE( id, id_var, DIMIDS = id_dim ) |
---|
| 4091 | nc_stat = NF90_INQUIRE_DIMENSION( id, id_dim(1), LEN = n_file ) |
---|
| 4092 | ! |
---|
| 4093 | !-- Read variable. |
---|
| 4094 | nc_stat = NF90_GET_VAR( id, id_var, var, & |
---|
| 4095 | start = (/ 1, t /), & |
---|
| 4096 | count = (/ n_file, 1 /) ) |
---|
| 4097 | CALL handle_error( 'get_variable_pr', 527 ) |
---|
| 4098 | |
---|
| 4099 | #endif |
---|
| 4100 | END SUBROUTINE get_variable_pr |
---|
| 4101 | |
---|
| 4102 | |
---|
| 4103 | !------------------------------------------------------------------------------! |
---|
| 4104 | ! Description: |
---|
| 4105 | ! ------------ |
---|
[2586] | 4106 | !> Reads a 2D REAL variable from a file. Reading is done processor-wise, |
---|
| 4107 | !> i.e. each core reads its own domain in slices along x. |
---|
| 4108 | !------------------------------------------------------------------------------! |
---|
| 4109 | SUBROUTINE get_variable_2d_real( id, variable_name, i, var ) |
---|
| 4110 | |
---|
| 4111 | USE indices |
---|
| 4112 | USE pegrid |
---|
| 4113 | |
---|
| 4114 | IMPLICIT NONE |
---|
| 4115 | |
---|
| 4116 | CHARACTER(LEN=*) :: variable_name !< variable name |
---|
| 4117 | |
---|
| 4118 | INTEGER(iwp), INTENT(IN) :: i !< index along x direction |
---|
| 4119 | INTEGER(iwp), INTENT(IN) :: id !< file id |
---|
| 4120 | INTEGER(iwp) :: id_var !< variable id |
---|
| 4121 | |
---|
| 4122 | REAL(wp), DIMENSION(nys:nyn), INTENT(INOUT) :: var !< variable to be read |
---|
[2874] | 4123 | #if defined( __netcdf ) |
---|
[2586] | 4124 | ! |
---|
| 4125 | !-- Inquire variable id |
---|
| 4126 | nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var ) |
---|
| 4127 | ! |
---|
| 4128 | !-- Get variable |
---|
| 4129 | nc_stat = NF90_GET_VAR( id, id_var, var(nys:nyn), & |
---|
| 4130 | start = (/ i+1, nys+1 /), & |
---|
| 4131 | count = (/ 1, nyn - nys + 1 /) ) |
---|
| 4132 | |
---|
| 4133 | CALL handle_error( 'get_variable_2d_real', 528 ) |
---|
| 4134 | #endif |
---|
| 4135 | END SUBROUTINE get_variable_2d_real |
---|
| 4136 | |
---|
| 4137 | !------------------------------------------------------------------------------! |
---|
| 4138 | ! Description: |
---|
| 4139 | ! ------------ |
---|
| 4140 | !> Reads a 2D 32-bit INTEGER variable from file. Reading is done processor-wise, |
---|
| 4141 | !> i.e. each core reads its own domain in slices along x. |
---|
| 4142 | !------------------------------------------------------------------------------! |
---|
| 4143 | SUBROUTINE get_variable_2d_int32( id, variable_name, i, var ) |
---|
| 4144 | |
---|
| 4145 | USE indices |
---|
| 4146 | USE pegrid |
---|
| 4147 | |
---|
| 4148 | IMPLICIT NONE |
---|
| 4149 | |
---|
| 4150 | CHARACTER(LEN=*) :: variable_name !< variable name |
---|
| 4151 | |
---|
| 4152 | INTEGER(iwp), INTENT(IN) :: i !< index along x direction |
---|
| 4153 | INTEGER(iwp), INTENT(IN) :: id !< file id |
---|
| 4154 | INTEGER(iwp) :: id_var !< variable id |
---|
| 4155 | INTEGER(iwp), DIMENSION(nys:nyn), INTENT(INOUT) :: var !< variable to be read |
---|
[2874] | 4156 | #if defined( __netcdf ) |
---|
[2586] | 4157 | ! |
---|
| 4158 | !-- Inquire variable id |
---|
| 4159 | nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var ) |
---|
| 4160 | ! |
---|
| 4161 | !-- Get variable |
---|
| 4162 | nc_stat = NF90_GET_VAR( id, id_var, var(nys:nyn), & |
---|
| 4163 | start = (/ i+1, nys+1 /), & |
---|
| 4164 | count = (/ 1, nyn - nys + 1 /) ) |
---|
| 4165 | |
---|
| 4166 | CALL handle_error( 'get_variable_2d_int32', 529 ) |
---|
| 4167 | #endif |
---|
| 4168 | END SUBROUTINE get_variable_2d_int32 |
---|
| 4169 | |
---|
| 4170 | !------------------------------------------------------------------------------! |
---|
| 4171 | ! Description: |
---|
| 4172 | ! ------------ |
---|
| 4173 | !> Reads a 2D 8-bit INTEGER variable from file. Reading is done processor-wise, |
---|
| 4174 | !> i.e. each core reads its own domain in slices along x. |
---|
| 4175 | !------------------------------------------------------------------------------! |
---|
| 4176 | SUBROUTINE get_variable_2d_int8( id, variable_name, i, var ) |
---|
| 4177 | |
---|
| 4178 | USE indices |
---|
| 4179 | USE pegrid |
---|
| 4180 | |
---|
| 4181 | IMPLICIT NONE |
---|
| 4182 | |
---|
| 4183 | CHARACTER(LEN=*) :: variable_name !< variable name |
---|
| 4184 | |
---|
| 4185 | INTEGER(iwp), INTENT(IN) :: i !< index along x direction |
---|
| 4186 | INTEGER(iwp), INTENT(IN) :: id !< file id |
---|
| 4187 | INTEGER(iwp) :: id_var !< variable id |
---|
| 4188 | INTEGER(KIND=1), DIMENSION(nys:nyn), INTENT(INOUT) :: var !< variable to be read |
---|
[2874] | 4189 | #if defined( __netcdf ) |
---|
[2586] | 4190 | ! |
---|
| 4191 | !-- Inquire variable id |
---|
| 4192 | nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var ) |
---|
| 4193 | ! |
---|
| 4194 | !-- Get variable |
---|
| 4195 | nc_stat = NF90_GET_VAR( id, id_var, var(nys:nyn), & |
---|
| 4196 | start = (/ i+1, nys+1 /), & |
---|
| 4197 | count = (/ 1, nyn - nys + 1 /) ) |
---|
| 4198 | |
---|
| 4199 | CALL handle_error( 'get_variable_2d_int8', 530 ) |
---|
| 4200 | #endif |
---|
| 4201 | END SUBROUTINE get_variable_2d_int8 |
---|
| 4202 | |
---|
| 4203 | !------------------------------------------------------------------------------! |
---|
| 4204 | ! Description: |
---|
| 4205 | ! ------------ |
---|
| 4206 | !> Reads a 3D 8-bit INTEGER variable from file. |
---|
| 4207 | !------------------------------------------------------------------------------! |
---|
| 4208 | SUBROUTINE get_variable_3d_int8( id, variable_name, i, j, var ) |
---|
| 4209 | |
---|
| 4210 | USE indices |
---|
| 4211 | USE pegrid |
---|
| 4212 | |
---|
| 4213 | IMPLICIT NONE |
---|
| 4214 | |
---|
| 4215 | CHARACTER(LEN=*) :: variable_name !< variable name |
---|
| 4216 | |
---|
| 4217 | INTEGER(iwp), INTENT(IN) :: i !< index along x direction |
---|
| 4218 | INTEGER(iwp), INTENT(IN) :: id !< file id |
---|
| 4219 | INTEGER(iwp) :: id_var !< variable id |
---|
| 4220 | INTEGER(iwp), INTENT(IN) :: j !< index along y direction |
---|
| 4221 | INTEGER(iwp) :: n_file !< number of data-points along 3rd dimension |
---|
| 4222 | |
---|
| 4223 | INTEGER(iwp), DIMENSION(1:3) :: id_dim |
---|
| 4224 | |
---|
[2637] | 4225 | INTEGER( KIND = 1 ), DIMENSION(nzb:nzt+1), INTENT(INOUT) :: var !< variable to be read |
---|
[2874] | 4226 | #if defined( __netcdf ) |
---|
[2586] | 4227 | |
---|
| 4228 | ! |
---|
| 4229 | !-- Inquire variable id |
---|
| 4230 | nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var ) |
---|
| 4231 | ! |
---|
| 4232 | !-- Get length of first dimension, required for the count parameter. |
---|
| 4233 | !-- Therefore, first inquired dimension ids |
---|
| 4234 | nc_stat = NF90_INQUIRE_VARIABLE( id, id_var, DIMIDS = id_dim ) |
---|
[2637] | 4235 | nc_stat = NF90_INQUIRE_DIMENSION( id, id_dim(3), LEN = n_file ) |
---|
[2586] | 4236 | ! |
---|
| 4237 | !-- Get variable |
---|
[2637] | 4238 | nc_stat = NF90_GET_VAR( id, id_var, var, & |
---|
[2586] | 4239 | start = (/ i+1, j+1, 1 /), & |
---|
| 4240 | count = (/ 1, 1, n_file /) ) |
---|
| 4241 | |
---|
| 4242 | CALL handle_error( 'get_variable_3d_int8', 531 ) |
---|
| 4243 | #endif |
---|
| 4244 | END SUBROUTINE get_variable_3d_int8 |
---|
| 4245 | |
---|
| 4246 | |
---|
| 4247 | !------------------------------------------------------------------------------! |
---|
| 4248 | ! Description: |
---|
| 4249 | ! ------------ |
---|
| 4250 | !> Reads a 3D float variable from file. |
---|
| 4251 | !------------------------------------------------------------------------------! |
---|
| 4252 | SUBROUTINE get_variable_3d_real( id, variable_name, i, j, var ) |
---|
| 4253 | |
---|
| 4254 | USE indices |
---|
| 4255 | USE pegrid |
---|
| 4256 | |
---|
| 4257 | IMPLICIT NONE |
---|
| 4258 | |
---|
| 4259 | CHARACTER(LEN=*) :: variable_name !< variable name |
---|
| 4260 | |
---|
| 4261 | INTEGER(iwp), INTENT(IN) :: i !< index along x direction |
---|
| 4262 | INTEGER(iwp), INTENT(IN) :: id !< file id |
---|
| 4263 | INTEGER(iwp) :: id_var !< variable id |
---|
| 4264 | INTEGER(iwp), INTENT(IN) :: j !< index along y direction |
---|
| 4265 | INTEGER(iwp) :: n3 !< number of data-points along 3rd dimension |
---|
| 4266 | |
---|
| 4267 | INTEGER(iwp), DIMENSION(3) :: id_dim |
---|
| 4268 | |
---|
| 4269 | REAL(wp), DIMENSION(:), INTENT(INOUT) :: var !< variable to be read |
---|
[2874] | 4270 | #if defined( __netcdf ) |
---|
[2586] | 4271 | |
---|
| 4272 | ! |
---|
| 4273 | !-- Inquire variable id |
---|
| 4274 | nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var ) |
---|
| 4275 | ! |
---|
| 4276 | !-- Get length of first dimension, required for the count parameter. |
---|
| 4277 | !-- Therefore, first inquired dimension ids |
---|
| 4278 | nc_stat = NF90_INQUIRE_VARIABLE( id, id_var, DIMIDS = id_dim ) |
---|
| 4279 | nc_stat = NF90_INQUIRE_DIMENSION( id, id_dim(3), LEN = n3 ) |
---|
| 4280 | ! |
---|
| 4281 | !-- Get variable |
---|
| 4282 | nc_stat = NF90_GET_VAR( id, id_var, var, & |
---|
| 4283 | start = (/ i+1, j+1, 1 /), & |
---|
| 4284 | count = (/ 1, 1, n3 /) ) |
---|
| 4285 | |
---|
| 4286 | CALL handle_error( 'get_variable_3d_real', 532 ) |
---|
| 4287 | #endif |
---|
| 4288 | END SUBROUTINE get_variable_3d_real |
---|
| 4289 | |
---|
| 4290 | |
---|
| 4291 | !------------------------------------------------------------------------------! |
---|
| 4292 | ! Description: |
---|
| 4293 | ! ------------ |
---|
| 4294 | !> Reads a 4D float variable from file. Note, in constrast to 3D versions, |
---|
| 4295 | !> dimensions are already inquired and passed so that they are known here. |
---|
| 4296 | !------------------------------------------------------------------------------! |
---|
| 4297 | SUBROUTINE get_variable_4d_real( id, variable_name, i, j, var, n3, n4 ) |
---|
| 4298 | |
---|
| 4299 | USE indices |
---|
| 4300 | USE pegrid |
---|
| 4301 | |
---|
| 4302 | IMPLICIT NONE |
---|
| 4303 | |
---|
| 4304 | CHARACTER(LEN=*) :: variable_name !< variable name |
---|
| 4305 | |
---|
| 4306 | INTEGER(iwp), INTENT(IN) :: i !< index along x direction |
---|
| 4307 | INTEGER(iwp), INTENT(IN) :: id !< file id |
---|
| 4308 | INTEGER(iwp) :: id_var !< variable id |
---|
| 4309 | INTEGER(iwp), INTENT(IN) :: j !< index along y direction |
---|
| 4310 | INTEGER(iwp), INTENT(IN) :: n3 !< number of data-points along 3rd dimension |
---|
| 4311 | INTEGER(iwp), INTENT(IN) :: n4 !< number of data-points along 4th dimension |
---|
| 4312 | |
---|
| 4313 | INTEGER(iwp), DIMENSION(3) :: id_dim |
---|
| 4314 | |
---|
| 4315 | REAL(wp), DIMENSION(:,:), INTENT(INOUT) :: var !< variable to be read |
---|
[2874] | 4316 | #if defined( __netcdf ) |
---|
[2586] | 4317 | |
---|
| 4318 | ! |
---|
| 4319 | !-- Inquire variable id |
---|
| 4320 | nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var ) |
---|
| 4321 | ! |
---|
| 4322 | !-- Get variable |
---|
| 4323 | nc_stat = NF90_GET_VAR( id, id_var, var, & |
---|
| 4324 | start = (/ i+1, j+1, 1, 1 /), & |
---|
| 4325 | count = (/ 1, 1, n3, n4 /) ) |
---|
| 4326 | |
---|
| 4327 | CALL handle_error( 'get_variable_4d_real', 533 ) |
---|
| 4328 | #endif |
---|
| 4329 | END SUBROUTINE get_variable_4d_real |
---|
| 4330 | |
---|
| 4331 | |
---|
| 4332 | |
---|
| 4333 | !------------------------------------------------------------------------------! |
---|
| 4334 | ! Description: |
---|
| 4335 | ! ------------ |
---|
| 4336 | !> Reads a 3D float variable at left, right, north, south and top boundaries. |
---|
| 4337 | !------------------------------------------------------------------------------! |
---|
| 4338 | SUBROUTINE get_variable_bc( id, variable_name, t_start, & |
---|
| 4339 | i2_s, count_2, i3_s, count_3, var ) |
---|
| 4340 | |
---|
| 4341 | USE indices |
---|
| 4342 | USE pegrid |
---|
| 4343 | |
---|
| 4344 | IMPLICIT NONE |
---|
| 4345 | |
---|
| 4346 | CHARACTER(LEN=*) :: variable_name !< variable name |
---|
| 4347 | |
---|
| 4348 | INTEGER(iwp) :: count_2 !< number of elements in second dimension |
---|
| 4349 | INTEGER(iwp) :: count_3 !< number of elements in third dimension (usually 1) |
---|
| 4350 | INTEGER(iwp) :: i2_s !< start index of second dimension |
---|
| 4351 | INTEGER(iwp) :: i3_s !< start index of third dimension |
---|
| 4352 | INTEGER(iwp), INTENT(IN) :: id !< file id |
---|
| 4353 | INTEGER(iwp) :: id_var !< variable id |
---|
| 4354 | INTEGER(iwp) :: t_start !< start index at time dimension with respect to netcdf convention |
---|
| 4355 | |
---|
| 4356 | REAL(wp), DIMENSION(:), INTENT(INOUT) :: var !< input variable |
---|
[2874] | 4357 | #if defined( __netcdf ) |
---|
[2586] | 4358 | |
---|
| 4359 | ! |
---|
| 4360 | !-- Inquire variable id |
---|
| 4361 | nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var ) |
---|
| 4362 | ! |
---|
| 4363 | !-- Get variable |
---|
| 4364 | nc_stat = NF90_GET_VAR( id, id_var, var, & |
---|
| 4365 | start = (/ i3_s, i2_s, t_start /), & |
---|
| 4366 | count = (/ count_3, count_2, 1 /) ) |
---|
| 4367 | |
---|
| 4368 | CALL handle_error( 'get_variable_bc', 532 ) |
---|
| 4369 | #endif |
---|
| 4370 | END SUBROUTINE get_variable_bc |
---|
| 4371 | |
---|
| 4372 | |
---|
| 4373 | |
---|
| 4374 | !------------------------------------------------------------------------------! |
---|
| 4375 | ! Description: |
---|
| 4376 | ! ------------ |
---|
| 4377 | !> Inquires the number of variables in a file |
---|
| 4378 | !------------------------------------------------------------------------------! |
---|
| 4379 | SUBROUTINE inquire_num_variables( id, num_vars ) |
---|
| 4380 | |
---|
| 4381 | USE indices |
---|
| 4382 | USE pegrid |
---|
| 4383 | |
---|
| 4384 | IMPLICIT NONE |
---|
| 4385 | |
---|
| 4386 | INTEGER(iwp), INTENT(IN) :: id !< file id |
---|
| 4387 | INTEGER(iwp), INTENT(INOUT) :: num_vars !< number of variables in a file |
---|
[2874] | 4388 | #if defined( __netcdf ) |
---|
[2586] | 4389 | |
---|
| 4390 | nc_stat = NF90_INQUIRE( id, NVARIABLES = num_vars ) |
---|
| 4391 | CALL handle_error( 'inquire_num_variables', 534 ) |
---|
| 4392 | |
---|
| 4393 | #endif |
---|
| 4394 | END SUBROUTINE inquire_num_variables |
---|
| 4395 | |
---|
| 4396 | |
---|
| 4397 | !------------------------------------------------------------------------------! |
---|
| 4398 | ! Description: |
---|
| 4399 | ! ------------ |
---|
| 4400 | !> Inquires the variable names belonging to a file. |
---|
| 4401 | !------------------------------------------------------------------------------! |
---|
| 4402 | SUBROUTINE inquire_variable_names( id, var_names ) |
---|
| 4403 | |
---|
| 4404 | USE indices |
---|
| 4405 | USE pegrid |
---|
| 4406 | |
---|
| 4407 | IMPLICIT NONE |
---|
| 4408 | |
---|
| 4409 | CHARACTER(LEN=*), DIMENSION(:), INTENT(INOUT) :: var_names !< return variable - variable names |
---|
| 4410 | INTEGER(iwp) :: i !< loop variable |
---|
| 4411 | INTEGER(iwp), INTENT(IN) :: id !< file id |
---|
| 4412 | INTEGER(iwp) :: num_vars !< number of variables (unused return parameter) |
---|
| 4413 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: varids !< dummy array to strore variable ids temporarily |
---|
[2874] | 4414 | #if defined( __netcdf ) |
---|
[2586] | 4415 | |
---|
| 4416 | ALLOCATE( varids(1:SIZE(var_names)) ) |
---|
| 4417 | nc_stat = NF90_INQ_VARIDS( id, NVARS = num_vars, VARIDS = varids ) |
---|
| 4418 | CALL handle_error( 'inquire_variable_names', 535 ) |
---|
| 4419 | |
---|
| 4420 | DO i = 1, SIZE(var_names) |
---|
| 4421 | nc_stat = NF90_INQUIRE_VARIABLE( id, varids(i), NAME = var_names(i) ) |
---|
| 4422 | CALL handle_error( 'inquire_variable_names', 535 ) |
---|
| 4423 | ENDDO |
---|
| 4424 | |
---|
| 4425 | DEALLOCATE( varids ) |
---|
| 4426 | #endif |
---|
| 4427 | END SUBROUTINE inquire_variable_names |
---|
| 4428 | |
---|
| 4429 | !------------------------------------------------------------------------------! |
---|
| 4430 | ! Description: |
---|
| 4431 | ! ------------ |
---|
| 4432 | !> Prints out a text message corresponding to the current status. |
---|
| 4433 | !------------------------------------------------------------------------------! |
---|
| 4434 | SUBROUTINE handle_error( routine_name, errno ) |
---|
| 4435 | |
---|
| 4436 | USE control_parameters, & |
---|
| 4437 | ONLY: message_string |
---|
| 4438 | |
---|
| 4439 | IMPLICIT NONE |
---|
| 4440 | |
---|
| 4441 | CHARACTER(LEN=6) :: message_identifier |
---|
| 4442 | CHARACTER(LEN=*) :: routine_name |
---|
| 4443 | |
---|
| 4444 | INTEGER(iwp) :: errno |
---|
[2874] | 4445 | #if defined( __netcdf ) |
---|
[2586] | 4446 | |
---|
| 4447 | IF ( nc_stat /= NF90_NOERR ) THEN |
---|
| 4448 | |
---|
| 4449 | WRITE( message_identifier, '(''NC'',I4.4)' ) errno |
---|
| 4450 | message_string = TRIM( NF90_STRERROR( nc_stat ) ) |
---|
| 4451 | |
---|
| 4452 | CALL message( routine_name, message_identifier, 2, 2, 0, 6, 1 ) |
---|
| 4453 | |
---|
| 4454 | ENDIF |
---|
| 4455 | |
---|
| 4456 | #endif |
---|
| 4457 | END SUBROUTINE handle_error |
---|
| 4458 | |
---|
| 4459 | |
---|
| 4460 | END MODULE netcdf_data_input_mod |
---|