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