Skip to content
GitLab
    • Explore Projects Groups Topics Snippets
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • R Rsic2
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 3
    • Issues 3
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 2
    • Merge requests 2
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar

En prévision de l'arrivée de la forge institutionnelle INRAE, nous vous invitons à créer vos nouveaux projets sur la forge MIA.

  • SIC2SIC2
  • Rsic2
  • Merge requests
  • !2

Resolve "Import initial conditions from a result to a new scenario/variant"

  • Review changes

  • Download
  • Patches
  • Plain diff
Merged Dorchies David requested to merge 4-import-initial-conditions-from-a-result-to-a-new-scenario-variant into main 3 years ago
  • Overview 0
  • Commits 4
  • Pipelines 0
  • Changes 8

Closes #4 (closed)

Edited 3 years ago by Dorchies David
Viewing commit 2f7e64bb
Prev Next
Show latest version
8 files
+ 4462
− 1

    Preferences

    File browser
    Compare changes

Some changes are not shown

For a faster browsing experience, some files are collapsed by default.

  • 2f7e64bb
    Dorchies David
    Merge branch 'main' into 4-import-initial-conditions-from-a-result-to-a-new-scenario-variant · 2f7e64bb
    Dorchies David authored 3 years ago
R/loadConfig.R
+ 4
− 1
  • View file @ 2f7e64bb

  • Edit in single-file editor

  • Open in Web IDE


@@ -30,7 +30,10 @@
@@ -30,7 +30,10 @@
#' str(cfg)
#' str(cfg)
loadConfig <- function(sic_path = NULL, xml_path = NULL, userFile = "config.yml", pathDefaultCfg = system.file("config.yml", package = "rsic2")) {
loadConfig <- function(sic_path = NULL, xml_path = NULL, userFile = "config.yml", pathDefaultCfg = system.file("config.yml", package = "rsic2")) {
cfg <- config::get(file = pathDefaultCfg)
cfg <- config::get(file = pathDefaultCfg)
if (file.exists(userFile)) {cfg = config::merge(cfg,config::get(file = userFile))}
if (file.exists(userFile)) {
 
message("Reading user configuration from ", userFile)
 
cfg = config::merge(cfg,config::get(file = userFile))
 
}
if (!is.null(sic_path)) cfg$sic$path <- sic_path
if (!is.null(sic_path)) cfg$sic$path <- sic_path
if (!is.null(xml_path)) cfg$project$path <- xml_path
if (!is.null(xml_path)) cfg$project$path <- xml_path
if (!dir.exists(cfg$sic$path)) {
if (!dir.exists(cfg$sic$path)) {
R/sic_run_fortran.R 0 → 100644
+ 32
− 0
  • View file @ 2f7e64bb

  • Edit in single-file editor

  • Open in Web IDE

 
#' 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(cfg$project$path, type = "cmd"),
 
params
 
),
 
type = "cmd2"),
 
wait = T,
 
translate = T
 
)
 
}
inst/sic_project_test1.xml 0 → 100644
+ 4376
− 0
  • View file @ 2f7e64bb

  • Edit in single-file editor

  • Open in Web IDE

Files with large changes are collapsed by default.

man/sic_run_fortran.Rd 0 → 100644
+ 32
− 0
  • View file @ 2f7e64bb

  • Edit in single-file editor

  • Open in Web IDE

 
% 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)
 
}
 
}
tests/testthat/helper-sic_local_config.R 0 → 100644
+ 7
− 0
  • View file @ 2f7e64bb

  • Edit in single-file editor

  • Open in Web IDE

 
# Set local configuration for SIC tests
 
 
xml_path <- tempfile("sic_project", fileext = ".xml")
 
file.copy(system.file("sic_project_test1.xml", package = "rsic2"),
 
xml_path,
 
overwrite = TRUE)
 
cfg <- loadConfig(xml_path = xml_path)
tests/testthat/test-sic_run_fortran.R 0 → 100644
+ 5
− 0
  • View file @ 2f7e64bb

  • Edit in single-file editor

  • Open in Web IDE

 
test_that("fluvia on SCE=1 should create a binary result file", {
 
sic_run_fortran("fluvia", list(SCE = 1), cfg = cfg)
 
expect_true(file.exists(gsub("\\.xml", "_1_0.res", cfg$project$path)))
 
expect_true(file.exists(gsub("\\.xml", "_1_0.rci", cfg$project$path)))
 
})
.gitignore
+ 5
− 0
  • View file @ 2f7e64bb

  • Edit in single-file editor

  • Open in Web IDE


@@ -43,3 +43,8 @@ vignettes/*.pdf
@@ -43,3 +43,8 @@ vignettes/*.pdf
# Project specific
# Project specific
###############################################################################
###############################################################################
 
/config.yml
 
/vignettes/config.yml
 
/tests/testthat/config.yml
 
*.INI
 
*.ini
NAMESPACE
+ 1
− 0
  • View file @ 2f7e64bb

  • Edit in single-file editor

  • Open in Web IDE


@@ -2,3 +2,4 @@
@@ -2,3 +2,4 @@
export(loadConfig)
export(loadConfig)
export(set_initial_conditions)
export(set_initial_conditions)
 
export(sic_run_fortran)
Assignee
Dorchies David's avatar
Dorchies David
Assign to
0 Reviewers
None
Request review from
Labels
1
suggestion
1
suggestion
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
1
1 Participant
Dorchies David
Reference: SIC2/rsic2!2
Source branch: 4-import-initial-conditions-from-a-result-to-a-new-scenario-variant

Menu

Explore Projects Groups Topics Snippets