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