Mercurial > repos > siwaa > redelac
comparison parallelSticsRRotation.R @ 0:e8b0d1d0797d draft default tip
"planemo upload for repository https://forgemia.inra.fr/quaysofthestics/sticsquays/-/tree/master/tools commit 34d462246915d2d24868042deeda35a01985d2aa"
author | siwaa |
---|---|
date | Tue, 21 Feb 2023 19:03:38 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e8b0d1d0797d |
---|---|
1 library(SticsRFiles) | |
2 library(SticsOnR) | |
3 library(parallel) | |
4 library(doParallel) | |
5 library(readxl) | |
6 | |
7 workspace <- paste0(getwd(), "/WS") | |
8 javastics_path <- paste0(getwd(), "/JavaSTICS-1.5.1-STICS-10.0.0") | |
9 | |
10 # copy of the var.mod and rap.mod into the config folder | |
11 file.copy(from = file.path(workspace, "var.mod"), to = "config/var.mod", overwrite = TRUE) | |
12 file.copy(from = file.path(workspace, "rap.mod"), to = "config/rap.mod", overwrite = TRUE) | |
13 | |
14 txt_path <- paste0(getwd(), "/WS/txt_files") | |
15 dir.create(txt_path,recursive = T) | |
16 | |
17 print("==================================") | |
18 | |
19 print(paste0("Cores=", detectCores())) | |
20 print(paste0("javastics=", javastics_path)) | |
21 print(paste0("ws=", workspace)) | |
22 print(paste0("out_dir=", txt_path)) | |
23 | |
24 print("==================================") | |
25 | |
26 | |
27 # List of successive USMs | |
28 successive_usms_file <- ("rotationPlan.xlsx") | |
29 successive_usms_tab <- read_excel(path = file.path(workspace, successive_usms_file), sheet = "usms") | |
30 | |
31 no_cores <- detectCores() - 1 | |
32 cl <- makeCluster(no_cores) | |
33 registerDoParallel(cl) | |
34 | |
35 result <- foreach(i=1:nrow(successive_usms_tab), | |
36 .packages = c("SticsRFiles", "SticsOnR") ) %dopar% { | |
37 | |
38 nusms <- as.numeric(successive_usms_tab[i,2]) | |
39 | |
40 vec <- as.character(successive_usms_tab[i,c(3:(2+nusms))]) | |
41 | |
42 list_successive_usms <- list(vec) | |
43 | |
44 sim_options <- stics_wrapper_options(javastics = javastics_path, | |
45 stics_exe = paste0(javastics_path,"/bin/stics_modulo"), | |
46 workspace = txt_path, | |
47 verbose = TRUE, | |
48 successive = list_successive_usms) | |
49 list_usms <- vec | |
50 | |
51 stics_wrapper(model_options = sim_options, situation = list_usms) | |
52 } | |
53 | |
54 stopCluster(cl) | |
55 | |
56 for (i in 1:nrow(successive_usms_tab)) { #i=1 | |
57 if (i == 1) { | |
58 simPCP <- result[[i]] | |
59 } else { | |
60 simPCP$sim_list <- c(simPCP$sim_list, result[[i]]$sim_list) | |
61 } | |
62 | |
63 } | |
64 | |
65 save(simPCP, file = "results.RData") |