Skip to content
Snippets Groups Projects
Commit e8c0a5a5 authored by David Klein's avatar David Klein
Browse files

Start scripts: improve the readibility of the screen output

parent 63997f31
No related branches found
No related tags found
1 merge request!50Adapt scripts for manually restarting subsequent runs to the new structure of start scripts. New input.gdx. Cosmetics
......@@ -15,7 +15,7 @@
submit <- function(cfg) {
cat("Creating results folder for",cfg$title,"\n")
cat(" Creating results folder for",cfg$title,"\n")
# Generate name of output folder and create the folder
date <- format(Sys.time(), "_%Y-%m-%d_%H.%M.%S")
......@@ -27,7 +27,7 @@ submit <- function(cfg) {
} else if (!cfg$force_replace) {
stop(paste0("Results folder ",cfg$results_folder," could not be created because it already exists."))
} else {
cat("Deleting results folder because it alreay exists:",cfg$results_folder,"\n")
cat(" Deleting results folder because it alreay exists:",cfg$results_folder,"\n")
unlink(cfg$results_folder, recursive = TRUE)
dir.create(cfg$results_folder, recursive = TRUE, showWarnings = FALSE)
}
......@@ -39,7 +39,7 @@ submit <- function(cfg) {
# Do not save the new name of the results folder to the .RData file in REMINDs main folder, because it
# might be needed to restart subsequent runs manually and should not contain the time stamp in this case.
filename <- paste0(cfg$results_folder,"/config.Rdata")
cat("Writing cfg to file",filename,"\n")
cat(" Writing cfg to file",filename,"\n")
save(cfg,file=filename)
# Copy files required to confiugre and start a run
......@@ -53,7 +53,7 @@ submit <- function(cfg) {
on.exit(setwd(cfg$remind_folder))
# send prepare_and_run.R to cluster
cat("Executing prepare_and_run.R with",cfg$title,"\n")
cat(" Executing prepare_and_run.R for",cfg$results_folder,"\n")
if(cfg$slurmConfig=="direct") {
log <- format(Sys.time(), paste0(cfg$title,"-%Y-%H-%M-%S-%OS3.log"))
system("Rscript prepare_and_run.R")
......
......@@ -15,7 +15,7 @@ configure_cfg <- function(icfg, iscen, iscenarios, isettings) {
# Edit run title
icfg$title <- iscen
cat("\n", iscen, "\n")
cat(" Configuring cfg for", iscen,"\n")
# Edit main file of model
if( "model" %in% names(iscenarios)){
......@@ -106,7 +106,7 @@ if ('--testOneRegi' %in% argv) {
}
if (!is.na(config.file)) {
cat(paste("reading config file", config.file, "\n"))
cat(paste("\nReading config file", config.file, "\n"))
# Read-in the switches table, use first column as row names
settings <- read.csv2(config.file, stringsAsFactors = FALSE, row.names = 1, comment.char = "#", na.strings = "")
......@@ -142,6 +142,8 @@ for (scen in rownames(scenarios)) {
cfg$force_replace <- TRUE
}
cat("\n",scen,"\n")
# configure cfg based on settings from csv if provided
if (!is.na(config.file)) {
cfg <- configure_cfg(cfg, scen, scenarios, settings)
......@@ -149,14 +151,19 @@ for (scen in rownames(scenarios)) {
start_now <- (substr(scenarios[scen,"path_gdx_ref"], nchar(scenarios[scen,"path_gdx_ref"])-3, nchar(scenarios[scen,"path_gdx_ref"])) == ".gdx"
| is.na(scenarios[scen,"path_gdx_ref"]))
}
# save the cfg data for later start of subsequent runs (after preceding run finished)
filename <- paste0(scen,".RData")
cat("Writing cfg to file",filename,"\n")
cat(" Writing cfg to file",filename,"\n")
save(cfg,file=filename)
if (start_now){
# Create results folder and start run
submit(cfg)
}
# Create results folder and start run
submit(cfg)
} else {
cat(" Waiting for", scenarios[scen,'path_gdx_ref'] ,"\n")
}
if (!identical(cfg$subsequentruns,character(0))) cat(" Subsequent runs:",cfg$subsequentruns,"\n")
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment