Repository navigation
fix(sfr): read bedk, manning, and upstream_frac from the input context - #128
Open
jdhughes-dev wants to merge 8 commits into
Open
jdhughes-dev wants to merge 8 commits into
jdhughes-dev wants to merge 8 commits into
Conversation
MODFLOW 6.8.2 reads SFR packagedata through IDM and keeps HK, ROUGH, and USTRF only as aliases that are reported as deprecated when used through the API. For libmf6 6.8.2 and later, the packagedata hk, rough, and ustrf columns are now read from __INPUT__/<model>/<sfr>/BEDK, MANNING, and UPSTREAM_FRAC; earlier versions still use the legacy names. Column names are unchanged.
Contributor
Author
Reviewer Summary
|
The SFR test used a copy of the ex-gwf-sfr-p01 example from modflow6-examples. It now uses a three-cell, three-reach model with one diversion, written by hand so the input runs on every libmf6 version tested.
The SFR test read a hand-written model committed to docs/examples/data. It now builds the same three-reach model with flopy in the test directory, and takes the expected hk, rough, and ustrf values from the arrays passed to flopy. flopy is added to the test dependency group.
mjreno
approved these changes
Oct 29, 2026
mjreno
left a comment
There was a problem hiding this comment.
Verified
- On MODFLOW 6 develop, this%hk, this%rough and this%ustrf point at BEDK, MANNING and UPSTREAM_FRAC in the input context, and HK, ROUGH and USTRF are deprecated aliases of the same memory, so the new addresses read and write exactly what the old ones did. These arrays are indexed by reach, so PACKAGEDATA row order doesn't matter. Using them rather than the PACKAGEDATA input arrays (RHK, MAN, USTRF) is correct.
- Behavior with MODFLOW-ORG/modflow6#3093 (in 6.8.2): a value written through modflowapi persists unless that reach's PACKAGEDATA value is linked to a time series, in which case the series value replaces it at the next time step.
- test_sfr_input_context_names passes against libmf6 6.8.1 and against current develop (which includes #3093).
Minor suggestions
- libmf6_version(): re.match returns None for a version string it doesn't recognize, which surfaces as an AttributeError. A clear error message would help.
- The test writes hk and immediately reads the same address back. Reading it again at the next time step, or comparing with the deprecated HK address (same memory), would show the write reaches the package's working array and persists, which the manual comparison in the summary already demonstrates.
Contributor
Author
|
Thanks @mjreno.
|
wpbonelli
reviewed
Oct 29, 2026
The input context address for hk, rough, and ustrf was chosen by libmf6 version, which picks it for a pre-6.8.2 nightly (6.9.0.dev0) that does not have it. The address is now used when it is in the libmf6 input variable names, with the package address as the fallback, and libmf6_version() is removed.
Drop flopy from the test group so modflowapi does not depend on it.
Removing flopy from the test group in e2bbd7a also removed it from the docs group.
wpbonelli
approved these changes
Oct 29, 2026
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.
MODFLOW 6.8.2 reads SFR packagedata through IDM and keeps
HK,ROUGH, andUSTRFonly as deprecated API aliases, so every SFR model run through modflowapi writes three deprecation warnings tomfsim.lst. The packagedatahk,rough, andustrfcolumns are now read from__INPUT__/<model>/<sfr>/BEDK,MANNING, andUPSTREAM_FRACwhen libmf6 has those addresses, and from the legacy names otherwise; the column names are unchanged.adv_input_varsindatamodel.pymaps a column to its input context name.test_sfr_input_context_nameschecks the addresses, values, and a write that persists into the next stress period, against a small SFR model whose input files the test writes as text; it passes against 6.8.1 and current MODFLOW 6develop.