Skip to content

Commit

Permalink
fix(keyword data): optional keywords (#1920)
Browse files Browse the repository at this point in the history
Flopy allows some keywords to be excluded from recarrays, like "FILEIN".  This fix makes sure that optional keywords, like "MIXED" are not excluded from recarrays.  Since they are optional their presence adds information to the recarray and they therefore can not be excluded.

Co-authored-by: scottrp <45947939+scottrp@users.noreply.github.com>
  • Loading branch information
spaulins-usgs and scottrp committed Aug 16, 2023
1 parent 0418f85 commit 3cef778
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions autotest/test_mf6.py
Original file line number Diff line number Diff line change
Expand Up @@ -2187,6 +2187,20 @@ def test_multi_model(function_tmpdir):
assert rec_array[0][3] == model_names[1]
assert rec_array[1][1] == "transport.ims"
assert rec_array[1][2] == model_names[2]
# test ssm fileinput
gwt2 = sim2.get_model("gwt_model_1")
ssm2 = gwt2.get_package("ssm")
fileinput = [
("RCH-1", f"gwt_model_1.rch1.spc"),
("RCH-2", f"gwt_model_1.rch2.spc"),
("RCH-3", f"gwt_model_1.rch3.spc", "MIXED"),
("RCH-4", f"gwt_model_1.rch4.spc"),
]
ssm2.fileinput = fileinput
fi_out = ssm2.fileinput.get_data()
assert fi_out[2][1] == "gwt_model_1.rch3.spc"
assert fi_out[1][2] is None
assert fi_out[2][2] == "MIXED"

# create a new gwt model
sourcerecarray = [("WEL-1", "AUX", "CONCENTRATION")]
Expand Down
1 change: 1 addition & 0 deletions flopy/mf6/data/mfdatastorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2857,6 +2857,7 @@ def build_type_list(
if (
data_item.type != DatumType.keyword
or data_set.block_variable
or data_item.optional
):
initial_keyword = False
shape_rule = None
Expand Down

0 comments on commit 3cef778

Please sign in to comment.