diff --git a/mkexp b/mkexp index f2faf8d0cabc760c5949e8a84015408fbe0752f6..8d650ac7f65b7f36d378feb13695f2d59b99d4ca 100755 --- a/mkexp +++ b/mkexp @@ -574,11 +574,12 @@ for subjob, subconfig in jobs_config.items(): del subconfig # Extend all namelists - for namelist in job_config['namelists'].sections: - groups = job_config['namelists'][namelist] - extended_groups = set() - for group in groups.sections: - extend(group, groups, extended_groups) + if 'namelists' in job_config: + for namelist in job_config['namelists'].sections: + groups = job_config['namelists'][namelist] + extended_groups = set() + for group in groups.sections: + extend(group, groups, extended_groups) # Prepare namelists for inclusion in scripts var_format = job_config['JOB'].get('.var_format', '${%s}') @@ -588,45 +589,46 @@ for subjob, subconfig in jobs_config.items(): expconfig.merge_comments(job_config['jobs'], jobs_config) job_config.walk(format_vars, log=var_list, fmt=var_format) 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 - # Support deprecated keyword 'use_template' but warn user - if groups.get('use_template'): - keyword_warning('use_template') - - namelist_name = re.sub(r'\W', '_', namelist.upper()) - use_template = (groups.get('.use_template') or - groups.get('use_template') or '') - use_full_config = groups.get('.use_full_config', '') - if use_full_config.lower() == 'true': - namelist_config = ConfigObj(job_config) - namelist_config['_'] = job_config - namelist_config.merge(expconfig.odict(groups)) - expconfig.merge_comments(namelist_config, groups) - else: - namelist_config = groups - if use_template: - if use_template.lower() == 'true': - use_template = namelist - job_config[namelist_name] = expand_template( - namelist_config, get_exp_template_names( - experiment_config_id, config, use_template)) - else: - job_config[namelist_name] = format_namelist( - namelist_config) + if 'namelists' in job_config: + 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 + # Support deprecated keyword 'use_template' but warn user + if groups.get('use_template'): + keyword_warning('use_template') + + namelist_name = re.sub(r'\W', '_', namelist.upper()) + use_template = (groups.get('.use_template') or + groups.get('use_template') or '') + use_full_config = groups.get('.use_full_config', '') + if use_full_config.lower() == 'true': + namelist_config = ConfigObj(job_config) + namelist_config['_'] = job_config + namelist_config.merge(expconfig.odict(groups)) + expconfig.merge_comments(namelist_config, groups) + else: + namelist_config = groups + if use_template: + if use_template.lower() == 'true': + use_template = namelist + job_config[namelist_name] = expand_template( + namelist_config, get_exp_template_names( + experiment_config_id, config, use_template)) + else: + job_config[namelist_name] = format_namelist( + namelist_config) # Generate job script template_search_list = ()