diff --git a/autotest/regression/test_mf6.py b/autotest/regression/test_mf6.py index fd7b6538ac..8d1e9bedc9 100644 --- a/autotest/regression/test_mf6.py +++ b/autotest/regression/test_mf6.py @@ -751,7 +751,7 @@ def test_np001(function_tmpdir, example_data_path): found_cellid = True assert found_cellid - # test empty stress period + # test empty stress period and remove output well_spd = {0: [(-1, -1, -1, -2000.0), (0, 0, 7, -2.0)], 1: []} wel_package = ModflowGwfwel( model, @@ -763,6 +763,13 @@ def test_np001(function_tmpdir, example_data_path): maxbound=2, stress_period_data=well_spd, ) + oc_package = ModflowGwfoc( + model, + budget_filerecord=[("np001_mod 1.cbc",)], + head_filerecord=[("np001_mod 1.hds",)], + saverecord={0: []}, + printrecord={0: []}, + ) sim.write_simulation() found_begin = False found_end = False @@ -787,6 +794,10 @@ def test_np001(function_tmpdir, example_data_path): spath, write_headers=False, ) + # test to make sure oc empty record dictionary is set + oc = test_sim.get_model().get_package("oc") + assert oc.saverecord.empty_keys[0] is True + # test wel package wel = test_sim.get_model().get_package("wel_2") wel._filename = "np001_spd_test.wel" wel.write() diff --git a/flopy/mf6/data/mfdatalist.py b/flopy/mf6/data/mfdatalist.py index a3627ace14..f35147206b 100644 --- a/flopy/mf6/data/mfdatalist.py +++ b/flopy/mf6/data/mfdatalist.py @@ -1745,6 +1745,9 @@ def has_data(self, key=None): self.get_data_prep(sto_key) if super().has_data(): return True + for val in self.empty_keys.values(): + if val: + return True return False else: self.get_data_prep(key) diff --git a/flopy/mf6/mfpackage.py b/flopy/mf6/mfpackage.py index f52a38d425..1a0b09b2c2 100644 --- a/flopy/mf6/mfpackage.py +++ b/flopy/mf6/mfpackage.py @@ -1031,6 +1031,13 @@ def load(self, block_header, fd, strict=True): and result[1][:3].upper() == "END" ): break + else: + # block empty, store empty array in block variables + empty_arr = [] + for ds in self.datasets.values(): + if isinstance(ds, mfdata.MFTransient): + transient_key = block_header.get_transient_key() + ds.set_data(empty_arr, transient_key) self.loaded = True self.is_valid() @@ -2976,7 +2983,7 @@ def _load_blocks(self, fd_input_file, strict=True, max_blocks=sys.maxsize): block_header_info, fd_input_file, strict ) - # write post block comment comment + # write post block comment self._simulation_data.mfdata[ cur_block.block_headers[-1].blk_post_comment_path ] = self.post_block_comments