diff --git a/autotest/regression/test_mf6.py b/autotest/regression/test_mf6.py index aec1d847ba..17824801a2 100644 --- a/autotest/regression/test_mf6.py +++ b/autotest/regression/test_mf6.py @@ -42,6 +42,7 @@ ModflowGwtssm, ModflowIms, ModflowTdis, + ModflowUtlhpc, ModflowUtltas, ) from flopy.mf6.data.mfdatastorage import DataStorageType @@ -3110,7 +3111,7 @@ def test028_create_tests_sfr(function_tmpdir, example_data_path): delc=5000.0, top=top, botm=botm, - # idomain=idomain, + idomain=idomain, filename=f"{model_name}.dis", ) strt = testutils.read_std_array(os.path.join(pth, "strt.txt"), "float") @@ -3310,8 +3311,77 @@ def test028_create_tests_sfr(function_tmpdir, example_data_path): htol=10.0, ) + # test hpc package + part = [("model1", 1), ("model2", 2)] + hpc = ModflowUtlhpc( + sim, dev_log_mpi=True, partitions=part, filename="test.hpc" + ) + + assert sim.hpc.dev_log_mpi.get_data() + assert hpc.filename == "test.hpc" + part = hpc.partitions.get_data() + assert part[0][0] == "model1" + assert part[0][1] == 1 + assert part[1][0] == "model2" + assert part[1][1] == 2 + + sim.write_simulation() + sim2 = MFSimulation.load( + sim_name=test_ex_name, + version="mf6", + exe_name="mf6", + sim_ws=function_tmpdir, + ) + hpc_a = sim2.get_package("hpc") + assert hpc_a.filename == "test.hpc" + fr = sim2.name_file._hpc_filerecord.get_data() + assert fr[0][0] == "test.hpc" + assert hpc_a.dev_log_mpi.get_data() + part_a = hpc_a.partitions.get_data() + assert part_a[0][0] == "model1" + assert part_a[0][1] == 1 + assert part_a[1][0] == "model2" + assert part_a[1][1] == 2 + + sim2.remove_package(hpc_a) + sim2.set_sim_path(os.path.join(function_tmpdir, "temp")) + sim2.write_simulation() + sim3 = MFSimulation.load( + sim_name=test_ex_name, + version="mf6", + exe_name="mf6", + sim_ws=os.path.join(function_tmpdir, "temp"), + ) + hpc_n = sim3.get_package("hpc") + assert hpc_n is None + fr_2 = sim3.name_file._hpc_filerecord.get_data() + assert fr_2 is None + sim3.set_sim_path(function_tmpdir) + + hpc_data = { + "filename": "hpc_data_file.hpc", + "dev_log_mpi": True, + "partitions": part, + } + sim4 = MFSimulation( + sim_name=test_ex_name, + version="mf6", + exe_name="mf6", + sim_ws=pth, + hpc_data=hpc_data, + ) + fr_4 = sim4.name_file._hpc_filerecord.get_data() + assert fr_4[0][0] == "hpc_data_file.hpc" + assert sim4.hpc.filename == "hpc_data_file.hpc" + assert sim4.hpc.dev_log_mpi.get_data() + part = sim4.hpc.partitions.get_data() + assert part[0][0] == "model1" + assert part[0][1] == 1 + assert part[1][0] == "model2" + assert part[1][1] == 2 + # clean up - sim.delete_output_files() + sim3.delete_output_files() @requires_exe("mf6") diff --git a/examples/data/mf6/notebooks/iconvert.txt b/examples/data/mf6/notebooks/iconvert.txt index 6dc05af7fb..d1a9c33662 100644 --- a/examples/data/mf6/notebooks/iconvert.txt +++ b/examples/data/mf6/notebooks/iconvert.txt @@ -1 +1,4 @@ -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \ No newline at end of file +1 1 1 1 1 +1 1 1 1 1 +1 1 1 1 1 +1 1 1 1 1 \ No newline at end of file diff --git a/flopy/mf6/data/mffileaccess.py b/flopy/mf6/data/mffileaccess.py index 639b815843..237a8cba00 100644 --- a/flopy/mf6/data/mffileaccess.py +++ b/flopy/mf6/data/mffileaccess.py @@ -581,6 +581,10 @@ def read_text_data_from_file( fd=None, data_item=None, ): + # determine line size + line_size = None + if isinstance(data_dim, list): + line_size = data_dim[-1] # load variable data from file current_size = 0 if layer is None: @@ -601,6 +605,8 @@ def read_text_data_from_file( if line == "" or arr_line[0].upper() == "END": break if not MFComment.is_comment(arr_line, True): + if line_size is not None: + arr_line = arr_line[:line_size] data_raw += arr_line else: PyListUtil.reset_delimiter_used() @@ -609,6 +615,8 @@ def read_text_data_from_file( line = fd.readline() arr_line = PyListUtil.split_data_line(line, True) if not MFComment.is_comment(arr_line, True): + if line_size is not None: + arr_line = arr_line[:line_size] data_raw += arr_line else: PyListUtil.reset_delimiter_used() diff --git a/flopy/mf6/modflow.zip b/flopy/mf6/modflow.zip deleted file mode 100644 index fc81d6ca70..0000000000 Binary files a/flopy/mf6/modflow.zip and /dev/null differ diff --git a/flopy/mf6/modflow/mfnam.py b/flopy/mf6/modflow/mfnam.py index 777597f775..43a0ee75ff 100644 --- a/flopy/mf6/modflow/mfnam.py +++ b/flopy/mf6/modflow/mfnam.py @@ -1,6 +1,6 @@ # DO NOT MODIFY THIS FILE DIRECTLY. THIS FILE MUST BE CREATED BY # mf6/utils/createpackages.py -# FILE created on February 07, 2024 20:16:08 UTC +# FILE created on April 23, 2024 17:27:32 UTC from .. import mfpackage from ..data.mfdatautil import ListTemplateGenerator @@ -40,6 +40,11 @@ class ModflowNam(mfpackage.MFPackage): keyword, input summaries will be written for those packages that support newer input data model routines. Not all packages are supported yet by the newer input data model routines. + hpc : {varname:data} or hpc_data data + * Contains data for the hpc package. Data can be stored in a dictionary + containing data for the hpc package with variable names as keys and + package data as values. Data just for the hpc variable is also + acceptable. See hpc package documentation for more information. tdis6 : string * tdis6 (string) is the name of the Temporal Discretization (TDIS) Input File. @@ -79,6 +84,9 @@ class ModflowNam(mfpackage.MFPackage): """ + hpc_filerecord = ListTemplateGenerator( + ("nam", "options", "hpc_filerecord") + ) models = ListTemplateGenerator(("nam", "models", "models")) exchanges = ListTemplateGenerator(("nam", "exchanges", "exchanges")) solutiongroup = ListTemplateGenerator( @@ -128,6 +136,48 @@ class ModflowNam(mfpackage.MFPackage): "reader urword", "optional true", ], + [ + "block options", + "name hpc_filerecord", + "type record hpc6 filein hpc6_filename", + "shape", + "reader urword", + "tagged true", + "optional true", + "construct_package hpc", + "construct_data hpc_data", + "parameter_name hpc", + ], + [ + "block options", + "name hpc6", + "type keyword", + "shape", + "in_record true", + "reader urword", + "tagged true", + "optional false", + ], + [ + "block options", + "name filein", + "type keyword", + "shape", + "in_record true", + "reader urword", + "tagged true", + "optional false", + ], + [ + "block options", + "name hpc6_filename", + "type string", + "preserve_case true", + "in_record true", + "reader urword", + "optional false", + "tagged false", + ], [ "block timing", "name tdis6", @@ -290,6 +340,7 @@ def __init__( ) self.maxerrors = self.build_mfdata("maxerrors", maxerrors) self.print_input = self.build_mfdata("print_input", print_input) + self._hpc_filerecord = self.build_mfdata("hpc_filerecord", None) self.tdis6 = self.build_mfdata("tdis6", tdis6) self.models = self.build_mfdata("models", models) self.exchanges = self.build_mfdata("exchanges", exchanges)