Skip to content

Commit

Permalink
let preempted and resumed runs start their subsequent runs
Browse files Browse the repository at this point in the history
  • Loading branch information
orichters committed Sep 18, 2023
1 parent c2174b3 commit ffcd255
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
[[#1354](https://github.com/remindmodel/remind/pull/1354)]
- switch off MAgPIE emission abatement for 45/NPi realization
[[#1401](https://github.com/remindmodel/remind/pull/1401)]
- let preempted and resumed runs start their subsequent runs

## [3.2.1] - 2023-07-13 (incomplete)

Expand Down
7 changes: 3 additions & 4 deletions scripts/start/prepareAndRun.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@ prepareAndRun <- function() {
# If no "full.gms" exists, the script assumes that REMIND did not run before and
# prepares all inputs before starting the run.
prepare()
start_subsequent_runs <- TRUE
} 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("fulldata.gdx")) file.copy("fulldata.gdx", "input.gdx", overwrite = TRUE)
start_subsequent_runs <- FALSE
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)
}

# Run REMIND, start subsequent runs (if applicable), and produce output.
run(start_subsequent_runs)
run()
}

# Only if this file is run directly via Rscript prepareAndRun.R, but not if this file
Expand Down
4 changes: 2 additions & 2 deletions scripts/start/run.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# | REMIND License Exception, version 1.0 (see LICENSE file).
# | Contact: [email protected]

run <- function(start_subsequent_runs = TRUE) {
run <- function() {

load("config.Rdata")

Expand Down Expand Up @@ -175,7 +175,7 @@ run <- function(start_subsequent_runs = TRUE) {
# Use the name to check whether it is a coupled run (TRUE if the name ends with "-rem-xx")
coupled_run <- grepl("-rem-[0-9]{1,2}$",cfg$title)
# Don't start subsequent runs form here if REMIND runs coupled. They are started in start_coupled.R instead.
start_subsequent_runs <- (start_subsequent_runs | isTRUE(cfg$restart_subsequent_runs)) & !coupled_run
start_subsequent_runs <- ! isFALSE(cfg$restart_subsequent_runs) && ! coupled_run

if (start_subsequent_runs & (length(rownames(cfg$RunsUsingTHISgdxAsInput)) > 0)) {
# track whether any subsequent run was actually started
Expand Down

0 comments on commit ffcd255

Please sign in to comment.