From 2196cf62ea81a66d8d56335afebd94a1b2906a45 Mon Sep 17 00:00:00 2001 From: scottrp <45947939+scottrp@users.noreply.github.com> Date: Mon, 14 Aug 2023 12:23:10 -0700 Subject: [PATCH] fix(keyword data): optional keywords 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. --- autotest/test_mf6.py | 14 ++++++++++++++ flopy/mf6/data/mfdatastorage.py | 1 + 2 files changed, 15 insertions(+) diff --git a/autotest/test_mf6.py b/autotest/test_mf6.py index 3a35108f2c..30bb7053e6 100644 --- a/autotest/test_mf6.py +++ b/autotest/test_mf6.py @@ -2186,6 +2186,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")] diff --git a/flopy/mf6/data/mfdatastorage.py b/flopy/mf6/data/mfdatastorage.py index 491c2e20cf..c74fd31d62 100644 --- a/flopy/mf6/data/mfdatastorage.py +++ b/flopy/mf6/data/mfdatastorage.py @@ -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