diff --git a/hydrus/main_script.R b/hydrus/main_script.R
index ad329f38e8815694c460c2147a6f08ed93a6bd28..0f3fa769122825504592bc7e585bbf080dfc9b1f 100644
--- a/hydrus/main_script.R
+++ b/hydrus/main_script.R
@@ -1,4 +1,8 @@
-hydrus.batch <- function(setup.file, parameter.file HP1 = FALSE){
+hydrus.batch <- function(setup.file, parameter.file, HP1 = FALSE, loop.time = 60){
+  # setup file: json file with setup information
+  # parameter file: json file with information on the parameter to be modified
+  # HP1: option to enable HP1
+  # loop.time: option to adjust the scrutation loop to run several model in parallel
   #--------- load necessary libraries ----------#
   library(fs)
   library(rjson)
@@ -40,7 +44,6 @@ hydrus.batch <- function(setup.file, parameter.file HP1 = FALSE){
     stop("invalid format for simulation.number")
     }
   
-  
   #--------- load rhydrus functions --------#
   
   # source the file with the functions dedicated to file manipulation
@@ -58,9 +61,6 @@ hydrus.batch <- function(setup.file, parameter.file HP1 = FALSE){
     dir_copy(path = setup$reference.model.folder,
              new_path = paste0(setup$working.folder,"/","simulation","_",as.character(i)), overwrite = TRUE)
   
-    # modify input files
-    modify.input(path = parameter.file, working.foler = setup$working.folder)
-  
     # create level_01.dir (and path.dat)
     level_01.creator(paste0(setup$working.folder,"/","simulation","_",as.character(i)), HP1 = HP1)
     # and copy executable file(s)
@@ -68,63 +68,91 @@ hydrus.batch <- function(setup.file, parameter.file HP1 = FALSE){
     
   }
   
+  #------- modify input files --------#
+  
+  modify.input(path = parameter.file, working.folder = setup$working.folder)
+  
   #-------- start simulations --------#
-}
-
-# set the working directory to main.directory 
-setwd(main.directory)
-
-# nb of simulation to run
-nb.runs <- 1
-
-# generic name = the name that will be given to the model that will be run iteratively
-# hydrus.folder = the original hydrus folder generated using the GUI
-# VERY IMPORTANT = the reference folder MUST contain the HYDRUS exe file !!!
-# The option press enter at the end must have been unchecked in the GUI
-generic.name <- "PF_Model_"
-hydrus.folder <- "DPo_1pulse_modifpdt_180108"
-
-## van Genuchten parameters (here you can enter matrices for the different cases you want to test)
-# gravel parameters
-deposit = matrix(c(0, 0.05, 0.12, 1.8, 5, 0.5, 0.64, 0.79, 0.05),ncol=9)
-
-# sand parameters
-gravel = matrix(c(0, 0.1, 0.572, 2.917, 300, 0.5, 0.052, 0.4, 0),ncol=9)
-
-# create all simulation folders, copy files and modify the one containing the van Genuchten parameters
-for (i in 1:nb.runs){
-  # current simulation name
-  new.name <- paste(generic.name,as.character(i),sep = "")
-  # create a copy of the reference model in a folder named as the current simulation
-  new.hydrus.subfolder(new.name,main.directory,hydrus.folder)
-  # create the level_01 file
-  level_01.creator(new.name,main.directory)
-  # modification of the selector.in file
-  new.data <- rbind(deposit,gravel)
-  modify.hydraulic.parameters(new.name,hydrus.folder,new.data,hydrus.version="1D")
-}
-
-# computation loop
-start.time <- Sys.time()
-sim.counter <- 0
-
-while (sim.counter < nb.runs){
-  # how busy the processor is?
-  temp <- system('C:/Users/forquet/Documents/script_R/rhydrus/processor_load.bat',intern = TRUE)
-  processor.usage <- output.bat(temp)
-  if (processor.usage < 75){
-    # if processor usage is less than 75%, start a new run
-    sim.counter <- sim.counter + 1
-    # go to the simulation working directory
-    setwd(paste(main.directory,"/",generic.name,as.character(sim.counter),sep=""))
-    # run Hydrus
-    system("H1D_Dual.exe", wait = FALSE)
-    # print the current simulation number
-    print(sim.counter)
-    # go back to main directory
-    setwd(main.directory)
+  
+  # start measuring computation time
+  start.time <- Sys.time()
+  # initialize the simulation counter
+  sim.counter <- 0
+  
+  # computation loop
+  while (sim.counter < setup$simulation.number){
+    # how busy the processor is?
+    temp <- system(paste0(setup$rhydrus.folder,"//processor_load.bat"),intern = TRUE)
+    processor.usage <- output.bat(temp)
+    if (processor.usage < 75){
+      # if processor usage is less than 75%, start a new run
+      sim.counter <- sim.counter + 1
+      # run Hydrus
+      system(paste0(setup$working.folder,"/","simulation","_",as.character(i),"//H1D_CALC.exe"), wait = FALSE)
+      # print the current simulation number
+      print(sim.counter)
+    }
+    # wait loop.time before restarting the loop
+    Sys.sleep(loop.time)
   }
-  # wait a minute before restarting the loop
-  Sys.sleep(60)
+  # stop measuring computation time
+  end.time <- Sys.time()
 }
-end.time <- Sys.time()
\ No newline at end of file
+
+# # set the working directory to main.directory 
+# setwd(main.directory)
+# 
+# # nb of simulation to run
+# nb.runs <- 1
+# 
+# # generic name = the name that will be given to the model that will be run iteratively
+# # hydrus.folder = the original hydrus folder generated using the GUI
+# # VERY IMPORTANT = the reference folder MUST contain the HYDRUS exe file !!!
+# # The option press enter at the end must have been unchecked in the GUI
+# generic.name <- "PF_Model_"
+# hydrus.folder <- "DPo_1pulse_modifpdt_180108"
+# 
+# ## van Genuchten parameters (here you can enter matrices for the different cases you want to test)
+# # gravel parameters
+# deposit = matrix(c(0, 0.05, 0.12, 1.8, 5, 0.5, 0.64, 0.79, 0.05),ncol=9)
+# 
+# # sand parameters
+# gravel = matrix(c(0, 0.1, 0.572, 2.917, 300, 0.5, 0.052, 0.4, 0),ncol=9)
+# 
+# # create all simulation folders, copy files and modify the one containing the van Genuchten parameters
+# for (i in 1:nb.runs){
+#   # current simulation name
+#   new.name <- paste(generic.name,as.character(i),sep = "")
+#   # create a copy of the reference model in a folder named as the current simulation
+#   new.hydrus.subfolder(new.name,main.directory,hydrus.folder)
+#   # create the level_01 file
+#   level_01.creator(new.name,main.directory)
+#   # modification of the selector.in file
+#   new.data <- rbind(deposit,gravel)
+#   modify.hydraulic.parameters(new.name,hydrus.folder,new.data,hydrus.version="1D")
+# }
+# 
+# # computation loop
+# start.time <- Sys.time()
+# sim.counter <- 0
+# 
+# while (sim.counter < nb.runs){
+#   # how busy the processor is?
+#   temp <- system('C:/Users/forquet/Documents/script_R/rhydrus/processor_load.bat',intern = TRUE)
+#   processor.usage <- output.bat(temp)
+#   if (processor.usage < 75){
+#     # if processor usage is less than 75%, start a new run
+#     sim.counter <- sim.counter + 1
+#     # go to the simulation working directory
+#     setwd(paste(main.directory,"/",generic.name,as.character(sim.counter),sep=""))
+#     # run Hydrus
+#     system("H1D_Dual.exe", wait = FALSE)
+#     # print the current simulation number
+#     print(sim.counter)
+#     # go back to main directory
+#     setwd(main.directory)
+#   }
+#   # wait a minute before restarting the loop
+#   Sys.sleep(60)
+# }
+# end.time <- Sys.time()
\ No newline at end of file
diff --git a/hydrus/processor_load.bat b/hydrus/processor_load.bat
new file mode 100644
index 0000000000000000000000000000000000000000..ae6a3207736a66a494b69fd90cd1793914c6e6ba
--- /dev/null
+++ b/hydrus/processor_load.bat
@@ -0,0 +1 @@
+typeperf "\processeur(_Total)\%% temps processeur" -sc 5