Fix UnboundLocalError in explicit-cycledef path (parse COLDSTART_CYCS) - #1699
Open
ywangwof wants to merge 1 commit into
Open
Fix UnboundLocalError in explicit-cycledef path (parse COLDSTART_CYCS)#1699ywangwof wants to merge 1 commit into
ywangwof wants to merge 1 commit into
Conversation
When users set CYCLEDEF_* explicitly in the experiment file,
smart_cycledefs() takes the explicit-override branch and never parses
COLDSTART_CYCS into `cold_cycs`. The later `da_nocold` block (built when
DO_JEDI=true or DO_NONVAR_CLOUD_ANA=true, and COLDSTART_CYCS_DO_DA=false)
references `cold_cycs`, raising:
UnboundLocalError: local variable 'cold_cycs' referenced before assignment
This makes explicit cycledefs unusable for DA experiments that skip DA at
the cold-start cycles (a common configuration).
Parse COLDSTART_CYCS in the explicit branch too, using the same default
('03 15') as the auto-compute branch, so `da_nocold` can exclude the
cold-start cycles. Experiments using the auto-compute path (no CYCLEDEF_*
set) are unaffected, so all existing XML output is unchanged.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ywangwof
requested review from
BenjaminBlake-NOAA,
MatthewPyle-NOAA and
ShunLiu-NOAA
as code owners
September 3, 2026 21:32
guoqing-noaa
reviewed
Sep 3, 2026
| # cycles from DA. The auto-compute branch parses this too; the explicit | ||
| # branch must as well, otherwise cold_cycs is undefined whenever | ||
| # (DO_JEDI or DO_NONVAR_CLOUD_ANA) and COLDSTART_CYCS_DO_DA=false. | ||
| cold_cycs = os.getenv('COLDSTART_CYCS', '03 15').strip().split() |
Contributor
There was a problem hiding this comment.
@ywangwof Thanks for fixing this! 👍
WE can safely remove comment lines 18-21. Thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes an
UnboundLocalErrorthat makes the explicit-cycledef path unusable for DA experiments.When a user sets
CYCLEDEF_*variables explicitly in the experiment file,smart_cycledefs()takes the explicit-override branch and never parsesCOLDSTART_CYCSintocold_cycs. The laterda_nocoldblock — built wheneverDO_JEDI=true(orDO_NONVAR_CLOUD_ANA=true) andCOLDSTART_CYCS_DO_DA=false— referencescold_cycsand raises:That configuration (DA, skipping DA at the cold-start cycles) is common, so explicit cycledefs currently cannot be used with it.
Fix
Parse
COLDSTART_CYCSin the explicit-override branch too, using the same default ('03 15') as the auto-compute branch, soda_nocoldcan exclude the cold-start cycles.Impact
CYCLEDEF_*set) never enter the modified branch → all existing XML output is unchanged.Reproducer / verification
Append to
workflow/exp/exp.conus12km(which hasDO_JEDI=true,COLDSTART_CYCS_DO_DA=false,COLDSTART_CYCS="00 12"):./setup_rocoto.pyaborts with theUnboundLocalErrorabove.da_nocoldcycledef, e.g.:py_compileclean.