Repository navigation
Add cbrt keyword for a fast cube root in the friction term, remove the h73 table - #446
maartenvanormondt wants to merge 3 commits into
Conversation
Remove the h^(7/3) lookup table and calculate the friction term from a cube root instead. Add `cbrt=exact` (default) and `cbrt=fast` approximation, and record the selected mode in NetCDF output.
There was a problem hiding this comment.
🟡 Changes recommended
The module header still contains stale documentation for the removed fill_h73_tables() routine, so the change requires cleanup before approval.
1 open issue
What changed in this PR
Adds an optional cbrt input keyword for selecting an approximate cube-root calculation in the Manning friction term while preserving the existing exact behavior by default. The obsolete h73table lookup-table implementation and related support are removed.
Changes:
- Adds
cbrt = exact|fastparsing, validation, fallback handling, documentation, and map metadata. - Uses a bit-based cube-root seed with one Newton iteration for the
fastoption. - Removes the
h73tablestate, lookup table, initialization routine, power helper, and OpenACC references.
| File | Description |
|---|---|
| source/src/sfincs_openacc.f90 | Removes obsolete x73 lookup-table references from OpenACC data management. |
| source/src/sfincs_ncoutput.F90 | Adds the cbrt_fast setting to map output metadata. |
| source/src/sfincs_momentum.f90 | Implements exact and fast cube-root paths and updates the Manning friction calculation. |
| source/src/sfincs_input.f90 | Parses and validates the new cbrt keyword and removes the active h73table input. |
| source/src/sfincs_domain.f90 | Removes initialization of the obsolete lookup table. |
| source/src/sfincs_data.f90 | Adds the cbrt_fast state and removes obsolete lookup-table data and routines. |
| docs/parameters.rst | Documents the cbrt parameter and removes the obsolete h73table entry. |
Review effort: Lite
|
Thanks, good to see the table go. I checked that nothing in Accuracy, checked with a float32 script over Blocking
Non-blocking
Suggestions
Question
|
|
Follow-up on blocking point 1 ( I built a combined branch of #445, #446, #447, #448 and #449 on top of This only covers compilation: the GPU results with |
- Read h73table again into a local logical in sfincs_input and write a warning when it is set: the look-up table has been removed, the keyword is ignored, and cbrt = fast is the replacement. - Restore the h73table entry in docs/parameters.rst, marked as deprecated after SFINCS v2.5.0 and replaced by cbrt. - Guard the fast cube-root seed with max(hu, tiny(hu)), so that a negative hu (including -0.0) cannot give a NaN seed. The default cbrt = exact path is unchanged and stays bit-identical to main. - Accuracy wording for cbrt = fast in code comments and docs: at most 0.13 % off, always slightly overestimates hu**(1/3). - Style: single ! before end subroutine in sfincs_domain, standard ! lines around contains in sfincs_data. Co-Authored-By: SFINCS <sfincs@deltares.nl>

Description
The Manning friction term in
compute_fluxesneedshu**(7/3). This PR adds a fast approximation of the cube root as an option, and removes the look-up table that was the earlier attempt to speed this up. With the default setting the results do not change.New keyword
cbrt:exact(default)hu**(1/3)with the power function, as beforefasthu, refined by one Newton iteration; accurate to about 0.1 %, no power functionThe cube root
hu13giveshu**(7/3) = hu * hu * hu13. Withcbrt = fastit also giveshu**(5/3) = hu * hu13 * hu13in the flux estimate at points that just became wet. Withcbrt = exactthat estimate keeps the expressionhu ** (5.0 / 3.0)ofmain, so that the output stays identical; a comment marks it for replacement later. An unknown value ofcbrtgives a warning and falls back toexact.Removed: the keyword
h73table, the tablex73,fill_h73_tablesand the functionpower7over3. An input file that still setsh73tableruns as before: the keyword is ignored without a message.Also: the map file gets the attribute
cbrt_fast, anddocs/parameters.rsthas an entry forcbrtin place ofh73table.Test. Release build on Windows, one thread, against
main(f2845d9):cbrt = exact) against maincbrt = fastagainstexact, largest difference in water levelurban_drainage_charlestonThacker1DThe differences with
cbrt = fastare not the 0.1 % of the approximation itself. They are of the size this model gives for any change in the last digit: wetting and drying moves a jump in water level by one time step. Inurban_drainage_charleston,mainagainstmainwithalphachanged in the last digit gives 0.17 m at single cells.Checklist
Compilation
Testing (for additions to the code)
If this PR modifies model functionality:
If this PR adds model functionality:
Documentation
HydroMT-SFINCS
Self Review
Additional Notes
urban_drainage_charlestonthe time in momentum showed no measurable difference betweenfastandexact. A gain has not been demonstrated yet on this branch; it needs timing on a larger model beforefastbecomes the default.exacthere on purpose. A later PR will change the defaults of this and the related PRs in one go, with a full test bed comparison.transferbetweenreal*4andinteger*4is used inside the OpenACC region and has not been compiled with an OpenACC compiler.docs/developments.rststill mentionsh73tablein the release notes of the version that introduced it; that line is history and is left as it is.bates-wiggle-advection: Swap flux and velocity arrays instead of copying them #445 (array swap), Add cbrt keyword for a fast cube root in the friction term, remove the h73 table #446 (cbrt), Add wet-area wiggle suppression as an option (wiggle_detect) #447 (wiggle suppression) and Keep advection on next to inactive cells, add advection_bank_correction #448 (advection). Each is based onmainand they can be merged in any order. They add lines at the same places (the OpenMP private list insfincs_momentum.f90, the logical flags insfincs_data.f90, keyword lines insfincs_input.f90, attributes insfincs_ncoutput.F90, entries inparameters.rst), so the ones merged later will have small conflicts where both sides are to be kept.🤖 Generated with Claude Code