Commit 8afbc00
Add unset capability for ParmParse (#5263)
## Summary
For ParmParse, once a variable is set in an input file, there is no way
to remove it completely from the command line or subsequently in the
input file. For example, you may have specified `amr.keyword = 5` in
`inputs.inp` but then want to override it on the command line so a check
on `pp.contains("amr.keyword")` comes up as false. Right now, using
command line input overrides you can set it to a null value but not
completely remove it from the table (pp.remove() can remove from the
table in source code).
This PR adds an UNSET directive to ParmParse that removes a
previously-defined keyword from the parse table. This enables input
files to conditionally suppress parameters — for example, an included
file can cancel a key set by its parent.
```
amr.keyword = 5
UNSET = amr.keyword
# equivalent to never having set amr.keyword
```
Multiple keys can be removed in a single directive:
```
UNSET = key1 key2 key3
```
## Additional background
Motivated by discussion in
Exawind/amr-wind#1897. Code generated by
Copilot.
Mirrors the design of the existing FILE directive. The new
`ParmParse::UnsetKeyword = "UNSET"` static is exposed in the header for
symmetry with FileKeyword. The directive is handled in addDefn() by
erasing each listed key from the table; keys not present are silently
ignored.
Tests added to Tests/ParmParse/inputs and Tests/ParmParse/main.cpp cover
single-key unset, multi-key unset, and verifying that non-listed keys
are unaffected.
## Checklist
The proposed changes:
- [ ] fix a bug or incorrect behavior in AMReX
- [X] add new capabilities to AMReX
- [ ] changes answers in the test suite to more than roundoff level
- [ ] are likely to significantly affect the results of downstream AMReX
users
- [X] include documentation in the code and/or rst files, if appropriate
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>1 parent 80f53a4 commit 8afbc00
File tree
5 files changed
+53
-0
lines changed- Docs/sphinx_documentation/source
- Src/Base
- Tests/ParmParse
5 files changed
+53
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
668 | 668 | | |
669 | 669 | | |
670 | 670 | | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
671 | 686 | | |
672 | 687 | | |
673 | 688 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1773 | 1773 | | |
1774 | 1774 | | |
1775 | 1775 | | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
1776 | 1779 | | |
1777 | 1780 | | |
1778 | 1781 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
772 | 773 | | |
773 | 774 | | |
774 | 775 | | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
775 | 785 | | |
776 | 786 | | |
777 | 787 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
338 | 353 | | |
339 | 354 | | |
340 | 355 | | |
| |||
0 commit comments