Skip to content

Commit 29089be

Browse files
authored
Ensure OCNRES and ICERES have 3 digits in the archive script (NOAA-EMC#3199)
This PR: - ensures the `OCNRES` and `ICERES` variables in `task_config` are 3 digits Resolves NOAA-EMC#3198
1 parent e5d857b commit 29089be

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

scripts/exglobal_archive.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ def main():
1717
# Instantiate the Archive object
1818
archive = Archive(config)
1919

20+
# update these keys to be 3 digits if they are part of archive.task_config.keys
21+
for key in ['OCNRES', 'ICERES']:
22+
try:
23+
archive.task_config[key] = f"{archive.task_config[key]:03d}"
24+
except KeyError as ee:
25+
logger.info(f"key ({key}) not found in archive.task_config!")
26+
2027
# Pull out all the configuration keys needed to run the rest of archive steps
2128
keys = ['ATARDIR', 'current_cycle', 'FHMIN', 'FHMAX', 'FHOUT', 'RUN', 'PDY',
2229
'DO_VERFRAD', 'DO_VMINMON', 'DO_VERFOZN', 'DO_ICE', 'DO_PREP_OBS_AERO',
@@ -37,16 +44,15 @@ def main():
3744

3845
archive_dict = AttrDict()
3946
for key in keys:
40-
archive_dict[key] = archive.task_config.get(key)
41-
if archive_dict[key] is None:
42-
print(f"Warning: key ({key}) not found in task_config!")
47+
try:
48+
archive_dict[key] = archive.task_config[key]
49+
except KeyError as ee:
50+
logger.warning(f"WARNING: key ({key}) not found in archive.task_config!")
4351

4452
# Also import all COMIN* and COMOUT* directory and template variables
4553
for key in archive.task_config.keys():
46-
if key.startswith("COM_") or key.startswith("COMIN_") or key.startswith("COMOUT_"):
54+
if key.startswith(("COM_", "COMIN_", "COMOUT_")):
4755
archive_dict[key] = archive.task_config.get(key)
48-
if archive_dict[key] is None:
49-
print(f"Warning: key ({key}) not found in task_config!")
5056

5157
with chdir(config.ROTDIR):
5258

0 commit comments

Comments
 (0)