Install MODFLOW and related programs
Using get_modflow.py as a script
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.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]
get_modflow.py as a script
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
bindir = Path("/tmp/bin")
# Or use an auto-select option
Where to install?
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 used
:flopy- special option that will create and install programs for FloPy
:python- use Python’s bin (or Scripts) directory
Selecting a distribution
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:
To select a distribution, specify a repository name with the
--repo command line option or the
repo function argument. Valid names are:
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.