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-2019 Leibniz Universitaet Hannover |
---|
18 | !------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: netcdf_data_input_mod.f90 4298 2019-11-21 15:59:16Z suehring $ |
---|
27 | ! Open input files with read-only attribute instead of write attribute. |
---|
28 | ! |
---|
29 | ! 4280 2019-10-29 14:34:15Z monakurppa |
---|
30 | ! Remove id_emis flags from get_variable_4d_to_3d_real and |
---|
31 | ! get_variable_5d_to_4d_real |
---|
32 | ! |
---|
33 | ! 4258 2019-10-07 13:29:08Z suehring |
---|
34 | ! - Migrate input of soil temperature and moisture to land-surface model. |
---|
35 | ! - Remove interpolate routines and move the only required subroutine to |
---|
36 | ! land-surface model. |
---|
37 | ! |
---|
38 | ! 4247 2019-09-30 10:18:24Z pavelkrc |
---|
39 | ! Add reading and processing of building_surface_pars |
---|
40 | ! |
---|
41 | ! 4226 2019-09-10 17:03:24Z suehring |
---|
42 | ! - Netcdf input routine for dimension length renamed |
---|
43 | ! - Move offline-nesting-specific checks to nesting_offl_mod |
---|
44 | ! - Module-specific input of boundary data for offline nesting moved to |
---|
45 | ! nesting_offl_mod |
---|
46 | ! - Define module specific data type for offline nesting in nesting_offl_mod |
---|
47 | ! |
---|
48 | ! 4190 2019-08-27 15:42:37Z suehring |
---|
49 | ! type real_1d changed to real_1d_3d |
---|
50 | ! |
---|
51 | ! 4186 2019-08-23 16:06:14Z suehring |
---|
52 | ! Minor formatting adjustments |
---|
53 | ! |
---|
54 | ! 4182 2019-08-22 15:20:23Z scharf |
---|
55 | ! Corrected "Former revisions" section |
---|
56 | ! |
---|
57 | ! 4178 2019-08-21 11:13:06Z suehring |
---|
58 | ! Implement input of external radiation forcing. Therefore, provide public |
---|
59 | ! subroutines and variables. |
---|
60 | ! |
---|
61 | ! 4150 2019-08-08 20:00:47Z suehring |
---|
62 | ! Some variables are given the public attribute, in order to call netcdf input |
---|
63 | ! from single routines |
---|
64 | ! |
---|
65 | ! 4125 2019-07-29 13:31:44Z suehring |
---|
66 | ! To enable netcdf-parallel access for lateral boundary data (dynamic input), |
---|
67 | ! zero number of elements are passed to the respective get_variable routine |
---|
68 | ! for non-boundary cores. |
---|
69 | ! |
---|
70 | ! 4100 2019-07-17 08:11:29Z forkel |
---|
71 | ! Made check for input_pids_dynamic and 'inifor' more general |
---|
72 | ! |
---|
73 | ! 4012 2019-05-31 15:19:05Z monakurppa |
---|
74 | ! |
---|
75 | ! 3994 2019-05-22 18:08:09Z suehring |
---|
76 | ! Remove single location message |
---|
77 | ! |
---|
78 | ! 3976 2019-05-15 11:02:34Z hellstea |
---|
79 | ! Remove unused variables from last commit |
---|
80 | ! |
---|
81 | ! 3969 2019-05-13 12:14:33Z suehring |
---|
82 | ! - clean-up index notations for emission_values to eliminate magic numbers |
---|
83 | ! - introduce temporary variable dum_var_5d as well as subroutines |
---|
84 | ! get_var_5d_real and get_var_5d_real_dynamic |
---|
85 | ! - remove emission-specific code in generic get_variable routines |
---|
86 | ! - in subroutine netcdf_data_input_chemistry_data change netCDF LOD 1 |
---|
87 | ! (default) emission_values to the following index order: |
---|
88 | ! z, y, x, species, category |
---|
89 | ! - in subroutine netcdf_data_input_chemistry_data |
---|
90 | ! changed netCDF LOD 2 pre-processed emission_values to the following index |
---|
91 | ! order: time, z, y, x, species |
---|
92 | ! - in type chem_emis_att_type replace nspec with n_emiss_species |
---|
93 | ! but retained nspec for backward compatibility with salsa_mod. (E.C. Chan) |
---|
94 | ! |
---|
95 | ! 3961 2019-05-08 16:12:31Z suehring |
---|
96 | ! Revise checks for building IDs and types |
---|
97 | ! |
---|
98 | ! 3943 2019-05-02 09:50:41Z maronga |
---|
99 | ! Temporarily disabled some (faulty) checks for static driver. |
---|
100 | ! |
---|
101 | ! 3942 2019-04-30 13:08:30Z kanani |
---|
102 | ! Fix: increase LEN of all NetCDF attribute values (caused crash in |
---|
103 | ! netcdf_create_global_atts due to insufficient length) |
---|
104 | ! |
---|
105 | ! 3941 2019-04-30 09:48:33Z suehring |
---|
106 | ! Move check for grid dimension to an earlier point in time when first array |
---|
107 | ! is read. |
---|
108 | ! Improve checks for building types / IDs with respect to 2D/3D buildings. |
---|
109 | ! |
---|
110 | ! 3885 2019-04-11 11:29:34Z kanani |
---|
111 | ! Changes related to global restructuring of location messages and introduction |
---|
112 | ! of additional debug messages |
---|
113 | ! |
---|
114 | ! 3864 2019-04-05 09:01:56Z monakurppa |
---|
115 | ! get_variable_4d_to_3d_real modified to enable read in data of type |
---|
116 | ! data(t,y,x,n) one timestep at a time + some routines made public |
---|
117 | ! |
---|
118 | ! 3855 2019-04-03 10:00:59Z suehring |
---|
119 | ! Typo removed |
---|
120 | ! |
---|
121 | ! 3854 2019-04-02 16:59:33Z suehring |
---|
122 | ! Bugfix in one of the checks. Typo removed. |
---|
123 | ! |
---|
124 | ! 3744 2019-02-15 18:38:58Z suehring |
---|
125 | ! Enable mesoscale offline nesting for chemistry variables as well as |
---|
126 | ! initialization of chemistry via dynamic input file. |
---|
127 | ! |
---|
128 | ! 3705 2019-01-29 19:56:39Z suehring |
---|
129 | ! Interface for attribute input of 8-bit and 32-bit integer |
---|
130 | ! |
---|
131 | ! 3704 2019-01-29 19:51:41Z suehring |
---|
132 | ! unused variables removed |
---|
133 | ! |
---|
134 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
135 | ! Initial revision (suehring) |
---|
136 | ! |
---|
137 | ! Authors: |
---|
138 | ! -------- |
---|
139 | ! @author Matthias Suehring |
---|
140 | ! @author Edward C. Chan |
---|
141 | ! @author Emanuele Russo |
---|
142 | ! |
---|
143 | ! Description: |
---|
144 | ! ------------ |
---|
145 | !> Modulue contains routines to input data according to Palm input data |
---|
146 | !> standart using dynamic and static input files. |
---|
147 | !> @todo - Chemistry: revise reading of netcdf file and ajdust formatting |
---|
148 | !> according to standard!!! (ecc/done) |
---|
149 | !> @todo - Order input alphabetically |
---|
150 | !> @todo - Revise error messages and error numbers |
---|
151 | !> @todo - Input of missing quantities (chemical species, emission rates) |
---|
152 | !> @todo - Defninition and input of still missing variable attributes |
---|
153 | !> (ecc/what are they?) |
---|
154 | !> @todo - Input of initial geostrophic wind profiles with cyclic conditions. |
---|
155 | !> @todo - remove z dimension from default_emission_data nad preproc_emission_data |
---|
156 | ! and correpsonding subroutines get_var_5d_real and get_var_5d_dynamic (ecc) |
---|
157 | !> @todo - decpreciate chem_emis_att_type@nspec (ecc) |
---|
158 | !> @todo - depreciate subroutines get_variable_4d_to_3d_real and |
---|
159 | !> get_variable_5d_to_4d_real (ecc) |
---|
160 | !> @todo - introduce useful debug_message(s) |
---|
161 | !------------------------------------------------------------------------------! |
---|
162 | MODULE netcdf_data_input_mod |
---|
163 | |
---|
164 | USE control_parameters, & |
---|
165 | ONLY: coupling_char, io_blocks, io_group |
---|
166 | |
---|
167 | USE cpulog, & |
---|
168 | ONLY: cpu_log, log_point_s |
---|
169 | |
---|
170 | USE indices, & |
---|
171 | ONLY: nbgp |
---|
172 | |
---|
173 | USE kinds |
---|
174 | |
---|
175 | #if defined ( __netcdf ) |
---|
176 | USE NETCDF |
---|
177 | #endif |
---|
178 | |
---|
179 | USE pegrid |
---|
180 | |
---|
181 | USE surface_mod, & |
---|
182 | ONLY: ind_pav_green, ind_veg_wall, ind_wat_win |
---|
183 | ! |
---|
184 | !-- Define type for dimensions. |
---|
185 | TYPE dims_xy |
---|
186 | INTEGER(iwp) :: nx !< dimension length in x |
---|
187 | INTEGER(iwp) :: ny !< dimension length in y |
---|
188 | INTEGER(iwp) :: nz !< dimension length in z |
---|
189 | REAL(wp), DIMENSION(:), ALLOCATABLE :: x !< dimension array in x |
---|
190 | REAL(wp), DIMENSION(:), ALLOCATABLE :: y !< dimension array in y |
---|
191 | REAL(wp), DIMENSION(:), ALLOCATABLE :: z !< dimension array in z |
---|
192 | END TYPE dims_xy |
---|
193 | TYPE init_type |
---|
194 | |
---|
195 | CHARACTER(LEN=16) :: init_char = 'init_atmosphere_' !< leading substring for init variables |
---|
196 | CHARACTER(LEN=23) :: origin_time = '2000-01-01 00:00:00 +00' !< reference time of input data |
---|
197 | CHARACTER(LEN=100), DIMENSION(:), ALLOCATABLE :: var_names_chem !< list of chemistry variable names that can potentially be on file |
---|
198 | |
---|
199 | INTEGER(iwp) :: lod_msoil !< level of detail - soil moisture |
---|
200 | INTEGER(iwp) :: lod_pt !< level of detail - pt |
---|
201 | INTEGER(iwp) :: lod_q !< level of detail - q |
---|
202 | INTEGER(iwp) :: lod_tsoil !< level of detail - soil temperature |
---|
203 | INTEGER(iwp) :: lod_u !< level of detail - u-component |
---|
204 | INTEGER(iwp) :: lod_v !< level of detail - v-component |
---|
205 | INTEGER(iwp) :: lod_w !< level of detail - w-component |
---|
206 | INTEGER(iwp) :: nx !< number of scalar grid points along x in dynamic input file |
---|
207 | INTEGER(iwp) :: nxu !< number of u grid points along x in dynamic input file |
---|
208 | INTEGER(iwp) :: ny !< number of scalar grid points along y in dynamic input file |
---|
209 | INTEGER(iwp) :: nyv !< number of v grid points along y in dynamic input file |
---|
210 | INTEGER(iwp) :: nzs !< number of vertical soil levels in dynamic input file |
---|
211 | INTEGER(iwp) :: nzu !< number of vertical levels on scalar grid in dynamic input file |
---|
212 | INTEGER(iwp) :: nzw !< number of vertical levels on w grid in dynamic input file |
---|
213 | |
---|
214 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: lod_chem !< level of detail - chemistry variables |
---|
215 | |
---|
216 | LOGICAL :: from_file_msoil = .FALSE. !< flag indicating whether soil moisture is already initialized from file |
---|
217 | LOGICAL :: from_file_pt = .FALSE. !< flag indicating whether pt is already initialized from file |
---|
218 | LOGICAL :: from_file_q = .FALSE. !< flag indicating whether q is already initialized from file |
---|
219 | LOGICAL :: from_file_tsoil = .FALSE. !< flag indicating whether soil temperature is already initialized from file |
---|
220 | LOGICAL :: from_file_u = .FALSE. !< flag indicating whether u is already initialized from file |
---|
221 | LOGICAL :: from_file_ug = .FALSE. !< flag indicating whether ug is already initialized from file |
---|
222 | LOGICAL :: from_file_v = .FALSE. !< flag indicating whether v is already initialized from file |
---|
223 | LOGICAL :: from_file_vg = .FALSE. !< flag indicating whether ug is already initialized from file |
---|
224 | LOGICAL :: from_file_w = .FALSE. !< flag indicating whether w is already initialized from file |
---|
225 | |
---|
226 | LOGICAL, DIMENSION(:), ALLOCATABLE :: from_file_chem !< flag indicating whether chemistry variable is read from file |
---|
227 | |
---|
228 | REAL(wp) :: fill_msoil !< fill value for soil moisture |
---|
229 | REAL(wp) :: fill_pt !< fill value for pt |
---|
230 | REAL(wp) :: fill_q !< fill value for q |
---|
231 | REAL(wp) :: fill_tsoil !< fill value for soil temperature |
---|
232 | REAL(wp) :: fill_u !< fill value for u |
---|
233 | REAL(wp) :: fill_v !< fill value for v |
---|
234 | REAL(wp) :: fill_w !< fill value for w |
---|
235 | REAL(wp) :: latitude = 0.0_wp !< latitude of the lower left corner |
---|
236 | REAL(wp) :: longitude = 0.0_wp !< longitude of the lower left corner |
---|
237 | REAL(wp) :: origin_x = 500000.0_wp !< UTM easting of the lower left corner |
---|
238 | REAL(wp) :: origin_y = 0.0_wp !< UTM northing of the lower left corner |
---|
239 | REAL(wp) :: origin_z = 0.0_wp !< reference height of input data |
---|
240 | REAL(wp) :: rotation_angle = 0.0_wp !< rotation angle of input data |
---|
241 | |
---|
242 | REAL(wp), DIMENSION(:), ALLOCATABLE :: fill_chem !< fill value - chemistry variables |
---|
243 | REAL(wp), DIMENSION(:), ALLOCATABLE :: msoil_1d !< initial vertical profile of soil moisture |
---|
244 | REAL(wp), DIMENSION(:), ALLOCATABLE :: pt_init !< initial vertical profile of pt |
---|
245 | REAL(wp), DIMENSION(:), ALLOCATABLE :: q_init !< initial vertical profile of q |
---|
246 | REAL(wp), DIMENSION(:), ALLOCATABLE :: tsoil_1d !< initial vertical profile of soil temperature |
---|
247 | REAL(wp), DIMENSION(:), ALLOCATABLE :: u_init !< initial vertical profile of u |
---|
248 | REAL(wp), DIMENSION(:), ALLOCATABLE :: ug_init !< initial vertical profile of ug |
---|
249 | REAL(wp), DIMENSION(:), ALLOCATABLE :: v_init !< initial vertical profile of v |
---|
250 | REAL(wp), DIMENSION(:), ALLOCATABLE :: vg_init !< initial vertical profile of ug |
---|
251 | REAL(wp), DIMENSION(:), ALLOCATABLE :: w_init !< initial vertical profile of w |
---|
252 | REAL(wp), DIMENSION(:), ALLOCATABLE :: z_soil !< vertical levels in soil in dynamic input file, used for interpolation |
---|
253 | REAL(wp), DIMENSION(:), ALLOCATABLE :: zu_atmos !< vertical levels at scalar grid in dynamic input file, used for interpolation |
---|
254 | REAL(wp), DIMENSION(:), ALLOCATABLE :: zw_atmos !< vertical levels at w grid in dynamic input file, used for interpolation |
---|
255 | |
---|
256 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: chem_init !< initial vertical profiles of chemistry variables |
---|
257 | |
---|
258 | |
---|
259 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: msoil_3d !< initial 3d soil moisture provide by Inifor and interpolated onto soil grid |
---|
260 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: tsoil_3d !< initial 3d soil temperature provide by Inifor and interpolated onto soil grid |
---|
261 | |
---|
262 | END TYPE init_type |
---|
263 | |
---|
264 | !-- Data type for the general information of chemistry emissions, do not dependent on the particular chemical species |
---|
265 | TYPE chem_emis_att_type |
---|
266 | |
---|
267 | !-DIMENSIONS |
---|
268 | |
---|
269 | INTEGER(iwp) :: nspec=0 !< no of chem species provided in emission_values |
---|
270 | INTEGER(iwp) :: n_emiss_species=0 !< no of chem species provided in emission_values |
---|
271 | !< same function as nspec, which will be depreciated (ecc) |
---|
272 | |
---|
273 | INTEGER(iwp) :: ncat=0 !< number of emission categories |
---|
274 | INTEGER(iwp) :: nvoc=0 !< number of VOC components |
---|
275 | INTEGER(iwp) :: npm=0 !< number of PM components |
---|
276 | INTEGER(iwp) :: nnox=2 !< number of NOx components: NO and NO2 |
---|
277 | INTEGER(iwp) :: nsox=2 !< number of SOX components: SO and SO4 |
---|
278 | INTEGER(iwp) :: nhoursyear !< number of hours of a specific year in the HOURLY mode |
---|
279 | !< of the default mode |
---|
280 | INTEGER(iwp) :: nmonthdayhour !< number of month days and hours in the MDH mode |
---|
281 | !< of the default mode |
---|
282 | INTEGER(iwp) :: dt_emission !< Number of emissions timesteps for one year |
---|
283 | !< in the pre-processed emissions case |
---|
284 | !-- 1d emission input variables |
---|
285 | CHARACTER (LEN=25),ALLOCATABLE, DIMENSION(:) :: pm_name !< Names of PM components |
---|
286 | CHARACTER (LEN=25),ALLOCATABLE, DIMENSION(:) :: cat_name !< Emission category names |
---|
287 | CHARACTER (LEN=25),ALLOCATABLE, DIMENSION(:) :: species_name !< Names of emission chemical species |
---|
288 | CHARACTER (LEN=25),ALLOCATABLE, DIMENSION(:) :: voc_name !< Names of VOCs components |
---|
289 | CHARACTER (LEN=25) :: units !< Units |
---|
290 | |
---|
291 | INTEGER(iwp) :: i_hour !< indices for assigning emission values at different timesteps |
---|
292 | INTEGER(iwp),ALLOCATABLE, DIMENSION(:) :: cat_index !< Indices for emission categories |
---|
293 | INTEGER(iwp),ALLOCATABLE, DIMENSION(:) :: species_index !< Indices for emission chem species |
---|
294 | |
---|
295 | REAL(wp),ALLOCATABLE, DIMENSION(:) :: xm !< Molecular masses of emission chem species |
---|
296 | |
---|
297 | !-- 2d emission input variables |
---|
298 | REAL(wp),ALLOCATABLE, DIMENSION(:,:) :: hourly_emis_time_factor !< Time factors for HOURLY emissions (DEFAULT mode) |
---|
299 | REAL(wp),ALLOCATABLE, DIMENSION(:,:) :: mdh_emis_time_factor !< Time factors for MDH emissions (DEFAULT mode) |
---|
300 | REAL(wp),ALLOCATABLE, DIMENSION(:,:) :: nox_comp !< Composition of NO and NO2 |
---|
301 | REAL(wp),ALLOCATABLE, DIMENSION(:,:) :: sox_comp !< Composition of SO2 and SO4 |
---|
302 | REAL(wp),ALLOCATABLE, DIMENSION(:,:) :: voc_comp !< Composition of VOC components (not fixed) |
---|
303 | |
---|
304 | !-- 3d emission input variables |
---|
305 | REAL(wp),ALLOCATABLE, DIMENSION(:,:,:) :: pm_comp !< Composition of PM components (not fixed) |
---|
306 | |
---|
307 | END TYPE chem_emis_att_type |
---|
308 | |
---|
309 | |
---|
310 | !-- Data type for the values of chemistry emissions |
---|
311 | TYPE chem_emis_val_type |
---|
312 | |
---|
313 | !REAL(wp),ALLOCATABLE, DIMENSION(:,:) :: stack_height !< stack height (ecc / to be implemented) |
---|
314 | REAL(wp),ALLOCATABLE, DIMENSION(:,:,:) :: default_emission_data !< Emission input values for LOD1 (DEFAULT mode) |
---|
315 | REAL(wp),ALLOCATABLE, DIMENSION(:,:,:,:) :: preproc_emission_data !< Emission input values for LOD2 (PRE-PROCESSED mode) |
---|
316 | |
---|
317 | END TYPE chem_emis_val_type |
---|
318 | |
---|
319 | ! |
---|
320 | !-- Define data structures for different input data types. |
---|
321 | !-- 8-bit Integer 2D |
---|
322 | TYPE int_2d_8bit |
---|
323 | INTEGER(KIND=1) :: fill = -127 !< fill value |
---|
324 | INTEGER(KIND=1), DIMENSION(:,:), ALLOCATABLE :: var !< respective variable |
---|
325 | |
---|
326 | LOGICAL :: from_file = .FALSE. !< flag indicating whether an input variable is available and read from file or default values are used |
---|
327 | END TYPE int_2d_8bit |
---|
328 | ! |
---|
329 | !-- 8-bit Integer 3D |
---|
330 | TYPE int_3d_8bit |
---|
331 | INTEGER(KIND=1) :: fill = -127 !< fill value |
---|
332 | INTEGER(KIND=1), DIMENSION(:,:,:), ALLOCATABLE :: var_3d !< respective variable |
---|
333 | |
---|
334 | LOGICAL :: from_file = .FALSE. !< flag indicating whether an input variable is available and read from file or default values are used |
---|
335 | END TYPE int_3d_8bit |
---|
336 | ! |
---|
337 | !-- 32-bit Integer 2D |
---|
338 | TYPE int_2d_32bit |
---|
339 | INTEGER(iwp) :: fill = -9999 !< fill value |
---|
340 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: var !< respective variable |
---|
341 | |
---|
342 | LOGICAL :: from_file = .FALSE. !< flag indicating whether an input variable is available and read from file or default values are used |
---|
343 | END TYPE int_2d_32bit |
---|
344 | ! |
---|
345 | !-- Define data type to read 1D or 3D real variables. |
---|
346 | TYPE real_1d_3d |
---|
347 | LOGICAL :: from_file = .FALSE. !< flag indicating whether an input variable is available and read from file or default values are used |
---|
348 | |
---|
349 | INTEGER(iwp) :: lod = -1 !< level-of-detail |
---|
350 | |
---|
351 | REAL(wp) :: fill = -9999.9_wp !< fill value |
---|
352 | |
---|
353 | REAL(wp), DIMENSION(:), ALLOCATABLE :: var1d !< respective 1D variable |
---|
354 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: var3d !< respective 3D variable |
---|
355 | END TYPE real_1d_3d |
---|
356 | ! |
---|
357 | !-- Define data type to read 2D real variables |
---|
358 | TYPE real_2d |
---|
359 | LOGICAL :: from_file = .FALSE. !< flag indicating whether an input variable is available and read from file or default values are used |
---|
360 | |
---|
361 | INTEGER(iwp) :: lod !< level-of-detail |
---|
362 | |
---|
363 | REAL(wp) :: fill = -9999.9_wp !< fill value |
---|
364 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: var !< respective variable |
---|
365 | END TYPE real_2d |
---|
366 | |
---|
367 | ! |
---|
368 | !-- Define data type to read 3D real variables |
---|
369 | TYPE real_3d |
---|
370 | LOGICAL :: from_file = .FALSE. !< flag indicating whether an input variable is available and read from file or default values are used |
---|
371 | |
---|
372 | INTEGER(iwp) :: nz !< number of grid points along vertical dimension |
---|
373 | |
---|
374 | REAL(wp) :: fill = -9999.9_wp !< fill value |
---|
375 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: var !< respective variable |
---|
376 | END TYPE real_3d |
---|
377 | ! |
---|
378 | !-- Define data structure where the dimension and type of the input depends |
---|
379 | !-- on the given level of detail. |
---|
380 | !-- For buildings, the input is either 2D float, or 3d byte. |
---|
381 | TYPE build_in |
---|
382 | INTEGER(iwp) :: lod = 1 !< level of detail |
---|
383 | INTEGER(KIND=1) :: fill2 = -127 !< fill value for lod = 2 |
---|
384 | INTEGER(iwp) :: nz !< number of vertical layers in file |
---|
385 | INTEGER(KIND=1), DIMENSION(:,:,:), ALLOCATABLE :: var_3d !< 3d variable (lod = 2) |
---|
386 | |
---|
387 | REAL(wp), DIMENSION(:), ALLOCATABLE :: z !< vertical coordinate for 3D building, used for consistency check |
---|
388 | |
---|
389 | LOGICAL :: from_file = .FALSE. !< flag indicating whether an input variable is available and read from file or default values are used |
---|
390 | |
---|
391 | REAL(wp) :: fill1 = -9999.9_wp !< fill values for lod = 1 |
---|
392 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: var_2d !< 2d variable (lod = 1) |
---|
393 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: oro_max !< terraing height under particular buildings |
---|
394 | END TYPE build_in |
---|
395 | |
---|
396 | ! |
---|
397 | !-- For soil_type, the input is either 2D or 3D one-byte integer. |
---|
398 | TYPE soil_in |
---|
399 | INTEGER(iwp) :: lod = 1 !< level of detail |
---|
400 | INTEGER(KIND=1) :: fill = -127 !< fill value for lod = 2 |
---|
401 | INTEGER(KIND=1), DIMENSION(:,:), ALLOCATABLE :: var_2d !< 2d variable (lod = 1) |
---|
402 | INTEGER(KIND=1), DIMENSION(:,:,:), ALLOCATABLE :: var_3d !< 3d variable (lod = 2) |
---|
403 | |
---|
404 | LOGICAL :: from_file = .FALSE. !< flag indicating whether an input variable is available and read from file or default values are used |
---|
405 | END TYPE soil_in |
---|
406 | |
---|
407 | ! |
---|
408 | !-- Define data type for fractions between surface types |
---|
409 | TYPE fracs |
---|
410 | INTEGER(iwp) :: nf !< total number of fractions |
---|
411 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: nfracs !< dimension array for fraction |
---|
412 | |
---|
413 | LOGICAL :: from_file = .FALSE. !< flag indicating whether an input variable is available and read from file or default values are used |
---|
414 | |
---|
415 | REAL(wp) :: fill = -9999.9_wp !< fill value |
---|
416 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: frac !< respective fraction between different surface types |
---|
417 | END TYPE fracs |
---|
418 | ! |
---|
419 | !-- Data type for parameter lists, Depending on the given level of detail, |
---|
420 | !-- the input is 3D or 4D |
---|
421 | TYPE pars |
---|
422 | INTEGER(iwp) :: lod = 1 !< level of detail |
---|
423 | INTEGER(iwp) :: np !< total number of parameters |
---|
424 | INTEGER(iwp) :: nz !< vertical dimension - number of soil layers |
---|
425 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: layers !< dimension array for soil layers |
---|
426 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: pars !< dimension array for parameters |
---|
427 | |
---|
428 | LOGICAL :: from_file = .FALSE. !< flag indicating whether an input variable is available and read from file or default values are used |
---|
429 | |
---|
430 | REAL(wp) :: fill = -9999.9_wp !< fill value |
---|
431 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: pars_xy !< respective parameters, level of detail = 1 |
---|
432 | REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE :: pars_xyz !< respective parameters, level of detail = 2 |
---|
433 | END TYPE pars |
---|
434 | ! |
---|
435 | !-- Data type for surface parameter lists |
---|
436 | TYPE pars_surf |
---|
437 | INTEGER(iwp) :: np !< total number of parameters |
---|
438 | INTEGER(iwp) :: nsurf !< number of local surfaces |
---|
439 | INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE :: index_ji !< index for beginning and end of surfaces at (j,i) |
---|
440 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: coords !< (k,j,i,norm_z,norm_y,norm_x) |
---|
441 | !< k,j,i: surface position |
---|
442 | !< norm_z,norm_y,norm_x: surface normal vector |
---|
443 | |
---|
444 | LOGICAL :: from_file = .FALSE. !< flag indicating whether an input variable is available and read from file or default values are used |
---|
445 | |
---|
446 | REAL(wp) :: fill = -9999.9_wp !< fill value |
---|
447 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: pars !< respective parameters per surface |
---|
448 | END TYPE pars_surf |
---|
449 | ! |
---|
450 | !-- Define type for global file attributes |
---|
451 | !-- Please refer to the PALM data standard for a detailed description of each |
---|
452 | !-- attribute. |
---|
453 | TYPE global_atts_type |
---|
454 | CHARACTER(LEN=200) :: acronym = ' ' !< acronym of institution |
---|
455 | CHARACTER(LEN=7) :: acronym_char = 'acronym' !< name of attribute |
---|
456 | CHARACTER(LEN=200) :: author = ' ' !< first name, last name, email adress |
---|
457 | CHARACTER(LEN=6) :: author_char = 'author' !< name of attribute |
---|
458 | CHARACTER(LEN=200) :: campaign = 'PALM-4U' !< name of campaign |
---|
459 | CHARACTER(LEN=8) :: campaign_char = 'campaign' !< name of attribute |
---|
460 | CHARACTER(LEN=200) :: comment = ' ' !< comment to data |
---|
461 | CHARACTER(LEN=7) :: comment_char = 'comment' !< name of attribute |
---|
462 | CHARACTER(LEN=200) :: contact_person = ' ' !< first name, last name, email adress |
---|
463 | CHARACTER(LEN=14) :: contact_person_char = 'contact_person' !< name of attribute |
---|
464 | CHARACTER(LEN=200) :: conventions = 'CF-1.7' !< netCDF convention |
---|
465 | CHARACTER(LEN=11) :: conventions_char = 'Conventions' !< name of attribute |
---|
466 | CHARACTER(LEN=23 ) :: creation_time = ' ' !< creation time of data set |
---|
467 | CHARACTER(LEN=13) :: creation_time_char = 'creation_time' !< name of attribute |
---|
468 | CHARACTER(LEN=200) :: data_content = ' ' !< content of data set |
---|
469 | CHARACTER(LEN=12) :: data_content_char = 'data_content' !< name of attribute |
---|
470 | CHARACTER(LEN=200) :: dependencies = ' ' !< dependencies of data set |
---|
471 | CHARACTER(LEN=12) :: dependencies_char = 'dependencies' !< name of attribute |
---|
472 | CHARACTER(LEN=200) :: history = ' ' !< information about data processing |
---|
473 | CHARACTER(LEN=7) :: history_char = 'history' !< name of attribute |
---|
474 | CHARACTER(LEN=200) :: institution = ' ' !< name of responsible institution |
---|
475 | CHARACTER(LEN=11) :: institution_char = 'institution' !< name of attribute |
---|
476 | CHARACTER(LEN=200) :: keywords = ' ' !< keywords of data set |
---|
477 | CHARACTER(LEN=8) :: keywords_char = 'keywords' !< name of attribute |
---|
478 | CHARACTER(LEN=200) :: licence = ' ' !< licence of data set |
---|
479 | CHARACTER(LEN=7) :: licence_char = 'licence' !< name of attribute |
---|
480 | CHARACTER(LEN=200) :: location = ' ' !< place which refers to data set |
---|
481 | CHARACTER(LEN=8) :: location_char = 'location' !< name of attribute |
---|
482 | CHARACTER(LEN=10) :: origin_lat_char = 'origin_lat' !< name of attribute |
---|
483 | CHARACTER(LEN=10) :: origin_lon_char = 'origin_lon' !< name of attribute |
---|
484 | CHARACTER(LEN=23 ) :: origin_time = '2000-01-01 00:00:00 +00' !< reference time |
---|
485 | CHARACTER(LEN=11) :: origin_time_char = 'origin_time' !< name of attribute |
---|
486 | CHARACTER(LEN=8) :: origin_x_char = 'origin_x' !< name of attribute |
---|
487 | CHARACTER(LEN=8) :: origin_y_char = 'origin_y' !< name of attribute |
---|
488 | CHARACTER(LEN=8) :: origin_z_char = 'origin_z' !< name of attribute |
---|
489 | CHARACTER(LEN=12) :: palm_version_char = 'palm_version' !< name of attribute |
---|
490 | CHARACTER(LEN=200) :: references = ' ' !< literature referring to data set |
---|
491 | CHARACTER(LEN=10) :: references_char = 'references' !< name of attribute |
---|
492 | CHARACTER(LEN=14) :: rotation_angle_char = 'rotation_angle' !< name of attribute |
---|
493 | CHARACTER(LEN=200) :: site = ' ' !< name of model domain |
---|
494 | CHARACTER(LEN=4) :: site_char = 'site' !< name of attribute |
---|
495 | CHARACTER(LEN=200) :: source = ' ' !< source of data set |
---|
496 | CHARACTER(LEN=6) :: source_char = 'source' !< name of attribute |
---|
497 | CHARACTER(LEN=200) :: title = ' ' !< title of data set |
---|
498 | CHARACTER(LEN=5) :: title_char = 'title' !< name of attribute |
---|
499 | CHARACTER(LEN=7) :: version_char = 'version' !< name of attribute |
---|
500 | |
---|
501 | INTEGER(iwp) :: version !< version of data set |
---|
502 | |
---|
503 | REAL(wp) :: origin_lat !< latitude of lower left corner |
---|
504 | REAL(wp) :: origin_lon !< longitude of lower left corner |
---|
505 | REAL(wp) :: origin_x !< easting (UTM coordinate) of lower left corner |
---|
506 | REAL(wp) :: origin_y !< northing (UTM coordinate) of lower left corner |
---|
507 | REAL(wp) :: origin_z !< reference height |
---|
508 | REAL(wp) :: palm_version !< PALM version of data set |
---|
509 | REAL(wp) :: rotation_angle !< rotation angle of coordinate system of data set |
---|
510 | END TYPE global_atts_type |
---|
511 | ! |
---|
512 | !-- Define type for coordinate reference system (crs) |
---|
513 | TYPE crs_type |
---|
514 | CHARACTER(LEN=200) :: epsg_code = 'EPSG:25831' !< EPSG code |
---|
515 | CHARACTER(LEN=200) :: grid_mapping_name = 'transverse_mercator' !< name of grid mapping |
---|
516 | CHARACTER(LEN=200) :: long_name = 'coordinate reference system' !< name of variable crs |
---|
517 | CHARACTER(LEN=200) :: units = 'm' !< unit of crs |
---|
518 | |
---|
519 | REAL(wp) :: false_easting = 500000.0_wp !< false easting |
---|
520 | REAL(wp) :: false_northing = 0.0_wp !< false northing |
---|
521 | REAL(wp) :: inverse_flattening = 298.257223563_wp !< 1/f (default for WGS84) |
---|
522 | REAL(wp) :: latitude_of_projection_origin = 0.0_wp !< latitude of projection origin |
---|
523 | REAL(wp) :: longitude_of_central_meridian = 3.0_wp !< longitude of central meridian of UTM zone (default: zone 31) |
---|
524 | REAL(wp) :: longitude_of_prime_meridian = 0.0_wp !< longitude of prime meridian |
---|
525 | REAL(wp) :: scale_factor_at_central_meridian = 0.9996_wp !< scale factor of UTM coordinates |
---|
526 | REAL(wp) :: semi_major_axis = 6378137.0_wp !< length of semi major axis (default for WGS84) |
---|
527 | END TYPE crs_type |
---|
528 | |
---|
529 | ! |
---|
530 | !-- Define variables |
---|
531 | TYPE(crs_type) :: coord_ref_sys !< coordinate reference system |
---|
532 | |
---|
533 | TYPE(dims_xy) :: dim_static !< data structure for x, y-dimension in static input file |
---|
534 | |
---|
535 | TYPE(init_type) :: init_3d !< data structure for the initialization of the 3D flow and soil fields |
---|
536 | TYPE(init_type) :: init_model !< data structure for the initialization of the model |
---|
537 | |
---|
538 | ! |
---|
539 | !-- Define 2D variables of type NC_BYTE |
---|
540 | TYPE(int_2d_8bit) :: albedo_type_f !< input variable for albedo type |
---|
541 | TYPE(int_2d_8bit) :: building_type_f !< input variable for building type |
---|
542 | TYPE(int_2d_8bit) :: pavement_type_f !< input variable for pavenment type |
---|
543 | TYPE(int_2d_8bit) :: street_crossing_f !< input variable for water type |
---|
544 | TYPE(int_2d_8bit) :: street_type_f !< input variable for water type |
---|
545 | TYPE(int_2d_8bit) :: vegetation_type_f !< input variable for vegetation type |
---|
546 | TYPE(int_2d_8bit) :: water_type_f !< input variable for water type |
---|
547 | ! |
---|
548 | !-- Define 3D variables of type NC_BYTE |
---|
549 | TYPE(int_3d_8bit) :: building_obstruction_f !< input variable for building obstruction |
---|
550 | TYPE(int_3d_8bit) :: building_obstruction_full !< input variable for building obstruction |
---|
551 | ! |
---|
552 | !-- Define 2D variables of type NC_INT |
---|
553 | TYPE(int_2d_32bit) :: building_id_f !< input variable for building ID |
---|
554 | ! |
---|
555 | !-- Define 2D variables of type NC_FLOAT |
---|
556 | TYPE(real_2d) :: terrain_height_f !< input variable for terrain height |
---|
557 | TYPE(real_2d) :: uvem_irradiance_f !< input variable for uvem irradiance lookup table |
---|
558 | TYPE(real_2d) :: uvem_integration_f !< input variable for uvem integration |
---|
559 | ! |
---|
560 | !-- Define 3D variables of type NC_FLOAT |
---|
561 | TYPE(real_3d) :: basal_area_density_f !< input variable for basal area density - resolved vegetation |
---|
562 | TYPE(real_3d) :: leaf_area_density_f !< input variable for leaf area density - resolved vegetation |
---|
563 | TYPE(real_3d) :: root_area_density_lad_f !< input variable for root area density - resolved vegetation |
---|
564 | TYPE(real_3d) :: root_area_density_lsm_f !< input variable for root area density - parametrized vegetation |
---|
565 | TYPE(real_3d) :: uvem_radiance_f !< input variable for uvem radiance lookup table |
---|
566 | TYPE(real_3d) :: uvem_projarea_f !< input variable for uvem projection area lookup table |
---|
567 | ! |
---|
568 | !-- Define input variable for buildings |
---|
569 | TYPE(build_in) :: buildings_f !< input variable for buildings |
---|
570 | ! |
---|
571 | !-- Define input variables for soil_type |
---|
572 | TYPE(soil_in) :: soil_type_f !< input variable for soil type |
---|
573 | |
---|
574 | TYPE(fracs) :: surface_fraction_f !< input variable for surface fraction |
---|
575 | |
---|
576 | TYPE(pars) :: albedo_pars_f !< input variable for albedo parameters |
---|
577 | TYPE(pars) :: building_pars_f !< input variable for building parameters |
---|
578 | TYPE(pars) :: pavement_pars_f !< input variable for pavement parameters |
---|
579 | TYPE(pars) :: pavement_subsurface_pars_f !< input variable for pavement parameters |
---|
580 | TYPE(pars) :: soil_pars_f !< input variable for soil parameters |
---|
581 | TYPE(pars) :: vegetation_pars_f !< input variable for vegetation parameters |
---|
582 | TYPE(pars) :: water_pars_f !< input variable for water parameters |
---|
583 | |
---|
584 | TYPE(pars_surf) :: building_surface_pars_f !< input variable for building surface parameters |
---|
585 | |
---|
586 | TYPE(chem_emis_att_type) :: chem_emis_att !< Input Information of Chemistry Emission Data from netcdf |
---|
587 | TYPE(chem_emis_val_type), ALLOCATABLE, DIMENSION(:) :: chem_emis !< Input Chemistry Emission Data from netcdf |
---|
588 | |
---|
589 | CHARACTER(LEN=3) :: char_lod = 'lod' !< name of level-of-detail attribute in NetCDF file |
---|
590 | |
---|
591 | CHARACTER(LEN=10) :: char_fill = '_FillValue' !< name of fill value attribute in NetCDF file |
---|
592 | |
---|
593 | CHARACTER(LEN=100) :: input_file_static = 'PIDS_STATIC' !< Name of file which comprises static input data |
---|
594 | CHARACTER(LEN=100) :: input_file_dynamic = 'PIDS_DYNAMIC' !< Name of file which comprises dynamic input data |
---|
595 | CHARACTER(LEN=100) :: input_file_chem = 'PIDS_CHEM' !< Name of file which comprises chemistry input data |
---|
596 | CHARACTER(LEN=100) :: input_file_uvem = 'PIDS_UVEM' !< Name of file which comprises static uv_exposure model input data |
---|
597 | CHARACTER(LEN=100) :: input_file_vm = 'PIDS_VM' !< Name of file which comprises virtual measurement data |
---|
598 | |
---|
599 | CHARACTER(LEN=25), ALLOCATABLE, DIMENSION(:) :: string_values !< output of string variables read from netcdf input files |
---|
600 | CHARACTER(LEN=50), DIMENSION(:), ALLOCATABLE :: vars_pids !< variable in input file |
---|
601 | |
---|
602 | INTEGER(iwp) :: id_emis !< NetCDF id of input file for chemistry emissions: TBD: It has to be removed |
---|
603 | |
---|
604 | INTEGER(iwp) :: nc_stat !< return value of nf90 function call |
---|
605 | INTEGER(iwp) :: num_var_pids !< number of variables in file |
---|
606 | INTEGER(iwp) :: pids_id !< file id |
---|
607 | |
---|
608 | LOGICAL :: input_pids_static = .FALSE. !< Flag indicating whether Palm-input-data-standard file containing static information exists |
---|
609 | LOGICAL :: input_pids_dynamic = .FALSE. !< Flag indicating whether Palm-input-data-standard file containing dynamic information exists |
---|
610 | LOGICAL :: input_pids_chem = .FALSE. !< Flag indicating whether Palm-input-data-standard file containing chemistry information exists |
---|
611 | LOGICAL :: input_pids_uvem = .FALSE. !< Flag indicating whether uv-expoure-model input file containing static information exists |
---|
612 | LOGICAL :: input_pids_vm = .FALSE. !< Flag indicating whether input file for virtual measurements exist |
---|
613 | |
---|
614 | LOGICAL :: collective_read = .FALSE. !< Enable NetCDF collective read |
---|
615 | |
---|
616 | TYPE(global_atts_type) :: input_file_atts !< global attributes of input file |
---|
617 | |
---|
618 | SAVE |
---|
619 | |
---|
620 | PRIVATE |
---|
621 | |
---|
622 | INTERFACE netcdf_data_input_check_dynamic |
---|
623 | MODULE PROCEDURE netcdf_data_input_check_dynamic |
---|
624 | END INTERFACE netcdf_data_input_check_dynamic |
---|
625 | |
---|
626 | INTERFACE netcdf_data_input_check_static |
---|
627 | MODULE PROCEDURE netcdf_data_input_check_static |
---|
628 | END INTERFACE netcdf_data_input_check_static |
---|
629 | |
---|
630 | INTERFACE netcdf_data_input_chemistry_data |
---|
631 | MODULE PROCEDURE netcdf_data_input_chemistry_data |
---|
632 | END INTERFACE netcdf_data_input_chemistry_data |
---|
633 | |
---|
634 | INTERFACE get_dimension_length |
---|
635 | MODULE PROCEDURE get_dimension_length |
---|
636 | END INTERFACE get_dimension_length |
---|
637 | |
---|
638 | INTERFACE netcdf_data_input_inquire_file |
---|
639 | MODULE PROCEDURE netcdf_data_input_inquire_file |
---|
640 | END INTERFACE netcdf_data_input_inquire_file |
---|
641 | |
---|
642 | INTERFACE netcdf_data_input_init |
---|
643 | MODULE PROCEDURE netcdf_data_input_init |
---|
644 | END INTERFACE netcdf_data_input_init |
---|
645 | |
---|
646 | INTERFACE netcdf_data_input_att |
---|
647 | MODULE PROCEDURE netcdf_data_input_att_int8 |
---|
648 | MODULE PROCEDURE netcdf_data_input_att_int32 |
---|
649 | MODULE PROCEDURE netcdf_data_input_att_real |
---|
650 | MODULE PROCEDURE netcdf_data_input_att_string |
---|
651 | END INTERFACE netcdf_data_input_att |
---|
652 | |
---|
653 | INTERFACE netcdf_data_input_init_3d |
---|
654 | MODULE PROCEDURE netcdf_data_input_init_3d |
---|
655 | END INTERFACE netcdf_data_input_init_3d |
---|
656 | |
---|
657 | INTERFACE netcdf_data_input_surface_data |
---|
658 | MODULE PROCEDURE netcdf_data_input_surface_data |
---|
659 | END INTERFACE netcdf_data_input_surface_data |
---|
660 | |
---|
661 | INTERFACE netcdf_data_input_var |
---|
662 | MODULE PROCEDURE netcdf_data_input_var_char |
---|
663 | MODULE PROCEDURE netcdf_data_input_var_real_1d |
---|
664 | MODULE PROCEDURE netcdf_data_input_var_real_2d |
---|
665 | END INTERFACE netcdf_data_input_var |
---|
666 | |
---|
667 | INTERFACE netcdf_data_input_uvem |
---|
668 | MODULE PROCEDURE netcdf_data_input_uvem |
---|
669 | END INTERFACE netcdf_data_input_uvem |
---|
670 | |
---|
671 | INTERFACE get_variable |
---|
672 | MODULE PROCEDURE get_variable_1d_char |
---|
673 | MODULE PROCEDURE get_variable_1d_int |
---|
674 | MODULE PROCEDURE get_variable_1d_real |
---|
675 | MODULE PROCEDURE get_variable_2d_int8 |
---|
676 | MODULE PROCEDURE get_variable_2d_int32 |
---|
677 | MODULE PROCEDURE get_variable_2d_real |
---|
678 | MODULE PROCEDURE get_variable_3d_int8 |
---|
679 | MODULE PROCEDURE get_variable_3d_real |
---|
680 | MODULE PROCEDURE get_variable_3d_real_dynamic |
---|
681 | MODULE PROCEDURE get_variable_4d_to_3d_real |
---|
682 | MODULE PROCEDURE get_variable_4d_real |
---|
683 | MODULE PROCEDURE get_variable_5d_to_4d_real |
---|
684 | MODULE PROCEDURE get_variable_5d_real ! (ecc) temp subroutine 4 reading 5D NC arrays |
---|
685 | MODULE PROCEDURE get_variable_5d_real_dynamic ! 2B removed as z is out of emission_values |
---|
686 | MODULE PROCEDURE get_variable_string |
---|
687 | END INTERFACE get_variable |
---|
688 | |
---|
689 | INTERFACE get_variable_pr |
---|
690 | MODULE PROCEDURE get_variable_pr |
---|
691 | END INTERFACE get_variable_pr |
---|
692 | |
---|
693 | INTERFACE get_attribute |
---|
694 | MODULE PROCEDURE get_attribute_real |
---|
695 | MODULE PROCEDURE get_attribute_int8 |
---|
696 | MODULE PROCEDURE get_attribute_int32 |
---|
697 | MODULE PROCEDURE get_attribute_string |
---|
698 | END INTERFACE get_attribute |
---|
699 | |
---|
700 | ! |
---|
701 | !-- Public data structures |
---|
702 | PUBLIC real_1d_3d, & |
---|
703 | real_2d |
---|
704 | ! |
---|
705 | !-- Public variables |
---|
706 | PUBLIC albedo_pars_f, albedo_type_f, basal_area_density_f, buildings_f, & |
---|
707 | building_id_f, building_pars_f, building_surface_pars_f, & |
---|
708 | building_type_f, & |
---|
709 | char_fill, & |
---|
710 | char_lod, & |
---|
711 | chem_emis, chem_emis_att, chem_emis_att_type, chem_emis_val_type, & |
---|
712 | coord_ref_sys, & |
---|
713 | init_3d, init_model, input_file_atts, & |
---|
714 | input_file_dynamic, & |
---|
715 | input_file_static, & |
---|
716 | input_pids_static, & |
---|
717 | input_pids_dynamic, input_pids_vm, input_file_vm, & |
---|
718 | leaf_area_density_f, & |
---|
719 | num_var_pids, & |
---|
720 | pavement_pars_f, pavement_subsurface_pars_f, pavement_type_f, & |
---|
721 | pids_id, & |
---|
722 | root_area_density_lad_f, root_area_density_lsm_f, soil_pars_f, & |
---|
723 | soil_type_f, street_crossing_f, street_type_f, surface_fraction_f, & |
---|
724 | terrain_height_f, vegetation_pars_f, vegetation_type_f, & |
---|
725 | vars_pids, & |
---|
726 | water_pars_f, water_type_f |
---|
727 | ! |
---|
728 | !-- Public uv exposure variables |
---|
729 | PUBLIC building_obstruction_f, input_file_uvem, input_pids_uvem, & |
---|
730 | netcdf_data_input_uvem, & |
---|
731 | uvem_integration_f, uvem_irradiance_f, & |
---|
732 | uvem_projarea_f, uvem_radiance_f |
---|
733 | |
---|
734 | ! |
---|
735 | !-- Public subroutines |
---|
736 | PUBLIC netcdf_data_input_check_dynamic, & |
---|
737 | netcdf_data_input_check_static, & |
---|
738 | netcdf_data_input_chemistry_data, & |
---|
739 | get_dimension_length, & |
---|
740 | netcdf_data_input_inquire_file, & |
---|
741 | netcdf_data_input_init, & |
---|
742 | netcdf_data_input_init_3d, & |
---|
743 | netcdf_data_input_att, & |
---|
744 | netcdf_data_input_surface_data, & |
---|
745 | netcdf_data_input_topo, & |
---|
746 | netcdf_data_input_var, & |
---|
747 | get_attribute, & |
---|
748 | get_variable, & |
---|
749 | get_variable_pr, & |
---|
750 | open_read_file, & |
---|
751 | check_existence, & |
---|
752 | inquire_num_variables, & |
---|
753 | inquire_variable_names, & |
---|
754 | close_input_file |
---|
755 | |
---|
756 | |
---|
757 | CONTAINS |
---|
758 | |
---|
759 | !------------------------------------------------------------------------------! |
---|
760 | ! Description: |
---|
761 | ! ------------ |
---|
762 | !> Inquires whether NetCDF input files according to Palm-input-data standard |
---|
763 | !> exist. Moreover, basic checks are performed. |
---|
764 | !------------------------------------------------------------------------------! |
---|
765 | SUBROUTINE netcdf_data_input_inquire_file |
---|
766 | |
---|
767 | USE control_parameters, & |
---|
768 | ONLY: topo_no_distinct |
---|
769 | |
---|
770 | IMPLICIT NONE |
---|
771 | |
---|
772 | #if defined ( __netcdf ) |
---|
773 | INQUIRE( FILE = TRIM( input_file_static ) // TRIM( coupling_char ), & |
---|
774 | EXIST = input_pids_static ) |
---|
775 | INQUIRE( FILE = TRIM( input_file_dynamic ) // TRIM( coupling_char ), & |
---|
776 | EXIST = input_pids_dynamic ) |
---|
777 | INQUIRE( FILE = TRIM( input_file_chem ) // TRIM( coupling_char ), & |
---|
778 | EXIST = input_pids_chem ) |
---|
779 | INQUIRE( FILE = TRIM( input_file_uvem ) // TRIM( coupling_char ), & |
---|
780 | EXIST = input_pids_uvem ) |
---|
781 | INQUIRE( FILE = TRIM( input_file_vm ) // TRIM( coupling_char ), & |
---|
782 | EXIST = input_pids_vm ) |
---|
783 | #endif |
---|
784 | |
---|
785 | ! |
---|
786 | !-- As long as topography can be input via ASCII format, no distinction |
---|
787 | !-- between building and terrain can be made. This case, classify all |
---|
788 | !-- surfaces as default type. Same in case land-surface and urban-surface |
---|
789 | !-- model are not applied. |
---|
790 | IF ( .NOT. input_pids_static ) THEN |
---|
791 | topo_no_distinct = .TRUE. |
---|
792 | ENDIF |
---|
793 | |
---|
794 | END SUBROUTINE netcdf_data_input_inquire_file |
---|
795 | |
---|
796 | !------------------------------------------------------------------------------! |
---|
797 | ! Description: |
---|
798 | ! ------------ |
---|
799 | !> Reads global attributes and coordinate reference system required for |
---|
800 | !> initialization of the model. |
---|
801 | !------------------------------------------------------------------------------! |
---|
802 | SUBROUTINE netcdf_data_input_init |
---|
803 | |
---|
804 | IMPLICIT NONE |
---|
805 | |
---|
806 | INTEGER(iwp) :: id_mod !< NetCDF id of input file |
---|
807 | INTEGER(iwp) :: var_id_crs !< NetCDF id of variable crs |
---|
808 | |
---|
809 | IF ( .NOT. input_pids_static ) RETURN |
---|
810 | |
---|
811 | #if defined ( __netcdf ) |
---|
812 | ! |
---|
813 | !-- Open file in read-only mode |
---|
814 | CALL open_read_file( TRIM( input_file_static ) // & |
---|
815 | TRIM( coupling_char ), id_mod ) |
---|
816 | ! |
---|
817 | !-- Read global attributes |
---|
818 | CALL get_attribute( id_mod, input_file_atts%origin_lat_char, & |
---|
819 | input_file_atts%origin_lat, .TRUE. ) |
---|
820 | |
---|
821 | CALL get_attribute( id_mod, input_file_atts%origin_lon_char, & |
---|
822 | input_file_atts%origin_lon, .TRUE. ) |
---|
823 | |
---|
824 | CALL get_attribute( id_mod, input_file_atts%origin_time_char, & |
---|
825 | input_file_atts%origin_time, .TRUE. ) |
---|
826 | |
---|
827 | CALL get_attribute( id_mod, input_file_atts%origin_x_char, & |
---|
828 | input_file_atts%origin_x, .TRUE. ) |
---|
829 | |
---|
830 | CALL get_attribute( id_mod, input_file_atts%origin_y_char, & |
---|
831 | input_file_atts%origin_y, .TRUE. ) |
---|
832 | |
---|
833 | CALL get_attribute( id_mod, input_file_atts%origin_z_char, & |
---|
834 | input_file_atts%origin_z, .TRUE. ) |
---|
835 | |
---|
836 | CALL get_attribute( id_mod, input_file_atts%rotation_angle_char, & |
---|
837 | input_file_atts%rotation_angle, .TRUE. ) |
---|
838 | |
---|
839 | CALL get_attribute( id_mod, input_file_atts%author_char, & |
---|
840 | input_file_atts%author, .TRUE., no_abort=.FALSE. ) |
---|
841 | CALL get_attribute( id_mod, input_file_atts%contact_person_char, & |
---|
842 | input_file_atts%contact_person, .TRUE., no_abort=.FALSE. ) |
---|
843 | CALL get_attribute( id_mod, input_file_atts%institution_char, & |
---|
844 | input_file_atts%institution, .TRUE., no_abort=.FALSE. ) |
---|
845 | CALL get_attribute( id_mod, input_file_atts%acronym_char, & |
---|
846 | input_file_atts%acronym, .TRUE., no_abort=.FALSE. ) |
---|
847 | |
---|
848 | CALL get_attribute( id_mod, input_file_atts%campaign_char, & |
---|
849 | input_file_atts%campaign, .TRUE., no_abort=.FALSE. ) |
---|
850 | CALL get_attribute( id_mod, input_file_atts%location_char, & |
---|
851 | input_file_atts%location, .TRUE., no_abort=.FALSE. ) |
---|
852 | CALL get_attribute( id_mod, input_file_atts%site_char, & |
---|
853 | input_file_atts%site, .TRUE., no_abort=.FALSE. ) |
---|
854 | |
---|
855 | CALL get_attribute( id_mod, input_file_atts%source_char, & |
---|
856 | input_file_atts%source, .TRUE., no_abort=.FALSE. ) |
---|
857 | CALL get_attribute( id_mod, input_file_atts%references_char, & |
---|
858 | input_file_atts%references, .TRUE., no_abort=.FALSE. ) |
---|
859 | CALL get_attribute( id_mod, input_file_atts%keywords_char, & |
---|
860 | input_file_atts%keywords, .TRUE., no_abort=.FALSE. ) |
---|
861 | CALL get_attribute( id_mod, input_file_atts%licence_char, & |
---|
862 | input_file_atts%licence, .TRUE., no_abort=.FALSE. ) |
---|
863 | CALL get_attribute( id_mod, input_file_atts%comment_char, & |
---|
864 | input_file_atts%comment, .TRUE., no_abort=.FALSE. ) |
---|
865 | ! |
---|
866 | !-- Read coordinate reference system if available |
---|
867 | nc_stat = NF90_INQ_VARID( id_mod, 'crs', var_id_crs ) |
---|
868 | IF ( nc_stat == NF90_NOERR ) THEN |
---|
869 | CALL get_attribute( id_mod, 'epsg_code', & |
---|
870 | coord_ref_sys%epsg_code, & |
---|
871 | .FALSE., 'crs' ) |
---|
872 | CALL get_attribute( id_mod, 'false_easting', & |
---|
873 | coord_ref_sys%false_easting, & |
---|
874 | .FALSE., 'crs' ) |
---|
875 | CALL get_attribute( id_mod, 'false_northing', & |
---|
876 | coord_ref_sys%false_northing, & |
---|
877 | .FALSE., 'crs' ) |
---|
878 | CALL get_attribute( id_mod, 'grid_mapping_name', & |
---|
879 | coord_ref_sys%grid_mapping_name, & |
---|
880 | .FALSE., 'crs' ) |
---|
881 | CALL get_attribute( id_mod, 'inverse_flattening', & |
---|
882 | coord_ref_sys%inverse_flattening, & |
---|
883 | .FALSE., 'crs' ) |
---|
884 | CALL get_attribute( id_mod, 'latitude_of_projection_origin', & |
---|
885 | coord_ref_sys%latitude_of_projection_origin, & |
---|
886 | .FALSE., 'crs' ) |
---|
887 | CALL get_attribute( id_mod, 'long_name', & |
---|
888 | coord_ref_sys%long_name, & |
---|
889 | .FALSE., 'crs' ) |
---|
890 | CALL get_attribute( id_mod, 'longitude_of_central_meridian', & |
---|
891 | coord_ref_sys%longitude_of_central_meridian, & |
---|
892 | .FALSE., 'crs' ) |
---|
893 | CALL get_attribute( id_mod, 'longitude_of_prime_meridian', & |
---|
894 | coord_ref_sys%longitude_of_prime_meridian, & |
---|
895 | .FALSE., 'crs' ) |
---|
896 | CALL get_attribute( id_mod, 'scale_factor_at_central_meridian', & |
---|
897 | coord_ref_sys%scale_factor_at_central_meridian, & |
---|
898 | .FALSE., 'crs' ) |
---|
899 | CALL get_attribute( id_mod, 'semi_major_axis', & |
---|
900 | coord_ref_sys%semi_major_axis, & |
---|
901 | .FALSE., 'crs' ) |
---|
902 | CALL get_attribute( id_mod, 'units', & |
---|
903 | coord_ref_sys%units, & |
---|
904 | .FALSE., 'crs' ) |
---|
905 | ELSE |
---|
906 | ! |
---|
907 | !-- Calculate central meridian from origin_lon |
---|
908 | coord_ref_sys%longitude_of_central_meridian = & |
---|
909 | CEILING( input_file_atts%origin_lon / 6.0_wp ) * 6.0_wp - 3.0_wp |
---|
910 | ENDIF |
---|
911 | ! |
---|
912 | !-- Finally, close input file |
---|
913 | CALL close_input_file( id_mod ) |
---|
914 | #endif |
---|
915 | ! |
---|
916 | !-- Copy latitude, longitude, origin_z, rotation angle on init type |
---|
917 | init_model%latitude = input_file_atts%origin_lat |
---|
918 | init_model%longitude = input_file_atts%origin_lon |
---|
919 | init_model%origin_time = input_file_atts%origin_time |
---|
920 | init_model%origin_x = input_file_atts%origin_x |
---|
921 | init_model%origin_y = input_file_atts%origin_y |
---|
922 | init_model%origin_z = input_file_atts%origin_z |
---|
923 | init_model%rotation_angle = input_file_atts%rotation_angle |
---|
924 | |
---|
925 | ! |
---|
926 | !-- In case of nested runs, each model domain might have different longitude |
---|
927 | !-- and latitude, which would result in different Coriolis parameters and |
---|
928 | !-- sun-zenith angles. To avoid this, longitude and latitude in each model |
---|
929 | !-- domain will be set to the values of the root model. Please note, this |
---|
930 | !-- synchronization is required already here. |
---|
931 | #if defined( __parallel ) |
---|
932 | CALL MPI_BCAST( init_model%latitude, 1, MPI_REAL, 0, & |
---|
933 | MPI_COMM_WORLD, ierr ) |
---|
934 | CALL MPI_BCAST( init_model%longitude, 1, MPI_REAL, 0, & |
---|
935 | MPI_COMM_WORLD, ierr ) |
---|
936 | #endif |
---|
937 | |
---|
938 | END SUBROUTINE netcdf_data_input_init |
---|
939 | |
---|
940 | !------------------------------------------------------------------------------! |
---|
941 | ! Description: |
---|
942 | ! ------------ |
---|
943 | !> Read an array of characters. |
---|
944 | !------------------------------------------------------------------------------! |
---|
945 | SUBROUTINE netcdf_data_input_var_char( val, search_string, id_mod ) |
---|
946 | |
---|
947 | IMPLICIT NONE |
---|
948 | |
---|
949 | CHARACTER(LEN=*) :: search_string !< name of the variable |
---|
950 | CHARACTER(LEN=*), DIMENSION(:) :: val !< variable which should be read |
---|
951 | |
---|
952 | INTEGER(iwp) :: id_mod !< NetCDF id of input file |
---|
953 | |
---|
954 | #if defined ( __netcdf ) |
---|
955 | ! |
---|
956 | !-- Read variable |
---|
957 | CALL get_variable( id_mod, search_string, val ) |
---|
958 | #endif |
---|
959 | |
---|
960 | END SUBROUTINE netcdf_data_input_var_char |
---|
961 | |
---|
962 | !------------------------------------------------------------------------------! |
---|
963 | ! Description: |
---|
964 | ! ------------ |
---|
965 | !> Read an 1D array of REAL values. |
---|
966 | !------------------------------------------------------------------------------! |
---|
967 | SUBROUTINE netcdf_data_input_var_real_1d( val, search_string, id_mod ) |
---|
968 | |
---|
969 | IMPLICIT NONE |
---|
970 | |
---|
971 | CHARACTER(LEN=*) :: search_string !< name of the variable |
---|
972 | |
---|
973 | INTEGER(iwp) :: id_mod !< NetCDF id of input file |
---|
974 | |
---|
975 | REAL(wp), DIMENSION(:) :: val !< variable which should be read |
---|
976 | |
---|
977 | #if defined ( __netcdf ) |
---|
978 | ! |
---|
979 | !-- Read variable |
---|
980 | CALL get_variable( id_mod, search_string, val ) |
---|
981 | #endif |
---|
982 | |
---|
983 | END SUBROUTINE netcdf_data_input_var_real_1d |
---|
984 | |
---|
985 | !------------------------------------------------------------------------------! |
---|
986 | ! Description: |
---|
987 | ! ------------ |
---|
988 | !> Read an 1D array of REAL values. |
---|
989 | !------------------------------------------------------------------------------! |
---|
990 | SUBROUTINE netcdf_data_input_var_real_2d( val, search_string, & |
---|
991 | id_mod, d1s, d1e, d2s, d2e ) |
---|
992 | |
---|
993 | IMPLICIT NONE |
---|
994 | |
---|
995 | CHARACTER(LEN=*) :: search_string !< name of the variable |
---|
996 | |
---|
997 | INTEGER(iwp) :: id_mod !< NetCDF id of input file |
---|
998 | INTEGER(iwp) :: d1e !< end index of first dimension to be read |
---|
999 | INTEGER(iwp) :: d2e !< end index of second dimension to be read |
---|
1000 | INTEGER(iwp) :: d1s !< start index of first dimension to be read |
---|
1001 | INTEGER(iwp) :: d2s !< start index of second dimension to be read |
---|
1002 | |
---|
1003 | REAL(wp), DIMENSION(:,:) :: val !< variable which should be read |
---|
1004 | |
---|
1005 | #if defined ( __netcdf ) |
---|
1006 | ! |
---|
1007 | !-- Read character variable |
---|
1008 | CALL get_variable( id_mod, search_string, val, d1s, d1e, d2s, d2e ) |
---|
1009 | #endif |
---|
1010 | |
---|
1011 | END SUBROUTINE netcdf_data_input_var_real_2d |
---|
1012 | |
---|
1013 | !------------------------------------------------------------------------------! |
---|
1014 | ! Description: |
---|
1015 | ! ------------ |
---|
1016 | !> Read a global string attribute |
---|
1017 | !------------------------------------------------------------------------------! |
---|
1018 | SUBROUTINE netcdf_data_input_att_string( val, search_string, id_mod, & |
---|
1019 | input_file, global, openclose, & |
---|
1020 | variable_name ) |
---|
1021 | |
---|
1022 | IMPLICIT NONE |
---|
1023 | |
---|
1024 | CHARACTER(LEN=*) :: search_string !< name of the attribue |
---|
1025 | CHARACTER(LEN=*) :: val !< attribute |
---|
1026 | |
---|
1027 | CHARACTER(LEN=*) :: input_file !< name of input file |
---|
1028 | CHARACTER(LEN=*) :: openclose !< string indicating whether NetCDF needs to be opend or closed |
---|
1029 | CHARACTER(LEN=*) :: variable_name !< string indicating whether NetCDF needs to be opend or closed |
---|
1030 | |
---|
1031 | INTEGER(iwp) :: id_mod !< NetCDF id of input file |
---|
1032 | |
---|
1033 | LOGICAL :: global !< flag indicating a global or a variable's attribute |
---|
1034 | |
---|
1035 | #if defined ( __netcdf ) |
---|
1036 | ! |
---|
1037 | !-- Open file in read-only mode if necessary |
---|
1038 | IF ( openclose == 'open' ) THEN |
---|
1039 | CALL open_read_file( TRIM( input_file ) // TRIM( coupling_char ), & |
---|
1040 | id_mod ) |
---|
1041 | ENDIF |
---|
1042 | ! |
---|
1043 | !-- Read global attribute |
---|
1044 | IF ( global ) THEN |
---|
1045 | CALL get_attribute( id_mod, search_string, val, global ) |
---|
1046 | ! |
---|
1047 | !-- Read variable attribute |
---|
1048 | ELSE |
---|
1049 | CALL get_attribute( id_mod, search_string, val, global, variable_name ) |
---|
1050 | ENDIF |
---|
1051 | ! |
---|
1052 | !-- Close input file |
---|
1053 | IF ( openclose == 'close' ) CALL close_input_file( id_mod ) |
---|
1054 | #endif |
---|
1055 | |
---|
1056 | END SUBROUTINE netcdf_data_input_att_string |
---|
1057 | |
---|
1058 | !------------------------------------------------------------------------------! |
---|
1059 | ! Description: |
---|
1060 | ! ------------ |
---|
1061 | !> Read a global 8-bit integer attribute |
---|
1062 | !------------------------------------------------------------------------------! |
---|
1063 | SUBROUTINE netcdf_data_input_att_int8( val, search_string, id_mod, & |
---|
1064 | input_file, global, openclose, & |
---|
1065 | variable_name ) |
---|
1066 | |
---|
1067 | IMPLICIT NONE |
---|
1068 | |
---|
1069 | CHARACTER(LEN=*) :: search_string !< name of the attribue |
---|
1070 | |
---|
1071 | CHARACTER(LEN=*) :: input_file !< name of input file |
---|
1072 | CHARACTER(LEN=*) :: openclose !< string indicating whether NetCDF needs to be opend or closed |
---|
1073 | CHARACTER(LEN=*) :: variable_name !< string indicating whether NetCDF needs to be opend or closed |
---|
1074 | |
---|
1075 | INTEGER(iwp) :: id_mod !< NetCDF id of input file |
---|
1076 | INTEGER(KIND=1) :: val !< value of the attribute |
---|
1077 | |
---|
1078 | LOGICAL :: global !< flag indicating a global or a variable's attribute |
---|
1079 | |
---|
1080 | #if defined ( __netcdf ) |
---|
1081 | ! |
---|
1082 | !-- Open file in read-only mode |
---|
1083 | IF ( openclose == 'open' ) THEN |
---|
1084 | CALL open_read_file( TRIM( input_file ) // TRIM( coupling_char ), & |
---|
1085 | id_mod ) |
---|
1086 | ENDIF |
---|
1087 | ! |
---|
1088 | !-- Read global attribute |
---|
1089 | IF ( global ) THEN |
---|
1090 | CALL get_attribute( id_mod, search_string, val, global ) |
---|
1091 | ! |
---|
1092 | !-- Read variable attribute |
---|
1093 | ELSE |
---|
1094 | CALL get_attribute( id_mod, search_string, val, global, variable_name ) |
---|
1095 | ENDIF |
---|
1096 | ! |
---|
1097 | !-- Finally, close input file |
---|
1098 | IF ( openclose == 'close' ) CALL close_input_file( id_mod ) |
---|
1099 | #endif |
---|
1100 | |
---|
1101 | END SUBROUTINE netcdf_data_input_att_int8 |
---|
1102 | |
---|
1103 | !------------------------------------------------------------------------------! |
---|
1104 | ! Description: |
---|
1105 | ! ------------ |
---|
1106 | !> Read a global 32-bit integer attribute |
---|
1107 | !------------------------------------------------------------------------------! |
---|
1108 | SUBROUTINE netcdf_data_input_att_int32( val, search_string, id_mod, & |
---|
1109 | input_file, global, openclose, & |
---|
1110 | variable_name ) |
---|
1111 | |
---|
1112 | IMPLICIT NONE |
---|
1113 | |
---|
1114 | CHARACTER(LEN=*) :: search_string !< name of the attribue |
---|
1115 | |
---|
1116 | CHARACTER(LEN=*) :: input_file !< name of input file |
---|
1117 | CHARACTER(LEN=*) :: openclose !< string indicating whether NetCDF needs to be opend or closed |
---|
1118 | CHARACTER(LEN=*) :: variable_name !< string indicating whether NetCDF needs to be opend or closed |
---|
1119 | |
---|
1120 | INTEGER(iwp) :: id_mod !< NetCDF id of input file |
---|
1121 | INTEGER(iwp) :: val !< value of the attribute |
---|
1122 | |
---|
1123 | LOGICAL :: global !< flag indicating a global or a variable's attribute |
---|
1124 | |
---|
1125 | #if defined ( __netcdf ) |
---|
1126 | ! |
---|
1127 | !-- Open file in read-only mode |
---|
1128 | IF ( openclose == 'open' ) THEN |
---|
1129 | CALL open_read_file( TRIM( input_file ) // TRIM( coupling_char ), & |
---|
1130 | id_mod ) |
---|
1131 | ENDIF |
---|
1132 | ! |
---|
1133 | !-- Read global attribute |
---|
1134 | IF ( global ) THEN |
---|
1135 | CALL get_attribute( id_mod, search_string, val, global ) |
---|
1136 | ! |
---|
1137 | !-- Read variable attribute |
---|
1138 | ELSE |
---|
1139 | CALL get_attribute( id_mod, search_string, val, global, variable_name ) |
---|
1140 | ENDIF |
---|
1141 | ! |
---|
1142 | !-- Finally, close input file |
---|
1143 | IF ( openclose == 'close' ) CALL close_input_file( id_mod ) |
---|
1144 | #endif |
---|
1145 | |
---|
1146 | END SUBROUTINE netcdf_data_input_att_int32 |
---|
1147 | |
---|
1148 | !------------------------------------------------------------------------------! |
---|
1149 | ! Description: |
---|
1150 | ! ------------ |
---|
1151 | !> Read a global real attribute |
---|
1152 | !------------------------------------------------------------------------------! |
---|
1153 | SUBROUTINE netcdf_data_input_att_real( val, search_string, id_mod, & |
---|
1154 | input_file, global, openclose, & |
---|
1155 | variable_name ) |
---|
1156 | |
---|
1157 | IMPLICIT NONE |
---|
1158 | |
---|
1159 | CHARACTER(LEN=*) :: search_string !< name of the attribue |
---|
1160 | |
---|
1161 | CHARACTER(LEN=*) :: input_file !< name of input file |
---|
1162 | CHARACTER(LEN=*) :: openclose !< string indicating whether NetCDF needs to be opend or closed |
---|
1163 | CHARACTER(LEN=*) :: variable_name !< string indicating whether NetCDF needs to be opend or closed |
---|
1164 | |
---|
1165 | INTEGER(iwp) :: id_mod !< NetCDF id of input file |
---|
1166 | |
---|
1167 | LOGICAL :: global !< flag indicating a global or a variable's attribute |
---|
1168 | |
---|
1169 | REAL(wp) :: val !< value of the attribute |
---|
1170 | |
---|
1171 | #if defined ( __netcdf ) |
---|
1172 | ! |
---|
1173 | !-- Open file in read-only mode |
---|
1174 | IF ( openclose == 'open' ) THEN |
---|
1175 | CALL open_read_file( TRIM( input_file ) // TRIM( coupling_char ), & |
---|
1176 | id_mod ) |
---|
1177 | ENDIF |
---|
1178 | ! |
---|
1179 | !-- Read global attribute |
---|
1180 | IF ( global ) THEN |
---|
1181 | CALL get_attribute( id_mod, search_string, val, global ) |
---|
1182 | ! |
---|
1183 | !-- Read variable attribute |
---|
1184 | ELSE |
---|
1185 | CALL get_attribute( id_mod, search_string, val, global, variable_name ) |
---|
1186 | ENDIF |
---|
1187 | ! |
---|
1188 | !-- Finally, close input file |
---|
1189 | IF ( openclose == 'close' ) CALL close_input_file( id_mod ) |
---|
1190 | #endif |
---|
1191 | |
---|
1192 | END SUBROUTINE netcdf_data_input_att_real |
---|
1193 | |
---|
1194 | !------------------------------------------------------------------------------! |
---|
1195 | ! Description: |
---|
1196 | ! ------------ |
---|
1197 | !> Reads Chemistry NETCDF Input data, such as emission values, emission species, etc. |
---|
1198 | !------------------------------------------------------------------------------! |
---|
1199 | |
---|
1200 | SUBROUTINE netcdf_data_input_chemistry_data(emt_att,emt) |
---|
1201 | |
---|
1202 | USE chem_modules, & |
---|
1203 | ONLY: emiss_lod, time_fac_type, surface_csflux_name |
---|
1204 | |
---|
1205 | USE control_parameters, & |
---|
1206 | ONLY: message_string |
---|
1207 | |
---|
1208 | USE indices, & |
---|
1209 | ONLY: nxl, nxr, nys, nyn |
---|
1210 | |
---|
1211 | IMPLICIT NONE |
---|
1212 | |
---|
1213 | TYPE(chem_emis_att_type), INTENT(INOUT) :: emt_att |
---|
1214 | TYPE(chem_emis_val_type), ALLOCATABLE, DIMENSION(:), INTENT(INOUT) :: emt |
---|
1215 | |
---|
1216 | INTEGER(iwp) :: i, j, k !< generic counters |
---|
1217 | INTEGER(iwp) :: ispec !< index for number of emission species in input |
---|
1218 | INTEGER(iwp) :: len_dims !< Length of dimension |
---|
1219 | INTEGER(iwp) :: num_vars !< number of variables in netcdf input file |
---|
1220 | |
---|
1221 | ! |
---|
1222 | !-- dum_var_4d are designed to read in emission_values from the chemistry netCDF file. |
---|
1223 | !-- Currently the vestigial "z" dimension in emission_values makes it a 5D array, |
---|
1224 | !-- hence the corresponding dum_var_5d array. When the "z" dimension is removed |
---|
1225 | !-- completely, dum_var_4d will be used instead |
---|
1226 | !-- (ecc 20190425) |
---|
1227 | |
---|
1228 | ! REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:) :: dum_var_4d !< temp array 4 4D chem emission data |
---|
1229 | REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:,:) :: dum_var_5d !< temp array 4 5D chem emission data |
---|
1230 | |
---|
1231 | ! |
---|
1232 | !-- Start processing data |
---|
1233 | ! |
---|
1234 | !-- Emission LOD 0 (Parameterized mode) |
---|
1235 | |
---|
1236 | IF ( emiss_lod == 0 ) THEN |
---|
1237 | |
---|
1238 | ! for reference (ecc) |
---|
1239 | ! IF (TRIM(mode_emis) == "PARAMETERIZED" .OR. TRIM(mode_emis) == "parameterized") THEN |
---|
1240 | |
---|
1241 | ispec=1 |
---|
1242 | emt_att%n_emiss_species = 0 |
---|
1243 | |
---|
1244 | ! |
---|
1245 | !-- number of species |
---|
1246 | |
---|
1247 | DO WHILE (TRIM( surface_csflux_name( ispec ) ) /= 'novalue' ) |
---|
1248 | |
---|
1249 | emt_att%n_emiss_species = emt_att%n_emiss_species + 1 |
---|
1250 | ispec=ispec+1 |
---|
1251 | ! |
---|
1252 | !-- followling line retained for compatibility with salsa_mod |
---|
1253 | !-- which still uses emt_att%nspec heavily (ecc) |
---|
1254 | |
---|
1255 | emt_att%nspec = emt_att%nspec + 1 |
---|
1256 | |
---|
1257 | ENDDO |
---|
1258 | |
---|
1259 | ! |
---|
1260 | !-- allocate emission values data type arrays |
---|
1261 | |
---|
1262 | ALLOCATE ( emt(emt_att%n_emiss_species) ) |
---|
1263 | |
---|
1264 | ! |
---|
1265 | !-- Read EMISSION SPECIES NAMES |
---|
1266 | |
---|
1267 | ! |
---|
1268 | !-- allocate space for strings |
---|
1269 | |
---|
1270 | ALLOCATE (emt_att%species_name(emt_att%n_emiss_species) ) |
---|
1271 | |
---|
1272 | DO ispec = 1, emt_att%n_emiss_species |
---|
1273 | emt_att%species_name(ispec) = TRIM(surface_csflux_name(ispec)) |
---|
1274 | ENDDO |
---|
1275 | |
---|
1276 | ! |
---|
1277 | !-- LOD 1 (default mode) and LOD 2 (pre-processed mode) |
---|
1278 | |
---|
1279 | ELSE |
---|
1280 | |
---|
1281 | #if defined ( __netcdf ) |
---|
1282 | |
---|
1283 | IF ( .NOT. input_pids_chem ) RETURN |
---|
1284 | |
---|
1285 | ! |
---|
1286 | !-- first we allocate memory space for the emission species and then |
---|
1287 | !-- we differentiate between LOD 1 (default mode) and LOD 2 (pre-processed mode) |
---|
1288 | |
---|
1289 | ! |
---|
1290 | !-- open emission data file ( {palmcase}_chemistry ) |
---|
1291 | |
---|
1292 | CALL open_read_file ( TRIM(input_file_chem) // TRIM(coupling_char), id_emis ) |
---|
1293 | |
---|
1294 | ! |
---|
1295 | !-- inquire number of variables |
---|
1296 | |
---|
1297 | CALL inquire_num_variables ( id_emis, num_vars ) |
---|
1298 | |
---|
1299 | ! |
---|
1300 | !-- Get General Dimension Lengths: only # species and # categories. |
---|
1301 | !-- Tther dimensions depend on the emission mode or specific components |
---|
1302 | |
---|
1303 | CALL get_dimension_length ( id_emis, emt_att%n_emiss_species, 'nspecies' ) |
---|
1304 | |
---|
1305 | ! |
---|
1306 | !-- backward compatibility for salsa_mod (ecc) |
---|
1307 | |
---|
1308 | emt_att%nspec = emt_att%n_emiss_species |
---|
1309 | |
---|
1310 | ! |
---|
1311 | !-- Allocate emission values data type arrays |
---|
1312 | |
---|
1313 | ALLOCATE ( emt(emt_att%n_emiss_species) ) |
---|
1314 | |
---|
1315 | ! |
---|
1316 | !-- READING IN SPECIES NAMES |
---|
1317 | |
---|
1318 | ! |
---|
1319 | !-- Allocate memory for species names |
---|
1320 | |
---|
1321 | ALLOCATE ( emt_att%species_name(emt_att%n_emiss_species) ) |
---|
1322 | |
---|
1323 | ! |
---|
1324 | !-- Retrieve variable name (again, should use n_emiss_strlen) |
---|
1325 | |
---|
1326 | CALL get_variable( id_emis, 'emission_name', & |
---|
1327 | string_values, emt_att%n_emiss_species ) |
---|
1328 | emt_att%species_name=string_values |
---|
1329 | |
---|
1330 | ! |
---|
1331 | !-- dealocate string_values previously allocated in get_variable call |
---|
1332 | |
---|
1333 | IF ( ALLOCATED(string_values) ) DEALLOCATE (string_values) |
---|
1334 | |
---|
1335 | ! |
---|
1336 | !-- READING IN SPECIES INDICES |
---|
1337 | |
---|
1338 | ! |
---|
1339 | !-- Allocate memory for species indices |
---|
1340 | |
---|
1341 | ALLOCATE ( emt_att%species_index(emt_att%n_emiss_species) ) |
---|
1342 | |
---|
1343 | ! |
---|
1344 | !-- Retrieve variable data |
---|
1345 | |
---|
1346 | CALL get_variable( id_emis, 'emission_index', emt_att%species_index ) |
---|
1347 | ! |
---|
1348 | !-- Now the routine has to distinguish between chemistry emission |
---|
1349 | !-- LOD 1 (DEFAULT mode) and LOD 2 (PRE-PROCESSED mode) |
---|
1350 | |
---|
1351 | ! |
---|
1352 | !-- START OF EMISSION LOD 1 (DEFAULT MODE) |
---|
1353 | |
---|
1354 | |
---|
1355 | IF ( emiss_lod == 1 ) THEN |
---|
1356 | |
---|
1357 | ! for reference (ecc) |
---|
1358 | ! IF (TRIM(mode_emis) == "DEFAULT" .OR. TRIM(mode_emis) == "default") THEN |
---|
1359 | |
---|
1360 | ! |
---|
1361 | !-- get number of emission categories |
---|
1362 | |
---|
1363 | CALL get_dimension_length ( id_emis, emt_att%ncat, 'ncat' ) |
---|
1364 | |
---|
1365 | !-- READING IN EMISSION CATEGORIES INDICES |
---|
1366 | |
---|
1367 | ALLOCATE ( emt_att%cat_index(emt_att%ncat) ) |
---|
1368 | |
---|
1369 | ! |
---|
1370 | !-- Retrieve variable data |
---|
1371 | |
---|
1372 | CALL get_variable( id_emis, 'emission_cat_index', emt_att%cat_index ) |
---|
1373 | |
---|
1374 | |
---|
1375 | ! |
---|
1376 | !-- Loop through individual species to get basic information on |
---|
1377 | !-- VOC/PM/NOX/SOX |
---|
1378 | |
---|
1379 | !------------------------------------------------------------------------------ |
---|
1380 | !-- NOTE - CHECK ARRAY INDICES FOR READING IN NAMES AND SPECIES |
---|
1381 | !-- IN LOD1 (DEFAULT MODE) FOR THE VARIOUS MODE SPLITS |
---|
1382 | !-- AS ALL ID_EMIS CONDITIONALS HAVE BEEN REMOVED FROM GET_VAR |
---|
1383 | !-- FUNCTIONS. IN THEORY THIS WOULD MEAN ALL ARRAYS SHOULD BE |
---|
1384 | !-- READ FROM 0 to N-1 (C CONVENTION) AS OPPOSED TO 1 to N |
---|
1385 | !-- (FORTRAN CONVENTION). KEEP THIS IN MIND !! |
---|
1386 | !-- (ecc 20190424) |
---|
1387 | !------------------------------------------------------------------------------ |
---|
1388 | |
---|
1389 | DO ispec = 1, emt_att%n_emiss_species |
---|
1390 | |
---|
1391 | ! |
---|
1392 | !-- VOC DATA (name and composition) |
---|
1393 | |
---|
1394 | IF ( TRIM(emt_att%species_name(ispec)) == "VOC" .OR. & |
---|
1395 | TRIM(emt_att%species_name(ispec)) == "voc" ) THEN |
---|
1396 | |
---|
1397 | ! |
---|
1398 | !-- VOC name |
---|
1399 | CALL get_dimension_length ( id_emis, emt_att%nvoc, 'nvoc' ) |
---|
1400 | ALLOCATE ( emt_att%voc_name(emt_att%nvoc) ) |
---|
1401 | CALL get_variable ( id_emis,"emission_voc_name", & |
---|
1402 | string_values, emt_att%nvoc ) |
---|
1403 | emt_att%voc_name = string_values |
---|
1404 | IF ( ALLOCATED(string_values) ) DEALLOCATE (string_values) |
---|
1405 | |
---|
1406 | ! |
---|
1407 | !-- VOC composition |
---|
1408 | |
---|
1409 | ALLOCATE ( emt_att%voc_comp(emt_att%ncat,emt_att%nvoc) ) |
---|
1410 | CALL get_variable ( id_emis, "composition_voc", emt_att%voc_comp, & |
---|
1411 | 1, emt_att%ncat, 1, emt_att%nvoc ) |
---|
1412 | |
---|
1413 | ENDIF ! VOC |
---|
1414 | |
---|
1415 | ! |
---|
1416 | !-- PM DATA (name and composition) |
---|
1417 | |
---|
1418 | IF ( TRIM(emt_att%species_name(ispec)) == "PM" .OR. & |
---|
1419 | TRIM(emt_att%species_name(ispec)) == "pm") THEN |
---|
1420 | |
---|
1421 | ! |
---|
1422 | !-- PM name |
---|
1423 | |
---|
1424 | CALL get_dimension_length ( id_emis, emt_att%npm, 'npm' ) |
---|
1425 | ALLOCATE ( emt_att%pm_name(emt_att%npm) ) |
---|
1426 | CALL get_variable ( id_emis, "pm_name", string_values, emt_att%npm ) |
---|
1427 | emt_att%pm_name = string_values |
---|
1428 | IF ( ALLOCATED(string_values) ) DEALLOCATE (string_values) |
---|
1429 | |
---|
1430 | ! |
---|
1431 | !-- PM composition (PM1, PM2.5 and PM10) |
---|
1432 | |
---|
1433 | len_dims = 3 ! PM1, PM2.5, PM10 |
---|
1434 | ALLOCATE(emt_att%pm_comp(emt_att%ncat,emt_att%npm,len_dims)) |
---|
1435 | CALL get_variable ( id_emis, "composition_pm", emt_att%pm_comp, & |
---|
1436 | 1, emt_att%ncat, 1, emt_att%npm, 1, len_dims ) |
---|
1437 | |
---|
1438 | ENDIF ! PM |
---|
1439 | |
---|
1440 | ! |
---|
1441 | !-- NOX (NO and NO2) |
---|
1442 | |
---|
1443 | IF ( TRIM(emt_att%species_name(ispec)) == "NOX" .OR. & |
---|
1444 | TRIM(emt_att%species_name(ispec)) == "nox" ) THEN |
---|
1445 | |
---|
1446 | ALLOCATE ( emt_att%nox_comp(emt_att%ncat,emt_att%nnox) ) |
---|
1447 | CALL get_variable ( id_emis, "composition_nox", emt_att%nox_comp, & |
---|
1448 | 1, emt_att%ncat, 1, emt_att%nnox ) |
---|
1449 | |
---|
1450 | ENDIF ! NOX |
---|
1451 | |
---|
1452 | ! |
---|
1453 | !-- SOX (SO2 and SO4) |
---|
1454 | |
---|
1455 | IF ( TRIM(emt_att%species_name(ispec)) == "SOX" .OR. & |
---|
1456 | TRIM(emt_att%species_name(ispec)) == "sox" ) THEN |
---|
1457 | |
---|
1458 | ALLOCATE ( emt_att%sox_comp(emt_att%ncat,emt_att%nsox) ) |
---|
1459 | CALL get_variable ( id_emis, "composition_sox", emt_att%sox_comp, & |
---|
1460 | 1, emt_att%ncat, 1, emt_att%nsox ) |
---|
1461 | |
---|
1462 | ENDIF ! SOX |
---|
1463 | |
---|
1464 | ENDDO ! do ispec |
---|
1465 | |
---|
1466 | ! |
---|
1467 | !-- EMISSION TIME SCALING FACTORS (hourly and MDH data) |
---|
1468 | |
---|
1469 | ! |
---|
1470 | !-- HOUR |
---|
1471 | IF ( TRIM(time_fac_type) == "HOUR" .OR. & |
---|
1472 | TRIM(time_fac_type) == "hour" ) THEN |
---|
1473 | |
---|
1474 | CALL get_dimension_length ( id_emis, emt_att%nhoursyear, 'nhoursyear' ) |
---|
1475 | ALLOCATE ( emt_att%hourly_emis_time_factor(emt_att%ncat,emt_att%nhoursyear) ) |
---|
1476 | CALL get_variable ( id_emis, "emission_time_factors", & |
---|
1477 | emt_att%hourly_emis_time_factor, & |
---|
1478 | 1, emt_att%ncat, 1, emt_att%nhoursyear ) |
---|
1479 | |
---|
1480 | ! |
---|
1481 | !-- MDH |
---|
1482 | |
---|
1483 | ELSE IF ( TRIM(time_fac_type) == "MDH" .OR. & |
---|
1484 | TRIM(time_fac_type) == "mdh" ) THEN |
---|
1485 | |
---|
1486 | CALL get_dimension_length ( id_emis, emt_att%nmonthdayhour, 'nmonthdayhour' ) |
---|
1487 | ALLOCATE ( emt_att%mdh_emis_time_factor(emt_att%ncat,emt_att%nmonthdayhour) ) |
---|
1488 | CALL get_variable ( id_emis, "emission_time_factors", & |
---|
1489 | emt_att%mdh_emis_time_factor, & |
---|
1490 | 1, emt_att%ncat, 1, emt_att%nmonthdayhour ) |
---|
1491 | |
---|
1492 | ! |
---|
1493 | !-- ERROR (time factor undefined) |
---|
1494 | |
---|
1495 | ELSE |
---|
1496 | |
---|
1497 | message_string = 'We are in the DEFAULT chemistry emissions mode: ' // & |
---|
1498 | ' !no time-factor type specified!' // & |
---|
1499 | 'Please specify the value of time_fac_type:' // & |
---|
1500 | ' either "MDH" or "HOUR"' |
---|
1501 | CALL message( 'netcdf_data_input_chemistry_data', 'CM0200', 2, 2, 0, 6, 0 ) |
---|
1502 | |
---|
1503 | |
---|
1504 | ENDIF ! time_fac_type |
---|
1505 | |
---|
1506 | ! |
---|
1507 | !-- read in default (LOD1) emissions from chemisty netCDF file per species |
---|
1508 | |
---|
1509 | ! |
---|
1510 | !-- NOTE - at the moment the data is read in per species, but in the future it would |
---|
1511 | !-- be much more sensible to read in per species per time step to reduce |
---|
1512 | !-- memory consumption and, to a lesser degree, dimensionality of data exchange |
---|
1513 | !-- (I expect this will be necessary when the problem size is large) |
---|
1514 | |
---|
1515 | DO ispec = 1, emt_att%n_emiss_species |
---|
1516 | |
---|
1517 | ! |
---|
1518 | !-- allocate space for species specific emission values |
---|
1519 | !-- NOTE - this array is extended by 1 cell in each horizontal direction |
---|
1520 | !-- to compensate for an apparent linear offset. The reason of this |
---|
1521 | !-- offset is not known but it has been determined to take place beyond the |
---|
1522 | !-- scope of this module, and has little to do with index conventions. |
---|
1523 | !-- That is, setting the array horizontal limit from nx0:nx1 to 1:(nx1-nx0+1) |
---|
1524 | !-- or nx0+1:nx1+1 did not result in correct or definite behavior |
---|
1525 | !-- This must be looked at at some point by the Hannover team but for now |
---|
1526 | !-- this workaround is deemed reasonable (ecc 20190417) |
---|
1527 | |
---|
1528 | IF ( .NOT. ALLOCATED ( emt(ispec)%default_emission_data ) ) THEN |
---|
1529 | ALLOCATE ( emt(ispec)%default_emission_data(emt_att%ncat,nys:nyn+1,nxl:nxr+1) ) |
---|
1530 | ENDIF |
---|
1531 | ! |
---|
1532 | !-- allocate dummy variable w/ index order identical to that shown in the netCDF header |
---|
1533 | |
---|
1534 | ALLOCATE ( dum_var_5d(1,nys:nyn,nxl:nxr,1,emt_att%ncat) ) |
---|
1535 | ! |
---|
1536 | !-- get variable. be very careful |
---|
1537 | !-- I am using get_variable_5d_real_dynamic (note logical argument at the end) |
---|
1538 | !-- 1) use Fortran index convention (i.e., 1 to N) |
---|
1539 | !-- 2) index order must be in reverse order from above allocation order |
---|
1540 | |
---|
1541 | CALL get_variable ( id_emis, "emission_values", dum_var_5d, & |
---|
1542 | 1, ispec, nxl+1, nys+1, 1, & |
---|
1543 | emt_att%ncat, 1, nxr-nxl+1, nyn-nys+1, emt_att%dt_emission, & |
---|
1544 | .FALSE. ) |
---|
1545 | ! |
---|
1546 | !-- assign temp array to data structure then deallocate temp array |
---|
1547 | !-- NOTE - indices are shifted from nx0:nx1 to nx0+1:nx1+1 to offset |
---|
1548 | !-- the emission data array to counter said domain offset |
---|
1549 | !-- (ecc 20190417) |
---|
1550 | |
---|
1551 | DO k = 1, emt_att%ncat |
---|
1552 | DO j = nys+1, nyn+1 |
---|
1553 | DO i = nxl+1, nxr+1 |
---|
1554 | emt(ispec)%default_emission_data(k,j,i) = dum_var_5d(1,j-1,i-1,1,k) |
---|
1555 | ENDDO |
---|
1556 | ENDDO |
---|
1557 | ENDDO |
---|
1558 | |
---|
1559 | DEALLOCATE ( dum_var_5d ) |
---|
1560 | |
---|
1561 | ENDDO ! ispec |
---|
1562 | ! |
---|
1563 | !-- UNITS |
---|
1564 | |
---|
1565 | CALL get_attribute(id_emis,"units",emt_att%units,.FALSE.,"emission_values") |
---|
1566 | |
---|
1567 | ! |
---|
1568 | !-- END DEFAULT MODE |
---|
1569 | |
---|
1570 | |
---|
1571 | ! |
---|
1572 | !-- START LOD 2 (PRE-PROCESSED MODE) |
---|
1573 | |
---|
1574 | ELSE IF ( emiss_lod == 2 ) THEN |
---|
1575 | |
---|
1576 | ! for reference (ecc) |
---|
1577 | ! ELSE IF (TRIM(mode_emis) == "PRE-PROCESSED" .OR. TRIM(mode_emis) == "pre-processed") THEN |
---|
1578 | |
---|
1579 | ! |
---|
1580 | !-- For LOD 2 only VOC and emission data need be read |
---|
1581 | |
---|
1582 | !------------------------------------------------------------------------------ |
---|
1583 | !-- NOTE - CHECK ARRAY INDICES FOR READING IN NAMES AND SPECIES |
---|
1584 | !-- IN LOD2 (PRE-PROCESSED MODE) FOR THE VARIOUS MODE SPLITS |
---|
1585 | !-- AS ALL ID_EMIS CONDITIONALS HAVE BEEN REMOVED FROM GET_VAR |
---|
1586 | !-- FUNCTIONS. IN THEORY THIS WOULD MEAN ALL ARRAYS SHOULD BE |
---|
1587 | !-- READ FROM 0 to N-1 (C CONVENTION) AS OPPOSED TO 1 to N |
---|
1588 | !-- (FORTRAN CONVENTION). KEEP THIS IN MIND !! |
---|
1589 | !-- (ecc 20190424) |
---|
1590 | !------------------------------------------------------------------------------ |
---|
1591 | |
---|
1592 | DO ispec = 1, emt_att%n_emiss_species |
---|
1593 | |
---|
1594 | ! |
---|
1595 | !-- VOC DATA (name and composition) |
---|
1596 | |
---|
1597 | IF ( TRIM(emt_att%species_name(ispec)) == "VOC" .OR. & |
---|
1598 | TRIM(emt_att%species_name(ispec)) == "voc" ) THEN |
---|
1599 | |
---|
1600 | ! |
---|
1601 | !-- VOC name |
---|
1602 | CALL get_dimension_length ( id_emis, emt_att%nvoc, 'nvoc' ) |
---|
1603 | ALLOCATE ( emt_att%voc_name(emt_att%nvoc) ) |
---|
1604 | CALL get_variable ( id_emis, "emission_voc_name", & |
---|
1605 | string_values, emt_att%nvoc) |
---|
1606 | emt_att%voc_name = string_values |
---|
1607 | IF ( ALLOCATED(string_values) ) DEALLOCATE (string_values) |
---|
1608 | |
---|
1609 | ! |
---|
1610 | !-- VOC composition |
---|
1611 | |
---|
1612 | ALLOCATE ( emt_att%voc_comp(emt_att%ncat,emt_att%nvoc) ) |
---|
1613 | CALL get_variable ( id_emis, "composition_voc", emt_att%voc_comp, & |
---|
1614 | 1, emt_att%ncat, 1, emt_att%nvoc ) |
---|
1615 | ENDIF ! VOC |
---|
1616 | |
---|
1617 | ENDDO ! ispec |
---|
1618 | |
---|
1619 | ! |
---|
1620 | !-- EMISSION DATA |
---|
1621 | |
---|
1622 | CALL get_dimension_length ( id_emis, emt_att%dt_emission, 'time' ) |
---|
1623 | |
---|
1624 | ! |
---|
1625 | !-- read in pre-processed (LOD2) emissions from chemisty netCDF file per species |
---|
1626 | |
---|
1627 | ! |
---|
1628 | !-- NOTE - at the moment the data is read in per species, but in the future it would |
---|
1629 | !-- be much more sensible to read in per species per time step to reduce |
---|
1630 | !-- memory consumption and, to a lesser degree, dimensionality of data exchange |
---|
1631 | !-- (I expect this will be necessary when the problem size is large) |
---|
1632 | |
---|
1633 | DO ispec = 1, emt_att%n_emiss_species |
---|
1634 | |
---|
1635 | ! |
---|
1636 | !-- allocate space for species specific emission values |
---|
1637 | !-- NOTE - this array is extended by 1 cell in each horizontal direction |
---|
1638 | !-- to compensate for an apparent linear offset. The reason of this |
---|
1639 | !-- offset is not known but it has been determined to take place beyond the |
---|
1640 | !-- scope of this module, and has little to do with index conventions. |
---|
1641 | !-- That is, setting the array horizontal limit from nx0:nx1 to 1:(nx1-nx0+1) |
---|
1642 | !-- or nx0+1:nx1+1 did not result in correct or definite behavior |
---|
1643 | !-- This must be looked at at some point by the Hannover team but for now |
---|
1644 | !-- this workaround is deemed reasonable (ecc 20190417) |
---|
1645 | |
---|
1646 | IF ( .NOT. ALLOCATED( emt(ispec)%preproc_emission_data ) ) THEN |
---|
1647 | ALLOCATE( emt(ispec)%preproc_emission_data( & |
---|
1648 | emt_att%dt_emission, 1, nys:nyn+1, nxl:nxr+1) ) |
---|
1649 | ENDIF |
---|
1650 | ! |
---|
1651 | !-- allocate dummy variable w/ index order identical to that shown in the netCDF header |
---|
1652 | |
---|
1653 | ALLOCATE ( dum_var_5d(emt_att%dt_emission,1,nys:nyn,nxl:nxr,1) ) |
---|
1654 | ! |
---|
1655 | !-- get variable. be very careful |
---|
1656 | !-- I am using get_variable_5d_real_dynamic (note logical argument at the end) |
---|
1657 | !-- 1) use Fortran index convention (i.e., 1 to N) |
---|
1658 | !-- 2) index order must be in reverse order from above allocation order |
---|
1659 | |
---|
1660 | CALL get_variable ( id_emis, "emission_values", dum_var_5d, & |
---|
1661 | ispec, nxl+1, nys+1, 1, 1, & |
---|
1662 | 1, nxr-nxl+1, nyn-nys+1, 1, emt_att%dt_emission, & |
---|
1663 | .FALSE. ) |
---|
1664 | ! |
---|
1665 | !-- assign temp array to data structure then deallocate temp array |
---|
1666 | !-- NOTE - indices are shifted from nx0:nx1 to nx0+1:nx1+1 to offset |
---|
1667 | !-- the emission data array to counter said unkonwn offset |
---|
1668 | !-- (ecc 20190417) |
---|
1669 | |
---|
1670 | DO k = 1, emt_att%dt_emission |
---|
1671 | DO j = nys+1, nyn+1 |
---|
1672 | DO i = nxl+1, nxr+1 |
---|
1673 | emt(ispec)%preproc_emission_data(k,1,j,i) = dum_var_5d(k,1,j-1,i-1,1) |
---|
1674 | ENDDO |
---|
1675 | ENDDO |
---|
1676 | ENDDO |
---|
1677 | |
---|
1678 | DEALLOCATE ( dum_var_5d ) |
---|
1679 | |
---|
1680 | ENDDO ! ispec |
---|
1681 | ! |
---|
1682 | !-- UNITS |
---|
1683 | |
---|
1684 | CALL get_attribute ( id_emis, "units", emt_att%units, .FALSE. , "emission_values" ) |
---|
1685 | |
---|
1686 | ENDIF ! LOD1 & LOD2 (default and pre-processed mode) |
---|
1687 | |
---|
1688 | CALL close_input_file (id_emis) |
---|
1689 | |
---|
1690 | #endif |
---|
1691 | |
---|
1692 | ENDIF ! LOD0 (parameterized mode) |
---|
1693 | |
---|
1694 | END SUBROUTINE netcdf_data_input_chemistry_data |
---|
1695 | |
---|
1696 | |
---|
1697 | !------------------------------------------------------------------------------! |
---|
1698 | ! Description: |
---|
1699 | ! ------------ |
---|
1700 | !> Reads surface classification data, such as vegetation and soil type, etc. . |
---|
1701 | !------------------------------------------------------------------------------! |
---|
1702 | SUBROUTINE netcdf_data_input_surface_data |
---|
1703 | |
---|
1704 | USE control_parameters, & |
---|
1705 | ONLY: land_surface, plant_canopy, urban_surface |
---|
1706 | |
---|
1707 | USE indices, & |
---|
1708 | ONLY: nbgp, nxl, nxr, nyn, nys |
---|
1709 | |
---|
1710 | |
---|
1711 | IMPLICIT NONE |
---|
1712 | |
---|
1713 | CHARACTER(LEN=100), DIMENSION(:), ALLOCATABLE :: var_names !< variable names in static input file |
---|
1714 | |
---|
1715 | INTEGER(iwp) :: id_surf !< NetCDF id of input file |
---|
1716 | INTEGER(iwp) :: k !< running index along z-direction |
---|
1717 | INTEGER(iwp) :: k2 !< running index |
---|
1718 | INTEGER(iwp) :: num_vars !< number of variables in input file |
---|
1719 | INTEGER(iwp) :: nz_soil !< number of soil layers in file |
---|
1720 | |
---|
1721 | ! |
---|
1722 | !-- If not static input file is available, skip this routine |
---|
1723 | IF ( .NOT. input_pids_static ) RETURN |
---|
1724 | ! |
---|
1725 | !-- Measure CPU time |
---|
1726 | CALL cpu_log( log_point_s(82), 'NetCDF input', 'start' ) |
---|
1727 | ! |
---|
1728 | !-- Read plant canopy variables. |
---|
1729 | IF ( plant_canopy ) THEN |
---|
1730 | #if defined ( __netcdf ) |
---|
1731 | ! |
---|
1732 | !-- Open file in read-only mode |
---|
1733 | CALL open_read_file( TRIM( input_file_static ) // & |
---|
1734 | TRIM( coupling_char ) , id_surf ) |
---|
1735 | ! |
---|
1736 | !-- At first, inquire all variable names. |
---|
1737 | !-- This will be used to check whether an optional input variable |
---|
1738 | !-- exist or not. |
---|
1739 | CALL inquire_num_variables( id_surf, num_vars ) |
---|
1740 | |
---|
1741 | ALLOCATE( var_names(1:num_vars) ) |
---|
1742 | CALL inquire_variable_names( id_surf, var_names ) |
---|
1743 | |
---|
1744 | ! |
---|
1745 | !-- Read leaf area density - resolved vegetation |
---|
1746 | IF ( check_existence( var_names, 'lad' ) ) THEN |
---|
1747 | leaf_area_density_f%from_file = .TRUE. |
---|
1748 | CALL get_attribute( id_surf, char_fill, & |
---|
1749 | leaf_area_density_f%fill, & |
---|
1750 | .FALSE., 'lad' ) |
---|
1751 | ! |
---|
1752 | !-- Inquire number of vertical vegetation layer |
---|
1753 | CALL get_dimension_length( id_surf, & |
---|
1754 | leaf_area_density_f%nz, & |
---|
1755 | 'zlad' ) |
---|
1756 | ! |
---|
1757 | !-- Allocate variable for leaf-area density |
---|
1758 | ALLOCATE( leaf_area_density_f%var( 0:leaf_area_density_f%nz-1, & |
---|
1759 | nys:nyn,nxl:nxr) ) |
---|
1760 | |
---|
1761 | CALL get_variable( id_surf, 'lad', leaf_area_density_f%var, & |
---|
1762 | nxl, nxr, nys, nyn, & |
---|
1763 | 0, leaf_area_density_f%nz-1 ) |
---|
1764 | |
---|
1765 | ELSE |
---|
1766 | leaf_area_density_f%from_file = .FALSE. |
---|
1767 | ENDIF |
---|
1768 | |
---|
1769 | ! |
---|
1770 | !-- Read basal area density - resolved vegetation |
---|
1771 | IF ( check_existence( var_names, 'bad' ) ) THEN |
---|
1772 | basal_area_density_f%from_file = .TRUE. |
---|
1773 | CALL get_attribute( id_surf, char_fill, & |
---|
1774 | basal_area_density_f%fill, & |
---|
1775 | .FALSE., 'bad' ) |
---|
1776 | ! |
---|
1777 | !-- Inquire number of vertical vegetation layer |
---|
1778 | CALL get_dimension_length( id_surf, & |
---|
1779 | basal_area_density_f%nz, & |
---|
1780 | 'zlad' ) |
---|
1781 | ! |
---|
1782 | !-- Allocate variable |
---|
1783 | ALLOCATE( basal_area_density_f%var(0:basal_area_density_f%nz-1, & |
---|
1784 | nys:nyn,nxl:nxr) ) |
---|
1785 | |
---|
1786 | CALL get_variable( id_surf, 'bad', basal_area_density_f%var, & |
---|
1787 | nxl, nxr, nys, nyn, & |
---|
1788 | 0, basal_area_density_f%nz-1 ) |
---|
1789 | ELSE |
---|
1790 | basal_area_density_f%from_file = .FALSE. |
---|
1791 | ENDIF |
---|
1792 | |
---|
1793 | ! |
---|
1794 | !-- Read root area density - resolved vegetation |
---|
1795 | IF ( check_existence( var_names, 'root_area_dens_r' ) ) THEN |
---|
1796 | root_area_density_lad_f%from_file = .TRUE. |
---|
1797 | CALL get_attribute( id_surf, char_fill, & |
---|
1798 | root_area_density_lad_f%fill, & |
---|
1799 | .FALSE., 'root_area_dens_r' ) |
---|
1800 | ! |
---|
1801 | !-- Inquire number of vertical soil layers |
---|
1802 | CALL get_dimension_length( id_surf, & |
---|
1803 | root_area_density_lad_f%nz, & |
---|
1804 | 'zsoil' ) |
---|
1805 | ! |
---|
1806 | !-- Allocate variable |
---|
1807 | ALLOCATE( root_area_density_lad_f%var & |
---|
1808 | (0:root_area_density_lad_f%nz-1, & |
---|
1809 | nys:nyn,nxl:nxr) ) |
---|
1810 | |
---|
1811 | CALL get_variable( id_surf, 'root_area_dens_r', & |
---|
1812 | root_area_density_lad_f%var, & |
---|
1813 | nxl, nxr, nys, nyn, & |
---|
1814 | 0, root_area_density_lad_f%nz-1 ) |
---|
1815 | ELSE |
---|
1816 | root_area_density_lad_f%from_file = .FALSE. |
---|
1817 | ENDIF |
---|
1818 | ! |
---|
1819 | !-- Finally, close input file |
---|
1820 | CALL close_input_file( id_surf ) |
---|
1821 | #endif |
---|
1822 | ENDIF |
---|
1823 | ! |
---|
1824 | !-- Deallocate variable list. Will be re-allocated in case further |
---|
1825 | !-- variables are read from file. |
---|
1826 | IF ( ALLOCATED( var_names ) ) DEALLOCATE( var_names ) |
---|
1827 | ! |
---|
1828 | !-- Skip the following if no land-surface or urban-surface module are |
---|
1829 | !-- applied. This case, no one of the following variables is used anyway. |
---|
1830 | IF ( .NOT. land_surface .AND. .NOT. urban_surface ) RETURN |
---|
1831 | |
---|
1832 | #if defined ( __netcdf ) |
---|
1833 | ! |
---|
1834 | !-- Open file in read-only mode |
---|
1835 | CALL open_read_file( TRIM( input_file_static ) // & |
---|
1836 | TRIM( coupling_char ) , id_surf ) |
---|
1837 | ! |
---|
1838 | !-- Inquire all variable names. |
---|
1839 | !-- This will be used to check whether an optional input variable exist |
---|
1840 | !-- or not. |
---|
1841 | CALL inquire_num_variables( id_surf, num_vars ) |
---|
1842 | |
---|
1843 | ALLOCATE( var_names(1:num_vars) ) |
---|
1844 | CALL inquire_variable_names( id_surf, var_names ) |
---|
1845 | ! |
---|
1846 | !-- Read vegetation type and required attributes |
---|
1847 | IF ( check_existence( var_names, 'vegetation_type' ) ) THEN |
---|
1848 | vegetation_type_f%from_file = .TRUE. |
---|
1849 | CALL get_attribute( id_surf, char_fill, & |
---|
1850 | vegetation_type_f%fill, & |
---|
1851 | .FALSE., 'vegetation_type' ) |
---|
1852 | |
---|
1853 | ALLOCATE ( vegetation_type_f%var(nys:nyn,nxl:nxr) ) |
---|
1854 | |
---|
1855 | CALL get_variable( id_surf, 'vegetation_type', & |
---|
1856 | vegetation_type_f%var, nxl, nxr, nys, nyn ) |
---|
1857 | ELSE |
---|
1858 | vegetation_type_f%from_file = .FALSE. |
---|
1859 | ENDIF |
---|
1860 | |
---|
1861 | ! |
---|
1862 | !-- Read soil type and required attributes |
---|
1863 | IF ( check_existence( var_names, 'soil_type' ) ) THEN |
---|
1864 | soil_type_f%from_file = .TRUE. |
---|
1865 | ! |
---|
1866 | !-- Note, lod is currently not on file; skip for the moment |
---|
1867 | ! CALL get_attribute( id_surf, char_lod, & |
---|
1868 | ! soil_type_f%lod, & |
---|
1869 | ! .FALSE., 'soil_type' ) |
---|
1870 | CALL get_attribute( id_surf, char_fill, & |
---|
1871 | soil_type_f%fill, & |
---|
1872 | .FALSE., 'soil_type' ) |
---|
1873 | |
---|
1874 | IF ( soil_type_f%lod == 1 ) THEN |
---|
1875 | |
---|
1876 | ALLOCATE ( soil_type_f%var_2d(nys:nyn,nxl:nxr) ) |
---|
1877 | |
---|
1878 | CALL get_variable( id_surf, 'soil_type', soil_type_f%var_2d, & |
---|
1879 | nxl, nxr, nys, nyn ) |
---|
1880 | |
---|
1881 | ELSEIF ( soil_type_f%lod == 2 ) THEN |
---|
1882 | ! |
---|
1883 | !-- Obtain number of soil layers from file. |
---|
1884 | CALL get_dimension_length( id_surf, nz_soil, 'zsoil' ) |
---|
1885 | |
---|
1886 | ALLOCATE ( soil_type_f%var_3d(0:nz_soil,nys:nyn,nxl:nxr) ) |
---|
1887 | |
---|
1888 | CALL get_variable( id_surf, 'soil_type', soil_type_f%var_3d, & |
---|
1889 | nxl, nxr, nys, nyn, 0, nz_soil ) |
---|
1890 | |
---|
1891 | ENDIF |
---|
1892 | ELSE |
---|
1893 | soil_type_f%from_file = .FALSE. |
---|
1894 | ENDIF |
---|
1895 | |
---|
1896 | ! |
---|
1897 | !-- Read pavement type and required attributes |
---|
1898 | IF ( check_existence( var_names, 'pavement_type' ) ) THEN |
---|
1899 | pavement_type_f%from_file = .TRUE. |
---|
1900 | CALL get_attribute( id_surf, char_fill, & |
---|
1901 | pavement_type_f%fill, .FALSE., & |
---|
1902 | 'pavement_type' ) |
---|
1903 | |
---|
1904 | ALLOCATE ( pavement_type_f%var(nys:nyn,nxl:nxr) ) |
---|
1905 | |
---|
1906 | CALL get_variable( id_surf, 'pavement_type', pavement_type_f%var, & |
---|
1907 | nxl, nxr, nys, nyn ) |
---|
1908 | ELSE |
---|
1909 | pavement_type_f%from_file = .FALSE. |
---|
1910 | ENDIF |
---|
1911 | |
---|
1912 | ! |
---|
1913 | !-- Read water type and required attributes |
---|
1914 | IF ( check_existence( var_names, 'water_type' ) ) THEN |
---|
1915 | water_type_f%from_file = .TRUE. |
---|
1916 | CALL get_attribute( id_surf, char_fill, water_type_f%fill, & |
---|
1917 | .FALSE., 'water_type' ) |
---|
1918 | |
---|
1919 | ALLOCATE ( water_type_f%var(nys:nyn,nxl:nxr) ) |
---|
1920 | |
---|
1921 | CALL get_variable( id_surf, 'water_type', water_type_f%var, & |
---|
1922 | nxl, nxr, nys, nyn ) |
---|
1923 | |
---|
1924 | ELSE |
---|
1925 | water_type_f%from_file = .FALSE. |
---|
1926 | ENDIF |
---|
1927 | ! |
---|
1928 | !-- Read relative surface fractions of vegetation, pavement and water. |
---|
1929 | IF ( check_existence( var_names, 'surface_fraction' ) ) THEN |
---|
1930 | surface_fraction_f%from_file = .TRUE. |
---|
1931 | CALL get_attribute( id_surf, char_fill, & |
---|
1932 | surface_fraction_f%fill, & |
---|
1933 | .FALSE., 'surface_fraction' ) |
---|
1934 | ! |
---|
1935 | !-- Inquire number of surface fractions |
---|
1936 | CALL get_dimension_length( id_surf, & |
---|
1937 | surface_fraction_f%nf, & |
---|
1938 | 'nsurface_fraction' ) |
---|
1939 | ! |
---|
1940 | !-- Allocate dimension array and input array for surface fractions |
---|
1941 | ALLOCATE( surface_fraction_f%nfracs(0:surface_fraction_f%nf-1) ) |
---|
1942 | ALLOCATE( surface_fraction_f%frac(0:surface_fraction_f%nf-1, & |
---|
1943 | nys:nyn,nxl:nxr) ) |
---|
1944 | ! |
---|
1945 | !-- Get dimension of surface fractions |
---|
1946 | CALL get_variable( id_surf, 'nsurface_fraction', & |
---|
1947 | surface_fraction_f%nfracs ) |
---|
1948 | ! |
---|
1949 | !-- Read surface fractions |
---|
1950 | CALL get_variable( id_surf, 'surface_fraction', & |
---|
1951 | surface_fraction_f%frac, nxl, nxr, nys, nyn, & |
---|
1952 | 0, surface_fraction_f%nf-1 ) |
---|
1953 | ELSE |
---|
1954 | surface_fraction_f%from_file = .FALSE. |
---|
1955 | ENDIF |
---|
1956 | ! |
---|
1957 | !-- Read building parameters and related information |
---|
1958 | IF ( check_existence( var_names, 'building_pars' ) ) THEN |
---|
1959 | building_pars_f%from_file = .TRUE. |
---|
1960 | CALL get_attribute( id_surf, char_fill, & |
---|
1961 | building_pars_f%fill, & |
---|
1962 | .FALSE., 'building_pars' ) |
---|
1963 | ! |
---|
1964 | !-- Inquire number of building parameters |
---|
1965 | CALL get_dimension_length( id_surf, & |
---|
1966 | building_pars_f%np, & |
---|
1967 | 'nbuilding_pars' ) |
---|
1968 | ! |
---|
1969 | !-- Allocate dimension array and input array for building parameters |
---|
1970 | ALLOCATE( building_pars_f%pars(0:building_pars_f%np-1) ) |
---|
1971 | ALLOCATE( building_pars_f%pars_xy(0:building_pars_f%np-1, & |
---|
1972 | nys:nyn,nxl:nxr) ) |
---|
1973 | ! |
---|
1974 | !-- Get dimension of building parameters |
---|
1975 | CALL get_variable( id_surf, 'nbuilding_pars', & |
---|
1976 | building_pars_f%pars ) |
---|
1977 | ! |
---|
1978 | !-- Read building_pars |
---|
1979 | CALL get_variable( id_surf, 'building_pars', & |
---|
1980 | building_pars_f%pars_xy, nxl, nxr, nys, nyn, & |
---|
1981 | 0, building_pars_f%np-1 ) |
---|
1982 | ELSE |
---|
1983 | building_pars_f%from_file = .FALSE. |
---|
1984 | ENDIF |
---|
1985 | ! |
---|
1986 | !-- Read building surface parameters |
---|
1987 | IF ( check_existence( var_names, 'building_surface_pars' ) ) THEN |
---|
1988 | building_surface_pars_f%from_file = .TRUE. |
---|
1989 | CALL get_attribute( id_surf, char_fill, & |
---|
1990 | building_surface_pars_f%fill, & |
---|
1991 | .FALSE., 'building_surface_pars' ) |
---|
1992 | ! |
---|
1993 | !-- Read building_surface_pars |
---|
1994 | CALL get_variable_surf( id_surf, 'building_surface_pars', & |
---|
1995 | building_surface_pars_f ) |
---|
1996 | ELSE |
---|
1997 | building_surface_pars_f%from_file = .FALSE. |
---|
1998 | ENDIF |
---|
1999 | |
---|
2000 | ! |
---|
2001 | !-- Read albedo type and required attributes |
---|
2002 | IF ( check_existence( var_names, 'albedo_type' ) ) THEN |
---|
2003 | albedo_type_f%from_file = .TRUE. |
---|
2004 | CALL get_attribute( id_surf, char_fill, albedo_type_f%fill, & |
---|
2005 | .FALSE., 'albedo_type' ) |
---|
2006 | |
---|
2007 | ALLOCATE ( albedo_type_f%var(nys:nyn,nxl:nxr) ) |
---|
2008 | |
---|
2009 | CALL get_variable( id_surf, 'albedo_type', albedo_type_f%var, & |
---|
2010 | nxl, nxr, nys, nyn ) |
---|
2011 | ELSE |
---|
2012 | albedo_type_f%from_file = .FALSE. |
---|
2013 | ENDIF |
---|
2014 | ! |
---|
2015 | !-- Read albedo parameters and related information |
---|
2016 | IF ( check_existence( var_names, 'albedo_pars' ) ) THEN |
---|
2017 | albedo_pars_f%from_file = .TRUE. |
---|
2018 | CALL get_attribute( id_surf, char_fill, albedo_pars_f%fill, & |
---|
2019 | .FALSE., 'albedo_pars' ) |
---|
2020 | ! |
---|
2021 | !-- Inquire number of albedo parameters |
---|
2022 | CALL get_dimension_length( id_surf, & |
---|
2023 | albedo_pars_f%np, & |
---|
2024 | 'nalbedo_pars' ) |
---|
2025 | ! |
---|
2026 | !-- Allocate dimension array and input array for albedo parameters |
---|
2027 | ALLOCATE( albedo_pars_f%pars(0:albedo_pars_f%np-1) ) |
---|
2028 | ALLOCATE( albedo_pars_f%pars_xy(0:albedo_pars_f%np-1, & |
---|
2029 | nys:nyn,nxl:nxr) ) |
---|
2030 | ! |
---|
2031 | !-- Get dimension of albedo parameters |
---|
2032 | CALL get_variable( id_surf, 'nalbedo_pars', albedo_pars_f%pars ) |
---|
2033 | |
---|
2034 | CALL get_variable( id_surf, 'albedo_pars', albedo_pars_f%pars_xy, & |
---|
2035 | nxl, nxr, nys, nyn, & |
---|
2036 | 0, albedo_pars_f%np-1 ) |
---|
2037 | ELSE |
---|
2038 | albedo_pars_f%from_file = .FALSE. |
---|
2039 | ENDIF |
---|
2040 | |
---|
2041 | ! |
---|
2042 | !-- Read pavement parameters and related information |
---|
2043 | IF ( check_existence( var_names, 'pavement_pars' ) ) THEN |
---|
2044 | pavement_pars_f%from_file = .TRUE. |
---|
2045 | CALL get_attribute( id_surf, char_fill, & |
---|
2046 | pavement_pars_f%fill, & |
---|
2047 | .FALSE., 'pavement_pars' ) |
---|
2048 | ! |
---|
2049 | !-- Inquire number of pavement parameters |
---|
2050 | CALL get_dimension_length( id_surf, & |
---|
2051 | pavement_pars_f%np, & |
---|
2052 | 'npavement_pars' ) |
---|
2053 | ! |
---|
2054 | !-- Allocate dimension array and input array for pavement parameters |
---|
2055 | ALLOCATE( pavement_pars_f%pars(0:pavement_pars_f%np-1) ) |
---|
2056 | ALLOCATE( pavement_pars_f%pars_xy(0:pavement_pars_f%np-1, & |
---|
2057 | nys:nyn,nxl:nxr) ) |
---|
2058 | ! |
---|
2059 | !-- Get dimension of pavement parameters |
---|
2060 | CALL get_variable( id_surf, 'npavement_pars', pavement_pars_f%pars ) |
---|
2061 | |
---|
2062 | CALL get_variable( id_surf, 'pavement_pars', pavement_pars_f%pars_xy,& |
---|
2063 | nxl, nxr, nys, nyn, & |
---|
2064 | 0, pavement_pars_f%np-1 ) |
---|
2065 | ELSE |
---|
2066 | pavement_pars_f%from_file = .FALSE. |
---|
2067 | ENDIF |
---|
2068 | |
---|
2069 | ! |
---|
2070 | !-- Read pavement subsurface parameters and related information |
---|
2071 | IF ( check_existence( var_names, 'pavement_subsurface_pars' ) ) & |
---|
2072 | THEN |
---|
2073 | pavement_subsurface_pars_f%from_file = .TRUE. |
---|
2074 | CALL get_attribute( id_surf, char_fill, & |
---|
2075 | pavement_subsurface_pars_f%fill, & |
---|
2076 | .FALSE., 'pavement_subsurface_pars' ) |
---|
2077 | ! |
---|
2078 | !-- Inquire number of parameters |
---|
2079 | CALL get_dimension_length( id_surf, & |
---|
2080 | pavement_subsurface_pars_f%np, & |
---|
2081 | 'npavement_subsurface_pars' ) |
---|
2082 | ! |
---|
2083 | !-- Inquire number of soil layers |
---|
2084 | CALL get_dimension_length( id_surf, & |
---|
2085 | pavement_subsurface_pars_f%nz, & |
---|
2086 | 'zsoil' ) |
---|
2087 | ! |
---|
2088 | !-- Allocate dimension array and input array for pavement parameters |
---|
2089 | ALLOCATE( pavement_subsurface_pars_f%pars & |
---|
2090 | (0:pavement_subsurface_pars_f%np-1) ) |
---|
2091 | ALLOCATE( pavement_subsurface_pars_f%pars_xyz & |
---|
2092 | (0:pavement_subsurface_pars_f%np-1, & |
---|
2093 | 0:pavement_subsurface_pars_f%nz-1, & |
---|
2094 | nys:nyn,nxl:nxr) ) |
---|
2095 | ! |
---|
2096 | !-- Get dimension of pavement parameters |
---|
2097 | CALL get_variable( id_surf, 'npavement_subsurface_pars', & |
---|
2098 | pavement_subsurface_pars_f%pars ) |
---|
2099 | |
---|
2100 | CALL get_variable( id_surf, 'pavement_subsurface_pars', & |
---|
2101 | pavement_subsurface_pars_f%pars_xyz, & |
---|
2102 | nxl, nxr, nys, nyn, & |
---|
2103 | 0, pavement_subsurface_pars_f%nz-1, & |
---|
2104 | 0, pavement_subsurface_pars_f%np-1 ) |
---|
2105 | ELSE |
---|
2106 | pavement_subsurface_pars_f%from_file = .FALSE. |
---|
2107 | ENDIF |
---|
2108 | |
---|
2109 | |
---|
2110 | ! |
---|
2111 | !-- Read vegetation parameters and related information |
---|
2112 | IF ( check_existence( var_names, 'vegetation_pars' ) ) THEN |
---|
2113 | vegetation_pars_f%from_file = .TRUE. |
---|
2114 | CALL get_attribute( id_surf, char_fill, & |
---|
2115 | vegetation_pars_f%fill, & |
---|
2116 | .FALSE., 'vegetation_pars' ) |
---|
2117 | ! |
---|
2118 | !-- Inquire number of vegetation parameters |
---|
2119 | CALL get_dimension_length( id_surf, & |
---|
2120 | vegetation_pars_f%np, & |
---|
2121 | 'nvegetation_pars' ) |
---|
2122 | ! |
---|
2123 | !-- Allocate dimension array and input array for surface fractions |
---|
2124 | ALLOCATE( vegetation_pars_f%pars(0:vegetation_pars_f%np-1) ) |
---|
2125 | ALLOCATE( vegetation_pars_f%pars_xy(0:vegetation_pars_f%np-1, & |
---|
2126 | nys:nyn,nxl:nxr) ) |
---|
2127 | ! |
---|
2128 | !-- Get dimension of the parameters |
---|
2129 | CALL get_variable( id_surf, 'nvegetation_pars', & |
---|
2130 | vegetation_pars_f%pars ) |
---|
2131 | |
---|
2132 | CALL get_variable( id_surf, 'vegetation_pars', & |
---|
2133 | vegetation_pars_f%pars_xy, nxl, nxr, nys, nyn, & |
---|
2134 | 0, vegetation_pars_f%np-1 ) |
---|
2135 | ELSE |
---|
2136 | vegetation_pars_f%from_file = .FALSE. |
---|
2137 | ENDIF |
---|
2138 | |
---|
2139 | ! |
---|
2140 | !-- Read root parameters/distribution and related information |
---|
2141 | IF ( check_existence( var_names, 'soil_pars' ) ) THEN |
---|
2142 | soil_pars_f%from_file = .TRUE. |
---|
2143 | CALL get_attribute( id_surf, char_fill, & |
---|
2144 | soil_pars_f%fill, & |
---|
2145 | .FALSE., 'soil_pars' ) |
---|
2146 | |
---|
2147 | CALL get_attribute( id_surf, char_lod, & |
---|
2148 | soil_pars_f%lod, & |
---|
2149 | .FALSE., 'soil_pars' ) |
---|
2150 | |
---|
2151 | ! |
---|
2152 | !-- Inquire number of soil parameters |
---|
2153 | CALL get_dimension_length( id_surf, & |
---|
2154 | soil_pars_f%np, & |
---|
2155 | 'nsoil_pars' ) |
---|
2156 | ! |
---|
2157 | !-- Read parameters array |
---|
2158 | ALLOCATE( soil_pars_f%pars(0:soil_pars_f%np-1) ) |
---|
2159 | CALL get_variable( id_surf, 'nsoil_pars', soil_pars_f%pars ) |
---|
2160 | |
---|
2161 | ! |
---|
2162 | !-- In case of level of detail 2, also inquire number of vertical |
---|
2163 | !-- soil layers, allocate memory and read the respective dimension |
---|
2164 | IF ( soil_pars_f%lod == 2 ) THEN |
---|
2165 | CALL get_dimension_length( id_surf, & |
---|
2166 | soil_pars_f%nz, & |
---|
2167 | 'zsoil' ) |
---|
2168 | |
---|
2169 | ALLOCATE( soil_pars_f%layers(0:soil_pars_f%nz-1) ) |
---|
2170 | CALL get_variable( id_surf, 'zsoil', soil_pars_f%layers ) |
---|
2171 | |
---|
2172 | ENDIF |
---|
2173 | |
---|
2174 | ! |
---|
2175 | !-- Read soil parameters, depending on level of detail |
---|
2176 | IF ( soil_pars_f%lod == 1 ) THEN |
---|
2177 | ALLOCATE( soil_pars_f%pars_xy(0:soil_pars_f%np-1, & |
---|
2178 | nys:nyn,nxl:nxr) ) |
---|
2179 | |
---|
2180 | CALL get_variable( id_surf, 'soil_pars', soil_pars_f%pars_xy, & |
---|
2181 | nxl, nxr, nys, nyn, 0, soil_pars_f%np-1 ) |
---|
2182 | |
---|
2183 | ELSEIF ( soil_pars_f%lod == 2 ) THEN |
---|
2184 | ALLOCATE( soil_pars_f%pars_xyz(0:soil_pars_f%np-1, & |
---|
2185 | 0:soil_pars_f%nz-1, & |
---|
2186 | nys:nyn,nxl:nxr) ) |
---|
2187 | CALL get_variable( id_surf, 'soil_pars', & |
---|
2188 | soil_pars_f%pars_xyz, & |
---|
2189 | nxl, nxr, nys, nyn, 0, soil_pars_f%nz-1, & |
---|
2190 | 0, soil_pars_f%np-1 ) |
---|
2191 | |
---|
2192 | ENDIF |
---|
2193 | ELSE |
---|
2194 | soil_pars_f%from_file = .FALSE. |
---|
2195 | ENDIF |
---|
2196 | |
---|
2197 | ! |
---|
2198 | !-- Read water parameters and related information |
---|
2199 | IF ( check_existence( var_names, 'water_pars' ) ) THEN |
---|
2200 | water_pars_f%from_file = .TRUE. |
---|
2201 | CALL get_attribute( id_surf, char_fill, & |
---|
2202 | water_pars_f%fill, & |
---|
2203 | .FALSE., 'water_pars' ) |
---|
2204 | ! |
---|
2205 | !-- Inquire number of water parameters |
---|
2206 | CALL get_dimension_length( id_surf, & |
---|
2207 | water_pars_f%np, & |
---|
2208 | 'nwater_pars' ) |
---|
2209 | ! |
---|
2210 | !-- Allocate dimension array and input array for water parameters |
---|
2211 | ALLOCATE( water_pars_f%pars(0:water_pars_f%np-1) ) |
---|
2212 | ALLOCATE( water_pars_f%pars_xy(0:water_pars_f%np-1, & |
---|
2213 | nys:nyn,nxl:nxr) ) |
---|
2214 | ! |
---|
2215 | !-- Get dimension of water parameters |
---|
2216 | CALL get_variable( id_surf, 'nwater_pars', water_pars_f%pars ) |
---|
2217 | |
---|
2218 | CALL get_variable( id_surf, 'water_pars', water_pars_f%pars_xy, & |
---|
2219 | nxl, nxr, nys, nyn, 0, water_pars_f%np-1 ) |
---|
2220 | ELSE |
---|
2221 | water_pars_f%from_file = .FALSE. |
---|
2222 | ENDIF |
---|
2223 | ! |
---|
2224 | !-- Read root area density - parametrized vegetation |
---|
2225 | IF ( check_existence( var_names, 'root_area_dens_s' ) ) THEN |
---|
2226 | root_area_density_lsm_f%from_file = .TRUE. |
---|
2227 | CALL get_attribute( id_surf, char_fill, & |
---|
2228 | root_area_density_lsm_f%fill, & |
---|
2229 | .FALSE., 'root_area_dens_s' ) |
---|
2230 | ! |
---|
2231 | !-- Obtain number of soil layers from file and allocate variable |
---|
2232 | CALL get_dimension_length( id_surf, & |
---|
2233 | root_area_density_lsm_f%nz, & |
---|
2234 | 'zsoil' ) |
---|
2235 | ALLOCATE( root_area_density_lsm_f%var & |
---|
2236 | (0:root_area_density_lsm_f%nz-1, & |
---|
2237 | nys:nyn,nxl:nxr) ) |
---|
2238 | |
---|
2239 | ! |
---|
2240 | !-- Read root-area density |
---|
2241 | CALL get_variable( id_surf, 'root_area_dens_s', & |
---|
2242 | root_area_density_lsm_f%var, & |
---|
2243 | nxl, nxr, nys, nyn, & |
---|
2244 | 0, root_area_density_lsm_f%nz-1 ) |
---|
2245 | |
---|
2246 | ELSE |
---|
2247 | root_area_density_lsm_f%from_file = .FALSE. |
---|
2248 | ENDIF |
---|
2249 | ! |
---|
2250 | !-- Read street type and street crossing |
---|
2251 | IF ( check_existence( var_names, 'street_type' ) ) THEN |
---|
2252 | street_type_f%from_file = .TRUE. |
---|
2253 | CALL get_attribute( id_surf, char_fill, & |
---|
2254 | street_type_f%fill, .FALSE., & |
---|
2255 | 'street_type' ) |
---|
2256 | |
---|
2257 | ALLOCATE ( street_type_f%var(nys:nyn,nxl:nxr) ) |
---|
2258 | |
---|
2259 | CALL get_variable( id_surf, 'street_type', street_type_f%var, & |
---|
2260 | nxl, nxr, nys, nyn ) |
---|
2261 | ELSE |
---|
2262 | street_type_f%from_file = .FALSE. |
---|
2263 | ENDIF |
---|
2264 | |
---|
2265 | IF ( check_existence( var_names, 'street_crossing' ) ) THEN |
---|
2266 | street_crossing_f%from_file = .TRUE. |
---|
2267 | CALL get_attribute( id_surf, char_fill, & |
---|
2268 | street_crossing_f%fill, .FALSE., & |
---|
2269 | 'street_crossing' ) |
---|
2270 | |
---|
2271 | ALLOCATE ( street_crossing_f%var(nys:nyn,nxl:nxr) ) |
---|
2272 | |
---|
2273 | CALL get_variable( id_surf, 'street_crossing', & |
---|
2274 | street_crossing_f%var, nxl, nxr, nys, nyn ) |
---|
2275 | |
---|
2276 | ELSE |
---|
2277 | street_crossing_f%from_file = .FALSE. |
---|
2278 | ENDIF |
---|
2279 | ! |
---|
2280 | !-- Still missing: root_resolved and building_surface_pars. |
---|
2281 | !-- Will be implemented as soon as they are available. |
---|
2282 | |
---|
2283 | ! |
---|
2284 | !-- Finally, close input file |
---|
2285 | CALL close_input_file( id_surf ) |
---|
2286 | #endif |
---|
2287 | ! |
---|
2288 | !-- End of CPU measurement |
---|
2289 | CALL cpu_log( log_point_s(82), 'NetCDF input', 'stop' ) |
---|
2290 | ! |
---|
2291 | !-- Exchange ghost points for surface variables. Therefore, resize |
---|
2292 | !-- variables. |
---|
2293 | IF ( albedo_type_f%from_file ) THEN |
---|
2294 | CALL resize_array_2d_int8( albedo_type_f%var, nys, nyn, nxl, nxr ) |
---|
2295 | CALL exchange_horiz_2d_byte( albedo_type_f%var, nys, nyn, nxl, nxr, & |
---|
2296 | nbgp ) |
---|
2297 | ENDIF |
---|
2298 | IF ( pavement_type_f%from_file ) THEN |
---|
2299 | CALL resize_array_2d_int8( pavement_type_f%var, nys, nyn, nxl, nxr ) |
---|
2300 | CALL exchange_horiz_2d_byte( pavement_type_f%var, nys, nyn, nxl, nxr,& |
---|
2301 | nbgp ) |
---|
2302 | ENDIF |
---|
2303 | IF ( soil_type_f%from_file .AND. ALLOCATED( soil_type_f%var_2d ) ) THEN |
---|
2304 | CALL resize_array_2d_int8( soil_type_f%var_2d, nys, nyn, nxl, nxr ) |
---|
2305 | CALL exchange_horiz_2d_byte( soil_type_f%var_2d, nys, nyn, nxl, nxr, & |
---|
2306 | nbgp ) |
---|
2307 | ENDIF |
---|
2308 | IF ( vegetation_type_f%from_file ) THEN |
---|
2309 | CALL resize_array_2d_int8( vegetation_type_f%var, nys, nyn, nxl, nxr ) |
---|
2310 | CALL exchange_horiz_2d_byte( vegetation_type_f%var, nys, nyn, nxl, & |
---|
2311 | nxr, nbgp ) |
---|
2312 | ENDIF |
---|
2313 | IF ( water_type_f%from_file ) THEN |
---|
2314 | CALL resize_array_2d_int8( water_type_f%var, nys, nyn, nxl, nxr ) |
---|
2315 | CALL exchange_horiz_2d_byte( water_type_f%var, nys, nyn, nxl, nxr, & |
---|
2316 | nbgp ) |
---|
2317 | ENDIF |
---|
2318 | ! |
---|
2319 | !-- Exchange ghost points for 3/4-D variables. For the sake of simplicity, |
---|
2320 | !-- loop further dimensions to use 2D exchange routines. Unfortunately this |
---|
2321 | !-- is necessary, else new MPI-data types need to be introduced just for |
---|
2322 | !-- 2 variables. |
---|
2323 | IF ( soil_type_f%from_file .AND. ALLOCATED( soil_type_f%var_3d ) ) & |
---|
2324 | THEN |
---|
2325 | CALL resize_array_3d_int8( soil_type_f%var_3d, 0, nz_soil, & |
---|
2326 | nys, nyn, nxl, nxr ) |
---|
2327 | DO k = 0, nz_soil |
---|
2328 | CALL exchange_horiz_2d_int( & |
---|
2329 | soil_type_f%var_3d(k,:,:), nys, nyn, nxl, nxr, nbgp ) |
---|
2330 | ENDDO |
---|
2331 | ENDIF |
---|
2332 | |
---|
2333 | IF ( surface_fraction_f%from_file ) THEN |
---|
2334 | CALL resize_array_3d_real( surface_fraction_f%frac, & |
---|
2335 | 0, surface_fraction_f%nf-1, & |
---|
2336 | nys, nyn, nxl, nxr ) |
---|
2337 | DO k = 0, surface_fraction_f%nf-1 |
---|
2338 | CALL exchange_horiz_2d( surface_fraction_f%frac(k,:,:), nbgp ) |
---|
2339 | ENDDO |
---|
2340 | ENDIF |
---|
2341 | |
---|
2342 | IF ( building_pars_f%from_file ) THEN |
---|
2343 | CALL resize_array_3d_real( building_pars_f%pars_xy, & |
---|
2344 | 0, building_pars_f%np-1, & |
---|
2345 | nys, nyn, nxl, nxr ) |
---|
2346 | DO k = 0, building_pars_f%np-1 |
---|
2347 | CALL exchange_horiz_2d( building_pars_f%pars_xy(k,:,:), nbgp ) |
---|
2348 | ENDDO |
---|
2349 | ENDIF |
---|
2350 | |
---|
2351 | IF ( albedo_pars_f%from_file ) THEN |
---|
2352 | CALL resize_array_3d_real( albedo_pars_f%pars_xy, & |
---|
2353 | 0, albedo_pars_f%np-1, & |
---|
2354 | nys, nyn, nxl, nxr ) |
---|
2355 | DO k = 0, albedo_pars_f%np-1 |
---|
2356 | CALL exchange_horiz_2d( albedo_pars_f%pars_xy(k,:,:), nbgp ) |
---|
2357 | ENDDO |
---|
2358 | ENDIF |
---|
2359 | |
---|
2360 | IF ( pavement_pars_f%from_file ) THEN |
---|
2361 | CALL resize_array_3d_real( pavement_pars_f%pars_xy, & |
---|
2362 | 0, pavement_pars_f%np-1, & |
---|
2363 | nys, nyn, nxl, nxr ) |
---|
2364 | DO k = 0, pavement_pars_f%np-1 |
---|
2365 | CALL exchange_horiz_2d( pavement_pars_f%pars_xy(k,:,:), nbgp ) |
---|
2366 | ENDDO |
---|
2367 | ENDIF |
---|
2368 | |
---|
2369 | IF ( vegetation_pars_f%from_file ) THEN |
---|
2370 | CALL resize_array_3d_real( vegetation_pars_f%pars_xy, & |
---|
2371 | 0, vegetation_pars_f%np-1, & |
---|
2372 | nys, nyn, nxl, nxr ) |
---|
2373 | DO k = 0, vegetation_pars_f%np-1 |
---|
2374 | CALL exchange_horiz_2d( vegetation_pars_f%pars_xy(k,:,:), nbgp ) |
---|
2375 | ENDDO |
---|
2376 | ENDIF |
---|
2377 | |
---|
2378 | IF ( water_pars_f%from_file ) THEN |
---|
2379 | CALL resize_array_3d_real( water_pars_f%pars_xy, & |
---|
2380 | 0, water_pars_f%np-1, & |
---|
2381 | nys, nyn, nxl, nxr ) |
---|
2382 | DO k = 0, water_pars_f%np-1 |
---|
2383 | CALL exchange_horiz_2d( water_pars_f%pars_xy(k,:,:), nbgp ) |
---|
2384 | ENDDO |
---|
2385 | ENDIF |
---|
2386 | |
---|
2387 | IF ( root_area_density_lsm_f%from_file ) THEN |
---|
2388 | CALL resize_array_3d_real( root_area_density_lsm_f%var, & |
---|
2389 | 0, root_area_density_lsm_f%nz-1, & |
---|
2390 | nys, nyn, nxl, nxr ) |
---|
2391 | DO k = 0, root_area_density_lsm_f%nz-1 |
---|
2392 | CALL exchange_horiz_2d( root_area_density_lsm_f%var(k,:,:), nbgp ) |
---|
2393 | ENDDO |
---|
2394 | ENDIF |
---|
2395 | |
---|
2396 | IF ( soil_pars_f%from_file ) THEN |
---|
2397 | IF ( soil_pars_f%lod == 1 ) THEN |
---|
2398 | |
---|
2399 | CALL resize_array_3d_real( soil_pars_f%pars_xy, & |
---|
2400 | 0, soil_pars_f%np-1, & |
---|
2401 | nys, nyn, nxl, nxr ) |
---|
2402 | DO k = 0, soil_pars_f%np-1 |
---|
2403 | CALL exchange_horiz_2d( soil_pars_f%pars_xy(k,:,:), nbgp ) |
---|
2404 | ENDDO |
---|
2405 | |
---|
2406 | ELSEIF ( soil_pars_f%lod == 2 ) THEN |
---|
2407 | CALL resize_array_4d_real( soil_pars_f%pars_xyz, & |
---|
2408 | 0, soil_pars_f%np-1, & |
---|
2409 | 0, soil_pars_f%nz-1, & |
---|
2410 | nys, nyn, nxl, nxr ) |
---|
2411 | |
---|
2412 | DO k2 = 0, soil_pars_f%nz-1 |
---|
2413 | DO k = 0, soil_pars_f%np-1 |
---|
2414 | CALL exchange_horiz_2d( soil_pars_f%pars_xyz(k,k2,:,:), & |
---|
2415 | nbgp ) |
---|
2416 | ENDDO |
---|
2417 | ENDDO |
---|
2418 | ENDIF |
---|
2419 | ENDIF |
---|
2420 | |
---|
2421 | IF ( pavement_subsurface_pars_f%from_file ) THEN |
---|
2422 | CALL resize_array_4d_real( pavement_subsurface_pars_f%pars_xyz, & |
---|
2423 | 0, pavement_subsurface_pars_f%np-1, & |
---|
2424 | 0, pavement_subsurface_pars_f%nz-1, & |
---|
2425 | nys, nyn, nxl, nxr ) |
---|
2426 | |
---|
2427 | DO k2 = 0, pavement_subsurface_pars_f%nz-1 |
---|
2428 | DO k = 0, pavement_subsurface_pars_f%np-1 |
---|
2429 | CALL exchange_horiz_2d( & |
---|
2430 | pavement_subsurface_pars_f%pars_xyz(k,k2,:,:), nbgp ) |
---|
2431 | ENDDO |
---|
2432 | ENDDO |
---|
2433 | ENDIF |
---|
2434 | |
---|
2435 | END SUBROUTINE netcdf_data_input_surface_data |
---|
2436 | |
---|
2437 | !------------------------------------------------------------------------------! |
---|
2438 | ! Description: |
---|
2439 | ! ------------ |
---|
2440 | !> Reads uvem lookup table information. |
---|
2441 | !------------------------------------------------------------------------------! |
---|
2442 | SUBROUTINE netcdf_data_input_uvem |
---|
2443 | |
---|
2444 | USE indices, & |
---|
2445 | ONLY: nxl, nxr, nyn, nys |
---|
2446 | |
---|
2447 | IMPLICIT NONE |
---|
2448 | |
---|
2449 | CHARACTER(LEN=100), DIMENSION(:), ALLOCATABLE :: var_names !< variable names in static input file |
---|
2450 | |
---|
2451 | |
---|
2452 | INTEGER(iwp) :: id_uvem !< NetCDF id of uvem lookup table input file |
---|
2453 | INTEGER(iwp) :: nli = 35 !< dimension length of lookup table in x |
---|
2454 | INTEGER(iwp) :: nlj = 9 !< dimension length of lookup table in y |
---|
2455 | INTEGER(iwp) :: nlk = 90 !< dimension length of lookup table in z |
---|
2456 | INTEGER(iwp) :: num_vars !< number of variables in netcdf input file |
---|
2457 | ! |
---|
2458 | !-- Input via uv exposure model lookup table input |
---|
2459 | IF ( input_pids_uvem ) THEN |
---|
2460 | |
---|
2461 | #if defined ( __netcdf ) |
---|
2462 | ! |
---|
2463 | !-- Open file in read-only mode |
---|
2464 | CALL open_read_file( TRIM( input_file_uvem ) // & |
---|
2465 | TRIM( coupling_char ), id_uvem ) |
---|
2466 | ! |
---|
2467 | !-- At first, inquire all variable names. |
---|
2468 | !-- This will be used to check whether an input variable exist or not. |
---|
2469 | CALL inquire_num_variables( id_uvem, num_vars ) |
---|
2470 | ! |
---|
2471 | !-- Allocate memory to store variable names and inquire them. |
---|
2472 | ALLOCATE( var_names(1:num_vars) ) |
---|
2473 | CALL inquire_variable_names( id_uvem, var_names ) |
---|
2474 | ! |
---|
2475 | !-- uvem integration |
---|
2476 | IF ( check_existence( var_names, 'int_factors' ) ) THEN |
---|
2477 | uvem_integration_f%from_file = .TRUE. |
---|
2478 | ! |
---|
2479 | !-- Input 2D uvem integration. |
---|
2480 | ALLOCATE ( uvem_integration_f%var(0:nlj,0:nli) ) |
---|
2481 | |
---|
2482 | CALL get_variable( id_uvem, 'int_factors', uvem_integration_f%var, 0, nli, 0, nlj ) |
---|
2483 | ELSE |
---|
2484 | uvem_integration_f%from_file = .FALSE. |
---|
2485 | ENDIF |
---|
2486 | ! |
---|
2487 | !-- uvem irradiance |
---|
2488 | IF ( check_existence( var_names, 'irradiance' ) ) THEN |
---|
2489 | uvem_irradiance_f%from_file = .TRUE. |
---|
2490 | ! |
---|
2491 | !-- Input 2D uvem irradiance. |
---|
2492 | ALLOCATE ( uvem_irradiance_f%var(0:nlk, 0:2) ) |
---|
2493 | |
---|
2494 | CALL get_variable( id_uvem, 'irradiance', uvem_irradiance_f%var, 0, 2, 0, nlk ) |
---|
2495 | ELSE |
---|
2496 | uvem_irradiance_f%from_file = .FALSE. |
---|
2497 | ENDIF |
---|
2498 | ! |
---|
2499 | !-- uvem porjection areas |
---|
2500 | IF ( check_existence( var_names, 'projarea' ) ) THEN |
---|
2501 | uvem_projarea_f%from_file = .TRUE. |
---|
2502 | ! |
---|
2503 | !-- Input 3D uvem projection area (human geometgry) |
---|
2504 | ALLOCATE ( uvem_projarea_f%var(0:2,0:nlj,0:nli) ) |
---|
2505 | |
---|
2506 | CALL get_variable( id_uvem, 'projarea', uvem_projarea_f%var, 0, nli, 0, nlj, 0, 2 ) |
---|
2507 | ELSE |
---|
2508 | uvem_projarea_f%from_file = .FALSE. |
---|
2509 | ENDIF |
---|
2510 | ! |
---|
2511 | !-- uvem radiance |
---|
2512 | IF ( check_existence( var_names, 'radiance' ) ) THEN |
---|
2513 | uvem_radiance_f%from_file = .TRUE. |
---|
2514 | ! |
---|
2515 | !-- Input 3D uvem radiance |
---|
2516 | ALLOCATE ( uvem_radiance_f%var(0:nlk,0:nlj,0:nli) ) |
---|
2517 | |
---|
2518 | CALL get_variable( id_uvem, 'radiance', uvem_radiance_f%var, 0, nli, 0, nlj, 0, nlk ) |
---|
2519 | ELSE |
---|
2520 | uvem_radiance_f%from_file = .FALSE. |
---|
2521 | ENDIF |
---|
2522 | ! |
---|
2523 | !-- Read building obstruction |
---|
2524 | IF ( check_existence( var_names, 'obstruction' ) ) THEN |
---|
2525 | building_obstruction_full%from_file = .TRUE. |
---|
2526 | !-- Input 3D uvem building obstruction |
---|
2527 | ALLOCATE ( building_obstruction_full%var_3d(0:44,0:2,0:2) ) |
---|
2528 | CALL get_variable( id_uvem, 'obstruction', building_obstruction_full%var_3d,0, 2, 0, 2, 0, 44 ) |
---|
2529 | ELSE |
---|
2530 | building_obstruction_full%from_file = .FALSE. |
---|
2531 | ENDIF |
---|
2532 | ! |
---|
2533 | IF ( check_existence( var_names, 'obstruction' ) ) THEN |
---|
2534 | building_obstruction_f%from_file = .TRUE. |
---|
2535 | ! |
---|
2536 | !-- Input 3D uvem building obstruction |
---|
2537 | ALLOCATE ( building_obstruction_f%var_3d(0:44,nys:nyn,nxl:nxr) ) |
---|
2538 | ! |
---|
2539 | CALL get_variable( id_uvem, 'obstruction', building_obstruction_f%var_3d, & |
---|
2540 | nxl, nxr, nys, nyn, 0, 44 ) |
---|
2541 | ELSE |
---|
2542 | building_obstruction_f%from_file = .FALSE. |
---|
2543 | ENDIF |
---|
2544 | ! |
---|
2545 | !-- Close uvem lookup table input file |
---|
2546 | CALL close_input_file( id_uvem ) |
---|
2547 | #else |
---|
2548 | CONTINUE |
---|
2549 | #endif |
---|
2550 | ENDIF |
---|
2551 | END SUBROUTINE netcdf_data_input_uvem |
---|
2552 | |
---|
2553 | !------------------------------------------------------------------------------! |
---|
2554 | ! Description: |
---|
2555 | ! ------------ |
---|
2556 | !> Reads orography and building information. |
---|
2557 | !------------------------------------------------------------------------------! |
---|
2558 | SUBROUTINE netcdf_data_input_topo |
---|
2559 | |
---|
2560 | USE control_parameters, & |
---|
2561 | ONLY: message_string, topography |
---|
2562 | |
---|
2563 | USE grid_variables, & |
---|
2564 | ONLY: dx, dy |
---|
2565 | |
---|
2566 | USE indices, & |
---|
2567 | ONLY: nbgp, nx, nxl, nxr, ny, nyn, nys, nzb |
---|
2568 | |
---|
2569 | |
---|
2570 | IMPLICIT NONE |
---|
2571 | |
---|
2572 | CHARACTER(LEN=100), DIMENSION(:), ALLOCATABLE :: var_names !< variable names in static input file |
---|
2573 | |
---|
2574 | |
---|
2575 | INTEGER(iwp) :: i !< running index along x-direction |
---|
2576 | INTEGER(iwp) :: ii !< running index for IO blocks |
---|
2577 | INTEGER(iwp) :: id_topo !< NetCDF id of topograhy input file |
---|
2578 | INTEGER(iwp) :: j !< running index along y-direction |
---|
2579 | INTEGER(iwp) :: num_vars !< number of variables in netcdf input file |
---|
2580 | INTEGER(iwp) :: skip_n_rows !< counting variable to skip rows while reading topography file |
---|
2581 | |
---|
2582 | REAL(wp) :: dum !< dummy variable to skip columns while reading topography file |
---|
2583 | ! |
---|
2584 | !-- CPU measurement |
---|
2585 | CALL cpu_log( log_point_s(83), 'NetCDF/ASCII input topo', 'start' ) |
---|
2586 | |
---|
2587 | ! |
---|
2588 | !-- Input via palm-input data standard |
---|
2589 | IF ( input_pids_static ) THEN |
---|
2590 | #if defined ( __netcdf ) |
---|
2591 | ! |
---|
2592 | !-- Open file in read-only mode |
---|
2593 | CALL open_read_file( TRIM( input_file_static ) // & |
---|
2594 | TRIM( coupling_char ), id_topo ) |
---|
2595 | ! |
---|
2596 | !-- At first, inquire all variable names. |
---|
2597 | !-- This will be used to check whether an input variable exist |
---|
2598 | !-- or not. |
---|
2599 | CALL inquire_num_variables( id_topo, num_vars ) |
---|
2600 | ! |
---|
2601 | !-- Allocate memory to store variable names and inquire them. |
---|
2602 | ALLOCATE( var_names(1:num_vars) ) |
---|
2603 | CALL inquire_variable_names( id_topo, var_names ) |
---|
2604 | ! |
---|
2605 | !-- Read x, y - dimensions. Only required for consistency checks. |
---|
2606 | CALL get_dimension_length( id_topo, dim_static%nx, 'x' ) |
---|
2607 | CALL get_dimension_length( id_topo, dim_static%ny, 'y' ) |
---|
2608 | ALLOCATE( dim_static%x(0:dim_static%nx-1) ) |
---|
2609 | ALLOCATE( dim_static%y(0:dim_static%ny-1) ) |
---|
2610 | CALL get_variable( id_topo, 'x', dim_static%x ) |
---|
2611 | CALL get_variable( id_topo, 'y', dim_static%y ) |
---|
2612 | ! |
---|
2613 | !-- Check whether dimension size in input file matches the model dimensions |
---|
2614 | IF ( dim_static%nx-1 /= nx .OR. dim_static%ny-1 /= ny ) THEN |
---|
2615 | message_string = 'Static input file: horizontal dimension in ' // & |
---|
2616 | 'x- and/or y-direction ' // & |
---|
2617 | 'do not match the respective model dimension' |
---|
2618 | CALL message( 'netcdf_data_input_mod', 'PA0548', 1, 2, 0, 6, 0 ) |
---|
2619 | ENDIF |
---|
2620 | ! |
---|
2621 | !-- Check if grid spacing of provided input data matches the respective |
---|
2622 | !-- grid spacing in the model. |
---|
2623 | IF ( ABS( dim_static%x(1) - dim_static%x(0) - dx ) > 10E-6_wp .OR. & |
---|
2624 | ABS( dim_static%y(1) - dim_static%y(0) - dy ) > 10E-6_wp ) THEN |
---|
2625 | message_string = 'Static input file: horizontal grid spacing ' // & |
---|
2626 | 'in x- and/or y-direction ' // & |
---|
2627 | 'do not match the respective model grid spacing.' |
---|
2628 | CALL message( 'netcdf_data_input_mod', 'PA0549', 1, 2, 0, 6, 0 ) |
---|
2629 | ENDIF |
---|
2630 | ! |
---|
2631 | !-- Terrain height. First, get variable-related _FillValue attribute |
---|
2632 | IF ( check_existence( var_names, 'zt' ) ) THEN |
---|
2633 | terrain_height_f%from_file = .TRUE. |
---|
2634 | CALL get_attribute( id_topo, char_fill, terrain_height_f%fill, & |
---|
2635 | .FALSE., 'zt' ) |
---|
2636 | ! |
---|
2637 | !-- Input 2D terrain height. |
---|
2638 | ALLOCATE ( terrain_height_f%var(nys:nyn,nxl:nxr) ) |
---|
2639 | |
---|
2640 | CALL get_variable( id_topo, 'zt', terrain_height_f%var, & |
---|
2641 | nxl, nxr, nys, nyn ) |
---|
2642 | |
---|
2643 | ELSE |
---|
2644 | terrain_height_f%from_file = .FALSE. |
---|
2645 | ENDIF |
---|
2646 | |
---|
2647 | ! |
---|
2648 | !-- Read building height. First, read its _FillValue attribute, |
---|
2649 | !-- as well as lod attribute |
---|
2650 | buildings_f%from_file = .FALSE. |
---|
2651 | IF ( check_existence( var_names, 'buildings_2d' ) ) THEN |
---|
2652 | buildings_f%from_file = .TRUE. |
---|
2653 | CALL get_attribute( id_topo, char_lod, buildings_f%lod, & |
---|
2654 | .FALSE., 'buildings_2d' ) |
---|
2655 | |
---|
2656 | CALL get_attribute( id_topo, char_fill, buildings_f%fill1, & |
---|
2657 | .FALSE., 'buildings_2d' ) |
---|
2658 | |
---|
2659 | ! |
---|
2660 | !-- Read 2D buildings |
---|
2661 | IF ( buildings_f%lod == 1 ) THEN |
---|
2662 | ALLOCATE ( buildings_f%var_2d(nys:nyn,nxl:nxr) ) |
---|
2663 | |
---|
2664 | CALL get_variable( id_topo, 'buildings_2d', & |
---|
2665 | buildings_f%var_2d, & |
---|
2666 | nxl, nxr, nys, nyn ) |
---|
2667 | ELSE |
---|
2668 | message_string = 'NetCDF attribute lod ' // & |
---|
2669 | '(level of detail) is not set ' // & |
---|
2670 | 'properly for buildings_2d.' |
---|
2671 | CALL message( 'netcdf_data_input_mod', 'PA0540', & |
---|
2672 | 1, 2, 0, 6, 0 ) |
---|
2673 | ENDIF |
---|
2674 | ENDIF |
---|
2675 | ! |
---|
2676 | !-- If available, also read 3D building information. If both are |
---|
2677 | !-- available, use 3D information. |
---|
2678 | IF ( check_existence( var_names, 'buildings_3d' ) ) THEN |
---|
2679 | buildings_f%from_file = .TRUE. |
---|
2680 | CALL get_attribute( id_topo, char_lod, buildings_f%lod, & |
---|
2681 | .FALSE., 'buildings_3d' ) |
---|
2682 | |
---|
2683 | CALL get_attribute( id_topo, char_fill, buildings_f%fill2, & |
---|
2684 | .FALSE., 'buildings_3d' ) |
---|
2685 | |
---|
2686 | CALL get_dimension_length( id_topo, buildings_f%nz, 'z' ) |
---|
2687 | ! |
---|
2688 | !-- Read 3D buildings |
---|
2689 | IF ( buildings_f%lod == 2 ) THEN |
---|
2690 | ALLOCATE( buildings_f%z(nzb:buildings_f%nz-1) ) |
---|
2691 | CALL get_variable( id_topo, 'z', buildings_f%z ) |
---|
2692 | |
---|
2693 | ALLOCATE( buildings_f%var_3d(nzb:buildings_f%nz-1, & |
---|
2694 | nys:nyn,nxl:nxr) ) |
---|
2695 | buildings_f%var_3d = 0 |
---|
2696 | |
---|
2697 | CALL get_variable( id_topo, 'buildings_3d', & |
---|
2698 | buildings_f%var_3d, & |
---|
2699 | nxl, nxr, nys, nyn, 0, buildings_f%nz-1 ) |
---|
2700 | ELSE |
---|
2701 | message_string = 'NetCDF attribute lod ' // & |
---|
2702 | '(level of detail) is not set ' // & |
---|
2703 | 'properly for buildings_3d.' |
---|
2704 | CALL message( 'netcdf_data_input_mod', 'PA0541', & |
---|
2705 | 1, 2, 0, 6, 0 ) |
---|
2706 | ENDIF |
---|
2707 | ENDIF |
---|
2708 | ! |
---|
2709 | !-- Read building IDs and its FillValue attribute. Further required |
---|
2710 | !-- for mapping buildings on top of orography. |
---|
2711 | IF ( check_existence( var_names, 'building_id' ) ) THEN |
---|
2712 | building_id_f%from_file = .TRUE. |
---|
2713 | CALL get_attribute( id_topo, char_fill, & |
---|
2714 | building_id_f%fill, .FALSE., & |
---|
2715 | 'building_id' ) |
---|
2716 | |
---|
2717 | ALLOCATE ( building_id_f%var(nys:nyn,nxl:nxr) ) |
---|
2718 | |
---|
2719 | CALL get_variable( id_topo, 'building_id', building_id_f%var, & |
---|
2720 | nxl, nxr, nys, nyn ) |
---|
2721 | ELSE |
---|
2722 | building_id_f%from_file = .FALSE. |
---|
2723 | ENDIF |
---|
2724 | ! |
---|
2725 | !-- Read building_type and required attributes. |
---|
2726 | IF ( check_existence( var_names, 'building_type' ) ) THEN |
---|
2727 | building_type_f%from_file = .TRUE. |
---|
2728 | CALL get_attribute( id_topo, char_fill, & |
---|
2729 | building_type_f%fill, .FALSE., & |
---|
2730 | 'building_type' ) |
---|
2731 | |
---|
2732 | ALLOCATE ( building_type_f%var(nys:nyn,nxl:nxr) ) |
---|
2733 | |
---|
2734 | CALL get_variable( id_topo, 'building_type', building_type_f%var, & |
---|
2735 | nxl, nxr, nys, nyn ) |
---|
2736 | |
---|
2737 | ELSE |
---|
2738 | building_type_f%from_file = .FALSE. |
---|
2739 | ENDIF |
---|
2740 | ! |
---|
2741 | !-- Close topography input file |
---|
2742 | CALL close_input_file( id_topo ) |
---|
2743 | #else |
---|
2744 | CONTINUE |
---|
2745 | #endif |
---|
2746 | ! |
---|
2747 | !-- ASCII input |
---|
2748 | ELSEIF ( TRIM( topography ) == 'read_from_file' ) THEN |
---|
2749 | |
---|
2750 | DO ii = 0, io_blocks-1 |
---|
2751 | IF ( ii == io_group ) THEN |
---|
2752 | |
---|
2753 | OPEN( 90, FILE='TOPOGRAPHY_DATA'//TRIM( coupling_char ), & |
---|
2754 | STATUS='OLD', FORM='FORMATTED', ERR=10 ) |
---|
2755 | ! |
---|
2756 | !-- Read topography PE-wise. Rows are read from nyn to nys, columns |
---|
2757 | !-- are read from nxl to nxr. At first, ny-nyn rows need to be skipped. |
---|
2758 | skip_n_rows = 0 |
---|
2759 | DO WHILE ( skip_n_rows < ny - nyn ) |
---|
2760 | READ( 90, * ) |
---|
2761 | skip_n_rows = skip_n_rows + 1 |
---|
2762 | ENDDO |
---|
2763 | ! |
---|
2764 | !-- Read data from nyn to nys and nxl to nxr. Therefore, skip |
---|
2765 | !-- column until nxl-1 is reached |
---|
2766 | ALLOCATE ( buildings_f%var_2d(nys:nyn,nxl:nxr) ) |
---|
2767 | DO j = nyn, nys, -1 |
---|
2768 | READ( 90, *, ERR=11, END=11 ) & |
---|
2769 | ( dum, i = 0, nxl-1 ), & |
---|
2770 | ( buildings_f%var_2d(j,i), i = nxl, nxr ) |
---|
2771 | ENDDO |
---|
2772 | |
---|
2773 | GOTO 12 |
---|
2774 | |
---|
2775 | 10 message_string = 'file TOPOGRAPHY_DATA'// & |
---|
2776 | TRIM( coupling_char )// ' does not exist' |
---|
2777 | CALL message( 'netcdf_data_input_mod', 'PA0208', 1, 2, 0, 6, 0 ) |
---|
2778 | |
---|
2779 | 11 message_string = 'errors in file TOPOGRAPHY_DATA'// & |
---|
2780 | TRIM( coupling_char ) |
---|
2781 | CALL message( 'netcdf_data_input_mod', 'PA0209', 2, 2, 0, 6, 0 ) |
---|
2782 | |
---|
2783 | 12 CLOSE( 90 ) |
---|
2784 | buildings_f%from_file = .TRUE. |
---|
2785 | |
---|
2786 | ENDIF |
---|
2787 | #if defined( __parallel ) |
---|
2788 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
2789 | #endif |
---|
2790 | ENDDO |
---|
2791 | |
---|
2792 | ENDIF |
---|
2793 | ! |
---|
2794 | !-- End of CPU measurement |
---|
2795 | CALL cpu_log( log_point_s(83), 'NetCDF/ASCII input topo', 'stop' ) |
---|
2796 | ! |
---|
2797 | !-- Check for minimum requirement to setup building topography. If buildings |
---|
2798 | !-- are provided, also an ID and a type are required. |
---|
2799 | !-- Note, doing this check in check_parameters |
---|
2800 | !-- will be too late (data will be used for grid inititialization before). |
---|
2801 | IF ( input_pids_static ) THEN |
---|
2802 | IF ( buildings_f%from_file .AND. & |
---|
2803 | .NOT. building_id_f%from_file ) THEN |
---|
2804 | message_string = 'If building heights are prescribed in ' // & |
---|
2805 | 'static input file, also an ID is required.' |
---|
2806 | CALL message( 'netcdf_data_input_mod', 'PA0542', 1, 2, 0, 6, 0 ) |
---|
2807 | ENDIF |
---|
2808 | ENDIF |
---|
2809 | ! |
---|
2810 | !-- In case no terrain height is provided by static input file, allocate |
---|
2811 | !-- array nevertheless and set terrain height to 0, which simplifies |
---|
2812 | !-- topography initialization. |
---|
2813 | IF ( .NOT. terrain_height_f%from_file ) THEN |
---|
2814 | ALLOCATE ( terrain_height_f%var(nys:nyn,nxl:nxr) ) |
---|
2815 | terrain_height_f%var = 0.0_wp |
---|
2816 | ENDIF |
---|
2817 | ! |
---|
2818 | !-- Finally, exchange 1 ghost point for building ID and type. |
---|
2819 | !-- In case of non-cyclic boundary conditions set Neumann conditions at the |
---|
2820 | !-- lateral boundaries. |
---|
2821 | IF ( building_id_f%from_file ) THEN |
---|
2822 | CALL resize_array_2d_int32( building_id_f%var, nys, nyn, nxl, nxr ) |
---|
2823 | CALL exchange_horiz_2d_int( building_id_f%var, nys, nyn, nxl, nxr, & |
---|
2824 | nbgp ) |
---|
2825 | ENDIF |
---|
2826 | |
---|
2827 | IF ( building_type_f%from_file ) THEN |
---|
2828 | CALL resize_array_2d_int8( building_type_f%var, nys, nyn, nxl, nxr ) |
---|
2829 | CALL exchange_horiz_2d_byte( building_type_f%var, nys, nyn, nxl, nxr, & |
---|
2830 | nbgp ) |
---|
2831 | ENDIF |
---|
2832 | |
---|
2833 | END SUBROUTINE netcdf_data_input_topo |
---|
2834 | |
---|
2835 | !------------------------------------------------------------------------------! |
---|
2836 | ! Description: |
---|
2837 | ! ------------ |
---|
2838 | !> Reads initialization data of u, v, w, pt, q, geostrophic wind components, |
---|
2839 | !> as well as soil moisture and soil temperature, derived from larger-scale |
---|
2840 | !> model (COSMO) by Inifor. |
---|
2841 | !------------------------------------------------------------------------------! |
---|
2842 | SUBROUTINE netcdf_data_input_init_3d |
---|
2843 | |
---|
2844 | USE arrays_3d, & |
---|
2845 | ONLY: q, pt, u, v, w, zu, zw |
---|
2846 | |
---|
2847 | USE control_parameters, & |
---|
2848 | ONLY: air_chemistry, bc_lr_cyc, bc_ns_cyc, humidity, & |
---|
2849 | message_string, neutral |
---|
2850 | |
---|
2851 | USE indices, & |
---|
2852 | ONLY: nx, nxl, nxlu, nxr, ny, nyn, nys, nysv, nzb, nz, nzt |
---|
2853 | |
---|
2854 | IMPLICIT NONE |
---|
2855 | |
---|
2856 | CHARACTER(LEN=100), DIMENSION(:), ALLOCATABLE :: var_names |
---|
2857 | |
---|
2858 | LOGICAL :: dynamic_3d = .TRUE. !< flag indicating that 3D data is read from dynamic file |
---|
2859 | |
---|
2860 | INTEGER(iwp) :: id_dynamic !< NetCDF id of dynamic input file |
---|
2861 | INTEGER(iwp) :: n !< running index for chemistry variables |
---|
2862 | INTEGER(iwp) :: num_vars !< number of variables in netcdf input file |
---|
2863 | |
---|
2864 | LOGICAL :: check_passed !< flag indicating if a check passed |
---|
2865 | |
---|
2866 | ! |
---|
2867 | !-- Skip routine if no input file with dynamic input data is available. |
---|
2868 | IF ( .NOT. input_pids_dynamic ) RETURN |
---|
2869 | ! |
---|
2870 | !-- Please note, Inifor is designed to provide initial data for u and v for |
---|
2871 | !-- the prognostic grid points in case of lateral Dirichlet conditions. |
---|
2872 | !-- This means that Inifor provides data from nxlu:nxr (for u) and |
---|
2873 | !-- from nysv:nyn (for v) at the left and south domain boundary, respectively. |
---|
2874 | !-- However, as work-around for the moment, PALM will run with cyclic |
---|
2875 | !-- conditions and will be initialized with data provided by Inifor |
---|
2876 | !-- boundaries in case of Dirichlet. |
---|
2877 | !-- Hence, simply set set nxlu/nysv to 1 (will be reset to its original value |
---|
2878 | !-- at the end of this routine. |
---|
2879 | IF ( bc_lr_cyc .AND. nxl == 0 ) nxlu = 1 |
---|
2880 | IF ( bc_ns_cyc .AND. nys == 0 ) nysv = 1 |
---|
2881 | |
---|
2882 | ! |
---|
2883 | !-- CPU measurement |
---|
2884 | CALL cpu_log( log_point_s(85), 'NetCDF input init', 'start' ) |
---|
2885 | |
---|
2886 | #if defined ( __netcdf ) |
---|
2887 | ! |
---|
2888 | !-- Open file in read-only mode |
---|
2889 | CALL open_read_file( TRIM( input_file_dynamic ) // & |
---|
2890 | TRIM( coupling_char ), id_dynamic ) |
---|
2891 | |
---|
2892 | ! |
---|
2893 | !-- At first, inquire all variable names. |
---|
2894 | CALL inquire_num_variables( id_dynamic, num_vars ) |
---|
2895 | ! |
---|
2896 | !-- Allocate memory to store variable names. |
---|
2897 | ALLOCATE( var_names(1:num_vars) ) |
---|
2898 | CALL inquire_variable_names( id_dynamic, var_names ) |
---|
2899 | ! |
---|
2900 | !-- Read vertical dimension of scalar und w grid. |
---|
2901 | CALL get_dimension_length( id_dynamic, init_3d%nzu, 'z' ) |
---|
2902 | CALL get_dimension_length( id_dynamic, init_3d%nzw, 'zw' ) |
---|
2903 | ! |
---|
2904 | !-- Read also the horizontal dimensions. These are used just used fo |
---|
2905 | !-- checking the compatibility with the PALM grid before reading. |
---|
2906 | CALL get_dimension_length( id_dynamic, init_3d%nx, 'x' ) |
---|
2907 | CALL get_dimension_length( id_dynamic, init_3d%nxu, 'xu' ) |
---|
2908 | CALL get_dimension_length( id_dynamic, init_3d%ny, 'y' ) |
---|
2909 | CALL get_dimension_length( id_dynamic, init_3d%nyv, 'yv' ) |
---|
2910 | |
---|
2911 | ! |
---|
2912 | !-- Check for correct horizontal and vertical dimension. Please note, |
---|
2913 | !-- checks are performed directly here and not called from |
---|
2914 | !-- check_parameters as some varialbes are still not allocated there. |
---|
2915 | !-- Moreover, please note, u- and v-grid has 1 grid point less on |
---|
2916 | !-- Inifor grid. |
---|
2917 | IF ( init_3d%nx-1 /= nx .OR. init_3d%nxu-1 /= nx - 1 .OR. & |
---|
2918 | init_3d%ny-1 /= ny .OR. init_3d%nyv-1 /= ny - 1 ) THEN |
---|
2919 | message_string = 'Number of horizontal grid points in '// & |
---|
2920 | 'dynamic input file does not match ' // & |
---|
2921 | 'the number of numeric grid points.' |
---|
2922 | CALL message( 'netcdf_data_input_mod', 'PA0543', 1, 2, 0, 6, 0 ) |
---|
2923 | ENDIF |
---|
2924 | |
---|
2925 | IF ( init_3d%nzu /= nz ) THEN |
---|
2926 | message_string = 'Number of vertical grid points in '// & |
---|
2927 | 'dynamic input file does not match ' // & |
---|
2928 | 'the number of numeric grid points.' |
---|
2929 | CALL message( 'netcdf_data_input_mod', 'PA0543', 1, 2, 0, 6, 0 ) |
---|
2930 | ENDIF |
---|
2931 | ! |
---|
2932 | !-- Read vertical dimensions. Later, these are required for eventual |
---|
2933 | !-- inter- and extrapolations of the initialization data. |
---|
2934 | IF ( check_existence( var_names, 'z' ) ) THEN |
---|
2935 | ALLOCATE( init_3d%zu_atmos(1:init_3d%nzu) ) |
---|
2936 | CALL get_variable( id_dynamic, 'z', init_3d%zu_atmos ) |
---|
2937 | ENDIF |
---|
2938 | IF ( check_existence( var_names, 'zw' ) ) THEN |
---|
2939 | ALLOCATE( init_3d%zw_atmos(1:init_3d%nzw) ) |
---|
2940 | CALL get_variable( id_dynamic, 'zw', init_3d%zw_atmos ) |
---|
2941 | ENDIF |
---|
2942 | ! |
---|
2943 | !-- Check for consistency between vertical coordinates in dynamic |
---|
2944 | !-- driver and numeric grid. |
---|
2945 | !-- Please note, depending on compiler options both may be |
---|
2946 | !-- equal up to a certain threshold, and differences between |
---|
2947 | !-- the numeric grid and vertical coordinate in the driver can built- |
---|
2948 | !-- up to 10E-1-10E-0 m. For this reason, the check is performed not |
---|
2949 | !-- for exactly matching values. |
---|
2950 | IF ( ANY( ABS( zu(1:nzt) - init_3d%zu_atmos(1:init_3d%nzu) ) & |
---|
2951 | > 10E-1 ) .OR. & |
---|
2952 | ANY( ABS( zw(1:nzt-1) - init_3d%zw_atmos(1:init_3d%nzw) ) & |
---|
2953 | > 10E-1 ) ) THEN |
---|
2954 | message_string = 'Vertical grid in dynamic driver does not '// & |
---|
2955 | 'match the numeric grid.' |
---|
2956 | CALL message( 'netcdf_data_input_mod', 'PA0543', 1, 2, 0, 6, 0 ) |
---|
2957 | ENDIF |
---|
2958 | ! |
---|
2959 | !-- Read initial geostrophic wind components at |
---|
2960 | !-- t = 0 (index 1 in file). |
---|
2961 | IF ( check_existence( var_names, 'ls_forcing_ug' ) ) THEN |
---|
2962 | ALLOCATE( init_3d%ug_init(nzb:nzt+1) ) |
---|
2963 | init_3d%ug_init = 0.0_wp |
---|
2964 | |
---|
2965 | CALL get_variable_pr( id_dynamic, 'ls_forcing_ug', 1, & |
---|
2966 | init_3d%ug_init(1:nzt) ) |
---|
2967 | ! |
---|
2968 | !-- Set top-boundary condition (Neumann) |
---|
2969 | init_3d%ug_init(nzt+1) = init_3d%ug_init(nzt) |
---|
2970 | |
---|
2971 | init_3d%from_file_ug = .TRUE. |
---|
2972 | ELSE |
---|
2973 | init_3d%from_file_ug = .FALSE. |
---|
2974 | ENDIF |
---|
2975 | IF ( check_existence( var_names, 'ls_forcing_vg' ) ) THEN |
---|
2976 | ALLOCATE( init_3d%vg_init(nzb:nzt+1) ) |
---|
2977 | init_3d%vg_init = 0.0_wp |
---|
2978 | |
---|
2979 | CALL get_variable_pr( id_dynamic, 'ls_forcing_vg', 1, & |
---|
2980 | init_3d%vg_init(1:nzt) ) |
---|
2981 | ! |
---|
2982 | !-- Set top-boundary condition (Neumann) |
---|
2983 | init_3d%vg_init(nzt+1) = init_3d%vg_init(nzt) |
---|
2984 | |
---|
2985 | init_3d%from_file_vg = .TRUE. |
---|
2986 | ELSE |
---|
2987 | init_3d%from_file_vg = .FALSE. |
---|
2988 | ENDIF |
---|
2989 | ! |
---|
2990 | !-- Read inital 3D data of u, v, w, pt and q, |
---|
2991 | !-- derived from COSMO model. Read PE-wise yz-slices. |
---|
2992 | !-- Please note, the u-, v- and w-component are defined on different |
---|
2993 | !-- grids with one element less in the x-, y-, |
---|
2994 | !-- and z-direction, respectively. Hence, reading is subdivided |
---|
2995 | !-- into separate loops. |
---|
2996 | !-- Read u-component |
---|
2997 | IF ( check_existence( var_names, 'init_atmosphere_u' ) ) THEN |
---|
2998 | ! |
---|
2999 | !-- Read attributes for the fill value and level-of-detail |
---|
3000 | CALL get_attribute( id_dynamic, char_fill, init_3d%fill_u, & |
---|
3001 | .FALSE., 'init_atmosphere_u' ) |
---|
3002 | CALL get_attribute( id_dynamic, char_lod, init_3d%lod_u, & |
---|
3003 | .FALSE., 'init_atmosphere_u' ) |
---|
3004 | ! |
---|
3005 | !-- level-of-detail 1 - read initialization profile |
---|
3006 | IF ( init_3d%lod_u == 1 ) THEN |
---|
3007 | ALLOCATE( init_3d%u_init(nzb:nzt+1) ) |
---|
3008 | init_3d%u_init = 0.0_wp |
---|
3009 | |
---|
3010 | CALL get_variable( id_dynamic, 'init_atmosphere_u', & |
---|
3011 | init_3d%u_init(nzb+1:nzt) ) |
---|
3012 | ! |
---|
3013 | !-- Set top-boundary condition (Neumann) |
---|
3014 | init_3d%u_init(nzt+1) = init_3d%u_init(nzt) |
---|
3015 | ! |
---|
3016 | !-- level-of-detail 2 - read 3D initialization data |
---|
3017 | ELSEIF ( init_3d%lod_u == 2 ) THEN |
---|
3018 | CALL get_variable( id_dynamic, 'init_atmosphere_u', & |
---|
3019 | u(nzb+1:nzt,nys:nyn,nxlu:nxr), & |
---|
3020 | nxlu, nys+1, nzb+1, & |
---|
3021 | nxr-nxlu+1, nyn-nys+1, init_3d%nzu, & |
---|
3022 | dynamic_3d ) |
---|
3023 | ! |
---|
3024 | !-- Set value at leftmost model grid point nxl = 0. This is because |
---|
3025 | !-- Inifor provides data only from 1:nx-1 since it assumes non-cyclic |
---|
3026 | !-- conditions. |
---|
3027 | IF ( nxl == 0 ) & |
---|
3028 | u(nzb+1:nzt,nys:nyn,nxl) = u(nzb+1:nzt,nys:nyn,nxlu) |
---|
3029 | ! |
---|
3030 | !-- Set bottom and top-boundary |
---|
3031 | u(nzb,:,:) = u(nzb+1,:,:) |
---|
3032 | u(nzt+1,:,:) = u(nzt,:,:) |
---|
3033 | |
---|
3034 | ENDIF |
---|
3035 | init_3d%from_file_u = .TRUE. |
---|
3036 | ELSE |
---|
3037 | message_string = 'Missing initial data for u-component' |
---|
3038 | CALL message( 'netcdf_data_input_mod', 'PA0544', 1, 2, 0, 6, 0 ) |
---|
3039 | ENDIF |
---|
3040 | ! |
---|
3041 | !-- Read v-component |
---|
3042 | IF ( check_existence( var_names, 'init_atmosphere_v' ) ) THEN |
---|
3043 | ! |
---|
3044 | !-- Read attributes for the fill value and level-of-detail |
---|
3045 | CALL get_attribute( id_dynamic, char_fill, init_3d%fill_v, & |
---|
3046 | .FALSE., 'init_atmosphere_v' ) |
---|
3047 | CALL get_attribute( id_dynamic, char_lod, init_3d%lod_v, & |
---|
3048 | .FALSE., 'init_atmosphere_v' ) |
---|
3049 | ! |
---|
3050 | !-- level-of-detail 1 - read initialization profile |
---|
3051 | IF ( init_3d%lod_v == 1 ) THEN |
---|
3052 | ALLOCATE( init_3d%v_init(nzb:nzt+1) ) |
---|
3053 | init_3d%v_init = 0.0_wp |
---|
3054 | |
---|
3055 | CALL get_variable( id_dynamic, 'init_atmosphere_v', & |
---|
3056 | init_3d%v_init(nzb+1:nzt) ) |
---|
3057 | ! |
---|
3058 | !-- Set top-boundary condition (Neumann) |
---|
3059 | init_3d%v_init(nzt+1) = init_3d%v_init(nzt) |
---|
3060 | ! |
---|
3061 | !-- level-of-detail 2 - read 3D initialization data |
---|
3062 | ELSEIF ( init_3d%lod_v == 2 ) THEN |
---|
3063 | |
---|
3064 | CALL get_variable( id_dynamic, 'init_atmosphere_v', & |
---|
3065 | v(nzb+1:nzt,nysv:nyn,nxl:nxr), & |
---|
3066 | nxl+1, nysv, nzb+1, & |
---|
3067 | nxr-nxl+1, nyn-nysv+1, init_3d%nzu, & |
---|
3068 | dynamic_3d ) |
---|
3069 | ! |
---|
3070 | !-- Set value at southmost model grid point nys = 0. This is because |
---|
3071 | !-- Inifor provides data only from 1:ny-1 since it assumes non-cyclic |
---|
3072 | !-- conditions. |
---|
3073 | IF ( nys == 0 ) & |
---|
3074 | v(nzb+1:nzt,nys,nxl:nxr) = v(nzb+1:nzt,nysv,nxl:nxr) |
---|
3075 | ! |
---|
3076 | !-- Set bottom and top-boundary |
---|
3077 | v(nzb,:,:) = v(nzb+1,:,:) |
---|
3078 | v(nzt+1,:,:) = v(nzt,:,:) |
---|
3079 | |
---|
3080 | ENDIF |
---|
3081 | init_3d%from_file_v = .TRUE. |
---|
3082 | ELSE |
---|
3083 | message_string = 'Missing initial data for v-component' |
---|
3084 | CALL message( 'netcdf_data_input_mod', 'PA0544', 1, 2, 0, 6, 0 ) |
---|
3085 | ENDIF |
---|
3086 | ! |
---|
3087 | !-- Read w-component |
---|
3088 | IF ( check_existence( var_names, 'init_atmosphere_w' ) ) THEN |
---|
3089 | ! |
---|
3090 | !-- Read attributes for the fill value and level-of-detail |
---|
3091 | CALL get_attribute( id_dynamic, char_fill, init_3d%fill_w, & |
---|
3092 | .FALSE., 'init_atmosphere_w' ) |
---|
3093 | CALL get_attribute( id_dynamic, char_lod, init_3d%lod_w, & |
---|
3094 | .FALSE., 'init_atmosphere_w' ) |
---|
3095 | ! |
---|
3096 | !-- level-of-detail 1 - read initialization profile |
---|
3097 | IF ( init_3d%lod_w == 1 ) THEN |
---|
3098 | ALLOCATE( init_3d%w_init(nzb:nzt+1) ) |
---|
3099 | init_3d%w_init = 0.0_wp |
---|
3100 | |
---|
3101 | CALL get_variable( id_dynamic, 'init_atmosphere_w', & |
---|
3102 | init_3d%w_init(nzb+1:nzt-1) ) |
---|
3103 | ! |
---|
3104 | !-- Set top-boundary condition (Neumann) |
---|
3105 | init_3d%w_init(nzt:nzt+1) = init_3d%w_init(nzt-1) |
---|
3106 | ! |
---|
3107 | !-- level-of-detail 2 - read 3D initialization data |
---|
3108 | ELSEIF ( init_3d%lod_w == 2 ) THEN |
---|
3109 | |
---|
3110 | CALL get_variable( id_dynamic, 'init_atmosphere_w', & |
---|
3111 | w(nzb+1:nzt-1,nys:nyn,nxl:nxr), & |
---|
3112 | nxl+1, nys+1, nzb+1, & |
---|
3113 | nxr-nxl+1, nyn-nys+1, init_3d%nzw, & |
---|
3114 | dynamic_3d ) |
---|
3115 | ! |
---|
3116 | !-- Set bottom and top-boundary |
---|
3117 | w(nzb,:,:) = 0.0_wp |
---|
3118 | w(nzt,:,:) = w(nzt-1,:,:) |
---|
3119 | w(nzt+1,:,:) = w(nzt-1,:,:) |
---|
3120 | |
---|
3121 | ENDIF |
---|
3122 | init_3d%from_file_w = .TRUE. |
---|
3123 | ELSE |
---|
3124 | message_string = 'Missing initial data for w-component' |
---|
3125 | CALL message( 'netcdf_data_input_mod', 'PA0544', 1, 2, 0, 6, 0 ) |
---|
3126 | ENDIF |
---|
3127 | ! |
---|
3128 | !-- Read potential temperature |
---|
3129 | IF ( .NOT. neutral ) THEN |
---|
3130 | IF ( check_existence( var_names, 'init_atmosphere_pt' ) ) THEN |
---|
3131 | ! |
---|
3132 | !-- Read attributes for the fill value and level-of-detail |
---|
3133 | CALL get_attribute( id_dynamic, char_fill, init_3d%fill_pt, & |
---|
3134 | .FALSE., 'init_atmosphere_pt' ) |
---|
3135 | CALL get_attribute( id_dynamic, char_lod, init_3d%lod_pt, & |
---|
3136 | .FALSE., 'init_atmosphere_pt' ) |
---|
3137 | ! |
---|
3138 | !-- level-of-detail 1 - read initialization profile |
---|
3139 | IF ( init_3d%lod_pt == 1 ) THEN |
---|
3140 | ALLOCATE( init_3d%pt_init(nzb:nzt+1) ) |
---|
3141 | |
---|
3142 | CALL get_variable( id_dynamic, 'init_atmosphere_pt', & |
---|
3143 | init_3d%pt_init(nzb+1:nzt) ) |
---|
3144 | ! |
---|
3145 | !-- Set Neumann top and surface boundary condition for initial |
---|
3146 | !-- profil |
---|
3147 | init_3d%pt_init(nzb) = init_3d%pt_init(nzb+1) |
---|
3148 | init_3d%pt_init(nzt+1) = init_3d%pt_init(nzt) |
---|
3149 | ! |
---|
3150 | !-- level-of-detail 2 - read 3D initialization data |
---|
3151 | ELSEIF ( init_3d%lod_pt == 2 ) THEN |
---|
3152 | |
---|
3153 | CALL get_variable( id_dynamic, 'init_atmosphere_pt', & |
---|
3154 | pt(nzb+1:nzt,nys:nyn,nxl:nxr), & |
---|
3155 | nxl+1, nys+1, nzb+1, & |
---|
3156 | nxr-nxl+1, nyn-nys+1, init_3d%nzu, & |
---|
3157 | dynamic_3d ) |
---|
3158 | |
---|
3159 | ! |
---|
3160 | !-- Set bottom and top-boundary |
---|
3161 | pt(nzb,:,:) = pt(nzb+1,:,:) |
---|
3162 | pt(nzt+1,:,:) = pt(nzt,:,:) |
---|
3163 | |
---|
3164 | ENDIF |
---|
3165 | init_3d%from_file_pt = .TRUE. |
---|
3166 | ELSE |
---|
3167 | message_string = 'Missing initial data for ' // & |
---|
3168 | 'potential temperature' |
---|
3169 | CALL message( 'netcdf_data_input_mod', 'PA0544', 1, 2, 0, 6, 0 ) |
---|
3170 | ENDIF |
---|
3171 | ENDIF |
---|
3172 | ! |
---|
3173 | !-- Read mixing ratio |
---|
3174 | IF ( humidity ) THEN |
---|
3175 | IF ( check_existence( var_names, 'init_atmosphere_qv' ) ) THEN |
---|
3176 | ! |
---|
3177 | !-- Read attributes for the fill value and level-of-detail |
---|
3178 | CALL get_attribute( id_dynamic, char_fill, init_3d%fill_q, & |
---|
3179 | .FALSE., 'init_atmosphere_qv' ) |
---|
3180 | CALL get_attribute( id_dynamic, char_lod, init_3d%lod_q, & |
---|
3181 | .FALSE., 'init_atmosphere_qv' ) |
---|
3182 | ! |
---|
3183 | !-- level-of-detail 1 - read initialization profile |
---|
3184 | IF ( init_3d%lod_q == 1 ) THEN |
---|
3185 | ALLOCATE( init_3d%q_init(nzb:nzt+1) ) |
---|
3186 | |
---|
3187 | CALL get_variable( id_dynamic, 'init_atmosphere_qv', & |
---|
3188 | init_3d%q_init(nzb+1:nzt) ) |
---|
3189 | ! |
---|
3190 | !-- Set bottom and top boundary condition (Neumann) |
---|
3191 | init_3d%q_init(nzb) = init_3d%q_init(nzb+1) |
---|
3192 | init_3d%q_init(nzt+1) = init_3d%q_init(nzt) |
---|
3193 | ! |
---|
3194 | !-- level-of-detail 2 - read 3D initialization data |
---|
3195 | ELSEIF ( init_3d%lod_q == 2 ) THEN |
---|
3196 | |
---|
3197 | CALL get_variable( id_dynamic, 'init_atmosphere_qv', & |
---|
3198 | q(nzb+1:nzt,nys:nyn,nxl:nxr), & |
---|
3199 | nxl+1, nys+1, nzb+1, & |
---|
3200 | nxr-nxl+1, nyn-nys+1, init_3d%nzu, & |
---|
3201 | dynamic_3d ) |
---|
3202 | |
---|
3203 | ! |
---|
3204 | !-- Set bottom and top-boundary |
---|
3205 | q(nzb,:,:) = q(nzb+1,:,:) |
---|
3206 | q(nzt+1,:,:) = q(nzt,:,:) |
---|
3207 | |
---|
3208 | ENDIF |
---|
3209 | init_3d%from_file_q = .TRUE. |
---|
3210 | ELSE |
---|
3211 | message_string = 'Missing initial data for ' // & |
---|
3212 | 'mixing ratio' |
---|
3213 | CALL message( 'netcdf_data_input_mod', 'PA0544', 1, 2, 0, 6, 0 ) |
---|
3214 | ENDIF |
---|
3215 | ENDIF |
---|
3216 | ! |
---|
3217 | !-- Read chemistry variables. |
---|
3218 | !-- Please note, for the moment, only LOD=1 is allowed |
---|
3219 | IF ( air_chemistry ) THEN |
---|
3220 | ! |
---|
3221 | !-- Allocate chemistry input profiles, as well as arrays for fill values |
---|
3222 | !-- and LOD's. |
---|
3223 | ALLOCATE( init_3d%chem_init(nzb:nzt+1, & |
---|
3224 | 1:UBOUND(init_3d%var_names_chem, 1 )) ) |
---|
3225 | ALLOCATE( init_3d%fill_chem(1:UBOUND(init_3d%var_names_chem, 1)) ) |
---|
3226 | ALLOCATE( init_3d%lod_chem(1:UBOUND(init_3d%var_names_chem, 1)) ) |
---|
3227 | |
---|
3228 | DO n = 1, UBOUND(init_3d%var_names_chem, 1) |
---|
3229 | IF ( check_existence( var_names, & |
---|
3230 | TRIM( init_3d%var_names_chem(n) ) ) ) THEN |
---|
3231 | ! |
---|
3232 | !-- Read attributes for the fill value and level-of-detail |
---|
3233 | CALL get_attribute( id_dynamic, char_fill, & |
---|
3234 | init_3d%fill_chem(n), & |
---|
3235 | .FALSE., & |
---|
3236 | TRIM( init_3d%var_names_chem(n) ) ) |
---|
3237 | CALL get_attribute( id_dynamic, char_lod, & |
---|
3238 | init_3d%lod_chem(n), & |
---|
3239 | .FALSE., & |
---|
3240 | TRIM( init_3d%var_names_chem(n) ) ) |
---|
3241 | ! |
---|
3242 | !-- Give message that only LOD=1 is allowed. |
---|
3243 | IF ( init_3d%lod_chem(n) /= 1 ) THEN |
---|
3244 | message_string = 'For chemistry variables only LOD=1 is ' //& |
---|
3245 | 'allowed.' |
---|
3246 | CALL message( 'netcdf_data_input_mod', 'PA0586', & |
---|
3247 | 1, 2, 0, 6, 0 ) |
---|
3248 | ENDIF |
---|
3249 | ! |
---|
3250 | !-- level-of-detail 1 - read initialization profile |
---|
3251 | CALL get_variable( id_dynamic, & |
---|
3252 | TRIM( init_3d%var_names_chem(n) ), & |
---|
3253 | init_3d%chem_init(nzb+1:nzt,n) ) |
---|
3254 | ! |
---|
3255 | !-- Set bottom and top boundary condition (Neumann) |
---|
3256 | init_3d%chem_init(nzb,n) = init_3d%chem_init(nzb+1,n) |
---|
3257 | init_3d%chem_init(nzt+1,n) = init_3d%chem_init(nzt,n) |
---|
3258 | |
---|
3259 | init_3d%from_file_chem(n) = .TRUE. |
---|
3260 | ENDIF |
---|
3261 | ENDDO |
---|
3262 | ENDIF |
---|
3263 | ! |
---|
3264 | !-- Close input file |
---|
3265 | CALL close_input_file( id_dynamic ) |
---|
3266 | #endif |
---|
3267 | ! |
---|
3268 | !-- End of CPU measurement |
---|
3269 | CALL cpu_log( log_point_s(85), 'NetCDF input init', 'stop' ) |
---|
3270 | ! |
---|
3271 | !-- Finally, check if the input data has any fill values. Please note, |
---|
3272 | !-- checks depend on the LOD of the input data. |
---|
3273 | IF ( init_3d%from_file_u ) THEN |
---|
3274 | check_passed = .TRUE. |
---|
3275 | IF ( init_3d%lod_u == 1 ) THEN |
---|
3276 | IF ( ANY( init_3d%u_init(nzb+1:nzt+1) == init_3d%fill_u ) ) & |
---|
3277 | check_passed = .FALSE. |
---|
3278 | ELSEIF ( init_3d%lod_u == 2 ) THEN |
---|
3279 | IF ( ANY( u(nzb+1:nzt+1,nys:nyn,nxlu:nxr) == init_3d%fill_u ) ) & |
---|
3280 | check_passed = .FALSE. |
---|
3281 | ENDIF |
---|
3282 | IF ( .NOT. check_passed ) THEN |
---|
3283 | message_string = 'NetCDF input for init_atmosphere_u must ' // & |
---|
3284 | 'not contain any _FillValues' |
---|
3285 | CALL message( 'netcdf_data_input_mod', 'PA0545', 2, 2, 0, 6, 0 ) |
---|
3286 | ENDIF |
---|
3287 | ENDIF |
---|
3288 | |
---|
3289 | IF ( init_3d%from_file_v ) THEN |
---|
3290 | check_passed = .TRUE. |
---|
3291 | IF ( init_3d%lod_v == 1 ) THEN |
---|
3292 | IF ( ANY( init_3d%v_init(nzb+1:nzt+1) == init_3d%fill_v ) ) & |
---|
3293 | check_passed = .FALSE. |
---|
3294 | ELSEIF ( init_3d%lod_v == 2 ) THEN |
---|
3295 | IF ( ANY( v(nzb+1:nzt+1,nysv:nyn,nxl:nxr) == init_3d%fill_v ) ) & |
---|
3296 | check_passed = .FALSE. |
---|
3297 | ENDIF |
---|
3298 | IF ( .NOT. check_passed ) THEN |
---|
3299 | message_string = 'NetCDF input for init_atmosphere_v must ' // & |
---|
3300 | 'not contain any _FillValues' |
---|
3301 | CALL message( 'netcdf_data_input_mod', 'PA0545', 2, 2, 0, 6, 0 ) |
---|
3302 | ENDIF |
---|
3303 | ENDIF |
---|
3304 | |
---|
3305 | IF ( init_3d%from_file_w ) THEN |
---|
3306 | check_passed = .TRUE. |
---|
3307 | IF ( init_3d%lod_w == 1 ) THEN |
---|
3308 | IF ( ANY( init_3d%w_init(nzb+1:nzt) == init_3d%fill_w ) ) & |
---|
3309 | check_passed = .FALSE. |
---|
3310 | ELSEIF ( init_3d%lod_w == 2 ) THEN |
---|
3311 | IF ( ANY( w(nzb+1:nzt,nys:nyn,nxl:nxr) == init_3d%fill_w ) ) & |
---|
3312 | check_passed = .FALSE. |
---|
3313 | ENDIF |
---|
3314 | IF ( .NOT. check_passed ) THEN |
---|
3315 | message_string = 'NetCDF input for init_atmosphere_w must ' // & |
---|
3316 | 'not contain any _FillValues' |
---|
3317 | CALL message( 'netcdf_data_input_mod', 'PA0545', 2, 2, 0, 6, 0 ) |
---|
3318 | ENDIF |
---|
3319 | ENDIF |
---|
3320 | |
---|
3321 | IF ( init_3d%from_file_pt ) THEN |
---|
3322 | check_passed = .TRUE. |
---|
3323 | IF ( init_3d%lod_pt == 1 ) THEN |
---|
3324 | IF ( ANY( init_3d%pt_init(nzb+1:nzt+1) == init_3d%fill_pt ) ) & |
---|
3325 | check_passed = .FALSE. |
---|
3326 | ELSEIF ( init_3d%lod_pt == 2 ) THEN |
---|
3327 | IF ( ANY( pt(nzb+1:nzt+1,nys:nyn,nxl:nxr) == init_3d%fill_pt ) ) & |
---|
3328 | check_passed = .FALSE. |
---|
3329 | ENDIF |
---|
3330 | IF ( .NOT. check_passed ) THEN |
---|
3331 | message_string = 'NetCDF input for init_atmosphere_pt must ' // & |
---|
3332 | 'not contain any _FillValues' |
---|
3333 | CALL message( 'netcdf_data_input_mod', 'PA0545', 2, 2, 0, 6, 0 ) |
---|
3334 | ENDIF |
---|
3335 | ENDIF |
---|
3336 | |
---|
3337 | IF ( init_3d%from_file_q ) THEN |
---|
3338 | check_passed = .TRUE. |
---|
3339 | IF ( init_3d%lod_q == 1 ) THEN |
---|
3340 | IF ( ANY( init_3d%q_init(nzb+1:nzt+1) == init_3d%fill_q ) ) & |
---|
3341 | check_passed = .FALSE. |
---|
3342 | ELSEIF ( init_3d%lod_q == 2 ) THEN |
---|
3343 | IF ( ANY( q(nzb+1:nzt+1,nys:nyn,nxl:nxr) == init_3d%fill_q ) ) & |
---|
3344 | check_passed = .FALSE. |
---|
3345 | ENDIF |
---|
3346 | IF ( .NOT. check_passed ) THEN |
---|
3347 | message_string = 'NetCDF input for init_atmosphere_q must ' // & |
---|
3348 | 'not contain any _FillValues' |
---|
3349 | CALL message( 'netcdf_data_input_mod', 'PA0545', 2, 2, 0, 6, 0 ) |
---|
3350 | ENDIF |
---|
3351 | ENDIF |
---|
3352 | ! |
---|
3353 | !-- Workaround for cyclic conditions. Please see above for further explanation. |
---|
3354 | IF ( bc_lr_cyc .AND. nxl == 0 ) nxlu = nxl |
---|
3355 | IF ( bc_ns_cyc .AND. nys == 0 ) nysv = nys |
---|
3356 | |
---|
3357 | END SUBROUTINE netcdf_data_input_init_3d |
---|
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 |
---|
3368 | |
---|
3369 | IMPLICIT NONE |
---|
3370 | ! |
---|
3371 | !-- Dynamic input file must also be present if initialization via inifor is |
---|
3372 | !-- prescribed. |
---|
3373 | IF ( .NOT. input_pids_dynamic .AND. & |
---|
3374 | INDEX( initializing_actions, 'inifor' ) /= 0 ) THEN |
---|
3375 | message_string = 'initializing_actions = inifor requires dynamic ' //& |
---|
3376 | 'input file ' // TRIM( input_file_dynamic ) // & |
---|
3377 | TRIM( coupling_char ) |
---|
3378 | CALL message( 'netcdf_data_input_mod', 'PA0547', 1, 2, 0, 6, 0 ) |
---|
3379 | ENDIF |
---|
3380 | |
---|
3381 | END SUBROUTINE netcdf_data_input_check_dynamic |
---|
3382 | |
---|
3383 | !------------------------------------------------------------------------------! |
---|
3384 | ! Description: |
---|
3385 | ! ------------ |
---|
3386 | !> Checks input file for consistency and minimum requirements. |
---|
3387 | !------------------------------------------------------------------------------! |
---|
3388 | SUBROUTINE netcdf_data_input_check_static |
---|
3389 | |
---|
3390 | USE arrays_3d, & |
---|
3391 | ONLY: zu |
---|
3392 | |
---|
3393 | USE control_parameters, & |
---|
3394 | ONLY: land_surface, message_string, urban_surface |
---|
3395 | |
---|
3396 | USE indices, & |
---|
3397 | ONLY: nxl, nxr, nyn, nys, wall_flags_0 |
---|
3398 | |
---|
3399 | IMPLICIT NONE |
---|
3400 | |
---|
3401 | INTEGER(iwp) :: i !< loop index along x-direction |
---|
3402 | INTEGER(iwp) :: j !< loop index along y-direction |
---|
3403 | INTEGER(iwp) :: n_surf !< number of different surface types at given location |
---|
3404 | |
---|
3405 | LOGICAL :: check_passed !< flag indicating if a check passed |
---|
3406 | |
---|
3407 | ! |
---|
3408 | !-- Return if no static input file is available |
---|
3409 | IF ( .NOT. input_pids_static ) RETURN |
---|
3410 | ! |
---|
3411 | !-- Check for correct dimension of surface_fractions, should run from 0-2. |
---|
3412 | IF ( surface_fraction_f%from_file ) THEN |
---|
3413 | IF ( surface_fraction_f%nf-1 > 2 ) THEN |
---|
3414 | message_string = 'nsurface_fraction must not be larger than 3.' |
---|
3415 | CALL message( 'netcdf_data_input_mod', 'PA0580', 1, 2, 0, 6, 0 ) |
---|
3416 | ENDIF |
---|
3417 | ENDIF |
---|
3418 | ! |
---|
3419 | !-- Check orography for fill-values. For the moment, give an error message. |
---|
3420 | !-- More advanced methods, e.g. a nearest neighbor algorithm as used in GIS |
---|
3421 | !-- systems might be implemented later. |
---|
3422 | !-- Please note, if no terrain height is provided, it is set to 0. |
---|
3423 | IF ( ANY( terrain_height_f%var == terrain_height_f%fill ) ) THEN |
---|
3424 | message_string = 'NetCDF variable zt is not ' // & |
---|
3425 | 'allowed to have missing data' |
---|
3426 | CALL message( 'netcdf_data_input_mod', 'PA0550', 2, 2, myid, 6, 0 ) |
---|
3427 | ENDIF |
---|
3428 | ! |
---|
3429 | !-- Check for negative terrain heights |
---|
3430 | IF ( ANY( terrain_height_f%var < 0.0_wp ) ) THEN |
---|
3431 | message_string = 'NetCDF variable zt is not ' // & |
---|
3432 | 'allowed to have negative values' |
---|
3433 | CALL message( 'netcdf_data_input_mod', 'PA0551', 2, 2, myid, 6, 0 ) |
---|
3434 | ENDIF |
---|
3435 | ! |
---|
3436 | !-- If 3D buildings are read, check if building information is consistent |
---|
3437 | !-- to numeric grid. |
---|
3438 | IF ( buildings_f%from_file ) THEN |
---|
3439 | IF ( buildings_f%lod == 2 ) THEN |
---|
3440 | IF ( buildings_f%nz > SIZE( zu ) ) THEN |
---|
3441 | message_string = 'Reading 3D building data - too much ' // & |
---|
3442 | 'data points along the vertical coordinate.' |
---|
3443 | CALL message( 'netcdf_data_input_mod', 'PA0552', 2, 2, 0, 6, 0 ) |
---|
3444 | ENDIF |
---|
3445 | |
---|
3446 | IF ( ANY( ABS( buildings_f%z(0:buildings_f%nz-1) - & |
---|
3447 | zu(0:buildings_f%nz-1) ) > 1E-6_wp ) ) THEN |
---|
3448 | message_string = 'Reading 3D building data - vertical ' // & |
---|
3449 | 'coordinate do not match numeric grid.' |
---|
3450 | CALL message( 'netcdf_data_input_mod', 'PA0553', 2, 2, 0, 6, 0 ) |
---|
3451 | ENDIF |
---|
3452 | ENDIF |
---|
3453 | ENDIF |
---|
3454 | |
---|
3455 | ! |
---|
3456 | !-- Skip further checks concerning buildings and natural surface properties |
---|
3457 | !-- if no urban surface and land surface model are applied. |
---|
3458 | IF ( .NOT. land_surface .AND. .NOT. urban_surface ) RETURN |
---|
3459 | ! |
---|
3460 | !-- Check for minimum requirement of surface-classification data in case |
---|
3461 | !-- static input file is used. |
---|
3462 | IF ( ( .NOT. vegetation_type_f%from_file .OR. & |
---|
3463 | .NOT. pavement_type_f%from_file .OR. & |
---|
3464 | .NOT. water_type_f%from_file .OR. & |
---|
3465 | .NOT. soil_type_f%from_file ) .OR. & |
---|
3466 | ( urban_surface .AND. .NOT. building_type_f%from_file ) ) THEN |
---|
3467 | message_string = 'Minimum requirement for surface classification ' //& |
---|
3468 | 'is not fulfilled. At least ' // & |
---|
3469 | 'vegetation_type, pavement_type, ' // & |
---|
3470 | 'soil_type and water_type are '// & |
---|
3471 | 'required. If urban-surface model is applied, ' // & |
---|
3472 | 'also building_type is required' |
---|
3473 | CALL message( 'netcdf_data_input_mod', 'PA0554', 1, 2, 0, 6, 0 ) |
---|
3474 | ENDIF |
---|
3475 | ! |
---|
3476 | !-- Check for general availability of input variables. |
---|
3477 | !-- If vegetation_type is 0 at any location, vegetation_pars as well as |
---|
3478 | !-- root_area_dens_s are required. |
---|
3479 | IF ( vegetation_type_f%from_file ) THEN |
---|
3480 | IF ( ANY( vegetation_type_f%var == 0 ) ) THEN |
---|
3481 | IF ( .NOT. vegetation_pars_f%from_file ) THEN |
---|
3482 | message_string = 'If vegetation_type = 0 at any location, ' // & |
---|
3483 | 'vegetation_pars is required' |
---|
3484 | CALL message( 'netcdf_data_input_mod', 'PA0555', 2, 2, -1, 6, 0 ) |
---|
3485 | ENDIF |
---|
3486 | IF ( .NOT. root_area_density_lsm_f%from_file ) THEN |
---|
3487 | message_string = 'If vegetation_type = 0 at any location, ' // & |
---|
3488 | 'root_area_dens_s is required' |
---|
3489 | CALL message( 'netcdf_data_input_mod', 'PA0556', 2, 2, myid, 6, 0 ) |
---|
3490 | ENDIF |
---|
3491 | ENDIF |
---|
3492 | ENDIF |
---|
3493 | ! |
---|
3494 | !-- If soil_type is zero at any location, soil_pars is required. |
---|
3495 | IF ( soil_type_f%from_file ) THEN |
---|
3496 | check_passed = .TRUE. |
---|
3497 | IF ( ALLOCATED( soil_type_f%var_2d ) ) THEN |
---|
3498 | IF ( ANY( soil_type_f%var_2d == 0 ) ) THEN |
---|
3499 | IF ( .NOT. soil_pars_f%from_file ) check_passed = .FALSE. |
---|
3500 | ENDIF |
---|
3501 | ELSE |
---|
3502 | IF ( ANY( soil_type_f%var_3d == 0 ) ) THEN |
---|
3503 | IF ( .NOT. soil_pars_f%from_file ) check_passed = .FALSE. |
---|
3504 | ENDIF |
---|
3505 | ENDIF |
---|
3506 | IF ( .NOT. check_passed ) THEN |
---|
3507 | message_string = 'If soil_type = 0 at any location, ' // & |
---|
3508 | 'soil_pars is required' |
---|
3509 | CALL message( 'netcdf_data_input_mod', 'PA0557', 2, 2, myid, 6, 0 ) |
---|
3510 | ENDIF |
---|
3511 | ENDIF |
---|
3512 | ! |
---|
3513 | !-- Buildings require a type in case of urban-surface model. |
---|
3514 | IF ( buildings_f%from_file .AND. .NOT. building_type_f%from_file ) THEN |
---|
3515 | message_string = 'If buildings are provided, also building_type ' // & |
---|
3516 | 'is required' |
---|
3517 | CALL message( 'netcdf_data_input_mod', 'PA0581', 2, 2, myid, 6, 0 ) |
---|
3518 | ENDIF |
---|
3519 | ! |
---|
3520 | !-- Buildings require an ID. |
---|
3521 | IF ( buildings_f%from_file .AND. .NOT. building_id_f%from_file ) THEN |
---|
3522 | message_string = 'If buildings are provided, also building_id ' // & |
---|
3523 | 'is required' |
---|
3524 | CALL message( 'netcdf_data_input_mod', 'PA0582', 2, 2, myid, 6, 0 ) |
---|
3525 | ENDIF |
---|
3526 | ! |
---|
3527 | !-- If building_type is zero at any location, building_pars is required. |
---|
3528 | IF ( building_type_f%from_file ) THEN |
---|
3529 | IF ( ANY( building_type_f%var == 0 ) ) THEN |
---|
3530 | IF ( .NOT. building_pars_f%from_file ) THEN |
---|
3531 | message_string = 'If building_type = 0 at any location, ' // & |
---|
3532 | 'building_pars is required' |
---|
3533 | CALL message( 'netcdf_data_input_mod', 'PA0558', 2, 2, myid, 6, 0 ) |
---|
3534 | ENDIF |
---|
3535 | ENDIF |
---|
3536 | ENDIF |
---|
3537 | ! |
---|
3538 | !-- If building_type is provided, also building_id is needed (due to the |
---|
3539 | !-- filtering algorithm). |
---|
3540 | IF ( building_type_f%from_file .AND. .NOT. building_id_f%from_file ) & |
---|
3541 | THEN |
---|
3542 | message_string = 'If building_type is provided, also building_id '// & |
---|
3543 | 'is required' |
---|
3544 | CALL message( 'netcdf_data_input_mod', 'PA0519', 2, 2, myid, 6, 0 ) |
---|
3545 | ENDIF |
---|
3546 | ! |
---|
3547 | !-- If albedo_type is zero at any location, albedo_pars is required. |
---|
3548 | IF ( albedo_type_f%from_file ) THEN |
---|
3549 | IF ( ANY( albedo_type_f%var == 0 ) ) THEN |
---|
3550 | IF ( .NOT. albedo_pars_f%from_file ) THEN |
---|
3551 | message_string = 'If albedo_type = 0 at any location, ' // & |
---|
3552 | 'albedo_pars is required' |
---|
3553 | CALL message( 'netcdf_data_input_mod', 'PA0559', 2, 2, myid, 6, 0 ) |
---|
3554 | ENDIF |
---|
3555 | ENDIF |
---|
3556 | ENDIF |
---|
3557 | ! |
---|
3558 | !-- If pavement_type is zero at any location, pavement_pars is required. |
---|
3559 | IF ( pavement_type_f%from_file ) THEN |
---|
3560 | IF ( ANY( pavement_type_f%var == 0 ) ) THEN |
---|
3561 | IF ( .NOT. pavement_pars_f%from_file ) THEN |
---|
3562 | message_string = 'If pavement_type = 0 at any location, ' // & |
---|
3563 | 'pavement_pars is required' |
---|
3564 | CALL message( 'netcdf_data_input_mod', 'PA0560', 2, 2, myid, 6, 0 ) |
---|
3565 | ENDIF |
---|
3566 | ENDIF |
---|
3567 | ENDIF |
---|
3568 | ! |
---|
3569 | !-- If pavement_type is zero at any location, also pavement_subsurface_pars |
---|
3570 | !-- is required. |
---|
3571 | IF ( pavement_type_f%from_file ) THEN |
---|
3572 | IF ( ANY( pavement_type_f%var == 0 ) ) THEN |
---|
3573 | IF ( .NOT. pavement_subsurface_pars_f%from_file ) THEN |
---|
3574 | message_string = 'If pavement_type = 0 at any location, ' // & |
---|
3575 | 'pavement_subsurface_pars is required' |
---|
3576 | CALL message( 'netcdf_data_input_mod', 'PA0561', 2, 2, myid, 6, 0 ) |
---|
3577 | ENDIF |
---|
3578 | ENDIF |
---|
3579 | ENDIF |
---|
3580 | ! |
---|
3581 | !-- If water_type is zero at any location, water_pars is required. |
---|
3582 | IF ( water_type_f%from_file ) THEN |
---|
3583 | IF ( ANY( water_type_f%var == 0 ) ) THEN |
---|
3584 | IF ( .NOT. water_pars_f%from_file ) THEN |
---|
3585 | message_string = 'If water_type = 0 at any location, ' // & |
---|
3586 | 'water_pars is required' |
---|
3587 | CALL message( 'netcdf_data_input_mod', 'PA0562', 2, 2,myid, 6, 0 ) |
---|
3588 | ENDIF |
---|
3589 | ENDIF |
---|
3590 | ENDIF |
---|
3591 | ! |
---|
3592 | !-- Check for local consistency of the input data. |
---|
3593 | DO i = nxl, nxr |
---|
3594 | DO j = nys, nyn |
---|
3595 | ! |
---|
3596 | !-- For each (y,x)-location at least one of the parameters |
---|
3597 | !-- vegetation_type, pavement_type, building_type, or water_type |
---|
3598 | !-- must be set to a nonÂmissing value. |
---|
3599 | IF ( land_surface .AND. .NOT. urban_surface ) THEN |
---|
3600 | IF ( vegetation_type_f%var(j,i) == vegetation_type_f%fill .AND.& |
---|
3601 | pavement_type_f%var(j,i) == pavement_type_f%fill .AND.& |
---|
3602 | water_type_f%var(j,i) == water_type_f%fill ) THEN |
---|
3603 | WRITE( message_string, * ) & |
---|
3604 | 'At least one of the parameters '// & |
---|
3605 | 'vegetation_type, pavement_type, ' // & |
---|
3606 | 'or water_type must be set '// & |
---|
3607 | 'to a non-missing value. Grid point: ', j, i |
---|
3608 | CALL message( 'netcdf_data_input_mod', 'PA0563', 2, 2, myid, 6, 0 ) |
---|
3609 | ENDIF |
---|
3610 | ELSEIF ( land_surface .AND. urban_surface ) THEN |
---|
3611 | IF ( vegetation_type_f%var(j,i) == vegetation_type_f%fill .AND.& |
---|
3612 | pavement_type_f%var(j,i) == pavement_type_f%fill .AND.& |
---|
3613 | building_type_f%var(j,i) == building_type_f%fill .AND.& |
---|
3614 | water_type_f%var(j,i) == water_type_f%fill ) THEN |
---|
3615 | WRITE( message_string, * ) & |
---|
3616 | 'At least one of the parameters '// & |
---|
3617 | 'vegetation_type, pavement_type, ' // & |
---|
3618 | 'building_type, or water_type must be set '// & |
---|
3619 | 'to a non-missing value. Grid point: ', j, i |
---|
3620 | CALL message( 'netcdf_data_input_mod', 'PA0563', 2, 2, myid, 6, 0 ) |
---|
3621 | ENDIF |
---|
3622 | ENDIF |
---|
3623 | |
---|
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 | !-- Please note, buildings are already processed and filtered. |
---|
3813 | !-- For this reason, consistency checks are based on wall_flags_0 |
---|
3814 | !-- rather than buildings_f (buildings are represented by bit 6 in |
---|
3815 | !-- wall_flags_0). |
---|
3816 | IF ( building_type_f%from_file .AND. buildings_f%from_file ) THEN |
---|
3817 | IF ( ANY( BTEST ( wall_flags_0(:,j,i), 6 ) ) .AND. & |
---|
3818 | building_type_f%var(j,i) == building_type_f%fill .OR. & |
---|
3819 | .NOT. ANY( BTEST ( wall_flags_0(:,j,i), 6 ) ) .AND. & |
---|
3820 | building_type_f%var(j,i) /= building_type_f%fill ) THEN |
---|
3821 | WRITE( message_string, * ) 'Each location where a ' // & |
---|
3822 | 'building is set requires a type ' // & |
---|
3823 | '( and vice versa ) in case the ' // & |
---|
3824 | 'urban-surface model is applied. ' // & |
---|
3825 | 'i, j = ', i, j |
---|
3826 | CALL message( 'netcdf_data_input_mod', 'PA0573', & |
---|
3827 | 2, 2, myid, 6, 0 ) |
---|
3828 | ENDIF |
---|
3829 | ENDIF |
---|
3830 | ! |
---|
3831 | !-- Check if at each location where a building is present also an ID |
---|
3832 | !-- is set and vice versa. |
---|
3833 | IF ( buildings_f%from_file ) THEN |
---|
3834 | IF ( ANY( BTEST ( wall_flags_0(:,j,i), 6 ) ) .AND. & |
---|
3835 | building_id_f%var(j,i) == building_id_f%fill .OR. & |
---|
3836 | .NOT. ANY( BTEST ( wall_flags_0(:,j,i), 6 ) ) .AND. & |
---|
3837 | building_id_f%var(j,i) /= building_id_f%fill ) THEN |
---|
3838 | WRITE( message_string, * ) 'Each location where a ' // & |
---|
3839 | 'building is set requires an ID ' // & |
---|
3840 | '( and vice versa ). i, j = ', i, j |
---|
3841 | CALL message( 'netcdf_data_input_mod', 'PA0574', & |
---|
3842 | 2, 2, myid, 6, 0 ) |
---|
3843 | ENDIF |
---|
3844 | ENDIF |
---|
3845 | ! |
---|
3846 | !-- Check if building ID is set where a bulding is defined. |
---|
3847 | IF ( buildings_f%from_file ) THEN |
---|
3848 | IF ( ANY( BTEST ( wall_flags_0(:,j,i), 6 ) ) .AND. & |
---|
3849 | building_id_f%var(j,i) == building_id_f%fill ) THEN |
---|
3850 | WRITE( message_string, * ) 'Each building grid point '// & |
---|
3851 | 'requires an ID.', i, j |
---|
3852 | CALL message( 'netcdf_data_input_mod', 'PA0575', & |
---|
3853 | 2, 2, myid, 6, 0 ) |
---|
3854 | ENDIF |
---|
3855 | ENDIF |
---|
3856 | ! |
---|
3857 | !-- Check albedo parameters. If albedo_type is 0, all parameters |
---|
3858 | !-- must be set. |
---|
3859 | IF ( albedo_type_f%from_file ) THEN |
---|
3860 | IF ( albedo_type_f%var(j,i) == 0 ) THEN |
---|
3861 | IF ( ANY( albedo_pars_f%pars_xy(:,j,i) == & |
---|
3862 | albedo_pars_f%fill ) ) THEN |
---|
3863 | message_string = 'If albedo_type(y,x) = 0, all ' // & |
---|
3864 | 'parameters of albedo_pars at this ' // & |
---|
3865 | 'location must be set.' |
---|
3866 | CALL message( 'netcdf_data_input_mod', 'PA0576', & |
---|
3867 | 2, 2, myid, 6, 0 ) |
---|
3868 | ENDIF |
---|
3869 | ENDIF |
---|
3870 | ENDIF |
---|
3871 | |
---|
3872 | ! |
---|
3873 | !-- Check pavement parameters. If pavement_type is 0, all parameters |
---|
3874 | !-- of pavement_pars must be set at this location. |
---|
3875 | IF ( pavement_type_f%from_file ) THEN |
---|
3876 | IF ( pavement_type_f%var(j,i) == 0 ) THEN |
---|
3877 | IF ( ANY( pavement_pars_f%pars_xy(:,j,i) == & |
---|
3878 | pavement_pars_f%fill ) ) THEN |
---|
3879 | message_string = 'If pavement_type(y,x) = 0, all ' // & |
---|
3880 | 'parameters of pavement_pars at this '//& |
---|
3881 | 'location must be set.' |
---|
3882 | CALL message( 'netcdf_data_input_mod', 'PA0577', & |
---|
3883 | 2, 2, myid, 6, 0 ) |
---|
3884 | ENDIF |
---|
3885 | ENDIF |
---|
3886 | ENDIF |
---|
3887 | ! |
---|
3888 | !-- Check pavement-subsurface parameters. If pavement_type is 0, |
---|
3889 | !-- all parameters of pavement_subsurface_pars must be set at this |
---|
3890 | !-- location. |
---|
3891 | IF ( pavement_type_f%from_file ) THEN |
---|
3892 | IF ( pavement_type_f%var(j,i) == 0 ) THEN |
---|
3893 | IF ( ANY( pavement_subsurface_pars_f%pars_xyz(:,:,j,i) == & |
---|
3894 | pavement_subsurface_pars_f%fill ) ) THEN |
---|
3895 | message_string = 'If pavement_type(y,x) = 0, all ' // & |
---|
3896 | 'parameters of ' // & |
---|
3897 | 'pavement_subsurface_pars at this '// & |
---|
3898 | 'location must be set.' |
---|
3899 | CALL message( 'netcdf_data_input_mod', 'PA0578', & |
---|
3900 | 2, 2, myid, 6, 0 ) |
---|
3901 | ENDIF |
---|
3902 | ENDIF |
---|
3903 | ENDIF |
---|
3904 | |
---|
3905 | ! |
---|
3906 | !-- Check water parameters. If water_type is 0, all parameters |
---|
3907 | !-- must be set at this location. |
---|
3908 | IF ( water_type_f%from_file ) THEN |
---|
3909 | IF ( water_type_f%var(j,i) == 0 ) THEN |
---|
3910 | IF ( ANY( water_pars_f%pars_xy(:,j,i) == & |
---|
3911 | water_pars_f%fill ) ) THEN |
---|
3912 | message_string = 'If water_type(y,x) = 0, all ' // & |
---|
3913 | 'parameters of water_pars at this ' // & |
---|
3914 | 'location must be set.' |
---|
3915 | CALL message( 'netcdf_data_input_mod', 'PA0579', & |
---|
3916 | 2, 2, myid, 6, 0 ) |
---|
3917 | ENDIF |
---|
3918 | ENDIF |
---|
3919 | ENDIF |
---|
3920 | |
---|
3921 | ENDDO |
---|
3922 | ENDDO |
---|
3923 | |
---|
3924 | END SUBROUTINE netcdf_data_input_check_static |
---|
3925 | |
---|
3926 | !------------------------------------------------------------------------------! |
---|
3927 | ! Description: |
---|
3928 | ! ------------ |
---|
3929 | !> Resize 8-bit 2D Integer array: (nys:nyn,nxl:nxr) -> (nysg:nyng,nxlg:nxrg) |
---|
3930 | !------------------------------------------------------------------------------! |
---|
3931 | SUBROUTINE resize_array_2d_int8( var, js, je, is, ie ) |
---|
3932 | |
---|
3933 | IMPLICIT NONE |
---|
3934 | |
---|
3935 | INTEGER(iwp) :: je !< upper index bound along y direction |
---|
3936 | INTEGER(iwp) :: js !< lower index bound along y direction |
---|
3937 | INTEGER(iwp) :: ie !< upper index bound along x direction |
---|
3938 | INTEGER(iwp) :: is !< lower index bound along x direction |
---|
3939 | |
---|
3940 | INTEGER(KIND=1), DIMENSION(:,:), ALLOCATABLE :: var !< treated variable |
---|
3941 | INTEGER(KIND=1), DIMENSION(:,:), ALLOCATABLE :: var_tmp !< temporary copy |
---|
3942 | ! |
---|
3943 | !-- Allocate temporary variable |
---|
3944 | ALLOCATE( var_tmp(js-nbgp:je+nbgp,is-nbgp:ie+nbgp) ) |
---|
3945 | ! |
---|
3946 | !-- Temporary copy of the variable |
---|
3947 | var_tmp(js:je,is:ie) = var(js:je,is:ie) |
---|
3948 | ! |
---|
3949 | !-- Resize the array |
---|
3950 | DEALLOCATE( var ) |
---|
3951 | ALLOCATE( var(js-nbgp:je+nbgp,is-nbgp:ie+nbgp) ) |
---|
3952 | ! |
---|
3953 | !-- Transfer temporary copy back to original array |
---|
3954 | var(js:je,is:ie) = var_tmp(js:je,is:ie) |
---|
3955 | |
---|
3956 | END SUBROUTINE resize_array_2d_int8 |
---|
3957 | |
---|
3958 | !------------------------------------------------------------------------------! |
---|
3959 | ! Description: |
---|
3960 | ! ------------ |
---|
3961 | !> Resize 32-bit 2D Integer array: (nys:nyn,nxl:nxr) -> (nysg:nyng,nxlg:nxrg) |
---|
3962 | !------------------------------------------------------------------------------! |
---|
3963 | SUBROUTINE resize_array_2d_int32( var, js, je, is, ie ) |
---|
3964 | |
---|
3965 | IMPLICIT NONE |
---|
3966 | |
---|
3967 | INTEGER(iwp) :: je !< upper index bound along y direction |
---|
3968 | INTEGER(iwp) :: js !< lower index bound along y direction |
---|
3969 | INTEGER(iwp) :: ie !< upper index bound along x direction |
---|
3970 | INTEGER(iwp) :: is !< lower index bound along x direction |
---|
3971 | |
---|
3972 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: var !< treated variable |
---|
3973 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: var_tmp !< temporary copy |
---|
3974 | ! |
---|
3975 | !-- Allocate temporary variable |
---|
3976 | ALLOCATE( var_tmp(js-nbgp:je+nbgp,is-nbgp:ie+nbgp) ) |
---|
3977 | ! |
---|
3978 | !-- Temporary copy of the variable |
---|
3979 | var_tmp(js:je,is:ie) = var(js:je,is:ie) |
---|
3980 | ! |
---|
3981 | !-- Resize the array |
---|
3982 | DEALLOCATE( var ) |
---|
3983 | ALLOCATE( var(js-nbgp:je+nbgp,is-nbgp:ie+nbgp) ) |
---|
3984 | ! |
---|
3985 | !-- Transfer temporary copy back to original array |
---|
3986 | var(js:je,is:ie) = var_tmp(js:je,is:ie) |
---|
3987 | |
---|
3988 | END SUBROUTINE resize_array_2d_int32 |
---|
3989 | |
---|
3990 | !------------------------------------------------------------------------------! |
---|
3991 | ! Description: |
---|
3992 | ! ------------ |
---|
3993 | !> Resize 8-bit 3D Integer array: (:,nys:nyn,nxl:nxr) -> (:,nysg:nyng,nxlg:nxrg) |
---|
3994 | !------------------------------------------------------------------------------! |
---|
3995 | SUBROUTINE resize_array_3d_int8( var, ks, ke, js, je, is, ie ) |
---|
3996 | |
---|
3997 | IMPLICIT NONE |
---|
3998 | |
---|
3999 | INTEGER(iwp) :: je !< upper index bound along y direction |
---|
4000 | INTEGER(iwp) :: js !< lower index bound along y direction |
---|
4001 | INTEGER(iwp) :: ie !< upper index bound along x direction |
---|
4002 | INTEGER(iwp) :: is !< lower index bound along x direction |
---|
4003 | INTEGER(iwp) :: ke !< upper bound of treated array in z-direction |
---|
4004 | INTEGER(iwp) :: ks !< lower bound of treated array in z-direction |
---|
4005 | |
---|
4006 | INTEGER(KIND=1), DIMENSION(:,:,:), ALLOCATABLE :: var !< treated variable |
---|
4007 | INTEGER(KIND=1), DIMENSION(:,:,:), ALLOCATABLE :: var_tmp !< temporary copy |
---|
4008 | ! |
---|
4009 | !-- Allocate temporary variable |
---|
4010 | ALLOCATE( var_tmp(ks:ke,js-nbgp:je+nbgp,is-nbgp:ie+nbgp) ) |
---|
4011 | ! |
---|
4012 | !-- Temporary copy of the variable |
---|
4013 | var_tmp(ks:ke,js:je,is:ie) = var(ks:ke,js:je,is:ie) |
---|
4014 | ! |
---|
4015 | !-- Resize the array |
---|
4016 | DEALLOCATE( var ) |
---|
4017 | ALLOCATE( var(ks:ke,js-nbgp:je+nbgp,is-nbgp:ie+nbgp) ) |
---|
4018 | ! |
---|
4019 | !-- Transfer temporary copy back to original array |
---|
4020 | var(ks:ke,js:je,is:ie) = var_tmp(ks:ke,js:je,is:ie) |
---|
4021 | |
---|
4022 | END SUBROUTINE resize_array_3d_int8 |
---|
4023 | |
---|
4024 | !------------------------------------------------------------------------------! |
---|
4025 | ! Description: |
---|
4026 | ! ------------ |
---|
4027 | !> Resize 3D Real array: (:,nys:nyn,nxl:nxr) -> (:,nysg:nyng,nxlg:nxrg) |
---|
4028 | !------------------------------------------------------------------------------! |
---|
4029 | SUBROUTINE resize_array_3d_real( var, ks, ke, js, je, is, ie ) |
---|
4030 | |
---|
4031 | IMPLICIT NONE |
---|
4032 | |
---|
4033 | INTEGER(iwp) :: je !< upper index bound along y direction |
---|
4034 | INTEGER(iwp) :: js !< lower index bound along y direction |
---|
4035 | INTEGER(iwp) :: ie !< upper index bound along x direction |
---|
4036 | INTEGER(iwp) :: is !< lower index bound along x direction |
---|
4037 | INTEGER(iwp) :: ke !< upper bound of treated array in z-direction |
---|
4038 | INTEGER(iwp) :: ks !< lower bound of treated array in z-direction |
---|
4039 | |
---|
4040 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: var !< treated variable |
---|
4041 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: var_tmp !< temporary copy |
---|
4042 | ! |
---|
4043 | !-- Allocate temporary variable |
---|
4044 | ALLOCATE( var_tmp(ks:ke,js-nbgp:je+nbgp,is-nbgp:ie+nbgp) ) |
---|
4045 | ! |
---|
4046 | !-- Temporary copy of the variable |
---|
4047 | var_tmp(ks:ke,js:je,is:ie) = var(ks:ke,js:je,is:ie) |
---|
4048 | ! |
---|
4049 | !-- Resize the array |
---|
4050 | DEALLOCATE( var ) |
---|
4051 | ALLOCATE( var(ks:ke,js-nbgp:je+nbgp,is-nbgp:ie+nbgp) ) |
---|
4052 | ! |
---|
4053 | !-- Transfer temporary copy back to original array |
---|
4054 | var(ks:ke,js:je,is:ie) = var_tmp(ks:ke,js:je,is:ie) |
---|
4055 | |
---|
4056 | END SUBROUTINE resize_array_3d_real |
---|
4057 | |
---|
4058 | !------------------------------------------------------------------------------! |
---|
4059 | ! Description: |
---|
4060 | ! ------------ |
---|
4061 | !> Resize 4D Real array: (:,:,nys:nyn,nxl:nxr) -> (:,nysg:nyng,nxlg:nxrg) |
---|
4062 | !------------------------------------------------------------------------------! |
---|
4063 | SUBROUTINE resize_array_4d_real( var, k1s, k1e, k2s, k2e, js, je, is, ie ) |
---|
4064 | |
---|
4065 | IMPLICIT NONE |
---|
4066 | |
---|
4067 | INTEGER(iwp) :: je !< upper index bound along y direction |
---|
4068 | INTEGER(iwp) :: js !< lower index bound along y direction |
---|
4069 | INTEGER(iwp) :: ie !< upper index bound along x direction |
---|
4070 | INTEGER(iwp) :: is !< lower index bound along x direction |
---|
4071 | INTEGER(iwp) :: k1e !< upper bound of treated array in z-direction |
---|
4072 | INTEGER(iwp) :: k1s !< lower bound of treated array in z-direction |
---|
4073 | INTEGER(iwp) :: k2e !< upper bound of treated array along parameter space |
---|
4074 | INTEGER(iwp) :: k2s !< lower bound of treated array along parameter space |
---|
4075 | |
---|
4076 | REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE :: var !< treated variable |
---|
4077 | REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE :: var_tmp !< temporary copy |
---|
4078 | ! |
---|
4079 | !-- Allocate temporary variable |
---|
4080 | ALLOCATE( var_tmp(k1s:k1e,k2s:k2e,js-nbgp:je+nbgp,is-nbgp:ie+nbgp) ) |
---|
4081 | ! |
---|
4082 | !-- Temporary copy of the variable |
---|
4083 | var_tmp(k1s:k1e,k2s:k2e,js:je,is:ie) = var(k1s:k1e,k2s:k2e,js:je,is:ie) |
---|
4084 | ! |
---|
4085 | !-- Resize the array |
---|
4086 | DEALLOCATE( var ) |
---|
4087 | ALLOCATE( var(k1s:k1e,k2s:k2e,js-nbgp:je+nbgp,is-nbgp:ie+nbgp) ) |
---|
4088 | ! |
---|
4089 | !-- Transfer temporary copy back to original array |
---|
4090 | var(k1s:k1e,k2s:k2e,js:je,is:ie) = var_tmp(k1s:k1e,k2s:k2e,js:je,is:ie) |
---|
4091 | |
---|
4092 | END SUBROUTINE resize_array_4d_real |
---|
4093 | |
---|
4094 | !------------------------------------------------------------------------------! |
---|
4095 | ! Description: |
---|
4096 | ! ------------ |
---|
4097 | !> Checks if a given variables is on file |
---|
4098 | !------------------------------------------------------------------------------! |
---|
4099 | FUNCTION check_existence( vars_in_file, var_name ) |
---|
4100 | |
---|
4101 | IMPLICIT NONE |
---|
4102 | |
---|
4103 | CHARACTER(LEN=*) :: var_name !< variable to be checked |
---|
4104 | CHARACTER(LEN=*), DIMENSION(:) :: vars_in_file !< list of variables in file |
---|
4105 | |
---|
4106 | INTEGER(iwp) :: i !< loop variable |
---|
4107 | |
---|
4108 | LOGICAL :: check_existence !< flag indicating whether a variable exist or not - actual return value |
---|
4109 | |
---|
4110 | i = 1 |
---|
4111 | check_existence = .FALSE. |
---|
4112 | DO WHILE ( i <= SIZE( vars_in_file ) ) |
---|
4113 | check_existence = TRIM( vars_in_file(i) ) == TRIM( var_name ) .OR. & |
---|
4114 | check_existence |
---|
4115 | i = i + 1 |
---|
4116 | ENDDO |
---|
4117 | |
---|
4118 | RETURN |
---|
4119 | |
---|
4120 | END FUNCTION check_existence |
---|
4121 | |
---|
4122 | |
---|
4123 | !------------------------------------------------------------------------------! |
---|
4124 | ! Description: |
---|
4125 | ! ------------ |
---|
4126 | !> Closes an existing netCDF file. |
---|
4127 | !------------------------------------------------------------------------------! |
---|
4128 | SUBROUTINE close_input_file( id ) |
---|
4129 | #if defined( __netcdf ) |
---|
4130 | |
---|
4131 | USE pegrid |
---|
4132 | |
---|
4133 | IMPLICIT NONE |
---|
4134 | |
---|
4135 | INTEGER(iwp), INTENT(INOUT) :: id !< file id |
---|
4136 | |
---|
4137 | nc_stat = NF90_CLOSE( id ) |
---|
4138 | CALL handle_error( 'close', 540 ) |
---|
4139 | #endif |
---|
4140 | END SUBROUTINE close_input_file |
---|
4141 | |
---|
4142 | !------------------------------------------------------------------------------! |
---|
4143 | ! Description: |
---|
4144 | ! ------------ |
---|
4145 | !> Opens an existing netCDF file for reading only and returns its id. |
---|
4146 | !------------------------------------------------------------------------------! |
---|
4147 | SUBROUTINE open_read_file( filename, id ) |
---|
4148 | #if defined( __netcdf ) |
---|
4149 | |
---|
4150 | USE pegrid |
---|
4151 | |
---|
4152 | IMPLICIT NONE |
---|
4153 | |
---|
4154 | CHARACTER (LEN=*), INTENT(IN) :: filename !< filename |
---|
4155 | INTEGER(iwp), INTENT(INOUT) :: id !< file id |
---|
4156 | |
---|
4157 | #if defined( __netcdf4_parallel ) |
---|
4158 | ! |
---|
4159 | !-- If __netcdf4_parallel is defined, parrallel NetCDF will be used. |
---|
4160 | nc_stat = NF90_OPEN( filename, IOR( NF90_NOWRITE, NF90_MPIIO ), id, & |
---|
4161 | COMM = comm2d, INFO = MPI_INFO_NULL ) |
---|
4162 | ! |
---|
4163 | !-- In case the previous open call fails, check for possible Netcdf 3 file, |
---|
4164 | !-- and open it. However, this case, disable parallel access. |
---|
4165 | IF( nc_stat /= NF90_NOERR ) THEN |
---|
4166 | nc_stat = NF90_OPEN( filename, NF90_NOWRITE, id ) |
---|
4167 | collective_read = .FALSE. |
---|
4168 | ELSE |
---|
4169 | collective_read = .TRUE. |
---|
4170 | ENDIF |
---|
4171 | #else |
---|
4172 | ! |
---|
4173 | !-- All MPI processes open the file and read it (but not in parallel). |
---|
4174 | nc_stat = NF90_OPEN( filename, NF90_NOWRITE, id ) |
---|
4175 | #endif |
---|
4176 | |
---|
4177 | CALL handle_error( 'open_read_file', 539 ) |
---|
4178 | |
---|
4179 | #endif |
---|
4180 | END SUBROUTINE open_read_file |
---|
4181 | |
---|
4182 | !------------------------------------------------------------------------------! |
---|
4183 | ! Description: |
---|
4184 | ! ------------ |
---|
4185 | !> Reads global or variable-related attributes of type INTEGER (32-bit) |
---|
4186 | !------------------------------------------------------------------------------! |
---|
4187 | SUBROUTINE get_attribute_int32( id, attribute_name, value, global, & |
---|
4188 | variable_name ) |
---|
4189 | |
---|
4190 | USE pegrid |
---|
4191 | |
---|
4192 | IMPLICIT NONE |
---|
4193 | |
---|
4194 | CHARACTER(LEN=*) :: attribute_name !< attribute name |
---|
4195 | CHARACTER(LEN=*), OPTIONAL :: variable_name !< variable name |
---|
4196 | |
---|
4197 | INTEGER(iwp), INTENT(IN) :: id !< file id |
---|
4198 | INTEGER(iwp) :: id_var !< variable id |
---|
4199 | INTEGER(iwp), INTENT(INOUT) :: value !< read value |
---|
4200 | |
---|
4201 | LOGICAL, INTENT(IN) :: global !< flag indicating global attribute |
---|
4202 | #if defined( __netcdf ) |
---|
4203 | |
---|
4204 | ! |
---|
4205 | !-- Read global attribute |
---|
4206 | IF ( global ) THEN |
---|
4207 | nc_stat = NF90_GET_ATT( id, NF90_GLOBAL, TRIM( attribute_name ), value ) |
---|
4208 | CALL handle_error( 'get_attribute_int32 global', 522, attribute_name ) |
---|
4209 | ! |
---|
4210 | !-- Read attributes referring to a single variable. Therefore, first inquire |
---|
4211 | !-- variable id |
---|
4212 | ELSE |
---|
4213 | nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var ) |
---|
4214 | CALL handle_error( 'get_attribute_int32', 522, attribute_name ) |
---|
4215 | nc_stat = NF90_GET_ATT( id, id_var, TRIM( attribute_name ), value ) |
---|
4216 | CALL handle_error( 'get_attribute_int32', 522, attribute_name ) |
---|
4217 | ENDIF |
---|
4218 | #endif |
---|
4219 | END SUBROUTINE get_attribute_int32 |
---|
4220 | |
---|
4221 | !------------------------------------------------------------------------------! |
---|
4222 | ! Description: |
---|
4223 | ! ------------ |
---|
4224 | !> Reads global or variable-related attributes of type INTEGER (8-bit) |
---|
4225 | !------------------------------------------------------------------------------! |
---|
4226 | SUBROUTINE get_attribute_int8( id, attribute_name, value, global, & |
---|
4227 | variable_name ) |
---|
4228 | |
---|
4229 | USE pegrid |
---|
4230 | |
---|
4231 | IMPLICIT NONE |
---|
4232 | |
---|
4233 | CHARACTER(LEN=*) :: attribute_name !< attribute name |
---|
4234 | CHARACTER(LEN=*), OPTIONAL :: variable_name !< variable name |
---|
4235 | |
---|
4236 | INTEGER(iwp), INTENT(IN) :: id !< file id |
---|
4237 | INTEGER(iwp) :: id_var !< variable id |
---|
4238 | INTEGER(KIND=1), INTENT(INOUT) :: value !< read value |
---|
4239 | |
---|
4240 | LOGICAL, INTENT(IN) :: global !< flag indicating global attribute |
---|
4241 | #if defined( __netcdf ) |
---|
4242 | |
---|
4243 | ! |
---|
4244 | !-- Read global attribute |
---|
4245 | IF ( global ) THEN |
---|
4246 | nc_stat = NF90_GET_ATT( id, NF90_GLOBAL, TRIM( attribute_name ), value ) |
---|
4247 | CALL handle_error( 'get_attribute_int8 global', 523, attribute_name ) |
---|
4248 | ! |
---|
4249 | !-- Read attributes referring to a single variable. Therefore, first inquire |
---|
4250 | !-- variable id |
---|
4251 | ELSE |
---|
4252 | nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var ) |
---|
4253 | CALL handle_error( 'get_attribute_int8', 523, attribute_name ) |
---|
4254 | nc_stat = NF90_GET_ATT( id, id_var, TRIM( attribute_name ), value ) |
---|
4255 | CALL handle_error( 'get_attribute_int8', 523, attribute_name ) |
---|
4256 | ENDIF |
---|
4257 | #endif |
---|
4258 | END SUBROUTINE get_attribute_int8 |
---|
4259 | |
---|
4260 | !------------------------------------------------------------------------------! |
---|
4261 | ! Description: |
---|
4262 | ! ------------ |
---|
4263 | !> Reads global or variable-related attributes of type REAL |
---|
4264 | !------------------------------------------------------------------------------! |
---|
4265 | SUBROUTINE get_attribute_real( id, attribute_name, value, global, & |
---|
4266 | variable_name ) |
---|
4267 | |
---|
4268 | USE pegrid |
---|
4269 | |
---|
4270 | IMPLICIT NONE |
---|
4271 | |
---|
4272 | CHARACTER(LEN=*) :: attribute_name !< attribute name |
---|
4273 | CHARACTER(LEN=*), OPTIONAL :: variable_name !< variable name |
---|
4274 | |
---|
4275 | INTEGER(iwp), INTENT(IN) :: id !< file id |
---|
4276 | INTEGER(iwp) :: id_var !< variable id |
---|
4277 | |
---|
4278 | LOGICAL, INTENT(IN) :: global !< flag indicating global attribute |
---|
4279 | |
---|
4280 | REAL(wp), INTENT(INOUT) :: value !< read value |
---|
4281 | #if defined( __netcdf ) |
---|
4282 | |
---|
4283 | |
---|
4284 | ! |
---|
4285 | !-- Read global attribute |
---|
4286 | IF ( global ) THEN |
---|
4287 | nc_stat = NF90_GET_ATT( id, NF90_GLOBAL, TRIM( attribute_name ), value ) |
---|
4288 | CALL handle_error( 'get_attribute_real global', 524, attribute_name ) |
---|
4289 | ! |
---|
4290 | !-- Read attributes referring to a single variable. Therefore, first inquire |
---|
4291 | !-- variable id |
---|
4292 | ELSE |
---|
4293 | nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var ) |
---|
4294 | CALL handle_error( 'get_attribute_real', 524, attribute_name ) |
---|
4295 | nc_stat = NF90_GET_ATT( id, id_var, TRIM( attribute_name ), value ) |
---|
4296 | CALL handle_error( 'get_attribute_real', 524, attribute_name ) |
---|
4297 | ENDIF |
---|
4298 | #endif |
---|
4299 | END SUBROUTINE get_attribute_real |
---|
4300 | |
---|
4301 | !------------------------------------------------------------------------------! |
---|
4302 | ! Description: |
---|
4303 | ! ------------ |
---|
4304 | !> Reads global or variable-related attributes of type CHARACTER |
---|
4305 | !> Remark: reading attributes of type NF_STRING return an error code 56 - |
---|
4306 | !> Attempt to convert between text & numbers. |
---|
4307 | !------------------------------------------------------------------------------! |
---|
4308 | SUBROUTINE get_attribute_string( id, attribute_name, value, global, & |
---|
4309 | variable_name, no_abort ) |
---|
4310 | |
---|
4311 | USE pegrid |
---|
4312 | |
---|
4313 | IMPLICIT NONE |
---|
4314 | |
---|
4315 | CHARACTER(LEN=*) :: attribute_name !< attribute name |
---|
4316 | CHARACTER(LEN=*), OPTIONAL :: variable_name !< variable name |
---|
4317 | CHARACTER(LEN=*), INTENT(INOUT) :: value !< read value |
---|
4318 | |
---|
4319 | INTEGER(iwp), INTENT(IN) :: id !< file id |
---|
4320 | INTEGER(iwp) :: id_var !< variable id |
---|
4321 | |
---|
4322 | LOGICAL :: check_error !< flag indicating if handle_error shall be checked |
---|
4323 | LOGICAL, INTENT(IN) :: global !< flag indicating global attribute |
---|
4324 | LOGICAL, INTENT(IN), OPTIONAL :: no_abort !< flag indicating if errors should be checked |
---|
4325 | #if defined( __netcdf ) |
---|
4326 | |
---|
4327 | IF ( PRESENT( no_abort ) ) THEN |
---|
4328 | check_error = no_abort |
---|
4329 | ELSE |
---|
4330 | check_error = .TRUE. |
---|
4331 | ENDIF |
---|
4332 | ! |
---|
4333 | !-- Read global attribute |
---|
4334 | IF ( global ) THEN |
---|
4335 | nc_stat = NF90_GET_ATT( id, NF90_GLOBAL, TRIM( attribute_name ), value ) |
---|
4336 | IF ( check_error) CALL handle_error( 'get_attribute_string global', 525, attribute_name ) |
---|
4337 | ! |
---|
4338 | !-- Read attributes referring to a single variable. Therefore, first inquire |
---|
4339 | !-- variable id |
---|
4340 | ELSE |
---|
4341 | nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var ) |
---|
4342 | IF ( check_error) CALL handle_error( 'get_attribute_string', 525, attribute_name ) |
---|
4343 | |
---|
4344 | nc_stat = NF90_GET_ATT( id, id_var, TRIM( attribute_name ), value ) |
---|
4345 | IF ( check_error) CALL handle_error( 'get_attribute_string',525, attribute_name ) |
---|
4346 | |
---|
4347 | ENDIF |
---|
4348 | #endif |
---|
4349 | END SUBROUTINE get_attribute_string |
---|
4350 | |
---|
4351 | |
---|
4352 | |
---|
4353 | !------------------------------------------------------------------------------! |
---|
4354 | ! Description: |
---|
4355 | ! ------------ |
---|
4356 | !> Get dimension array for a given dimension |
---|
4357 | !------------------------------------------------------------------------------! |
---|
4358 | SUBROUTINE get_dimension_length( id, dim_len, variable_name ) |
---|
4359 | USE pegrid |
---|
4360 | |
---|
4361 | IMPLICIT NONE |
---|
4362 | |
---|
4363 | CHARACTER(LEN=*) :: variable_name !< dimension name |
---|
4364 | CHARACTER(LEN=100) :: dum !< dummy variable to receive return character |
---|
4365 | |
---|
4366 | INTEGER(iwp) :: dim_len !< dimension size |
---|
4367 | INTEGER(iwp), INTENT(IN) :: id !< file id |
---|
4368 | INTEGER(iwp) :: id_dim !< dimension id |
---|
4369 | |
---|
4370 | #if defined( __netcdf ) |
---|
4371 | ! |
---|
4372 | !-- First, inquire dimension ID |
---|
4373 | nc_stat = NF90_INQ_DIMID( id, TRIM( variable_name ), id_dim ) |
---|
4374 | CALL handle_error( 'get_dimension_length', 526, variable_name ) |
---|
4375 | ! |
---|
4376 | !-- Inquire dimension length |
---|
4377 | nc_stat = NF90_INQUIRE_DIMENSION( id, id_dim, dum, LEN = dim_len ) |
---|
4378 | CALL handle_error( 'get_dimension_length', 526, variable_name ) |
---|
4379 | |
---|
4380 | #endif |
---|
4381 | END SUBROUTINE get_dimension_length |
---|
4382 | |
---|
4383 | !------------------------------------------------------------------------------! |
---|
4384 | ! Description: |
---|
4385 | ! ------------ |
---|
4386 | !> Routine for reading-in a character string from the chem emissions netcdf |
---|
4387 | !> input file. |
---|
4388 | !------------------------------------------------------------------------------! |
---|
4389 | SUBROUTINE get_variable_string( id, variable_name, var_string, names_number) |
---|
4390 | #if defined( __netcdf ) |
---|
4391 | |
---|
4392 | USE indices |
---|
4393 | USE pegrid |
---|
4394 | |
---|
4395 | IMPLICIT NONE |
---|
4396 | |
---|
4397 | CHARACTER (LEN=25), ALLOCATABLE, DIMENSION(:), INTENT(INOUT) :: var_string |
---|
4398 | |
---|
4399 | CHARACTER(LEN=*) :: variable_name !> variable name |
---|
4400 | |
---|
4401 | CHARACTER (LEN=1), ALLOCATABLE, DIMENSION(:,:) :: tmp_var_string !> variable to be read |
---|
4402 | |
---|
4403 | |
---|
4404 | INTEGER(iwp), INTENT(IN) :: id !> file id |
---|
4405 | |
---|
4406 | INTEGER(iwp), INTENT(IN) :: names_number !> number of names |
---|
4407 | |
---|
4408 | INTEGER(iwp) :: id_var !> variable id |
---|
4409 | |
---|
4410 | INTEGER(iwp) :: i,j !> index to go through the length of the dimensions |
---|
4411 | |
---|
4412 | INTEGER(iwp) :: max_string_length=25 !> this is both the maximum length of a name, but also |
---|
4413 | ! the number of the components of the first dimensions |
---|
4414 | ! (rows) |
---|
4415 | |
---|
4416 | |
---|
4417 | ALLOCATE(tmp_var_string(max_string_length,names_number)) |
---|
4418 | |
---|
4419 | ALLOCATE(var_string(names_number)) |
---|
4420 | |
---|
4421 | !-- Inquire variable id |
---|
4422 | nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var ) |
---|
4423 | |
---|
4424 | |
---|
4425 | !-- Get variable |
---|
4426 | !-- Start cycle over the emission species |
---|
4427 | DO i = 1, names_number |
---|
4428 | !-- read the first letter of each component |
---|
4429 | nc_stat = NF90_GET_VAR( id, id_var, var_string(i), start = (/ 1,i /), & |
---|
4430 | count = (/ 1,1 /) ) |
---|
4431 | CALL handle_error( 'get_variable_string', 701 ) |
---|
4432 | |
---|
4433 | !-- Start cycle over charachters |
---|
4434 | DO j = 1, max_string_length |
---|
4435 | |
---|
4436 | !-- read the rest of the components of the name |
---|
4437 | nc_stat = NF90_GET_VAR( id, id_var, tmp_var_string(j,i), start = (/ j,i /),& |
---|
4438 | count = (/ 1,1 /) ) |
---|
4439 | CALL handle_error( 'get_variable_string', 702 ) |
---|
4440 | |
---|
4441 | IF ( iachar(tmp_var_string(j,i) ) == 0 ) THEN |
---|
4442 | tmp_var_string(j,i)='' |
---|
4443 | ENDIF |
---|
4444 | |
---|
4445 | IF ( j>1 ) THEN |
---|
4446 | !-- Concatenate first letter of the name and the others |
---|
4447 | var_string(i)=TRIM(var_string(i)) // TRIM(tmp_var_string(j,i)) |
---|
4448 | |
---|
4449 | ENDIF |
---|
4450 | ENDDO |
---|
4451 | ENDDO |
---|
4452 | |
---|
4453 | #endif |
---|
4454 | END SUBROUTINE get_variable_string |
---|
4455 | |
---|
4456 | !------------------------------------------------------------------------------! |
---|
4457 | ! Description: |
---|
4458 | ! ------------ |
---|
4459 | !> Reads a character variable in a 1D array |
---|
4460 | !------------------------------------------------------------------------------! |
---|
4461 | SUBROUTINE get_variable_1d_char( id, variable_name, var ) |
---|
4462 | |
---|
4463 | USE pegrid |
---|
4464 | |
---|
4465 | IMPLICIT NONE |
---|
4466 | |
---|
4467 | CHARACTER(LEN=*) :: variable_name !< variable name |
---|
4468 | CHARACTER(LEN=*), DIMENSION(:), INTENT(INOUT) :: var !< variable to be read |
---|
4469 | |
---|
4470 | INTEGER(iwp) :: i !< running index over variable dimension |
---|
4471 | INTEGER(iwp), INTENT(IN) :: id !< file id |
---|
4472 | INTEGER(iwp) :: id_var !< dimension id |
---|
4473 | |
---|
4474 | INTEGER(iwp), DIMENSION(2) :: dimid !< dimension IDs |
---|
4475 | INTEGER(iwp), DIMENSION(2) :: dimsize !< dimension size |
---|
4476 | |
---|
4477 | #if defined( __netcdf ) |
---|
4478 | |
---|
4479 | ! |
---|
4480 | !-- First, inquire variable ID |
---|
4481 | nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var ) |
---|
4482 | CALL handle_error( 'get_variable_1d_int', 527, variable_name ) |
---|
4483 | ! |
---|
4484 | !-- Inquire dimension IDs |
---|
4485 | nc_stat = NF90_INQUIRE_VARIABLE( id, id_var, dimids = dimid(1:2) ) |
---|
4486 | CALL handle_error( 'get_variable_1d_char', 527, variable_name ) |
---|
4487 | ! |
---|
4488 | !-- Read dimesnion length |
---|
4489 | nc_stat = NF90_INQUIRE_DIMENSION( id, dimid(1), LEN = dimsize(1) ) |
---|
4490 | nc_stat = NF90_INQUIRE_DIMENSION( id, dimid(2), LEN = dimsize(2) ) |
---|
4491 | |
---|
4492 | ! |
---|
4493 | !-- Read character array. Note, each element is read individually, in order |
---|
4494 | !-- to better separate single strings. |
---|
4495 | DO i = 1, dimsize(2) |
---|
4496 | nc_stat = NF90_GET_VAR( id, id_var, var(i), & |
---|
4497 | start = (/ 1, i /), & |
---|
4498 | count = (/ dimsize(1 |
---|