Source Code

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

Last updated