FloPy includes a get-modflow
utility to install USGS MODFLOW and related programs for Windows, Mac or Linux. If FloPy is installed, the utility is available in the Python environment as a get-modflow
command. The script flopy/utils/get_modflow.py
has no dependencies and can be invoked independently.
The utility uses the GitHub releases API to download versioned archives containing executables compiled with Intel Fortran. The utility is able to match the binary archive to the operating system and extract the console programs to a user-defined directory. A prompt can also be used to help the user choose where to install programs.
When FloPy is installed, a get-modflow
(or get-modflow.exe
for Windows) program is installed, which is usually installed to the PATH (depending on the Python setup). From a console:
$ get-modflow --help
usage: get-modflow [-h]
...
The script requires Python 3.6 or later and does not have any dependencies, not even FloPy. It can be downloaded separately and used the same as the console program, except with a different invocation. For example:
$ wget https://raw.githubusercontent.com/modflowpy/flopy/develop/flopy/utils/get_modflow.py
$ python3 get_modflow.py --help
usage: get_modflow.py [-h]
...
The same functionality of the command-line interface is available from the FloPy module, as demonstrated below:
from pathlib import Path
import flopy
bindir = Path("/tmp/bin")
bindir.mkdir(exist_ok=True)
flopy.utils.get_modflow(bindir)
list(bindir.iterdir())
# Or use an auto-select option
flopy.utils.get_modflow(":flopy")
A required bindir
parameter must be supplied to the utility, which specifies where to install the programs. This can be any existing directory, usually which is on the users' PATH environment variable.
To assist the user, special values can be specified starting with the colon character. Use a single :
to interactively select an option of paths.
Other auto-select options are only available if the current user can write files (some may require sudo
for Linux or macOS):
:prev
- if this utility was run by FloPy more than once, the first option will be the previously usedbindir
path selection:flopy
- special option that will create and install programs for FloPy:python
- use Python's bin (or Scripts) directory:home
- use$HOME/.local/bin
:system
- use/usr/local/bin
:windowsapps
- use%LOCALAPPDATA%\Microsoft\WindowsApps
By default the distribution from the MODFLOW-USGS/executables
repository is installed. This includes the MODFLOW 6 binary mf6
and over 20 other related programs. The utility can also install from the main MODFLOW 6 repo or the nightly build distributions, which contain only:
mf6
mf5to6
zbud6
libmf6.dylib
To select a distribution, specify a repository name with the --repo
command line option or the repo
function argument. Valid names are:
executables
(default)modflow6
modflow6-nightly-build
The repository owner can also be configured with the --owner
option. This can be useful for installing from unreleased MODFLOW 6 feature branches still in development — the only compatibility requirement is that release assets be named identically to those on the official repositories.