From e1f5218f5a5ea880a91993e06ba4a338eb006c3d Mon Sep 17 00:00:00 2001 From: orichters Date: Tue, 19 Sep 2023 17:32:24 +0200 Subject: [PATCH] make sure log is preserved in case of requeueing --- scripts/start/prepareAndRun.R | 2 -- scripts/start/submit.R | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/start/prepareAndRun.R b/scripts/start/prepareAndRun.R index b9dd435547..86abb79462 100644 --- a/scripts/start/prepareAndRun.R +++ b/scripts/start/prepareAndRun.R @@ -22,8 +22,6 @@ prepareAndRun <- function() { } else { # If "full.gms" exists, the script assumes that a full.gms has been generated before and you want # to restart REMIND in the same folder using the gdx that it eventually previously produced. - message("\nRestarting REMIND, find old log in 'log_beforeRestart.txt'.") - if (file.exists("log.txt")) file.copy("log.txt", "log_beforeRestart.txt", overwrite = TRUE) if (file.exists("fulldata.gdx")) file.copy("fulldata.gdx", "input.gdx", overwrite = TRUE) } diff --git a/scripts/start/submit.R b/scripts/start/submit.R index 42d4cc0e3b..be7f35360e 100644 --- a/scripts/start/submit.R +++ b/scripts/start/submit.R @@ -128,9 +128,13 @@ submit <- function(cfg, restart = FALSE, stopOnFolderCreateError = TRUE) { if (grepl("^direct", cfg$slurmConfig) || ! isSlurmAvailable()) { exitCode <- system("Rscript prepareAndRun.R") } else { + if (file.exists("log.txt")) { + message("\nRestarting REMIND, find old log in 'log_beforeRestart.txt'.") + file.rename("log.txt", "log_beforeRestart.R") + } exitCode <- system(paste0("sbatch --job-name=", cfg$title, - " --output=log.txt", + " --output=log.txt --open-mode=append", # append for requeued jobs " --mail-type=END", " --comment=REMIND", " --wrap=\"Rscript prepareAndRun.R \" ",