SWATGenXSWATGenX
Watershed ExplorerExample modelsCloud calibrationDocsAccess
SWATGenXDocs

Engine I/O and run modes

Applies to SWATGenX engine extensions · Updated August 2026

Run modes of the OpenMP SWAT+ fork (OMP_NUM_THREADS, SWATPLUS_ROUTING_SERIAL), print_filter.prt channel filtering, and NetCDF-4 output (cdfout = y).

Run modes

Downloaded models run with any compatible SWAT+ binary. The SWATGenX OpenMP fork adds shared-memory parallelism and optional NetCDF-4 output; hydrologic equations are unchanged. Build the fork with the Compile the SWAT+ fork chapter rather than improvising compiler flags.

# 1. serial reference
OMP_NUM_THREADS=1 ./swatplus

# 2. HRU-parallel (routing in command order)
OMP_NUM_THREADS=8 SWATPLUS_ROUTING_SERIAL=1 ./swatplus

# 3. full routing wavefront (fastest)
OMP_NUM_THREADS=8 SWATPLUS_ROUTING_SERIAL=0 ./swatplus
  • Optional NetCDF: set cdfout = y under the csvout/dbout/cdfout line in print.prt; SWATPLUS_NC_DEFLATE controls compression (default 4).
  • Correctness check for a given build: run the same model at 1 and N threads on that binary and compare outputs for the streams you care about.
  • Scoped identity: production/canary verification compares the same certified build under controlled conditions — do not generalize an unqualified “identical at every thread count on every machine” claim from this page.
  • mgt_out.txt caveat: when management text output is enabled, line order can differ across parallel runs even when sorted content matches; NetCDF mode (cdfout = y) also suppresses that text stream.

Compile the SWAT+ fork

print_filter.prt

Optional file in the run directory (fixed name print_filter.prt). Absent file → all channels are written, exactly as stock SWAT+. It filters only the channel_sd_{day,mon,yr,aa} streams — no other object is affected.

print_filter.prt: limit channel_sd output to listed channel units (1-based).
# Present in shipped packages when gauges are assigned

channel_sd
12
45
RuleBehavior
Blank lines / # linesSkipped (comments allowed anywhere)
Line whose first token contains "channel_sd"Starts the channel list section
Lines inside the sectionEach must parse as one integer channel unit (1-based chandeg index); the first non-integer line ends the section
Range syntax (e.g. 12-45)Not supported — one id per line
Valid ids1 ≤ id ≤ number of chandeg channels; out-of-range ids ignored
Keyword present, zero valid idsFilter active with an empty list — no channel_sd files are opened at all
File absent or no channel_sd keywordNo filtering; all channels written

SWATGenX-shipped models include a generated print_filter.prt listing the gauge-assigned channels, which is what makes large-basin calibration output tractable.

NetCDF output (cdfout = y)

The third flag on the print.prt output-format line (csvout / use_obj_lbls / cdfout). With cdfout = y the engine writes NetCDF-4 (classic-model) files instead of the corresponding text outputs, one file per enabled object × period: hru_wb_day.nc, channel_sd_day.nc, basin_wb_aa.nc, and so on.

ItemValue
Dimensionstime (unlimited) × obj (HRUs / channels / 1 for basin; filtered channel count when print_filter.prt is active)
Coordinate variablestime (days since <start-year>-01-01), mo, day_mo, yrc, jday; obj_id, gis_id per object
Data variablesNamed columns for hru_wb-family streams; generic v1..vN for the rest (channel_sd_day: flow output is v41)
Fill / conventionsFill value -9999; CF-1.10; global attrs title, model="SWAT+"
SWATPLUS_NC_DEFLATEEnv var, first digit clamped 0–9; default compression level 4; production sets 0
Suppressed text streamsWith cdfout=y the engine forces mgtout, crop_yld, hydcon, fdcout (and several period flags without NetCDF writers) to n — otherwise those writers would hit never-opened units
Not all streams have NetCDF writers: routing-unit, recall, reservoir, wetland, hyd, crop_yld, and pest/salt/constituent outputs stay text-only. mgt_out is unavailable in NetCDF mode.