diff --git a/autotest/test_model_splitter.py b/autotest/test_model_splitter.py index 71a1cbd5da..712b2809ac 100644 --- a/autotest/test_model_splitter.py +++ b/autotest/test_model_splitter.py @@ -14,6 +14,12 @@ def test_structured_model_splitter(function_tmpdir): sim_path = get_example_data_path() / "mf6-freyberg" + from pathlib import Path + + function_tmpdir = Path("./temp") + + split_path = function_tmpdir / "split_model" + sim = MFSimulation.load(sim_ws=sim_path) sim.set_sim_path(function_tmpdir) sim.write_simulation() @@ -32,7 +38,7 @@ def test_structured_model_splitter(function_tmpdir): mfsplit = Mf6Splitter(sim) new_sim = mfsplit.split_model(array) - new_sim.set_sim_path(function_tmpdir / "split_model") + new_sim.set_sim_path(split_path) new_sim.write_simulation() new_sim.run_simulation() @@ -49,6 +55,21 @@ def test_structured_model_splitter(function_tmpdir): err_msg = "Heads from original and split models do not match" np.testing.assert_allclose(new_heads, original_heads, err_msg=err_msg) + # test that line length is ncol for each model.... + ll_dict = { + split_path / "freyberg_001.npf": ml0.dis.ncol.get_data(), + split_path / "freyberg_100.npf": ml1.dis.ncol.get_data(), + } + for f, ncol in ll_dict.items(): + with open(f) as foo: + while "internal" not in foo.readline().lower(): + continue + + line = foo.readline().strip() + tmp = line.split() + if len(tmp) != ncol: + raise AssertionError("Array column length is not equal to ncol") + @requires_exe("mf6") def test_vertex_model_splitter(function_tmpdir): diff --git a/flopy/mf6/mfmodel.py b/flopy/mf6/mfmodel.py index 54c6f49ba4..0abc25cbdf 100644 --- a/flopy/mf6/mfmodel.py +++ b/flopy/mf6/mfmodel.py @@ -1318,6 +1318,13 @@ def write(self, ext_file_action=ExtFileAction.copy_relative_paths): self.name_file.write(ext_file_action=ext_file_action) + if not self.simulation_data.max_columns_user_set: + grid_type = self.get_grid_type() + if grid_type == DiscretizationType.DIS: + self.simulation_data.max_columns_of_data = self.dis.ncol.get_data() + self.simulation_data.max_columns_user_set = False + self.simulation_data.max_columns_auto_set = True + # write packages for pp in self.packagelist: if (