Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mkexp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
esmenv
mkexp
Commits
0014c6aa
Commit
0014c6aa
authored
1 year ago
by
Karl-Hermann Wieners
Browse files
Options
Downloads
Patches
Plain Diff
Tools: make namelists section optional
parent
46cbc7b4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mkexp
+46
-44
46 additions, 44 deletions
mkexp
with
46 additions
and
44 deletions
mkexp
+
46
−
44
View file @
0014c6aa
...
...
@@ -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
=
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment