3

Since a few weeks i'm writing writing MODFLOW models with Flopy in Python. I chose to write models in Flopy because of the transparency of Python. However, once in a while my model doesn't run but it doesn't tell me where it goes wrong, that makes error handeling difficult.

At the moment my model gives an error at running the model. It raises the error with the message I added manually (and is common used):

success, mfoutput = mf.run_model(silent=False, pause=False) 
if not success:
    raise Exception('MODFLOW did not terminate normally.')

The error I got is:

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.

Besides, all the MODFLOW files are created but .hds and .cbc file contain zero bytes.

My question: does someone have tips to track down these kind of errors efficient and smart.

Dylan_w
  • 472
  • 5
  • 19
  • 3
    Hi Dylan, have you looked at the output list file? Most of the time you'll be able to see where MODFLOW hit a snag by scrolling through the file to the last line recorded before the program terminated. Check to see which package it bailed on and that the correct files are being read in. – Jason Bellino Apr 23 '19 at 18:03
  • I wasn't aware that it writes until it terminates, so exactly where I was looking for!. It appears that it terminates when it starts running the PCG solver. At Well no 30 and gives the error "layer number in list is outside of the grid" (my grid goes up to 29 layers). I checked all the variables that my model creates but none of them exceeds the 29 layers. So I'm going to try to figure it out by check my script line for line I guess. – Dylan_w Apr 24 '19 at 09:06
  • 1
    Make sure to check the input well package file you're using. Python uses a 0-based numbering system and it can be easy to misrepresent layers, rows, and columns if you're not careful because these get converted to 1-based numbering for MODFLOW, i.e. lay, row, col [29, 0, 0] in python gets written out as lay, row, col [30, 1, 1] for input to MODFLOW. – Jason Bellino Apr 25 '19 at 14:10
  • 1
    Thanks Jason, solved the problem 3 days ago. It was indeed the well package where I made some mistake. – Dylan_w Apr 29 '19 at 12:12

0 Answers0