# WWL-regionaal
# Wageningen Environmental Research
# waterwijzerlandbouw@wur.nl
#------------------------------------------------

# set start of program
TIMPRGSTART <- Sys.time()

# --- arguments ---

# set modus
test <- FALSE

# load arguments
if (!test) {
  command_args <- commandArgs(trailingOnly = TRUE)
  if (length(command_args) != 1) stop("wrong usage of script, arguments should be:\n- controlfile")
} else {
  setwd("c:/WaterwijzerLandbouw/WWL_regionaal")
  command_args <- NULL
  command_args[1] <- "control.inp"
}

# set arguments
ctrl <- command_args[1]

# --- load libraries ---

source("tools/R/libraries.R")

message("\nProgram R-PROG started...\n")

# --- main part of procedure ---

wwl_uitvoeren_analyse_regionaal(ctrl = ctrl)

# --- return of procedure ---

TIMPRGEND <- Sys.time()
TIMPRGCALC <- as.numeric(difftime(time1 = TIMPRGEND, time2 = TIMPRGSTART, units = "secs"))
message(paste0("\nProgram R-PROG successfully ended in ", floor(TIMPRGCALC / 60), " minutes and ", ceiling(TIMPRGCALC %% 60), " seconds"))
q(save = "no")
