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