Skip to content

Commit 76ce4f8

Browse files
authored
Merge branch 'master' into coastline_antarctica
2 parents 3b7aa45 + 496e175 commit 76ce4f8

File tree

10 files changed

+124
-22
lines changed

10 files changed

+124
-22
lines changed

.github/workflows/upload_to_dockerhub.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Log in to Docker Hub
2424
uses: docker/login-action@v1
2525
with:
26-
username: c2sm
26+
username: ${{ secrets.DOCKER_USERNAME }}
2727
password: ${{ secrets.DOCKER_PASSWORD }}
2828

2929
- name: Build base image
@@ -41,7 +41,5 @@ jobs:
4141
context: .
4242
file: ./Dockerfile.extpar
4343
push: true
44-
tags: |
45-
c2sm/extpar:${{ github.ref_name }}
46-
${{ github.ref_name == 'refs/heads/master' && 'c2sm/extpar:latest' || '' }}
47-
platforms: linux/amd64,linux/arm64
44+
tags: c2sm/extpar:${{ github.ref_name }}
45+
platforms: linux/amd64,linux/arm64

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: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,23 +73,26 @@ 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)
8688

8789
generate_external_parameters(
8890
igrid_type, args.input_grid, iaot_type, ilu_type, ialb_type,
8991
isoil_type, itopo_type, it_cl_type, iera_type, iemiss_type,
90-
enable_cdnc, enable_edgar, enable_art, use_array_cache, nhori,
91-
radtopo_radius, args.raw_data_path, args.run_dir, args.account,
92-
args.host, args.no_batch_job, lurban, lsgsl, lfilter_oro, lradtopo)
92+
ilookup_table_lu, enable_cdnc, enable_edgar, enable_art,
93+
use_array_cache, nhori, radtopo_radius, args.raw_data_path,
94+
args.run_dir, args.account, args.host, args.no_batch_job, lurban,
95+
lsgsl, lfilter_oro, l_use_corine, lradtopo)
9396

9497

