Skip to content

Commit a1456b8

Browse files
authored
Merge branch 'master' into soil_temp
2 parents d5282a9 + 496e175 commit a1456b8

File tree

8 files changed

+119
-16
lines changed

8 files changed

+119
-16
lines changed

docs/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,15 @@ _1. EXTPAR settings as JSON, see official docs_
4747
"it_cl_type": 1,
4848
"iera_type": 1,
4949
"iemiss_type": 1,
50+
"ilookup_table_lu": 1,
5051
"enable_cdnc": false,
5152
"enable_edgar": false,
5253
"enable_art": false,
5354
"use_array_cache": false,
5455
"lsgsl": false,
5556
"lfilter_oro": false,
5657
"lurban": false,
58+
"l_use_corine": false,
5759
"lradtopo": true,
5860
"nhori": 24,
5961
"radtopo_radius": 40000

python/WrapExtpar.py

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,15 @@ def main():
7373
it_cl_type = config.get('it_cl_type')
7474
iera_type = config.get('iera_type')
7575
iemiss_type = config.get('iemiss_type')
76+
ilookup_table_lu = config.get('ilookup_table_lu')
7677
enable_cdnc = config.get('enable_cdnc', False)
7778
enable_edgar = config.get('enable_edgar', False)
7879
enable_art = config.get('enable_art', False)
7980
use_array_cache = config.get('use_array_cache', False)
8081
lsgsl = config.get('lsgsl', False)
8182
lfilter_oro = config.get('lfilter_oro', False)
8283
lurban = config.get('lurban', False)
84+
l_use_corine = config.get('l_use_corine', False)
8385
lradtopo = config.get('lradtopo', False)
8486
nhori = config.get('nhori', 24)
8587
radtopo_radius = config.get('radtopo_radius', 40000.0)
@@ -89,10 +91,11 @@ def main():
8991
generate_external_parameters(
9092
igrid_type, args.input_grid, iaot_type, ilu_type, ialb_type,
9193
isoil_type, itopo_type, it_cl_type, iera_type, iemiss_type,
92-
enable_cdnc, enable_edgar, enable_art, use_array_cache, nhori,
93-
radtopo_radius, tcorr_lapse_rate, tcorr_offset, args.raw_data_path,
94-
args.run_dir, args.account, args.host, args.no_batch_job, lurban,
95-
lsgsl, lfilter_oro, lradtopo)
94+
ilookup_table_lu, enable_cdnc, enable_edgar, enable_art,
95+
use_array_cache, nhori, radtopo_radius, tcorr_lapse_rate,
96+
tcorr_offset, args.raw_data_path, args.run_dir, args.account,
97+
args.host, args.no_batch_job, lurban, lsgsl, lfilter_oro,
98+
l_use_corine, lradtopo)
9699

97100

