Repository navigation
Add a planner that aligns CDEPS stream years with the run dates - #53
Open
manishvenu wants to merge 1 commit into
Open
manishvenu wants to merge 1 commit into
manishvenu wants to merge 1 commit into
Conversation
Multi-year data streams default to cycling their full available range. plan_stream_years reads the stream definitions for a component's mode from the CESM tree and returns, per stream, the year_first/year_last/year_align (and optionally the narrowed data file list) that cover a run's years with padding, skipping single-year or non-covering streams. It writes nothing; callers apply the plan to user_nl_<comp>_streams.
This branch has not been deployed
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.
Why
JRA cases read the wrong data years. The CDEPS stream definitions for JRA forcing
(DATM
CORE_IAF_JRA*, DROFIAF_JRA) hardcodeyear_align=1and the dataset's fullyear span. The
DATM_YR_ALIGN/_START/_ENDxml variables are read only by theland-forcing and CPLHIST streams. So a JRA case reads data years unrelated to
RUN_STARTDATE, and no xmlchange can fix it. The only lever CDEPS offers isuser_nl_datm_streams/user_nl_drof_streams.Every year's file is listed.
<datafiles>is expanded from the stream definition'sown years before user mods are merged. Retagging the years alone still lists every year
of the dataset (59 files per
CORE_IAF_JRAstream), and CDEPS reads the time axis ofeach file in turn until it reaches the year it needs.
The right settings take CDEPS knowledge:
namelist_definition_datm.xml);<file>entries, each with a different datestamp.That is CESM case configuration, which is visualCaseGen's job. CrocoDash carries this
code today. It would call visualCaseGen instead and keep only the step that writes the
user_nl lines.
What
visualCaseGen/cdeps_streams.pyis a set of thin wrappers over CIME'sNamelistDefinitionand CDEPS'sStreamCDEPS, so names and paths match whatbuildnml generates:
stream_names(cesmroot, component, mode)coverage(cesmroot, component, stream_name, case)datafiles(cesmroot, component, stream_name, year_first, year_last, case)visualCaseGen/stream_years.pyaddsplan_stream_years(cesmroot, component, mode, case, start_year, end_year, *, padding=1, narrow=True).It returns a plan and writes nothing.
year_first = max(first available year, start_year - 1 - padding); the extraleading year lets CDEPS interpolate at the run start;
year_last = min(last available year, end_year + padding);year_align = year_first, so the data year equals the model year;narrow, the stream'sdatafilesfor those years.years, it returns
{"status": "skipped", "reason": ...}instead, and the callerleaves the component at its CDEPS defaults.
caseonly needsget_value, to expand$DIN_LOC_ROOT, so a CIMECaseworks.Nothing reads config variables or touches the GUI.
user_nl_<comp>_streams. For a2021 run:
Tests
New
tests/2_integration/test_stream_years.pyhas 2 tests (3 cases). They read the realCDEPS stream definitions from the CI's CESM tree, which they find through
CIME_interface().srcrootlike the other integration tests. No inputdata is needed.CORE_IAF_JRA_1p5_2023is aligned to 2019-2022 for all 8 streams. ThePREC stream's files carry each year's own datestamp (210504, 210504, 220505, 230718).
CORE2_NYF(one repeating year) is skipped, and so is a 2020 run onCORE_IAF_JRA,which ends in 2016.
The expected values were checked by calling
plan_stream_yearsdirectly against thecdeps1.0.101stream definitions.Notes for reviewers
coverageanddatafilescallStreamCDEPS._get_stream_first_and_last_dates,_resolve_valuesand_sub_paths,so the expansion matches buildnml exactly. Reimplementing it would risk emitting paths
that do not exist. All these calls are in
cdeps_streams.py, and the test's exact-pathassertion is there to catch a CDEPS update that changes them.
cdeps_streamsappends<cesmroot>/cimeand CDEPS'scime_configdirectory to
sys.path, becausestream_cdeps.pyis a loose module, not a package.That lets it work without a
CIME_interface.RUN_STARTDATE/STOP_N,so streams can be planned before those are set.
which keeps those files readable.
Possible follow-ups in visualCaseGen
DROF options (e.g. the JRA compsets), but never looks at the run dates. When a case uses
one, the launch stage could call
plan_stream_yearsfor the run's years and either:user_nl_datm_streams/user_nl_drof_streams, as tagged blockswith
user_nl_blocks; orotherwise silently cycle the wrong years.
🤖 Generated with Claude Code