3

几周以来,我一直在用 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 文件包含零字节。

我的问题:是否有人有技巧可以有效而智能地追踪这些错误。

4

0 回答 0