Note
Running MODFLOW through Flopy
[1]:
import os
import sys
try:
import flopy
except:
fpth = os.path.abspath(os.path.join("..", ".."))
sys.path.append(fpth)
import flopy
print(sys.version)
print("flopy version: {}".format(flopy.__version__))
3.10.10 | packaged by conda-forge | (main, Mar 24 2023, 20:08:06) [GCC 11.3.0]
flopy version: 3.3.7
In order for you to run a model you have created or loaded using FloPy the model executable must be available in your path. You can test if the model is available using:
[2]:
from flopy.utils.flopy_io import scrub_login
scrub_login(flopy.which("mf2005"))
[2]:
'/home/runner/.local/bin/modflow/mf2005'
The path to the executable is returned if the executable exists in your path or the current working directory. An empty string is passed if the executable does not exist in your path or the current working directory. Next we will test if a non-existent executable (no-exist.exe
) is available.
[3]:
flopy.which("no-exist.exe")
Nothing is written when no-exist.exe
is passed to flopy.which()
. This means the executable does not exist.
If this happens you should: 1. Check the that you have spelled the executable correctly. 2. If you have spelled the executable correctly then you need to move the executable into your working directory or into a directory in your path. 3. If you have spelled the executable correctly but don’t have the executable. Your options are: * Download a precompiled version of the executable. Precompiled versions of MODFLOW-based codes are available from the U.S. Geological Survey for the Windows
operating system. * Compile the source code (available from the U.S. Geological Survey) for the Windows, OS X, Linux, and UNIX operating systems and place the compiled executable in the working directory or a directory contained in your path (for example, /Users/jdhughes/.local/bin/
as indicated above).
You can get a list of the directories in your system path using:
[4]:
scrub_login(os.getenv("PATH"))
[4]:
'/home/runner/.local/share/flopy/bin:/home/runner/.local/share/flopy/bin:/home/runner/micromamba-root/envs/flopy/bin:/home/runner/micromamba-root/condabin:/home/runner/.local/bin/modflow:/home/runner/micromamba-bin:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/runner/.dotnet/tools'
After you download/compile the executable put it in the current working directory or one of the directories in your system path.