几个星期以来,我正在用Python用Flopy编写MODFLOW模型。由于Python的透明性,我选择用Flopy编写模型。但是,有时我的模型无法运行,但无法告诉我哪里出了问题,这使错误处理变得困难。
此刻,我的模型在运行模型时出现错误。我手动添加的消息(通常使用)会引发错误:
success, mfoutput = mf.run_model(silent=False, pause=False)
if not success:
raise Exception('MODFLOW did not terminate normally.')
我得到的错误是:
FloPy is using the following executable to run the model: /usr/bin/mf2005
MODFLOW-2005
U.S. GEOLOGICAL SURVEY MODULAR FINITE-DIFFERENCE GROUND-WATER FLOW MODEL
Version 1.12.00 2/3/2017
Using NAME file: spangen_mod.nam
Run start date and time (yyyy/mm/dd hh:mm:ss): 2019/04/23 16:12:39
Traceback (most recent call last):
File "<ipython-input-85-c7ecca798eed>", line 1, in <module>
runfile('/Users/user/Desktop/modflow/model.py', wdir='/Users/user/Desktop/modflow')
File "/Users/user/anaconda3/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py", line 704, in runfile
execfile(filename, namespace)
File "/Users/user/anaconda3/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py", line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "/Users/user/Desktop/modflow/model.py", line 223, in <module>
raise Exception('MODFLOW did not terminate normally.')
Exception: MODFLOW did not terminate normally.
此外,将创建所有MODFLOW文件,但.hds和.cbc文件包含零字节。
我的问题:有人有技巧来高效,智能地找到这类错误。