Optimized workflows for running SWAT+ (Soil & Water Assessment Tool Plus) on the Centre for High-Performance Computing’s (CHPC) Lengau cluster. This repository provides PBS Pro job scripts, configuration templates, and utilities for efficient large-scale watershed simulations.
- Key Features
- Prerequisites
- Setup Guide
- Job Submission
- Output Management
- Troubleshooting
- References
- License
- Maintainer
- PBS Pro-Optimized Scripts: Job scripts for multi-node SWAT+ runs
- Resource Scaling: Templates for
select,mpiprocs, andwalltimedirectives - Automated Post-Processing: Python utilities for result aggregation
- Logging: Integrated stdout/stderr capture for debugging
- Lengau Cluster Account: Access granted by CHPC South Africa
- Basic Knowledge:
- PBS Pro commands (
qsub,qstat,qdel) - Linux shell navigation
- SWAT+ input file structure
- PBS Pro commands (
module use /apps/chpc/scripts/modules
module load earth/swatplus/2025.03Watershed Configuration Files
main.sf: Main input file (defines simulation period, output options, etc.)watershed.sf: Watershed structure (subbasins, HRUs, routing)project.iniorproject.json: Project metadata and paths
Database Files
swatplus_datasets.sqlite: Core parameter database (soils, crops, fertilizers, etc.)project_db.sqlite: Project-specific database (created during setup)
Climate/Weather Data
precip.pcp: Precipitation datatemp.tmp: Temperature datahumidity.hmd: Relative humidity (Additional: solar.slr, wind.wnd if required)
Management Files
management.sch: Crop rotation schedulestillage.til: Tillage operationsfertilizer.frt: Fertilizer applications
Spatial Data (Optional but recommended)
- Digital Elevation Model (DEM)
- Land Use/Land Cover (LULC) raster
- Soil type raster
SWAT+ Watershed Project Structure
my_watershed/
├── input/
│ ├── main.sf
│ ├── watershed.sf
│ ├── project.ini
│ ├── swatplus_datasets.sqlite
│ ├── precip.pcp
│ ├── temp.tmp
│ ├── management/
│ │ ├── management.sch
│ │ ├── tillage.til
│ └── spatial/ # Optional rasters
│ ├── dem.tif
│ ├── landuse.tif
├── run_swatplus.pbs # PBS Pro job script
└── output/ # Auto-created during run
Database Setup
- Generate swatplus_datasets.sqlite using SWAT+ Editor
- Validate parameter units match your watershed
Climate Data Formatting
Example precip.pcp header:
nbyr tstep lat lon elev
30 1 -29.6 24.5 1200
19800101 0.0
19800102 5.2
Path Consistency
In project.ini:
[files]
watershed = input/watershed.sf
database = input/swatplus_datasets.sqliteLengau-Specific Tips
- Store large datasets in
/lustre/<project> - Compress text files with
gzipbefore transfer - Use
rsyncfor efficient data transfers:rsync -avz ./input/ user@lengau.chpc.ac.za:/path/to/project/input/
PBS Script (run_swatplus.pbs)
#!/bin/bash -l
#PBS -l select=10:ncpus=24:mpiprocs=24:nodetype=haswell_reg
#PBS -P PRJT1234
#PBS -q normal
#PBS -l walltime=4:00:00
#PBS -N swatplus_sim # Job name
#PBS -o /mnt/lustre/users/USERNAME/swatplus_tests/swatplus.out
#PBS -e /mnt/lustre/users/USERNAME/swatplus_tests/swatplus.err
#PBS -m abe # Email on job end
#PBS -M <email>@domain.com
# Load modules
module use /apps/chpc/scripts/modules
module load earth/swatplus/2025.03
# Navigate to project directory
cd $PBS_O_WORKDIR
# Run SWAT+ (MPI)
mpirun -np 24 swatplus_exe - swat: command not found
- Ensure the module is loaded (
module listshould showearth/swatplus/2025.03). - Check that
/home/apps/chpc/earth/swatplus-2025.03/execis in your$PATH. - Confirm the
swatexecutable exists in theexecdirectory and is executable.
- Ensure the module is loaded (
- Module load errors
- Remove any
if { [module-info mode] ... }blocks from your module file if you see Tcl errors. - Use the
ModulesHelpsection for help text and job script examples.
- Remove any
- Conflicting environments
- Deactivate any conda or virtual environments before loading the module.
Maintainer: Mthetho Vuyo Sovara
Got issues, submit a CHPC Helpdesk ticket: https://users.chpc.ac.za/helpdesk/tickets/submit/