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