Skip to content

Commit 57db578

Browse files
committed
EAMxx: archive yaml/nml files in CaseDocs when buildnml runs
1 parent 7a60e92 commit 57db578

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

components/eamxx/cime_config/buildnml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ from CIME.utils import expect, safe_copy, SharedArea, run_cmd_no_fail
2929
from CIME.buildnml import parse_input
3030

3131
from eamxx_buildnml import create_raw_xml_file, create_input_files, create_input_data_list_file, \
32-
do_cime_vars_on_yaml_output_files
32+
do_cime_vars_on_yaml_output_files, archive_case_docs
3333

3434
###############################################################################
3535
def buildnml(case, caseroot, compname):
@@ -75,6 +75,9 @@ def buildnml(case, caseroot, compname):
7575
#
7676
create_input_data_list_file(case,caseroot)
7777

78+
# archive yaml/nml files in CaseDocs
79+
archive_case_docs(case,caseroot)
80+
7881
###############################################################################
7982
def _main_func():
8083
###############################################################################

components/eamxx/cime_config/eamxx_buildnml.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,3 +1175,32 @@ def do_cime_vars_on_yaml_output_files(case, caseroot):
11751175
################################################################
11761176
""")
11771177
ordered_dump(scream_input, fd)
1178+
1179+
###############################################################################
1180+
def archive_case_docs(case,caseroot):
1181+
###############################################################################
1182+
# Copy ALL eamxx input yaml/nml files to CaseDocs, for provenance
1183+
with SharedArea():
1184+
# We for sure have scream_input.yaml and namelist.nl
1185+
files = ['scream_input.yaml', 'namelist.nl']
1186+
1187+
# Get the XML configs, and find all output yaml files
1188+
rundir = case.get_value("RUNDIR")
1189+
eamxx_xml_file = os.path.join(caseroot, "namelist_scream.xml")
1190+
1191+
with open(eamxx_xml_file, "r") as fd:
1192+
eamxx_xml = ET.parse(fd).getroot()
1193+
1194+
scorpio = get_child(eamxx_xml,'scorpio')
1195+
out_files_xml = get_child(scorpio,"output_yaml_files",must_exist=False)
1196+
out_files = out_files_xml.text.split(",") if (out_files_xml is not None and out_files_xml.text is not None) else []
1197+
1198+
for fn in out_files:
1199+
# Get full name
1200+
src_yaml = os.path.expanduser(os.path.join(fn.strip()))
1201+
files.append(os.path.basename(src_yaml))
1202+
1203+
for f in files:
1204+
src = os.path.join(caseroot,f'run/data/{f}')
1205+
dst = os.path.join(caseroot,f'CaseDocs/{f}')
1206+
safe_copy(src,dst)

0 commit comments

Comments
 (0)