diff --git a/config/default.cfg b/config/default.cfg index f2a73bec9116542e6a01afe08d1d8323a5fabfec..b889976c8597082af1f3a719d0069dc277bd2327 100755 --- a/config/default.cfg +++ b/config/default.cfg @@ -251,7 +251,6 @@ cfg$gms$cm_iteration_max <- 1 # def <- 1 cfg$gms$c_solver_try_max <- 2 # def <- 2 cfg$gms$c_keep_iteration_gdxes <- 0 # def <- 0 cfg$gms$cm_nash_autoconverge <- 1 # def <- 1 -cfg$gms$cm_postproc <- 0 # def <- 0 cfg$gms$cm_MAgPIE_coupling <- "off" # def <- "off" cfg$gms$cm_emiscen <- 1 # def <- 1 @@ -434,8 +433,6 @@ cfg$files2export$start <- c("config/conopt3.opt", "config/conopt3.op9", "scripts/run_submit/submit.cmd", "scripts/run_submit/submit.R", - "scripts/run_submit/submit_postp.cmd", - "scripts/run_submit/submit_postp.R", "scripts/run_submit/run_magicc.R", "scripts/run_submit/run_magicc_temperatureImpulseResponse.R", "scripts/run_submit/read_DAT_TOTAL_ANTHRO_RF.R", @@ -474,9 +471,6 @@ cfg$RunsUsingTHISgdxAsBAU <- NA # (0): manually set number of iterations by adjusting cm_iteration_max # (1): run until solution is sufficiently converged - coarse tolerances, quick solution. ! donot use in production runs ! # (2): run until solution is sufficiently converged - fine tolerances, for production runs. -# cm_postproc "turn on postprocessing" !! warning: does not work within an existing full.gms -# (0) postproc turned off -# (1) postproc turned on # cm_MAgPIE_coupling "switch on coupling mode with MAgPIE" # (off): off = REMIND expects to be run standalone (emission factors are used, shiftfactors are set to zero) # (on): on = REMIND expects to be run based on a MAgPIE reporting file (emission factors are set to zero because emissions are retrieved from the MAgPIE reporting, shift factors for supply curves are calculated) diff --git a/config/oneRegi.cfg b/config/oneRegi.cfg index 27c22cd9cfe3cbb5752d8edb9f7057d1adc74081..b441de2897cc293b45db88005ea3096efa043491 100644 --- a/config/oneRegi.cfg +++ b/config/oneRegi.cfg @@ -247,7 +247,6 @@ cfg$gms$cm_iteration_max <- 1 # def <- 1 cfg$gms$c_solver_try_max <- 2 # def <- 2 cfg$gms$c_keep_iteration_gdxes <- 0 # def <- 0 cfg$gms$cm_nash_autoconverge <- 1 # def <- 1 -cfg$gms$cm_postproc <- 0 # def <- 0 cfg$gms$cm_MAgPIE_coupling <- "off" # def <- "off" cfg$gms$cm_emiscen <- 1 # def <- 1 @@ -426,8 +425,6 @@ cfg$files2export$start <- c("config/conopt3.opt", "config/conopt3.op9", "scripts/run_submit/submit.cmd", "scripts/run_submit/submit.R", - "scripts/run_submit/submit_postp.cmd", - "scripts/run_submit/submit_postp.R", "scripts/run_submit/run_magicc.R", "scripts/run_submit/run_magicc_temperatureImpulseResponse.R", "scripts/run_submit/read_DAT_TOTAL_ANTHRO_RF.R", @@ -464,9 +461,6 @@ cfg$RunsUsingTHISgdxAsBAU <- NA # (0): manually set number of iterations by adjusting cm_iteration_max # (1): run until solution is sufficiently converged - coarse tolerances, quick solution. ! donot use in production runs ! # (2): run until solution is sufficiently converged - fine tolerances, for production runs. -# cm_postproc "turn on postprocessing" !! warning: does not work within an existing full.gms -# (0) postproc turned off -# (1) postproc turned on # cm_MAgPIE_coupling "switch on coupling mode with MAgPIE" # (off): off = REMIND expects to be run standalone (emission factors are used, shiftfactors are set to zero) # (on): on = REMIND expects to be run based on a MAgPIE reporting file (emission factors are set to zero because emissions are retrieved from the MAgPIE reporting, shift factors for supply curves are calculated) diff --git a/main.gms b/main.gms index e21df288b362ac7f614a63080e88c1d65ad4c803..f38411d8acf7c799155a341bd8c80541102ab1ca 100644 --- a/main.gms +++ b/main.gms @@ -74,7 +74,7 @@ * * Input data revision: 5.936 * -* Last modification (input data): Tue Jan 07 08:18:21 2020 +* Last modification (input data): Tue Jan 07 15:33:58 2020 * *###################### R SECTION END (VERSION INFO) ########################### @@ -198,7 +198,6 @@ cm_iteration_max "number of Negishi iterations (up to 49)" c_solver_try_max "maximum number of inner iterations within one Negishi iteration (<10)" c_keep_iteration_gdxes "save intermediate iteration gdxes" cm_nash_autoconverge "choice of nash convergence mode" -cm_postproc "turn on postprocessing" !! warning: you have to rerun the scenario cm_emiscen "policy scenario choice" cm_co2_tax_2020 "level of co2 tax in year 2020 in $ per t CO2eq, makes sense only for emiscen eq 9 and 45_carbonprice exponential" cm_co2_tax_growth "growth rate of carbon tax" @@ -286,7 +285,6 @@ cm_iteration_max = 1; !! def = 1 c_solver_try_max = 2; !! def = 2 c_keep_iteration_gdxes = 0; !! def = 0 cm_nash_autoconverge = 1; !! def = 1 -cm_postproc = 0; !! def = 0 $setglobal cm_MAgPIE_coupling off !! def = "off" cm_emiscen = 1; !! def = 1 diff --git a/modules/80_optimization/nash/datainput.gms b/modules/80_optimization/nash/datainput.gms index 2c9ff23a94b22d027d7d3ca3063a0802ad403405..fd6386fb6ce7a7e4477f0d1a4370b49179b1bc69 100644 --- a/modules/80_optimization/nash/datainput.gms +++ b/modules/80_optimization/nash/datainput.gms @@ -16,13 +16,8 @@ pm_co2eqForeign(t, regi) = (1 - pm_shPerm(t,regi)) * pm_emicapglob(t); ***convergence mode if(cm_nash_autoconverge gt 0, -*** in automatic mode, set max number of iterations -*** but do only one iteration if post-processing - if (cm_postproc eq 1, - cm_iteration_max = 1; - else - cm_iteration_max = 100; - ); +*** set max number of iterations +cm_iteration_max = 100; if(cm_nash_autoconverge eq 1, ***convergences thresholds - coarse diff --git a/modules/80_optimization/negishi/not_used.txt b/modules/80_optimization/negishi/not_used.txt index 24a2968ef1c81fe7939f348bf08e1835bee031f8..9d6ce077bc2847fd1676d4765ce752ec55538639 100644 --- a/modules/80_optimization/negishi/not_used.txt +++ b/modules/80_optimization/negishi/not_used.txt @@ -27,7 +27,6 @@ pm_budgetCO2eq, parameter, ??? sm_budgetCO2eqGlob, parameter, ??? qm_co2eqCum, equation, ??? sm_endBudgetCO2eq,scalar,??? -cm_postproc,switch,??? sm_fadeoutPriceAnticip,scalar,??? vm_co2eq,variable,??? diff --git a/modules/80_optimization/testOneRegi/not_used.txt b/modules/80_optimization/testOneRegi/not_used.txt index c10320fff052becac9e85bd75a23c0ab50062356..3146c12c9f994c11756089e9787614c3bb99f50d 100644 --- a/modules/80_optimization/testOneRegi/not_used.txt +++ b/modules/80_optimization/testOneRegi/not_used.txt @@ -27,7 +27,6 @@ sm_budgetCO2eqGlob, parameter, ??? qm_co2eqCum, equation, ??? sm_endBudgetCO2eq,scalar,??? pm_ttot_val,parameter,??? -cm_postproc,switch,??? qm_budget,equation,??? sm_fadeoutPriceAnticip,scalar,??? vm_co2eq,variable,??? diff --git a/scripts/input/create_Exog4xPrevious_CO2price_file.R b/scripts/input/create_Exog4xPrevious_CO2price_file.R deleted file mode 100644 index 0d047aba0ec33e10e673788ab8e803123bb3f519..0000000000000000000000000000000000000000 --- a/scripts/input/create_Exog4xPrevious_CO2price_file.R +++ /dev/null @@ -1,39 +0,0 @@ -# | (C) 2006-2019 Potsdam Institute for Climate Impact Research (PIK) -# | authors, and contributors see CITATION.cff file. This file is part -# | of REMIND and licensed under AGPL-3.0-or-later. Under Section 7 of -# | AGPL-3.0, you are granted additional permissions described in the -# | REMIND License Exception, version 1.0 (see LICENSE file). -# | Contact: remind@pik-potsdam.de -### Function to create files with price mark-ups (needed for cm_fetaxscen 102 - 116, ADVANCE WP2 price elasticity runs) - -create_Exog4xPrevious_CO2price_file<-function(gdx){ - - library(luplot,quietly=TRUE,warn.conflicts =FALSE) - library(lucode,quietly=TRUE,warn.conflicts =FALSE) - require(remind,quietly = TRUE,warn.conflicts =FALSE) - - ############################# BASIC CONFIGURATION ############################# - - #Define arguments that can be read from command line - # gdx <- "fulldata.gdx" - # readArgs("fulldata.gdx") - - ############################################################################### - - if (file.exists(gdx)) { - pr <- reportPrices(gdx) - } else { - stop("No gdx file found - please provide gdx from reference BAU run") - } - - #select right temporal/variable scope - pr <- pr[,,c( "Price|Carbon (US$2005/t CO2)")] - #get rid of variable name so that it is not printed - pr <- pr[,,1,drop=TRUE] - pr <- pr * 4 - - #write out file for mark-ups applied on FE level - write.magpie(pr[seq(1,11),,],"modules/45_carbonprice/Exog4xPrevious/input/p45_Exog4xPrevious_CO2_tax.cs4r", comment="** description: Carbon prices from previous run, upscaled by factor 4 for INDC2030_CO2price_DEF runs \n*** unit: $2005/t CO2 \n*** file created with scripts/input/create_Exog4xPrevious_CO2price_file.R") - - -} diff --git a/scripts/run_submit/submit_postp.R b/scripts/run_submit/submit_postp.R deleted file mode 100644 index d7e09866a3f989455e78e908035e7dd69c565df1..0000000000000000000000000000000000000000 --- a/scripts/run_submit/submit_postp.R +++ /dev/null @@ -1,118 +0,0 @@ -# | (C) 2006-2019 Potsdam Institute for Climate Impact Research (PIK) -# | authors, and contributors see CITATION.cff file. This file is part -# | of REMIND and licensed under AGPL-3.0-or-later. Under Section 7 of -# | AGPL-3.0, you are granted additional permissions described in the -# | REMIND License Exception, version 1.0 (see LICENSE file). -# | Contact: remind@pik-potsdam.de - -library(lucode, quietly = TRUE,warn.conflicts =FALSE) - -# Set value source_include so that loaded scripts know, that they are -# included as source (instead a load from command line) -source_include <- TRUE - -# unzip all .gz files -system("gzip -d -f *.gz") - -# Load REMIND run configuration -load("config.Rdata") - -# Change flag "cm_compile_main" from TRUE to FALSE since we are not compiling -# main.gms but executing full.gms and therefore want to load some data from the -# input.gdx files. -manipulateFile("full.gms", list(c("\\$setglobal cm_compile_main *TRUE", - "\\$setglobal cm_compile_main FALSE"))) - -file.copy("full.gms", "full_post.gms", overwrite=TRUE) - -# Declare empty list to hold the strings for the 'manipulateFile' function. -full_post_manipulateThis <- NULL - -if(cfg$gms$cm_postproc == 1) { -full_post_manipulateThis <- c(full_post_manipulateThis, - list(c("solve hybrid using nlp maximizing vm_welfareGlob;", "$$call 'gdxdump input.gdx Format=gamsbas Delim=comma Output=output_remind.gms';$include \"output_remind.gms\";"))) -} else { -full_post_manipulateThis <- c(full_post_manipulateThis, - list(c("solve hybrid using nlp maximizing vm_welfareGlob;", "$$call 'gdxdump fulldata.gdx Format=gamsbas Delim=comma Output=output_remind.gms';$include \"output_remind.gms\";"))) -} - -full_post_manipulateThis <- c(full_post_manipulateThis, - list(c("c_skip_output on !! def = off", "c_skip_output off !! def = off")), - list(c("Execute_Unload 'fulldata';","Execute_Unload 'fulldata_post';"))) - - -if(cfg$gms$optimization == "nash") { - full_post_manipulateThis <- c(full_post_manipulateThis, - list(c("file res_capcummo;","$ontext")), - list(c("putclose res_capcummo2;","$offtext")), - list(c("Repeat","")), - list(c("display\\$sleep\\(card\\(p80_handle\\)\\*10\\) 'sleep some time';","")), - list(c("until card\\(p80_handle\\) = 0;",""))) -} - -# Perform actual manipulation on full_post.gms, in single parse of the text. -manipulateFile("full_post.gms", full_post_manipulateThis) - -# Store REMIND directory and output file names -maindir <- cfg$remind_folder -REMIND_mif_name <- paste("REMIND_generic_",cfg$title,".mif",sep="") - -# Print message -cat("\nStarting REMIND POSTPROCESSING...\n") -# Save start time -begin <- Sys.time() - -# Call GAMS -system(paste0(cfg$gamsv, " full_post.gms -errmsg=1 -a=", cfg$action, - " -ps=0 -pw=185 -gdxcompress=1 -logoption=", cfg$logoption)) - -# Calculate run time -gams_runtime <- Sys.time() - begin - -# If REMIND actually did run -if (cfg$action == "ce" && cfg$gms$c_skip_output != "on") { - - file.copy("input.gdx","fulldata_post.gdx", overwrite = FALSE) - - # Print Message - cat("\nREMIND POSTPROCESSING finished!\n") -} - -# Compress files with the fixing-information -if (cfg$gms$cm_startyear > 2005) - system("gzip -f levs.gms margs.gms fixings.gms") - -# Return to the REMIND directory -setwd(maindir) - -# Reload the REMIND run configuration -load(cfg$val_workspace) - -# Print REMIND runtime -cat("\n gams_runtime is ", gams_runtime, "\n") -# Remove unused variables -rm(gams_runtime, validation) - -# Copy important files into output_folder (after REMIND execution) -for (file in cfg$files2export$end) - file.copy(file, cfg$results_folder, overwrite = TRUE) - -#Postprocessing / Output Generation -output <- cfg$output -outputdir <- cfg$results_folder -sys.source("output.R",envir=new.env()) - -# Call MAGICC -if (0 == nchar(Sys.getenv('MAGICC_BINARY'))) { - warning('Can\'t find magicc executable under environment variable MAGICC_BINARY') -} else { - system(paste("cd ",cfg$results_folder ,"/magicc; ", - "sed -f modify_MAGCFG_USER_CFG.sed -i MAGCFG_USER.CFG; ", - Sys.getenv('MAGICC_BINARY'), '; ', - "awk -f MAGICC_reporting.awk -v c_expname=\"", cfg$title, "\"", - " < climate_reporting_template.txt ", - " > REMIND_climate_", cfg$title, ".csv; ", - "cat REMIND_climate_", cfg$title, ".csv >> ../", REMIND_mif_name, "; ", - "cd ../..", sep = "")) -} - diff --git a/scripts/run_submit/submit_postp.cmd b/scripts/run_submit/submit_postp.cmd deleted file mode 100644 index 614a65928583b64290fac1358869f9ba263d781f..0000000000000000000000000000000000000000 --- a/scripts/run_submit/submit_postp.cmd +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -#--- Job Submission parameters ------ -#SBATCH --qos=short -#SBATCH --job-name=REMIND-PostProcessing -#SBATCH --output=log.txt -#SBATCH --mail-type=END -#------------------------------------------------ - -# start gams job -Rscript submit_postp.R diff --git a/scripts/start_functions.R b/scripts/start_functions.R index 18d7ef7c40cb650d7ae0f7d1787fbe6ec4692b46..b8bfb4eb662a18b8effc8f90d2bdf8e9fc8469c4 100644 --- a/scripts/start_functions.R +++ b/scripts/start_functions.R @@ -30,8 +30,7 @@ start_run <- function(cfg, scenario = NULL, report = NULL, sceninreport = NULL, on.exit(setwd(maindir)) # Is the run performed on the cluster? - on_cluster <- file.exists('/iplex/01/landuse') || file.exists('/p') - on_newcluster <- file.exists('/p') + on_cluster <- file.exists('/p') # Adapt configuration to predifined scenario, if given if(!is.null(scenario)) @@ -52,11 +51,6 @@ start_run <- function(cfg, scenario = NULL, report = NULL, sceninreport = NULL, # source("scripts/input/create_ExogSameAsPrevious_CO2price_file.R") # create_ExogSameAsPrevious_CO2price_file(as.character(cfg$files2export$start["input_ref.gdx"])) #} - # Update CO2 tax information for exogenous carbon price runs with 4x the CO2 price from a previous run - if(!is.null(cfg$gms$carbonprice) && (cfg$gms$carbonprice == "Exog4xPrevious")){ - source("scripts/input/create_Exog4xPrevious_CO2price_file.R") - create_Exog4xPrevious_CO2price_file(as.character(cfg$files2export$start["input_ref.gdx"])) - } #AJS if ( (cfg$gms$optimization != 'nash') & (cfg$gms$subsidizeLearning == 'globallyOptimal') ) { @@ -82,10 +76,10 @@ start_run <- function(cfg, scenario = NULL, report = NULL, sceninreport = NULL, "indu_",cfg$gms$industry,"-", "buil_",cfg$gms$buildings,"-", "tran_",cfg$gms$transport,"-", - "POP_", cfg$gms$cm_POPscen, "-", - "GDP_", cfg$gms$cm_GDPscen, "-", - "Kap_", cfg$gms$capitalMarket, "-", - "Reg_", substr(regionscode(cfg$regionmapping),1,10)) + "POP_", cfg$gms$cm_POPscen, "-", + "GDP_", cfg$gms$cm_GDPscen, "-", + "Kap_", cfg$gms$capitalMarket, "-", + "Reg_", substr(regionscode(cfg$regionmapping),1,10)) # adjust GDPpcScen based on GDPscen cfg$gms$c_GDPpcScen <- gsub("gdp_","",cfg$gms$cm_GDPscen) @@ -361,58 +355,33 @@ start_run <- function(cfg, scenario = NULL, report = NULL, sceninreport = NULL, } # "Compilation only" is always sequential - if (cfg$action == "c") - cfg$sequential <- TRUE + if (cfg$action == "c") cfg$sequential <- TRUE + # Call appropriate submit script if (!cfg$sequential) { - if(cfg$gms$optimization == "nash" && cfg$gms$cm_nash_mode == "parallel" && cfg$gms$cm_postproc == 0) { - if(length(unique(map$RegionCode)) <= 12) { - if (on_newcluster) { - system(paste0("sed -i 's/__JOB_NAME__/pREMIND_", cfg$title,"/g' submit_par.cmd")) - system("sbatch submit_par.cmd") - } else { - system("llsubmit submit_par.cmd") - } - } else { # use max amount of cores if regions number is greater than 12 - if (on_newcluster) { - system(paste0("sed -i 's/__JOB_NAME__/pREMIND_", cfg$title,"/g' submit_par16.cmd")) - system("sbatch submit_par16.cmd") - } else { - system("llsubmit submit_par16.cmd") - } - } - } else if (cfg$gms$optimization == "testOneRegi" && cfg$gms$cm_postproc == 0) { - if (on_newcluster) { - system(paste0("sed -i 's/__JOB_NAME__/REMIND_", cfg$title,"/g' submit_short.cmd")) - system("sbatch submit_short.cmd") + # parallel + 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("llsubmit submit_short.cmd") + 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") + } } - } else if (cfg$gms$cm_postproc == 1) { - if (on_newcluster) { - system(paste0("sed -i 's/__JOB_NAME__/REMIND-PP_", cfg$title,"/g' submit_postp.cmd")) - system("sbatch submit_postp.cmd") - } else { - system("llsubmit submit_postp.cmd") - } - } else { - if (on_newcluster) { - 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") - } - } else { - system("llsubmit submit.cmd") - } - } } else { - if (cfg$gms$cm_postproc == 1) { - system("Rscript submit_postp.R") - } else { + # sequential system("Rscript submit.R") - } } # on.exit sets working directory back to REMIND main folder diff --git a/standalone/MOFEX/MOFEX.gms b/standalone/MOFEX/MOFEX.gms index 39ce0d2211a7494e5e79c2777623df1af097b1ae..57b17aaaf753621cc0cef2f126113236899517b6 100644 --- a/standalone/MOFEX/MOFEX.gms +++ b/standalone/MOFEX/MOFEX.gms @@ -115,7 +115,6 @@ cm_iteration_max "number of Negishi iterations (up to 49)" c_solver_try_max "maximum number of inner iterations within one Negishi iteration (<10)" c_keep_iteration_gdxes "save intermediate iteration gdxes" cm_nash_autoconverge "choice of nash convergence mode" -cm_postproc "turn on postprocessing" !! warning: you have to rerun the scenario cm_emiscen "policy scenario choice" cm_co2_tax_2020 "level of co2 tax in year 2020 in $ per t CO2eq, makes sense only for emiscen eq 9 and 45_carbonprice exponential" cm_co2_tax_growth "growth rate of carbon tax" @@ -197,7 +196,6 @@ cm_iteration_max = 1; !! def = 1 c_solver_try_max = 2; !! def = 2 c_keep_iteration_gdxes = 0; !! def = 0 cm_nash_autoconverge = 1; !! def = 1 -cm_postproc = 0; !! def = 0 $setglobal cm_MAgPIE_coupling off !! def = "off" cm_emiscen = 1; !! def = 1 diff --git a/standalone/template.gms b/standalone/template.gms index 1931912f8db3c03019c633a98678b3663ad01662..2465aa9decf37ab6e08d1e09bb4983167d9ae72f 100644 --- a/standalone/template.gms +++ b/standalone/template.gms @@ -123,7 +123,6 @@ cm_iteration_max "number of Negishi iterations (up to 49)" c_solver_try_max "maximum number of inner iterations within one Negishi iteration (<10)" c_keep_iteration_gdxes "save intermediate iteration gdxes" cm_nash_autoconverge "choice of nash convergence mode" -cm_postproc "turn on postprocessing" !! warning: you have to rerun the scenario cm_emiscen "policy scenario choice" cm_co2_tax_2020 "level of co2 tax in year 2020 in $ per t CO2eq, makes sense only for emiscen eq 9 and 45_carbonprice exponential" cm_co2_tax_growth "growth rate of carbon tax" @@ -205,7 +204,6 @@ cm_iteration_max = 1; !! def = 1 c_solver_try_max = 2; !! def = 2 c_keep_iteration_gdxes = 0; !! def = 0 cm_nash_autoconverge = 1; !! def = 1 -cm_postproc = 0; !! def = 0 $setglobal cm_MAgPIE_coupling off !! def = "off" cm_emiscen = 1; !! def = 1