Skip to content

Commit

Permalink
fix(mtbtn): options from load method ignored
Browse files Browse the repository at this point in the history
* Pass options from load method to class constructor
* Correct case for "ALTWTSORB" case
* Show verbose message for optional keywords
* Add a unit tests to check options
  • Loading branch information
mwtoews committed Sep 18, 2019
1 parent 5914bbe commit 249593a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 12 additions & 0 deletions autotest/t012_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ def test_mf2005_p07():
namfile = 'p7mt.nam'
mt = flopy.mt3d.mt.Mt3dms.load(namfile, model_ws=pth, verbose=True,
exe_name=mt3d_exe)
# Optional keyword line is absent in this example, ensure defaults are kept
assert mt.btn.DRYCell is False
assert mt.btn.Legacy99Stor is False
assert mt.btn.MFStyleArr is False
assert mt.btn.AltWTSorb is False

mt.model_ws = cpth
ftlfile = 'p7.ftl'
mt.ftlfilename = ftlfile
Expand Down Expand Up @@ -374,6 +380,12 @@ def test_mfnwt_keat_uzf():
namefile = 'Keat_UZF_mt.nam'
mt = flopy.mt3d.mt.Mt3dms.load(namefile, model_ws=pth, verbose=True,
version='mt3d-usgs', exe_name=mt3d_usgs_exe)
# Check a few options specified as optional keywords on line 3
assert mt.btn.DRYCell is True
assert mt.btn.Legacy99Stor is False
assert mt.btn.MFStyleArr is True
assert mt.btn.AltWTSorb is False

mt.model_ws = cpth
ftlfile = 'Keat_UZF.ftl'
mt.ftlfilename = ftlfile
Expand Down
12 changes: 10 additions & 2 deletions flopy/mt3d/mtbtn.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,8 @@ def load(f, model, ext_unit_dict=None):
AltWTSorb = False
if m_arr[
0].strip().isdigit() is not True: # If m_arr[0] is not a digit, it is a keyword
if model.verbose:
print(' loading optional keywords: {}'.format(line.strip()))
for i in range(0, len(m_arr)):
if m_arr[i].upper() == "MODFLOWSTYLEARRAYS":
MFStyleArr = True
Expand All @@ -705,8 +707,10 @@ def load(f, model, ext_unit_dict=None):
NoWetDryPrint = True
if m_arr[i].upper() == "OMITDRYCELLBUDGET":
OmitDryBud = True
if m_arr[i].upper() == "AltWTSorb":
if m_arr[i].upper() == "ALTWTSORB":
AltWTSorb = True
elif model.verbose:
print(' optional keywords not identifed/loaded')

# A3
if model.verbose:
Expand Down Expand Up @@ -954,7 +958,11 @@ def load(f, model, ext_unit_dict=None):
model.get_ext_dict_attr(ext_unit_dict,
filetype=Mt3dBtn.ftype())

btn = Mt3dBtn(model, nlay=nlay, nrow=nrow, ncol=ncol, nper=nper,
btn = Mt3dBtn(model, MFStyleArr=MFStyleArr, DRYCell=DRYCell,
Legacy99Stor=Legacy99Stor, FTLPrint=FTLPrint,
NoWetDryPrint=NoWetDryPrint, OmitDryBud=OmitDryBud,
AltWTSorb=AltWTSorb,
nlay=nlay, nrow=nrow, ncol=ncol, nper=nper,
ncomp=ncomp, mcomp=mcomp, tunit=tunit,
laycon=laycon, delr=delr, delc=delc, htop=htop, dz=dz,
lunit=lunit, munit=munit, prsity=prsity, icbund=icbund,
Expand Down

0 comments on commit 249593a

Please sign in to comment.