From 48f369fcb1f57834296820e4ce192ee71afdc806 Mon Sep 17 00:00:00 2001
From: David Klein <dklein@pik-potsdam.de>
Date: Tue, 7 Apr 2020 15:42:04 +0200
Subject: [PATCH] MAgPIE coupling: automatically start SSP2-Base and SSP2-NDC
 with QOS priority since all other runs depend on them.

---
 start_bundle_coupled.R | 4 +++-
 start_coupled.R        | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/start_bundle_coupled.R b/start_bundle_coupled.R
index f8f5d49..e4fe8a8 100644
--- a/start_bundle_coupled.R
+++ b/start_bundle_coupled.R
@@ -299,7 +299,9 @@ for(scen in common){
   }
 
   if (start_now){
-      if (!exists("test")) system(paste0("sbatch --qos=priority --job-name=",runname," --output=",runname,".log --mail-type=END --comment=REMIND-MAgPIE --tasks-per-node=",nr_of_regions," --wrap=\"Rscript start_coupled.R coupled_config=",runname,".RData\""))
+      # Start SSP2-Base and SSP2-NDC as priority jobs since ALL subsequent runs depend on them
+      qos <- ifelse(grepl("SSP2-(NDC|Base)",runname),"priority","short")
+      if (!exists("test")) system(paste0("sbatch --qos=",qos," --job-name=",runname," --output=",runname,".log --mail-type=END --comment=REMIND-MAgPIE --tasks-per-node=",nr_of_regions," --wrap=\"Rscript start_coupled.R coupled_config=",runname,".RData\""))
       else cat("Test mode: run NOT submitted to the cluster\n")
   } else {
      cat(paste0("Run ",runname," will start after preceding run ",prefix_runname,settings_remind[scen,"path_gdx_ref"]," has finished\n"))
diff --git a/start_coupled.R b/start_coupled.R
index 1d74e97..f799cfe 100644
--- a/start_coupled.R
+++ b/start_coupled.R
@@ -209,7 +209,9 @@ start_coupled <- function(path_remind,path_magpie,cfg_rem,cfg_mag,runname,max_it
   #start subsequent runs via sbatch
   for(run in cfg_rem$subsequentruns){
     cat("Submitting subsequent run",run,"\n")
-    system(paste0("sbatch --qos=priority --job-name=C_",run," --output=C_",run,".log --mail-type=END --comment=REMIND-MAgPIE --tasks-per-node=",nr_of_regions," --wrap=\"Rscript start_coupled.R coupled_config=C_",run,".RData\""))
+    # Start SSP2-Base and SSP2-NDC as priority jobs since ALL subsequent runs depend on them
+    qos <- ifelse(grepl("SSP2-(NDC|Base)",run),"priority","short")
+    system(paste0("sbatch --qos=",qos," --job-name=C_",run," --output=C_",run,".log --mail-type=END --comment=REMIND-MAgPIE --tasks-per-node=",nr_of_regions," --wrap=\"Rscript start_coupled.R coupled_config=C_",run,".RData\""))
   }
   
   # Read runtime of ALL coupled runs (not just the current scenario) and produce comparison pdf
-- 
GitLab