From 6ecf87d0ca71637b16a119876a82fa04fa2db665 Mon Sep 17 00:00:00 2001 From: Karl-Hermann Wieners <karl-hermann.wieners@mpimet.mpg.de> Date: Thu, 20 Jul 2023 11:34:18 +0200 Subject: [PATCH] mkexp: always expand id for extended namelist groups --- mkexp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mkexp b/mkexp index b08a7bf..4741d19 100755 --- a/mkexp +++ b/mkexp @@ -222,6 +222,8 @@ def format_namelist(section, group=None, default_value=''): if not line: line = '' line = re.sub(r'^#', ' !', line) + # TODO next line needed to pass tests but questionable. + # See 'Replace id placeholder in namelist groups' below value = eval(repr(value).replace('%{id}', group_ident)) lines.write(' '*base_indent+key+' = '+ format_value(value, indent)+ @@ -583,6 +585,16 @@ for subjob, subconfig in jobs_config.items(): job_config['VARIABLES_'] = var_list for namelist, groups in job_config['namelists'].items(): if isinstance(groups, dict): + # Replace id placeholder in namelist groups + for group_id, group in groups.items(): + group_base, group_ident = expconfig.section_key_info( + group_id) + if group_ident: + for key in group.scalars: + value_repr = repr(group[key]) + if '%{id}' in value_repr: + group[key] = eval(value_repr.replace('%{id}', + group_ident)) # Skip hidden namelists if is_set(groups.get('.hide')): continue -- GitLab