diff --git a/scripts/start/choose_slurmConfig.R b/scripts/start/choose_slurmConfig.R new file mode 100644 index 0000000000000000000000000000000000000000..a5a425df47f58efbcce656ed1e91b702ad5ea2f7 --- /dev/null +++ b/scripts/start/choose_slurmConfig.R @@ -0,0 +1,103 @@ +####################################################################### +############### Select slurm partitiion ############################### +####################################################################### + +get_line <- function(){ + # gets characters (line) from the terminal or from a connection + # and returns it + if(interactive()){ + s <- readline() + } else { + con <- file("stdin") + s <- readLines(con, 1, warn=FALSE) + on.exit(close(con)) + } + return(s); +} + +choose_slurmConfig <- function() { + + slurm <- suppressWarnings(ifelse(system2("srun",stdout=FALSE,stderr=FALSE) != 127, TRUE, FALSE)) + if (slurm) { + modes <- c("SLURM standby - task per node: 12 (nash H12) [recommended]", + "SLURM standby - task per node: 13 (nash H12 coupled)", + "SLURM standby - task per node: 16 (nash H12+)", + "SLURM standby - task per node: 1 (nash debug, test one regi)", + "SLURM priority - task per node: 12 (nash H12) [recommended]", + "SLURM priority - task per node: 13 (nash H12 coupled)", + "SLURM priority - task per node: 16 (nash H12+)", + "SLURM priority - task per node: 1 (nash debug, test one regi)", + "SLURM short - task per node: 12 (nash H12)", + "SLURM short - task per node: 16 (nash H12+)", + "SLURM short - task per node: 1 (nash debug, test one regi)", + "SLURM medium - task per node: 1 (negishi)", + "SLURM long - task per node: 1 (negishi)") + + cat("\nCurrent cluster utilization:\n") + system("sclass") + cat("\n") + + cat("\nPlease choose run submission type:\n") + cat(paste(1:length(modes), modes, sep=": " ),sep="\n") + cat("Number: ") + identifier <- get_line() + identifier <- as.numeric(strsplit(identifier,",")[[1]]) + comp <- switch(identifier, + "1" = "--qos=standby --nodes=1 --tasks-per-node=12" , # SLURM standby - task per node: 12 (nash H12) [recommended] + "2" = "--qos=standby --nodes=1 --tasks-per-node=13" , # SLURM standby - task per node: 13 (nash H12 coupled) + "3" = "--qos=standby --nodes=1 --tasks-per-node=16" , # SLURM standby - task per node: 16 (nash H12+) + "4" = "--qos=standby --nodes=1 --tasks-per-node=1" , # SLURM standby - task per node: 1 (nash debug, test one regi) + "5" = "--qos=priority --nodes=1 --tasks-per-node=12" , # SLURM priority - task per node: 12 (nash H12) [recommended] + "6" = "--qos=priority --nodes=1 --tasks-per-node=13" , # SLURM priority - task per node: 13 (nash H12 coupled) + "7" = "--qos=priority --nodes=1 --tasks-per-node=16" , # SLURM priority - task per node: 16 (nash H12+) + "8" = "--qos=priority --nodes=1 --tasks-per-node=1" , # SLURM priority - task per node: 1 (nash debug, test one regi) + "9" = "--qos=short --nodes=1 --tasks-per-node=12" , # SLURM short - task per node: 12 (nash H12) + "10" = "--qos=short --nodes=1 --tasks-per-node=16" , # SLURM short - task per node: 16 (nash H12+) + "11" = "--qos=short --nodes=1 --tasks-per-node=1" , # SLURM short - task per node: 1 (nash debug, test one regi) + "12" = "--qos=medium --nodes=1 --tasks-per-node=1" , # SLURM medium - task per node: 1 (negishi) + "13" = "--qos=long --nodes=1 --tasks-per-node=1" ) # SLURM long - task per node: 1 (negishi) + + if(is.null(comp)) stop("This type is invalid. Please choose a valid type") + } else { + comp <- "direct" + } + + return(comp) +} + + Gedächtnisstütze für die slurm-Varianten + # Replace load leveler-script with appropriate version + if (cfg$gms$optimization == "nash" && cfg$gms$cm_nash_mode == "parallel") { + if(length(unique(map$RegionCode)) <= 12) { + cfg$files2export$start[cfg$files2export$start == "scripts/run_submit/submit.cmd"] <- + "scripts/run_submit/submit_par.cmd" + } else { # use max amount of cores if regions number is greater than 12 + cfg$files2export$start[cfg$files2export$start == "scripts/run_submit/submit.cmd"] <- + "scripts/run_submit/submit_par16.cmd" + } + } else if (cfg$gms$optimization == "testOneRegi") { + cfg$files2export$start[cfg$files2export$start == "scripts/run_submit/submit.cmd"] <- + "scripts/run_submit/submit_short.cmd" + } + # Call appropriate submit script + if (cfg$sendToSlurm) { + # send to slurm + if(cfg$gms$optimization == "nash" && cfg$gms$cm_nash_mode == "parallel") { + if(length(unique(map$RegionCode)) <= 12) { + system(paste0("sed -i 's/__JOB_NAME__/pREMIND_", cfg$title,"/g' submit_par.cmd")) + system("sbatch submit_par.cmd") + } else { # use max amount of cores if regions number is greater than 12 + system(paste0("sed -i 's/__JOB_NAME__/pREMIND_", cfg$title,"/g' submit_par16.cmd")) + system("sbatch submit_par16.cmd") + } + } else if (cfg$gms$optimization == "testOneRegi") { + system(paste0("sed -i 's/__JOB_NAME__/REMIND_", cfg$title,"/g' submit_short.cmd")) + system("sbatch submit_short.cmd") + } else { + system(paste0("sed -i 's/__JOB_NAME__/REMIND_", cfg$title,"/g' submit.cmd")) + if (cfg$gms$cm_startyear > 2030) { + system("sbatch --partition=ram_gpu submit.cmd") + } else { + system("sbatch submit.cmd") + } + diff --git a/scripts/start/submit.R b/scripts/start/submit.R index e100b46ac018a9ae9fe2b6a18a90d3bfe0f3f881..a4310ebce6bc86e1ec3ed93281a94b5f7925c72e 100644 --- a/scripts/start/submit.R +++ b/scripts/start/submit.R @@ -54,62 +54,11 @@ submit <- function(cfg) { sbatch_command <- paste0("sbatch --job-name=",cfg$title," --output=",cfg$title,".out --mail-type=END --comment=REMIND --wrap=\"Rscript prepare_and_run.R \"") if(cfg$slurmConfig=="direct") { log <- format(Sys.time(), paste0(cfg$title,"-%Y-%H-%M-%S-%OS3.log")) - system("Rscript prepare_and_run.R ",cfg$title, stderr = log, stdout = log, wait=FALSE) - } else if(cfg$slurmConfig=="priority") { - system(paste(sbatch_command,"--nodes=1 --tasks-per-node=12 --qos=priority")) - Sys.sleep(1) - } else if(cfg$slurmConfig=="standby") { - system(paste(sbatch_command,"--nodes=1 --tasks-per-node=12 --qos=standby")) - Sys.sleep(1) - } else if(cfg$slurmConfig=="short") { - system(paste(sbatch_command,"--qos=short")) - Sys.sleep(1) - } else if(cfg$slurmConfig=="medium") { - system(paste(sbatch_command,"--qos=medium")) - Sys.sleep(1) - } else if(cfg$slurmConfig=="long") { - system(paste(sbatch_command,"--qos=long")) - Sys.sleep(1) + system("Rscript prepare_and_run.R") } else { - stop("Unknown submission type") + system(paste(sbatch_command,cfg$slurmConfig)) + Sys.sleep(1) } - - # Gedächtnisstütze für die slurm-Varianten - ## Replace load leveler-script with appropriate version - #if (cfg$gms$optimization == "nash" && cfg$gms$cm_nash_mode == "parallel") { - # if(length(unique(map$RegionCode)) <= 12) { - # cfg$files2export$start[cfg$files2export$start == "scripts/run_submit/submit.cmd"] <- - # "scripts/run_submit/submit_par.cmd" - # } else { # use max amount of cores if regions number is greater than 12 - # cfg$files2export$start[cfg$files2export$start == "scripts/run_submit/submit.cmd"] <- - # "scripts/run_submit/submit_par16.cmd" - # } - #} else if (cfg$gms$optimization == "testOneRegi") { - # cfg$files2export$start[cfg$files2export$start == "scripts/run_submit/submit.cmd"] <- - # "scripts/run_submit/submit_short.cmd" - #} - # Call appropriate submit script - #if (cfg$sendToSlurm) { - # # send to slurm - # if(cfg$gms$optimization == "nash" && cfg$gms$cm_nash_mode == "parallel") { - # if(length(unique(map$RegionCode)) <= 12) { - # system(paste0("sed -i 's/__JOB_NAME__/pREMIND_", cfg$title,"/g' submit_par.cmd")) - # system("sbatch submit_par.cmd") - # } else { # use max amount of cores if regions number is greater than 12 - # system(paste0("sed -i 's/__JOB_NAME__/pREMIND_", cfg$title,"/g' submit_par16.cmd")) - # system("sbatch submit_par16.cmd") - # } - # } else if (cfg$gms$optimization == "testOneRegi") { - # system(paste0("sed -i 's/__JOB_NAME__/REMIND_", cfg$title,"/g' submit_short.cmd")) - # system("sbatch submit_short.cmd") - # } else { - # system(paste0("sed -i 's/__JOB_NAME__/REMIND_", cfg$title,"/g' submit.cmd")) - # if (cfg$gms$cm_startyear > 2030) { - # system("sbatch --partition=ram_gpu submit.cmd") - # } else { - # system("sbatch submit.cmd") - # } - + return(cfg$results_folder) - } diff --git a/start.R b/start.R index 457b54e9ae15128d1549d9ecb54810161f4309a7..40fb9ef0ede19a3d1d202768677a680b8c99b104 100644 --- a/start.R +++ b/start.R @@ -1,60 +1,10 @@ library(lucode) source("scripts/start/submit.R") - -####################################################################### -############### Select slurm partitiion ############################### -####################################################################### - -get_line <- function(){ - # gets characters (line) from the terminal or from a connection - # and returns it - if(interactive()){ - s <- readline() - } else { - con <- file("stdin") - s <- readLines(con, 1, warn=FALSE) - on.exit(close(con)) - } - return(s); -} - -choose_submit <- function(title="Please choose run submission type") { - - # xxx add REMIND specific combinations of qos and number of nodes - modes <- c("SLURM priority (recommended)", - "SLURM standby (recommended)", - "SLURM short", - "SLURM medium", - "SLURM long") - - cat("\nCurrent cluster utilization:\n") - system("sclass") - cat("\n") - - cat("\n",title,":\n", sep="") - cat(paste(1:length(modes), modes, sep=": " ),sep="\n") - cat("Number: ") - identifier <- get_line() - identifier <- as.numeric(strsplit(identifier,",")[[1]]) - comp <- switch(identifier, - "1" = "priority", - "2" = "standby", - "3" = "short", - "4" = "medium", - "5" = "long") - if(is.null(comp)) stop("This type is invalid. Please choose a valid type") - return(comp) -} - +source("scripts/start/choose_slurmConfig.R") # Choose submission type -slurm <- suppressWarnings(ifelse(system2("srun",stdout=FALSE,stderr=FALSE) != 127, TRUE, FALSE)) -if (slurm) { - slurmConfig <- choose_submit("Choose submission type") - } else { - slurmConfig <- "direct" - } +slurmConfig <- choose_slurmConfig() ####################################################################### ######################## Submit run ###################################