98101
def generate_external_parameters(igrid_type,
@@ -105,6 +108,7 @@ def generate_external_parameters(igrid_type,
105108
it_cl_type,
106109
iera_type,
107110
iemiss_type,
111+
ilookup_table_lu,
108112
enable_cdnc,
109113
enable_edgar,
110114
enable_art,
@@ -121,6 +125,7 @@ def generate_external_parameters(igrid_type,
121125
lurban=False,
122126
lsgsl=False,
123127
lfilter_oro=False,
128+
l_use_corine=False,
124129
lradtopo=False):
125130

126131
# initialize logger
@@ -142,10 +147,12 @@ def generate_external_parameters(igrid_type,
142147
'it_cl_type': it_cl_type,
143148
'iera_type': iera_type,
144149
'iemiss_type': iemiss_type,
150+
'ilookup_table_lu': ilookup_table_lu,
145151
'enable_cdnc': enable_cdnc,
146152
'enable_edgar': enable_edgar,
147153
'enable_art': enable_art,
148154
'use_array_cache': use_array_cache,
155+
'l_use_corine': l_use_corine,
149156
'lradtopo': lradtopo,
150157
'nhori': nhori,
151158
'radtopo_radius': radtopo_radius,
@@ -495,21 +502,35 @@ def generate_globe_filenames():
495502
def setup_lu_namelist(args):
496503
namelist = {}
497504
namelist['i_landuse_data'] = args['ilu_type']
498-
namelist['ilookup_table_lu'] = args['ilu_type']
505+
namelist['ilookup_table_lu'] = args['ilookup_table_lu']
499506
namelist['raw_data_lu_path'] = args['raw_data_path']
500507
namelist['raw_data_glcc_path'] = args['raw_data_path']
501508
namelist['lu_buffer_file'] = 'lu_buffer.nc'
502509
namelist['raw_data_glcc_filename'] = 'GLCC_usgs_class_byte.nc'
503510
namelist['glcc_buffer_file'] = 'glcc_buffer.nc'
504-
namelist['l_use_corine'] = ".FALSE."
511+
namelist['ntiles_globcover'] = 6
512+
namelist['l_terra_urb'] = ".FALSE."
513+
514+
if args['l_use_corine']:
515+
namelist['l_use_corine'] = ".TRUE."
516+
else:
517+
namelist['l_use_corine'] = ".FALSE."
518+
505519
if args['ilu_type'] == 1:
506-
namelist['raw_data_lu_filename'] = [
507-
f"'GLOBCOVER_{i}_16bit.nc' " for i in range(0, 6)
508-
]
520+
if args['l_use_corine']:
521+
namelist['raw_data_lu_filename'] = "'CORINE_globcover.nc'"
522+
namelist['ntiles_globcover'] = 1
523+
else:
524+
namelist['raw_data_lu_filename'] = [
525+
f"'GLOBCOVER_{i}_16bit.nc' " for i in range(0, 6)
526+
]
509527
elif args['ilu_type'] == 2:
510528
# we need "" padding for correct replacement in Fortran namelist
511529
namelist['raw_data_lu_filename'] = "'GLC2000_byte.nc'"
512-
530+
elif args['ilu_type'] == 6:
531+
# we need "" padding for correct replacement in Fortran namelist
532+
namelist['raw_data_lu_filename'] = "'ECOCLIMAP_SG.nc'"
533+
namelist['l_terra_urb'] = ".TRUE."
513534
else:
514535
logging.error(f'Unknown ilu_type {args["ilu_type"]}')
515536
raise ValueError(f'Unknown ilu_type {args["ilu_type"]}')
@@ -821,8 +842,14 @@ def replace_placeholders(args, templates, dir, actual_values):
821842
all_templates[template] = all_templates[template].replace(
822843
key, str("".join(value)))
823844
else:
824-
all_templates[template] = all_templates[template].replace(
825-
key, str(value))
845+
if value is not None:
846+
all_templates[template] = all_templates[template].replace(
847+
key, str(value))
848+
else:
849+
raise ValueError(
850+
f'The placeholder {key} in {all_templates[template]} was replaced with None.'
851+
'This likely means that it was not specified in the config file and has no default value.'
852+
)
826853

827854
# check that no @PLACEHOLDERS@ are left
828855
for template in templates:

python/lib/utilities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def launch_shell(bin, *args):
7070
raise
7171

7272
except subprocess.CalledProcessError as e:
73-
output = e.stderr
73+
output = e.stdout + e.stderr
7474
logging.warning(f'Problems with shell command: {args_for_logger} \n'
7575
'-> the output returned to the shell is:')
7676
logging.warning(f'{output}')

src/extpar_consistency_check.f90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,9 @@ PROGRAM extpar_consistency_check
700700
SELECT CASE (i_landuse_data)
701701
CASE (i_lu_globcover)
702702
lu_dataset = 'GLOBCOVER2009'
703+
IF (l_use_corine) THEN
704+
lu_dataset = TRIM(lu_dataset)//' (CORINE)'
705+
ENDIF
703706
CALL get_name_globcover_lookup_tables(ilookup_table_lu, name_lookup_table_lu)
704707
nclass_lu = nclass_globcover
705708
lu_data_southern_boundary = -56.0 ! Needed to capture the Antarctic peninsula

src/extpar_landuse_to_buffer.f90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,9 @@ PROGRAM extpar_landuse_to_buffer
344344
CASE (i_lu_globcover)
345345
nclass_lu = nclass_globcover
346346
lu_dataset = 'GLOBCOVER2009'
347+
IF (l_use_corine) THEN
348+
lu_dataset = TRIM(lu_dataset)//' (CORINE)'
349+
ENDIF
347350

348351
CALL get_dimension_globcover_data(nlon_globcover, &
349352
& nlat_globcover)

src/mo_lradtopo.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ SUBROUTINE haversine(semimaj,start_lat, start_lon, end_lat, end_lon, distance)
11971197
rend_lon=end_lon * deg2rad
11981198

11991199
! distance between two point with haversine formula
1200-
a = SIN(rend_lat - rstart_lat)* SIN(rend_lon - rstart_lon) + &
1200+
a = SIN((rend_lat - rstart_lat) / 2.0_wp) * SIN((rend_lat - rstart_lat) / 2.0_wp) + &
12011201
& COS(rend_lat) * COS(rstart_lat) * SIN((rend_lon-rstart_lon) / 2.0_wp) * &
12021202
& SIN((rend_lon-rstart_lon) / 2.0_wp)
12031203

templates/INPUT_LU

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
raw_data_lu_path = '@RAW_DATA_LU_PATH@'
33
raw_data_lu_filename = @RAW_DATA_LU_FILENAME@
44
i_landuse_data = @I_LANDUSE_DATA@
5+
ntiles_globcover = @NTILES_GLOBCOVER@
56
l_use_corine = @L_USE_CORINE@
7+
l_terra_urb = @L_TERRA_URB@
68
ilookup_table_lu = @ILOOKUP_TABLE_LU@
79
/
810
&lu_io_extpar

test/pytest/test_wrap_extpar.py

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,12 @@ def test_setup_check_namelist_tile_mode():
245245

246246

247247
def test_setup_lu_namelist_type_1():
248-
args = {'ilu_type': 1, 'raw_data_path': '/path/to/data'}
248+
args = {
249+
'ilu_type': 1,
250+
'raw_data_path': '/path/to/data',
251+
'l_use_corine': False,
252+
'ilookup_table_lu': 1
253+
}
249254
expected_namelist = {
250255
'i_landuse_data':
251256
1,
@@ -261,6 +266,10 @@ def test_setup_lu_namelist_type_1():
261266
'GLCC_usgs_class_byte.nc',
262267
'glcc_buffer_file':
263268
'glcc_buffer.nc',
269+
'ntiles_globcover':
270+
6,
271+
'l_terra_urb':
272+
".FALSE.",
264273
'l_use_corine':
265274
".FALSE.",
266275
'raw_data_lu_filename': [
@@ -272,8 +281,36 @@ def test_setup_lu_namelist_type_1():
272281
assert setup_lu_namelist(args) == expected_namelist
273282

274283

284+
def test_setup_lu_namelist_corine():
285+
args = {
286+
'ilu_type': 1,
287+
'raw_data_path': '/path/to/data',
288+
'l_use_corine': True,
289+
'ilookup_table_lu': 1
290+
}
291+
expected_namelist = {
292+
'i_landuse_data': 1,
293+
'ilookup_table_lu': 1,
294+
'raw_data_lu_path': '/path/to/data',
295+
'raw_data_glcc_path': '/path/to/data',
296+
'lu_buffer_file': 'lu_buffer.nc',
297+
'raw_data_glcc_filename': 'GLCC_usgs_class_byte.nc',
298+
'glcc_buffer_file': 'glcc_buffer.nc',
299+
'ntiles_globcover': 1,
300+
'l_terra_urb': ".FALSE.",
301+
'l_use_corine': ".TRUE.",
302+
'raw_data_lu_filename': "'CORINE_globcover.nc'"
303+
}
304+
assert setup_lu_namelist(args) == expected_namelist
305+
306+
275307
def test_setup_lu_namelist_type_2():
276-
args = {'ilu_type': 2, 'raw_data_path': '/path/to/data'}
308+
args = {
309+
'ilu_type': 2,
310+
'raw_data_path': '/path/to/data',
311+
'l_use_corine': False,
312+
'ilookup_table_lu': 2
313+
}
277314
expected_namelist = {
278315
'i_landuse_data': 2,
279316
'ilookup_table_lu': 2,
@@ -282,12 +319,37 @@ def test_setup_lu_namelist_type_2():
282319
'lu_buffer_file': 'lu_buffer.nc',
283320
'raw_data_glcc_filename': 'GLCC_usgs_class_byte.nc',
284321
'glcc_buffer_file': 'glcc_buffer.nc',
322+
'ntiles_globcover': 6,
323+
'l_terra_urb': ".FALSE.",
285324
'l_use_corine': ".FALSE.",
286325
'raw_data_lu_filename': "'GLC2000_byte.nc'"
287326
}
288327
assert setup_lu_namelist(args) == expected_namelist
289328

290329

330+
def test_setup_lu_namelist_type_6():
331+
args = {
332+
'ilu_type': 6,
333+
'raw_data_path': '/path/to/data',
334+
'l_use_corine': False,
335+
'ilookup_table_lu': 1
336+
}
337+
expected_namelist = {
338+
'i_landuse_data': 6,
339+
'ilookup_table_lu': 1,
340+
'raw_data_lu_path': '/path/to/data',
341+
'raw_data_glcc_path': '/path/to/data',
342+
'lu_buffer_file': 'lu_buffer.nc',
343+
'raw_data_glcc_filename': 'GLCC_usgs_class_byte.nc',
344+
'glcc_buffer_file': 'glcc_buffer.nc',
345+
'ntiles_globcover': 6,
346+
'l_terra_urb': ".TRUE.",
347+
'l_use_corine': ".FALSE.",
348+
'raw_data_lu_filename': "'ECOCLIMAP_SG.nc'"
349+
}
350+
assert setup_lu_namelist(args) == expected_namelist
351+
352+
291353
def test_setup_aot_namelist_type_1():
292354
args = {'iaot_type': 1, 'raw_data_path': '/path/to/data'}
293355
expected_namelist = {
@@ -926,6 +988,7 @@ def test_all_placeholders_replaced_cosmo(tmp_dir):
926988
"it_cl_type": 1,
927989
"iera_type": 1,
928990
"iemiss_type": 1,
991+
'ilookup_table_lu': 1,
929992
"enable_cdnc": False,
930993
"enable_edgar": False,
931994
"enable_art": False,
@@ -943,6 +1006,7 @@ def test_all_placeholders_replaced_cosmo(tmp_dir):
9431006
"lurban": False,
9441007
"lsgsl": False,
9451008
"lfilter_oro": False,
1009+
"l_use_corine": False,
9461010
"lradtopo": False
9471011
}
9481012

@@ -965,6 +1029,7 @@ def test_all_placeholders_replaced_icon(tmp_dir, icon_grid):
9651029
"it_cl_type": 1,
9661030
"iera_type": 1,
9671031
"iemiss_type": 1,
1032+
'ilookup_table_lu': 1,
9681033
"enable_cdnc": False,
9691034
"enable_edgar": False,
9701035
"enable_art": False,
@@ -982,6 +1047,7 @@ def test_all_placeholders_replaced_icon(tmp_dir, icon_grid):
9821047
"lurban": False,
9831048
"lsgsl": False,
9841049
"lfilter_oro": False,
1050+
"l_use_corine": False,
9851051
"lradtopo": False
9861052
}
9871053

0 commit comments

Comments
 (0)