Skip to content

Commit

Permalink
Ensure OCNRES and ICERES have 3 digits in the archive script (#3199)
Browse files Browse the repository at this point in the history
This PR:
- ensures the `OCNRES` and `ICERES` variables in `task_config` are 3
digits

Resolves #3198
  • Loading branch information
aerorahul authored Jan 4, 2025
1 parent e5d857b commit 29089be
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions scripts/exglobal_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ def main():
# Instantiate the Archive object
archive = Archive(config)

# update these keys to be 3 digits if they are part of archive.task_config.keys
for key in ['OCNRES', 'ICERES']:
try:
archive.task_config[key] = f"{archive.task_config[key]:03d}"
except KeyError as ee:
logger.info(f"key ({key}) not found in archive.task_config!")

# Pull out all the configuration keys needed to run the rest of archive steps
keys = ['ATARDIR', 'current_cycle', 'FHMIN', 'FHMAX', 'FHOUT', 'RUN', 'PDY',
'DO_VERFRAD', 'DO_VMINMON', 'DO_VERFOZN', 'DO_ICE', 'DO_PREP_OBS_AERO',
Expand All @@ -37,16 +44,15 @@ def main():

archive_dict = AttrDict()
for key in keys:
archive_dict[key] = archive.task_config.get(key)
if archive_dict[key] is None:
print(f"Warning: key ({key}) not found in task_config!")
try:
archive_dict[key] = archive.task_config[key]
except KeyError as ee:
logger.warning(f"WARNING: key ({key}) not found in archive.task_config!")

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

with chdir(config.ROTDIR):

Expand Down

0 comments on commit 29089be

Please sign in to comment.