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