SWAT+ Installation & Help
2.3
2.3
  • About SWAT+
  • Installation
  • Getting Started
  • Get Help
    • Troubleshooting
    • Linux and MacOS
  • Release Notes
  • Source Code
  • User Docs
    • SWAT+ IO Documentation
    • SWAT+ Editor Documentation
      • Project Setup
      • Edit SWAT+ Inputs
        • Climate
        • Connections
          • Channels
          • HRUs
          • Routing Units
          • Aquifers
          • Reservoirs
          • Recall (Point Source/Inlet)
          • Export Coefficients
          • Delivery Ratio
        • Basin
        • Regions
        • Land Use Management
        • Decision Tables
        • Change/Calibration
        • Initialization Data
        • Hydrology
        • Soils
        • Databases
        • Structural
        • Water_Rights
        • Sample Data
      • Run SWAT+
    • QSWAT+ Manual
    • How to Use SQLite
  • Developer Docs
    • SWAT+ Editor Design
Powered by GitBook
On this page
  • Repository Links
  • SWAT+ Model Compile Help
  • SWAT+ Editor Compile Help
Export as PDF

Source Code

Last updated 1 year ago

Repository Links

  • SWAT+ source code repository

  • SWAT+ Editor source code repository

  • QSWAT+ source code repository

SWAT+ Model Compile Help

The model is written in Fortran and the distributions on this website were compiled using the Intel Fortran compiler. This is now freely available for Windows, Linux, and MacOS. First, download and install the Intel oneAPI Base Toolkit. Then download and install the Intel oneAPI HPC Toolkit.

For Windows, we also use Visual Studio. Download the file below for settings configuration.

For Linux and MacOS, we currently just use the command line. First, you need to set your Intel environment. Find your installation directory and source setvars.sh.

Linux example:

. ~/intel/oneapi/setvars.sh

Or for all users:

. /opt/intel/oneapi/setvars.sh

MacOS example:

. /opt/intel/oneapi/setvars.sh

Next, we use the following script to compile the model. Please note: occasionally some extra files get included in the source code repository. If you notice this, it is safe to remove them.

ifort -c hru_module.f90 -traceback -O3 -parallel
ifort -c time_module.f90 -traceback -O3 -parallel
ifort -c constituent_mass_module.f90 -traceback -O3 -parallel
ifort -c *_module.f90 -traceback -O3 -parallel
ifort -c allocate_parms.f90 -traceback -O3 -parallel
ifort -c *.f90 -traceback -O3 -parallel
ifort -o swatplus_exe_file_name *.o -static -traceback -O3 -parallel

The -static flag in the last line is NOT available on MacOS. Instead, you should link the LAPACK and BLAS libraries and as of macOS Monterey change your library path. The last line should be:

ifort -o swatplus_exe_file_name *.o -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -llapack -lblas -traceback -O3 -parallel

We are new to compiling in Linux and MacOS, so suggestions are more than welcome.

SWAT+ Editor Compile Help

First set up your development environment as described in the README in the source code repository.

  1. From /src/api run the following depending on your OS:

    • Windows: python-build-windows

    • Linux: sh python-build-linux.sh

    • MacOS: sh python-build-mac.sh

  2. From the root of the source code directory run the following depending on your OS:

    • Windows: npm run build:win

    • Linux: npm run build:linux

    • MacOS: npm run build:mac

  3. Program will be in /release/dist

1MB
Intel_Fortran_newest_settings.doc
Intel Fortran Visual Studio Settings