diff --git a/R/stics_wrapper.R b/R/stics_wrapper.R index 4b47894..9e52f84 100644 --- a/R/stics_wrapper.R +++ b/R/stics_wrapper.R @@ -484,27 +484,13 @@ stics_wrapper <- function(model_options, next() } - - ## Select data to return - tmp <- select_results( - keep_all_data, sit_var_dates_mask, var_names, - dates, situation, sim_tmp, - varmod_modified, verbose, run_dir - ) - sim_list[[ip]] <- tmp$sim_list - flag_error[ip] <- tmp$flag_error - flag_rqd_res[ip] <- tmp$flag_rqd_res - messages[[ip]] <- tmp$message - simulate <- tmp$simulate - varmod_modified <- tmp$varmod_modified - # For phenological stages, replace the zeros by the following non-zero # value (works even in case of simulations replicated on several years # within a single USM) - if (length(tmp$sim_list) > 0) { - if (length(intersect(stages_list, names(sim_list[[ip]])) > 0)) { - sim_list[[ip]] <- - sim_list[[ip]] %>% + if (length(sim_tmp) > 0) { + if (length(intersect(stages_list, names(sim_tmp)) > 0)) { + sim_tmp <- + sim_tmp %>% dplyr::mutate( dplyr::across( dplyr::all_of( @@ -516,6 +502,19 @@ stics_wrapper <- function(model_options, } } + ## Select data to return + tmp <- select_results( + keep_all_data, sit_var_dates_mask, var_names, + dates, situation, sim_tmp, + varmod_modified, verbose, run_dir + ) + sim_list[[ip]] <- tmp$sim_list + flag_error[ip] <- tmp$flag_error + flag_rqd_res[ip] <- tmp$flag_rqd_res + messages[[ip]] <- tmp$message + simulate <- tmp$simulate + varmod_modified <- tmp$varmod_modified + } }