9598
def generate_external_parameters(igrid_type,
@@ -102,6 +105,7 @@ def generate_external_parameters(igrid_type,
102105
it_cl_type,
103106
iera_type,
104107
iemiss_type,
108+
ilookup_table_lu,
105109
enable_cdnc,
106110
enable_edgar,
107111
enable_art,
@@ -116,6 +120,7 @@ def generate_external_parameters(igrid_type,
116120
lurban=False,
117121
lsgsl=False,
118122
lfilter_oro=False,
123+
l_use_corine=False,
119124
lradtopo=False):
120125

121126
# initialize logger
@@ -137,10 +142,12 @@ def generate_external_parameters(igrid_type,
137142
'it_cl_type': it_cl_type,
138143
'iera_type': iera_type,
139144
'iemiss_type': iemiss_type,
145+
'ilookup_table_lu': ilookup_table_lu,
140146
'enable_cdnc': enable_cdnc,
141147
'enable_edgar': enable_edgar,
142148
'enable_art': enable_art,
143149
'use_array_cache': use_array_cache,
150+
'l_use_corine': l_use_corine,
144151
'lradtopo': lradtopo,
145152
'nhori': nhori,
146153
'radtopo_radius': radtopo_radius,
@@ -489,21 +496,35 @@ def generate_globe_filenames():
489496
def setup_lu_namelist(args):
490497
namelist = {}
491498
namelist['i_landuse_data'] = args['ilu_type']
492-
namelist['ilookup_table_lu'] = args['ilu_type']
499+
namelist['ilookup_table_lu'] = args['ilookup_table_lu']
493500
namelist['raw_data_lu_path'] = args['raw_data_path']
494501
namelist['raw_data_glcc_path'] = args['raw_data_path']
495502
namelist['lu_buffer_file'] = 'lu_buffer.nc'
496503
namelist['raw_data_glcc_filename'] = 'GLCC_usgs_class_byte.nc'
497504
namelist['glcc_buffer_file'] = 'glcc_buffer.nc'
498-
namelist['l_use_corine'] = ".FALSE."
505+
namelist['ntiles_globcover'] = 6
506+
namelist['l_terra_urb'] = ".FALSE."
507+
508+
if args['l_use_corine']:
509+
namelist['l_use_corine'] = ".TRUE."
510+
else:
511+
namelist['l_use_corine'] = ".FALSE."
512+
499513
if args['ilu_type'] == 1:
500-
namelist['raw_data_lu_filename'] = [
501-
f"'GLOBCOVER_{i}_16bit.nc' " for i in range(0, 6)
502-
]
514+
if args['l_use_corine']:
515+
namelist['raw_data_lu_filename'] = "'CORINE_globcover.nc'"
516+
namelist['ntiles_globcover'] = 1
517+
else:
518+
namelist['raw_data_lu_filename'] = [
519+
f"'GLOBCOVER_{i}_16bit.nc' " for i in range(0, 6)
520+
]
503521
elif args['ilu_type'] == 2:
504522
# we need "" padding for correct replacement in Fortran namelist
505523
namelist['raw_data_lu_filename'] = "'GLC2000_byte.nc'"
506-
524+
elif args['ilu_type'] == 6:
525+
# we need "" padding for correct replacement in Fortran namelist
526+
namelist['raw_data_lu_filename'] = "'ECOCLIMAP_SG.nc'"
527+
namelist['l_terra_urb'] = ".TRUE."
507528
else:
508529
logging.error(f'Unknown ilu_type {args["ilu_type"]}')
509530
raise ValueError(f'Unknown ilu_type {args["ilu_type"]}')
@@ -811,8 +832,14 @@ def replace_placeholders(args, templates, dir, actual_values):
811832
all_templates[template] = all_templates[template].replace(
812833
key, str("".join(value)))
813834
else:
814-
all_templates[template] = all_templates[template].replace(
815-
key, str(value))
835+
if value is not None:
836+
all_templates[template] = all_templates[template].replace(
837+
key, str(value))
838+
else:
839+
raise ValueError(
840+
f'The placeholder {key} in {all_templates[template]} was replaced with None.'
841+
'This likely means that it was not specified in the config file and has no default value.'
842+
)
816843

817844
# check that no @PLACEHOLDERS@ are left
818845
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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,8 @@ PROGRAM extpar_consistency_check
473473

474474
LOGICAL :: last=.FALSE., & ! in TCL leave loop
475475
& foundtcl=.FALSE., & ! in TCL
476-
& lsso_param,lsubtract_mean_slope, &
476+
& lsso_param, &
477+
& lsubtract_mean_slope = .FALSE., &
477478
& l_use_isa =.FALSE., & !< flag if additional urban data are present
478479
& l_use_ahf =.FALSE., & !< flag if additional urban data are present
479480
& l_use_sgsl=.FALSE., & !< flag if sgsl is used in topo
@@ -700,6 +701,9 @@ PROGRAM extpar_consistency_check
700701
SELECT CASE (i_landuse_data)
701702
CASE (i_lu_globcover)
702703
lu_dataset = 'GLOBCOVER2009'
704+
IF (l_use_corine) THEN
705+
lu_dataset = TRIM(lu_dataset)//' (CORINE)'
706+
ENDIF
703707
CALL get_name_globcover_lookup_tables(ilookup_table_lu, name_lookup_table_lu)
704708
nclass_lu = nclass_globcover
705709
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/extpar_topo_to_buffer.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ PROGRAM extpar_topo_to_buffer
178178
& lpreproc_oro = .FALSE., & !TRUE: preproc raw oro data FALSE: read directly from NetCDF
179179
& lscale_separation=.FALSE., &
180180
& lscale_file= .FALSE., &
181-
& lsubtract_mean_slope, &
181+
& lsubtract_mean_slope = .FALSE., &
182182
& lfilter_oro, &
183183
& lxso_first
184184

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
@@ -214,7 +214,12 @@ def test_setup_check_namelist_tile_mode():
214214

215215

216216
def test_setup_lu_namelist_type_1():
217-
args = {'ilu_type': 1, 'raw_data_path': '/path/to/data'}
217+
args = {
218+
'ilu_type': 1,
219+
'raw_data_path': '/path/to/data',
220+
'l_use_corine': False,
221+
'ilookup_table_lu': 1
222+
}
218223
expected_namelist = {
219224
'i_landuse_data':
220225
1,
@@ -230,6 +235,10 @@ def test_setup_lu_namelist_type_1():
230235
'GLCC_usgs_class_byte.nc',
231236
'glcc_buffer_file':
232237
'glcc_buffer.nc',
238+
'ntiles_globcover':
239+
6,
240+
'l_terra_urb':
241+
".FALSE.",
233242
'l_use_corine':
234243
".FALSE.",
235244
'raw_data_lu_filename': [
@@ -241,8 +250,36 @@ def test_setup_lu_namelist_type_1():
241250
assert setup_lu_namelist(args) == expected_namelist
242251

243252

253+
def test_setup_lu_namelist_corine():
254+
args = {
255+
'ilu_type': 1,
256+
'raw_data_path': '/path/to/data',
257+
'l_use_corine': True,
258+
'ilookup_table_lu': 1
259+
}
260+
expected_namelist = {
261+
'i_landuse_data': 1,
262+
'ilookup_table_lu': 1,
263+
'raw_data_lu_path': '/path/to/data',
264+
'raw_data_glcc_path': '/path/to/data',
265+
'lu_buffer_file': 'lu_buffer.nc',
266+
'raw_data_glcc_filename': 'GLCC_usgs_class_byte.nc',
267+
'glcc_buffer_file': 'glcc_buffer.nc',
268+
'ntiles_globcover': 1,
269+
'l_terra_urb': ".FALSE.",
270+
'l_use_corine': ".TRUE.",
271+
'raw_data_lu_filename': "'CORINE_globcover.nc'"
272+
}
273+
assert setup_lu_namelist(args) == expected_namelist
274+
275+
244276
def test_setup_lu_namelist_type_2():
245-
args = {'ilu_type': 2, 'raw_data_path': '/path/to/data'}
277+
args = {
278+
'ilu_type': 2,
279+
'raw_data_path': '/path/to/data',
280+
'l_use_corine': False,
281+
'ilookup_table_lu': 2
282+
}
246283
expected_namelist = {
247284
'i_landuse_data': 2,
248285
'ilookup_table_lu': 2,
@@ -251,12 +288,37 @@ def test_setup_lu_namelist_type_2():
251288
'lu_buffer_file': 'lu_buffer.nc',
252289
'raw_data_glcc_filename': 'GLCC_usgs_class_byte.nc',
253290
'glcc_buffer_file': 'glcc_buffer.nc',
291+
'ntiles_globcover': 6,
292+
'l_terra_urb': ".FALSE.",
254293
'l_use_corine': ".FALSE.",
255294
'raw_data_lu_filename': "'GLC2000_byte.nc'"
256295
}
257296
assert setup_lu_namelist(args) == expected_namelist
258297

259298

299+
def test_setup_lu_namelist_type_6():
300+
args = {
301+
'ilu_type': 6,
302+
'raw_data_path': '/path/to/data',
303+
'l_use_corine': False,
304+
'ilookup_table_lu': 1
305+
}
306+
expected_namelist = {
307+
'i_landuse_data': 6,
308+
'ilookup_table_lu': 1,
309+
'raw_data_lu_path': '/path/to/data',
310+
'raw_data_glcc_path': '/path/to/data',
311+
'lu_buffer_file': 'lu_buffer.nc',
312+
'raw_data_glcc_filename': 'GLCC_usgs_class_byte.nc',
313+
'glcc_buffer_file': 'glcc_buffer.nc',
314+
'ntiles_globcover': 6,
315+
'l_terra_urb': ".TRUE.",
316+
'l_use_corine': ".FALSE.",
317+
'raw_data_lu_filename': "'ECOCLIMAP_SG.nc'"
318+
}
319+
assert setup_lu_namelist(args) == expected_namelist
320+
321+
260322
def test_setup_aot_namelist_type_1():
261323
args = {'iaot_type': 1, 'raw_data_path': '/path/to/data'}
262324
expected_namelist = {
@@ -895,6 +957,7 @@ def test_all_placeholders_replaced_cosmo(tmp_dir):
895957
"it_cl_type": 1,
896958
"iera_type": 1,
897959
"iemiss_type": 1,
960+
'ilookup_table_lu': 1,
898961
"enable_cdnc": False,
899962
"enable_edgar": False,
900963
"enable_art": False,
@@ -910,6 +973,7 @@ def test_all_placeholders_replaced_cosmo(tmp_dir):
910973
"lurban": False,
911974
"lsgsl": False,
912975
"lfilter_oro": False,
976+
"l_use_corine": False,
913977
"lradtopo": False
914978
}
915979

@@ -932,6 +996,7 @@ def test_all_placeholders_replaced_icon(tmp_dir, icon_grid):
932996
"it_cl_type": 1,
933997
"iera_type": 1,
934998
"iemiss_type": 1,
999+
'ilookup_table_lu': 1,
9351000
"enable_cdnc": False,
9361001
"enable_edgar": False,
9371002
"enable_art": False,
@@ -947,6 +1012,7 @@ def test_all_placeholders_replaced_icon(tmp_dir, icon_grid):
9471012
"lurban": False,
9481013
"lsgsl": False,
9491014
"lfilter_oro": False,
1015+
"l_use_corine": False,
9501016
"lradtopo": False
9511017
}
9521018

0 commit comments

Comments
 (0)