Repository navigation
Add a planner that aligns CDEPS stream years with the run dates - #53
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.
| entries reads the ``DATM_YR_ALIGN``/``_START``/``_END`` xml variables (only | ||
| the land-forcing and CPLHIST streams do). So a JRA case silently reads an | ||
| arbitrary data year, and ``xmlchange`` cannot fix it. The only lever CDEPS | ||
| offers is ``user_nl_<comp>_streams``. |
There was a problem hiding this comment.
This comment here makes me wonder whether we are trying to fix a CDEPS limitation (or a bug) via visualCaseGen, which is not ideal. CDEPS already does both the alignment and the narrowing of datafiles for the land forcing streams via $DATM_YR_*. Would it make more sense to have the JRA streams do the same in CDEPS?
There was a problem hiding this comment.
It would make way more sense! I'm not sure why they are hardcoded.
There was a problem hiding this comment.
Shall I open a PR to CDEPS instead? That way this PR gets dramatically smaller
There was a problem hiding this comment.
How does this look to you? Shall I open this to ESCOMP/CDEPS? It won't make any changes to any behavior. It just makes xml variables of it all.
|
Closing: CrocoDash now aligns the stream years through CDEPS, whose JRA, CORE2 IAF and GLOFAS streams read DATM_YR_/DROF_YR_ (CROCODILE-CESM/CDEPS#3, used by CROCODILE-CESM/CrocoDash#326), so this planner isn't needed. |
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