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