diff --git a/R/stics_wrapper.R b/R/stics_wrapper.R index 42cc29b..5ff73f3 100644 --- a/R/stics_wrapper.R +++ b/R/stics_wrapper.R @@ -95,7 +95,7 @@ #' #' @export #' -#' @importFrom foreach %dopar% +#' @importFrom foreach %dopar% %do% #' @importFrom parallel clusterCall makeCluster stopCluster #' @importFrom doParallel registerDoParallel #' @importFrom magrittr %>% @@ -181,8 +181,13 @@ stics_wrapper <- function(model_options, registerDoParallel(cl) clusterCall(cl, function(x) .libPaths(x), .libPaths()) - `%doparornot%` <- `%dopar%` - } else `%doparornot%` <- `%do%` + #`%doparornot%` <- `%dopar%` + `%do_par_or_not%` <- foreach::`%dopar%` + } else { + #`%doparornot%` <- `%do%` + `%do_par_or_not%` <- foreach::`%do%` + + } # Define the list of USMs to simulate and initialize results ----------------- # Check the available USMs @@ -282,7 +287,8 @@ stics_wrapper <- function(model_options, i = seq_along(sit2simulate), .export = c("run_stics", "select_results"), .packages = c("SticsRFiles") - ) %doparornot% { + #) %doparornot% { + ) %do_par_or_not% { ## Loops on the USMs that can be simulated ## out is a list containing vectors of: ## o list of simulated outputs, @@ -411,7 +417,7 @@ stics_wrapper <- function(model_options, # The following could be done only once in case of repeated call # to the wrapper (e.g. parameters estimation ...) SticsRFiles::set_usm_txt( - filepath = file.path(run_dir, "new_travail.usm"), + file = file.path(run_dir, "new_travail.usm"), param = "codesuite", value = 1 ) } @@ -425,7 +431,7 @@ stics_wrapper <- function(model_options, ### snow_variables.txt (for usms that have a successor) if (!is.na(is_succ) && is_succ) { SticsRFiles::set_usm_txt( - filepath = file.path( + file = file.path( run_dir, "new_travail.usm" ), @@ -641,7 +647,7 @@ select_results <- function(keep_all_data, sit_var_dates_mask, var_names, req_var_names <- c(var_names) } - ## Convert required variables names to Stics variables names (i.e. handle ()) + ## Convert required variables names to Stics variables names (i.e. handle ()) req_var_names <- SticsRFiles:::var_to_col_names(req_var_names) ## Add reserved keywords "Plant" and "Date" from the list @@ -653,8 +659,8 @@ select_results <- function(keep_all_data, sit_var_dates_mask, var_names, inter_var_names <- sim_var_names[req_vars_idx] -## In case some variables are not simulated, warn the user, add them in var.mod -## and re-simulate or select the results if var.mod has already been modified. + ## In case some variables are not simulated, warn the user, add them in var.mod + ## and re-simulate or select the results if var.mod has already been modified. if (length(inter_var_names) < length(req_var_names)) { if (varmod_modified) { ## var.mod has already been modified ... warn the user the required @@ -668,7 +674,7 @@ select_results <- function(keep_all_data, sit_var_dates_mask, var_names, "not simulated by the Stics model for USM", situation, "although added in", file.path(run_dir, "var.mod"), - "=> these variables may not be Stics variables, please check spelling. \n ", + "=> these variables may not be Stics variables, please check spelling. \n ", "Simulated variables:", paste(sim_var_names, collapse = ", ") )) res$flag_error <- FALSE