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