From f2409d3583d56fb76c9876720ad8e5262bb94b44 Mon Sep 17 00:00:00 2001 From: Dorchies David <david.dorchies@inrae.fr> Date: Sat, 5 Feb 2022 18:52:07 +0100 Subject: [PATCH] feat(sic_run_fortran): add function Refs #2 --- NAMESPACE | 1 + R/sic_run_fortran.R | 32 ++++++++++++++++++++++++++++++++ man/sic_run_fortran.Rd | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 R/sic_run_fortran.R create mode 100644 man/sic_run_fortran.Rd diff --git a/NAMESPACE b/NAMESPACE index d4e57ad..5c5e5ee 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,3 +1,4 @@ # Generated by roxygen2: do not edit by hand export(loadConfig) +export(sic_run_fortran) diff --git a/R/sic_run_fortran.R b/R/sic_run_fortran.R new file mode 100644 index 0000000..5d19221 --- /dev/null +++ b/R/sic_run_fortran.R @@ -0,0 +1,32 @@ +#' Run Talweg, Fluvia or Sirene +#' +#' @param prog [character], the program to run. Should be one of "talweg" +#' @param params [list] or [character], see details +#' @param cfg +#' +#' @details If argument `params` is a [list], arguments are injected in the command line by taking the items of the list with the conversion +#' `[key]=[value]`. If argument `params` is a [character] +#' +#' @return +#' @export +#' +#' @examples +#' \dontrun{ +#' # Run steady simulation for the scenario #1 +#' params <- list(SCE=1) +#' sic_run_fortran("fluvia", params) +#'} +sic_run_fortran <- function(prog, params, cfg = loadConfig()) { + if (is.list(params)) params <- convert_sic_params(params, cfg) + shell( + shQuote( + paste( + file.path(cfg$sic$path, cfg$sic[[prog]]), + shQuote(sic$project$path, type = "cmd"), + params + ), + type = "cmd2"), + wait = T, + translate = T + ) +} diff --git a/man/sic_run_fortran.Rd b/man/sic_run_fortran.Rd new file mode 100644 index 0000000..e513d45 --- /dev/null +++ b/man/sic_run_fortran.Rd @@ -0,0 +1,32 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/sic_run_fortran.R +\name{sic_run_fortran} +\alias{sic_run_fortran} +\title{Run Talweg, Fluvia or Sirene} +\usage{ +sic_run_fortran(prog, params, cfg = loadConfig()) +} +\arguments{ +\item{prog}{\link{character}, the program to run. Should be one of "talweg"} + +\item{params}{\link{list} or \link{character}, see details} + +\item{cfg}{} +} +\value{ + +} +\description{ +Run Talweg, Fluvia or Sirene +} +\details{ +If argument \code{params} is a \link{list}, arguments are injected in the command line by taking the items of the list with the conversion +\verb{[key]=[value]}. If argument \code{params} is a \link{character} +} +\examples{ +\dontrun{ +# Run steady simulation for the scenario #1 +params <- list(SCE=1) +sic_run_fortran("fluvia", params) +} +} -- GitLab