Skip to content

Commit 75b34a0

Browse files
fix: fix duplicate unit numbers in NAM file for MFUSG external files (#2659)
When loading a model, DATA entries from the NAM file were being added to external_units even when they already existed in output_units (e.g., IUNITAFR from WEL package). This caused duplicate entries in the written NAM file. Added check for output_units in _prepare_external_files() to prevent adding unit numbers that are already registered as output files.
1 parent 5a94526 commit 75b34a0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

flopy/mfusg/mfusg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ def _prepare_external_files(model, key, item):
445445
print(f" {os.path.basename(item.filename)}")
446446
if key not in model.pop_key_list:
447447
# do not add unit number (key) if it already exists
448-
if key not in model.external_units:
448+
if key not in model.external_units and key not in model.output_units:
449449
model.external_fnames.append(item.filename)
450450
model.external_units.append(key)
451451
model.external_binflag.append("binary" in item.filetype.lower())

0 commit comments

Comments
 (0)