From 08f9e6d312c65edd8217f5580a4292fadf33fa6a Mon Sep 17 00:00:00 2001 From: Dorchies David <david.dorchies@inrae.fr> Date: Sun, 6 Feb 2022 10:19:17 +0100 Subject: [PATCH] fix(convert_sic_param): add missing funciton for `sic_run_fortran` Refs #2 --- NAMESPACE | 1 + R/convert_sic_params.R | 18 ++++++++++++++++++ man/convert_sic_params.Rd | 19 +++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 R/convert_sic_params.R create mode 100644 man/convert_sic_params.Rd diff --git a/NAMESPACE b/NAMESPACE index 77ce98b..fd18f04 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,6 @@ # Generated by roxygen2: do not edit by hand +export(convert_sic_params) export(loadConfig) export(set_initial_conditions) export(sic_run_fortran) diff --git a/R/convert_sic_params.R b/R/convert_sic_params.R new file mode 100644 index 0000000..d6b840e --- /dev/null +++ b/R/convert_sic_params.R @@ -0,0 +1,18 @@ +#' Convert a list of parameters into command line arguments +#' +#' @param params a [list] of [character] with each item is identified by +#' @param cfg +#' +#' @return A [character] with each parameter is converted to "[key param]=[value param]" and each parameter separated by a space character. +#' @export +#' +#' @examples +convert_sic_params <- function(params, cfg = loadConfig()) { + if (!"INTERF" %in% names(params)) { + params <- c(list(INTERF = cfg$sic$fortran$prms$INTERF), params) + } + params <- sapply(names(params), function(key) { + paste(key, params[[key]], sep= "=") + }) + paste(params, collapse = " ") +} diff --git a/man/convert_sic_params.Rd b/man/convert_sic_params.Rd new file mode 100644 index 0000000..375b4d9 --- /dev/null +++ b/man/convert_sic_params.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/convert_sic_params.R +\name{convert_sic_params} +\alias{convert_sic_params} +\title{Convert a list of parameters into command line arguments} +\usage{ +convert_sic_params(params, cfg = loadConfig()) +} +\arguments{ +\item{params}{a \link{list} of \link{character} with each item is identified by} + +\item{cfg}{} +} +\value{ +A \link{character} with each parameter is converted to "\link{key param}=\link{value param}" and each parameter separated by a space character. +} +\description{ +Convert a list of parameters into command line arguments +} -- GitLab