Skip to contents

Executes the SWAT model in the current working directory, which must contain a valid SWAT project (i.e., a TxtInOut folder with file.cio).

Usage

run_swat_exe(swat_exe_path = "swat.exe")

Arguments

swat_exe_path

character. Path to the SWAT executable (e.g., "swat.exe"). On Windows, see download_swat_exe; on Linux/macOS compile from source.

Value

integer. Exit status of the SWAT execution:

  • 0: Successful execution.

  • Non-zero: An error occurred during execution.

See also

Other Project setup and execution: download_swat_exe(), get_swat_example(), run_swat(), setup_swat()

Examples

# \donttest{
if (.Platform$OS.type == "windows") {
  old_wd <- getwd()
  on.exit(setwd(old_wd), add = TRUE)

  # Example SWAT project
  tmpdir <- tempdir()
  get_swat_example(tmpdir)
  setwd(file.path(tmpdir, "TxtInOut"))

  # Download SWAT executable
  exe_path <- download_swat_exe(dest_dir = tmpdir, type = "release")

  # Run SWAT
  run_swat_exe(exe_path)
}
# }