The Soil and Water Assessment Tool Plus SWAT+ is an open source model jointly developed by the USDA Agricultural Research Service (USDA-ARS) and Texas A&M AgriLife Research, part of The Texas A&M University System. Model contributions have been made by Colorado State University and others. SWAT+ is a small watershed to river basin-scale model to simulate the quality and quantity of surface and ground water and predict the environmental impact of land use, land management practices, and climate change. SWAT is widely used in assessing soil erosion prevention and control, non-point source pollution control and regional management in watersheds.
This repository contains the latest SWAT+ source code and some test data to create and test the executable for various compiler and platforms.
Get the SWAT+ sources by cloning the forked repository using git.
$ git clone https://github.com/<user>/swatplus.gitOr, download the sources directly from the artifacts, unzip. Use a tagged version (preferred).
$ wget https://github.com/swat-model/swatplus/archive/refs/tags/61.0.zipThe directory structure is shown below. The build directory gets created and populated during the generation of the cmake files and the cmake build.
swatplus
├── build
│ ├── ...
│ ├── *.mod
│ ├── Testing
│ └── CMakeFiles
│ ├── Makefile.cmake
│ ├── ...
│ └── swatplus-<ver>.dir
│ ├── *.mod.tstamp
│ ├── src
│ └── ...
├── data ---> contains all data sets for testing
│ ├── Ames_sub1
│ ├── <other>
│ └── ...
├── src ---> contains all swatplus Fortran source files
│ └── *.f90
├── test ---> contains all unit tests sources
│ ├── check.py
│ └── ...
├── jupyter_notebooks ---> carbon analysis notebooks (stripped, see below)
│ └── *.ipynb
├── doc ---> contains all hosted documentation
├── CMakeLists.txt ---> cmake project file
├── ford.md.in ---> FORD Documentation creation project
├── README.md ---> this file
└── ...
This GitHub repository is setup to build, test, and deploy SWAT+ using the CMake tool. CMake is a cross-platform build tool that can be used at the command line but it is also supported through various IDEs, etc. More information can be found at http://cmake.org.
In addition to CMake, the following tools are also needed:
gittool for version controlmaketool (for building)gfortranorifort/ifxcompiler and linker (for compiling/linking)python3(for testing, optional)ford(for documentation generation)nbstripout(required if you edit the Jupyter notebooks, see below)
Use the operating system's preferred way of adding those tools to your installation. There is certainly more than one way of getting and installing them.
The following sections are emphasizing various development aspects.
The notebooks in jupyter_notebooks/ are stored in git stripped: no cell outputs, no
execution counts, no language_info metadata, and with cell IDs normalized to sequential
integers. Merely opening or re-running a notebook otherwise rewrites every cell ID, which
produces large meaningless diffs and needless merge conflicts.
This is enforced by nbstripout as a git clean
filter. The .gitattributes entries are committed, but the filter itself lives in
per-clone local git config and is not carried by the repository. Once, after cloning and
before opening or editing any notebook, run the following commands in your project root
folder:
$ pip install nbstripout
$ nbstripout --install
$ git config filter.nbstripout.extrakeys 'metadata.language_info'The third command is required in addition to --install; without it the filter leaves a
language_info block containing the local Python version, which then churns between
machines.
Verify the filter is active:
$ nbstripout --statusIf it reports that nbstripout is not installed, committed notebooks will carry outputs and randomized cell IDs, reintroducing the conflicts this setup exists to prevent.
SWAT+ Source Documentation on GitHub