From 3715cccdaa2d9b573194763a81d7b4d1209df75b Mon Sep 17 00:00:00 2001
From: David Klein <dklein@pik-potsdam.de>
Date: Tue, 7 Jan 2020 17:37:31 +0100
Subject: [PATCH] Refactoring - delete realization linadjust of module
 45_carbonprice, general code cleaning (mainly start_functions.R)

---
 config/default.cfg                            |  10 +-
 config/oneRegi.cfg                            |   9 +-
 main.gms                                      |   6 +-
 .../ExogSameAsPrevious/not_used.txt           |   8 -
 modules/45_carbonprice/NDC2018/not_used.txt   |   8 -
 .../45_carbonprice/NDC2constant/not_used.txt  |   2 -
 modules/45_carbonprice/NPi2018/not_used.txt   |   8 -
 .../diffPhaseIn2Constant/not_used.txt         |   2 -
 .../diffPhaseIn2Lin/not_used.txt              |   2 -
 .../diffPhaseIn2LinFlex/not_used.txt          |   2 -
 .../diffPhaseInLin2LinFlex/not_used.txt       |   2 -
 .../diffPriceSameCost/not_used.txt            |   8 -
 modules/45_carbonprice/exogenous/not_used.txt |   8 -
 .../45_carbonprice/expoLinear/not_used.txt    |   8 -
 .../45_carbonprice/exponential/not_used.txt   |   8 -
 .../45_carbonprice/linadjust/datainput.gms    |  36 -----
 .../45_carbonprice/linadjust/declarations.gms |  22 ---
 modules/45_carbonprice/linadjust/not_used.txt |  38 -----
 .../45_carbonprice/linadjust/postsolve.gms    |  22 ---
 .../45_carbonprice/linadjust/realization.gms  |  18 ---
 modules/45_carbonprice/linear/not_used.txt    |   8 -
 modules/45_carbonprice/module.gms             |   1 -
 modules/45_carbonprice/none/not_used.txt      |   8 -
 .../temperatureNotToExceed/not_used.txt       |   8 -
 scripts/start_functions.R                     | 151 ++++++------------
 standalone/MOFEX/MOFEX.gms                    |   4 -
 standalone/template.gms                       |   4 -
 start_bundle.R                                |   3 +-
 start_bundle_climate.R                        |   3 +-
 start_bundle_coupled.R                        |   5 +-
 30 files changed, 60 insertions(+), 362 deletions(-)
 delete mode 100644 modules/45_carbonprice/linadjust/datainput.gms
 delete mode 100644 modules/45_carbonprice/linadjust/declarations.gms
 delete mode 100644 modules/45_carbonprice/linadjust/not_used.txt
 delete mode 100644 modules/45_carbonprice/linadjust/postsolve.gms
 delete mode 100644 modules/45_carbonprice/linadjust/realization.gms

diff --git a/config/default.cfg b/config/default.cfg
index b889976..5b05a14 100755
--- a/config/default.cfg
+++ b/config/default.cfg
@@ -189,11 +189,9 @@ cfg$gms$banking  <- "off"           # def = off
 # * (none): no tax policy (combined with all emiscens except emiscen eq 9)
 # * (exponential): 5% exponential increase over time of the tax level in 2020 set via cm_co2_tax_2020 (combined with emiscen eq 9 and cm_co2_tax_2020>0)
 # * (expoLinear): 5% exponential increase until c_expoLinear_yearStart, linear increase thereafter
-# * (linadjust): linearly adjusted tax level starting from exogenous moderate policy scenario and ending at optimal tax controlled by cm_rcp_scen (SPA2 equivalent for SSPs) (combined with emiscen eq 9)
 # * (exogenous): carbon price is speficied using an external input file
 # * (linear): linear increase over time of the tax level in 2020 set via cm_co2_tax_2020 (combined with emiscen eq 9 and cm_co2_tax_2020>0)
 # * (diffPriceSameCost) ! experimental ! adjusts regional carbon prices until regional mitigation costs (in NPV GDP) are equal across regions. Use with iterative_adjust=2, emiscen=9. Experimental feature, you are responsible to check for convergence yourself (check that p45_mitiCostRel is about constant over iterations)
-# * (Exog4xPrevious): uses 4 times the carbon price found in the input_ref.gdx file
 # * (ExogSameAsPrevious): uses the identical carbon prices of a previous run, so far requires manual updating of the input file - see outcommented text in scripts/start_functions.R
 # * (temperatureNotToExceed): [test and verify before using it!] Find the optimal carbon carbon tax (set cm_emiscen=9) for the not-to-exceed temperature target defined by cm_carbonprice_temperatureLimit.
 # * (NDC2constant): linearly phase in global constant price from NDC prices (default 2020-2040 phase-in)
@@ -282,8 +280,6 @@ cfg$gms$cm_POPscen            <- "pop_SSP2"     # def <- "pop_SSP2"
 cfg$gms$cm_GDPscen            <- "gdp_SSP2"     # def <- "gdp_SSP2"
 
 cfg$gms$cm_startyear          <- 2005    # def <- 2005 for BAU, 2015 for policy run
-cfg$gms$cm_stagestart         <- 2020    # def <- 2020
-cfg$gms$cm_stageend           <- 2040    # def <- 2040
 cfg$gms$c_start_budget        <- 2100    # def <- 2100
 
 cfg$gms$cm_prtpScen           <- 3       # def <- 3
@@ -407,9 +403,9 @@ cfg$action <- "ce"   #def <- ce
 # Tar-ball all the put files to save space?
 cfg$tarball_puts <- "on"       # def <- on
 
-# Decide whether the runs should be run in parallel (TRUE), or sequentially (FALSE)
-#NA means that this decision is taken automatically (typically on cluster = TRUE and locally = FALSE)
-cfg$sequential <- NA
+# Decide whether the runs should be send to slurm (TRUE) or executed directly (FALSE)
+# NA means that this decision is taken automatically (typically on cluster = TRUE and locally = FALSE)
+cfg$sendToSlurm <- NA
 
 # Should REMIND output be shown in console? (0:no, 2:logfile, 3:yes)
 cfg$logoption <- 2
diff --git a/config/oneRegi.cfg b/config/oneRegi.cfg
index b441de2..6697230 100644
--- a/config/oneRegi.cfg
+++ b/config/oneRegi.cfg
@@ -185,7 +185,6 @@ cfg$gms$banking  <- "off"           # def = off
 # * (none): no tax policy (combined with all emiscens except emiscen eq 9)
 # * (exponential): 5% exponential increase over time of the tax level in 2020 set via cm_co2_tax_2020 (combined with emiscen eq 9 and cm_co2_tax_2020>0)
 # * (expoLinear): 5% exponential increase until c_expoLinear_yearStart, linear increase thereafter
-# * (linadjust): linearly adjusted tax level starting from exogenous moderate policy scenario and ending at optimal tax controlled by cm_rcp_scen (SPA2 equivalent for SSPs) (combined with emiscen eq 9)
 # * (exogenous): carbon price is speficied using an external input file
 # * (linear): linear increase over time of the tax level in 2020 set via cm_co2_tax_2020 (combined with emiscen eq 9 and cm_co2_tax_2020>0)
 # * (diffPriceSameCost) ! experimental ! adjusts regional carbon prices until regional mitigation costs (in NPV GDP) are equal across regions. Use with iterative_adjust=2, emiscen=9. Experimental feature, you are responsible to check for convergence yourself (check that p45_mitiCostRel is about constant over iterations)
@@ -277,8 +276,6 @@ cfg$gms$cm_POPscen            <- "pop_SSP2"     # def <- "pop_SSP2"
 cfg$gms$cm_GDPscen            <- "gdp_SSP2"     # def <- "gdp_SSP2"
 
 cfg$gms$cm_startyear          <- 2005    # def <- 2005 for BAU, 2015 for policy run
-cfg$gms$cm_stagestart         <- 2020    # def <- 2020
-cfg$gms$cm_stageend           <- 2040    # def <- 2040
 cfg$gms$c_start_budget        <- 2100    # def <- 2100
 
 cfg$gms$cm_prtpScen           <- 3       # def <- 3
@@ -399,9 +396,9 @@ cfg$action <- "ce"   #def <- ce
 # Tar-ball all the put files to save space?
 cfg$tarball_puts <- "on"       # def <- on
 
-# Decide whether the runs should be run in parallel (TRUE), or sequentially (FALSE)
-#NA means that this decision is taken automatically (typically on cluster = TRUE and locally = FALSE)
-cfg$sequential <- NA
+# Decide whether the runs should be send to slurm (TRUE) or executed directly (FALSE)
+# NA means that this decision is taken automatically (typically on cluster = TRUE and locally = FALSE)
+cfg$sendToSlurm <- NA
 
 # Should REMIND output be shown in console? (0:no, 2:logfile, 3:yes)
 cfg$logoption <- 2
diff --git a/main.gms b/main.gms
index f38411d..2a6c4a8 100644
--- a/main.gms
+++ b/main.gms
@@ -74,7 +74,7 @@
 * 
 * Input data revision: 5.936
 * 
-* Last modification (input data): Tue Jan 07 15:33:58 2020
+* Last modification (input data): Tue Jan 07 17:33:08 2020
 * 
 *###################### R SECTION END (VERSION INFO) ###########################
 
@@ -218,8 +218,6 @@ c_tradecost_bio       "choose financal tradecosts for biomass (purpose grown peb
 c_1stgen_phaseout    "choose if 1st generation biofuels should phase out after 2030 (vm_deltaCap=0)"
 cm_cprice_red_factor  "reduction factor for price on co2luc when calculating the revenues. Replicates the reduction applied in MAgPIE"
 cm_startyear          "first optimized modelling time step [year]"
-cm_stagestart         "start of staged accession for delay runs"
-cm_stageend           "end of staged accession for delay runs"
 c_start_budget        "start of GHG budget limit"
 cm_prtpScen           "pure rate of time preference standard values"
 cm_fetaxscen          "choice of final energy tax path, subsidy path and inconvenience cost path, values other than 0 make setting module 21_tax on"
@@ -319,8 +317,6 @@ $setglobal c_GDPpcScen  SSP2     !! def = gdp_SSP2   (automatically adjusted by
 
 *AG* and *CB* for cm_startyear greater than 2005, you have to copy the fulldata.gdx (rename it to: input_ref.gdx) from the run you want to build your new run onto.
 cm_startyear      = 2005;      !! def = 2005 for a BAU, 2015 for policy runs
-cm_stagestart     = 2020;      !! def = 2020
-cm_stageend       = 2040;      !! def = 2040
 c_start_budget    = 2100;      !! def = 2100
 
 cm_prtpScen         = 3;         !! def = 3
diff --git a/modules/45_carbonprice/ExogSameAsPrevious/not_used.txt b/modules/45_carbonprice/ExogSameAsPrevious/not_used.txt
index f9f3ed5..9b1b6ee 100644
--- a/modules/45_carbonprice/ExogSameAsPrevious/not_used.txt
+++ b/modules/45_carbonprice/ExogSameAsPrevious/not_used.txt
@@ -1,17 +1,9 @@
-# |  (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
 name,type,reason
 sm_c_2_co2,switch, ???
 vm_prodSe,variable,???
 vm_prodFe,variable,???
 pm_ttot_val,parameter,???
 cm_emiscen,switch,???
-cm_stagestart,switch,???
-cm_stageend,switch,???
 cm_iterative_target_adj,switch,???
 cm_expoLinear_yearStart,switch,???
 pm_prodCouple,parameter,???
diff --git a/modules/45_carbonprice/NDC2018/not_used.txt b/modules/45_carbonprice/NDC2018/not_used.txt
index 586b2d5..3e9bd84 100644
--- a/modules/45_carbonprice/NDC2018/not_used.txt
+++ b/modules/45_carbonprice/NDC2018/not_used.txt
@@ -1,9 +1,3 @@
-# |  (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
 name,type,reason
 cm_emiscen, switch, ???
 cm_co2_tax_2020, switch, ???
@@ -11,8 +5,6 @@ pm_pvp,parameter,???
 pm_ttot_val,parameter,???
 pm_ts,parameter,???
 cm_co2_tax_growth,switch,???
-cm_stagestart,switch,???
-cm_stageend,switch,???
 cm_expoLinear_yearStart,switch,???
 vm_cesIO,variable,???
 pm_globalMeanTemperature,input,questionnaire
diff --git a/modules/45_carbonprice/NDC2constant/not_used.txt b/modules/45_carbonprice/NDC2constant/not_used.txt
index 2f0cfb8..baff324 100644
--- a/modules/45_carbonprice/NDC2constant/not_used.txt
+++ b/modules/45_carbonprice/NDC2constant/not_used.txt
@@ -22,8 +22,6 @@ cm_emiscen,input,questionnaire
 cm_co2_tax_2020,input,questionnaire
 cm_co2_tax_growth,input,questionnaire
 cm_startyear,input,questionnaire
-cm_stagestart,input,questionnaire
-cm_stageend,input,questionnaire
 cm_iterative_target_adj,input,questionnaire
 cm_expoLinear_yearStart,input,questionnaire
 cm_carbonprice_temperatureLimit,input,questionnaire
diff --git a/modules/45_carbonprice/NPi2018/not_used.txt b/modules/45_carbonprice/NPi2018/not_used.txt
index 4673ea2..a24059d 100644
--- a/modules/45_carbonprice/NPi2018/not_used.txt
+++ b/modules/45_carbonprice/NPi2018/not_used.txt
@@ -1,9 +1,3 @@
-# |  (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
 name,type,reason
 cm_emiscen, switch, ???
 cm_co2_tax_2020, switch, ???
@@ -12,8 +6,6 @@ pm_pvp,parameter,???
 pm_ttot_val,parameter,???
 pm_ts,parameter,???
 cm_co2_tax_growth,switch,???
-cm_stagestart,switch,???
-cm_stageend,switch,???
 cm_expoLinear_yearStart,switch,???
 pm_globalMeanTemperature,input,questionnaire
 pm_temperatureImpulseResponseCO2,input,questionnaire
diff --git a/modules/45_carbonprice/diffPhaseIn2Constant/not_used.txt b/modules/45_carbonprice/diffPhaseIn2Constant/not_used.txt
index 2bb3e19..ce8ce64 100644
--- a/modules/45_carbonprice/diffPhaseIn2Constant/not_used.txt
+++ b/modules/45_carbonprice/diffPhaseIn2Constant/not_used.txt
@@ -19,8 +19,6 @@ cm_emiscen,input,questionnaire
 cm_co2_tax_2020,input,questionnaire
 cm_co2_tax_growth,input,questionnaire
 cm_startyear,input,questionnaire
-cm_stagestart,input,questionnaire
-cm_stageend,input,questionnaire
 cm_iterative_target_adj,input,questionnaire
 cm_expoLinear_yearStart,input,questionnaire
 cm_carbonprice_temperatureLimit,input,questionnaire
diff --git a/modules/45_carbonprice/diffPhaseIn2Lin/not_used.txt b/modules/45_carbonprice/diffPhaseIn2Lin/not_used.txt
index f07da92..821b957 100644
--- a/modules/45_carbonprice/diffPhaseIn2Lin/not_used.txt
+++ b/modules/45_carbonprice/diffPhaseIn2Lin/not_used.txt
@@ -17,8 +17,6 @@ pm_ttot_2_tall,input,questionnaire
 pm_prtp,input,questionnaire
 cm_emiscen,input,questionnaire
 cm_co2_tax_growth,input,questionnaire
-cm_stagestart,input,questionnaire
-cm_stageend,input,questionnaire
 cm_iterative_target_adj,input,questionnaire
 cm_expoLinear_yearStart,input,questionnaire
 cm_carbonprice_temperatureLimit,input,questionnaire
diff --git a/modules/45_carbonprice/diffPhaseIn2LinFlex/not_used.txt b/modules/45_carbonprice/diffPhaseIn2LinFlex/not_used.txt
index 4d39777..c0d7371 100644
--- a/modules/45_carbonprice/diffPhaseIn2LinFlex/not_used.txt
+++ b/modules/45_carbonprice/diffPhaseIn2LinFlex/not_used.txt
@@ -16,8 +16,6 @@ pm_ttot_2_tall,input,questionnaire
 pm_prtp,input,questionnaire
 cm_emiscen,input,questionnaire
 cm_co2_tax_growth,input,questionnaire
-cm_stagestart,input,questionnaire
-cm_stageend,input,questionnaire
 cm_iterative_target_adj,input,questionnaire
 cm_expoLinear_yearStart,input,questionnaire
 cm_carbonprice_temperatureLimit,input,questionnaire
diff --git a/modules/45_carbonprice/diffPhaseInLin2LinFlex/not_used.txt b/modules/45_carbonprice/diffPhaseInLin2LinFlex/not_used.txt
index 4d39777..c0d7371 100644
--- a/modules/45_carbonprice/diffPhaseInLin2LinFlex/not_used.txt
+++ b/modules/45_carbonprice/diffPhaseInLin2LinFlex/not_used.txt
@@ -16,8 +16,6 @@ pm_ttot_2_tall,input,questionnaire
 pm_prtp,input,questionnaire
 cm_emiscen,input,questionnaire
 cm_co2_tax_growth,input,questionnaire
-cm_stagestart,input,questionnaire
-cm_stageend,input,questionnaire
 cm_iterative_target_adj,input,questionnaire
 cm_expoLinear_yearStart,input,questionnaire
 cm_carbonprice_temperatureLimit,input,questionnaire
diff --git a/modules/45_carbonprice/diffPriceSameCost/not_used.txt b/modules/45_carbonprice/diffPriceSameCost/not_used.txt
index b700e38..c7c253b 100644
--- a/modules/45_carbonprice/diffPriceSameCost/not_used.txt
+++ b/modules/45_carbonprice/diffPriceSameCost/not_used.txt
@@ -1,17 +1,9 @@
-# |  (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
 name,type,reason
 sm_c_2_co2,switch, ???
 vm_prodSe,variable,???
 vm_prodFe,variable,???
 pm_ttot_val,parameter,???
 cm_emiscen,switch,???
-cm_stagestart,switch,???
-cm_stageend,switch,???
 cm_iterative_target_adj,switch,???
 cm_expoLinear_yearStart,switch,???
 pm_prodCouple,parameter,???
diff --git a/modules/45_carbonprice/exogenous/not_used.txt b/modules/45_carbonprice/exogenous/not_used.txt
index 76dd0b0..4eae5e9 100644
--- a/modules/45_carbonprice/exogenous/not_used.txt
+++ b/modules/45_carbonprice/exogenous/not_used.txt
@@ -1,9 +1,3 @@
-# |  (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
 name,type,reason
 cm_co2_tax_2020, switch, ???
 sm_c_2_co2,switch, ???
@@ -15,8 +9,6 @@ pm_ttot_val,parameter,???
 pm_ts,parameter,???
 cm_co2_tax_growth,switch,???
 cm_startyear,switch,???
-cm_stagestart,switch,???
-cm_stageend,switch,???
 cm_iterative_target_adj,switch,???
 cm_expoLinear_yearStart,switch,???
 pm_prodCouple,parameter,???
diff --git a/modules/45_carbonprice/expoLinear/not_used.txt b/modules/45_carbonprice/expoLinear/not_used.txt
index de87af4..83de13b 100644
--- a/modules/45_carbonprice/expoLinear/not_used.txt
+++ b/modules/45_carbonprice/expoLinear/not_used.txt
@@ -1,9 +1,3 @@
-# |  (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
 name,type,reason
 sm_c_2_co2,switch, ???
 vm_cesIO,variable,???
@@ -12,8 +6,6 @@ vm_prodFe,variable,???
 pm_pvp,parameter,???
 pm_ts,parameter,???
 cm_emiscen,switch,???
-cm_stagestart,switch,???
-cm_stageend,switch,???
 cm_iterative_target_adj,switch,???
 pm_prodCouple,parameter,???
 pm_bunker_share_in_nonldv_fe,parameter,???
diff --git a/modules/45_carbonprice/exponential/not_used.txt b/modules/45_carbonprice/exponential/not_used.txt
index 0a8714c..58f5ebb 100644
--- a/modules/45_carbonprice/exponential/not_used.txt
+++ b/modules/45_carbonprice/exponential/not_used.txt
@@ -1,9 +1,3 @@
-# |  (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
 name,type,reason
 cm_emiscen, switch, ???
 sm_c_2_co2,switch, ???
@@ -14,8 +8,6 @@ pm_pvp,parameter,???
 pm_ttot_val,parameter,???
 pm_ts,parameter,???
 cm_startyear,switch,???
-cm_stagestart,switch,???
-cm_stageend,switch,???
 cm_iterative_target_adj,switch,???
 cm_expoLinear_yearStart,switch,???
 pm_prodCouple,parameter,???
diff --git a/modules/45_carbonprice/linadjust/datainput.gms b/modules/45_carbonprice/linadjust/datainput.gms
deleted file mode 100644
index 1a05ea4..0000000
--- a/modules/45_carbonprice/linadjust/datainput.gms
+++ /dev/null
@@ -1,36 +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
-*** SOF ./modules/45_carbonprice/linadjust/datainput.gms
-***-------------------------------------------------------------------------------
-*** *GL,IM* 20140402 calculation of tax paths for staged accession
-***-------------------------------------------------------------------------------
-s45_stagestart = cm_stagestart;
-s45_stageend = cm_stageend; 
-
-*** calculate tax paths based on carbon prices from reference policy and first best policy loaded from gdxs
-Execute_Loadpoint 'input_ref' p45_pvpRegi_ref = pm_pvpRegi;
-p45_tauCO2_ref(ttot, regi)$(ttot.val ge 2005) = p45_pvpRegi_ref(ttot,regi,"perm") / p45_pvpRegi_ref(ttot,regi,"good");
-
-Execute_Loadpoint 'input_opt' p45_pvpRegi_opt = pm_pvpRegi;
-p45_tauCO2_opt(ttot, regi)$(ttot.val ge 2005) = p45_pvpRegi_opt(ttot,regi,"perm") / p45_pvpRegi_opt(ttot,regi,"good");
-
-pm_taxCO2eq(ttot,regi)$(ttot.val ge 2005 and ttot.val le s45_stagestart) = p45_tauCO2_ref(ttot, regi);
- 
-*** calculate carbon price path for period of staged accession: linear interpolation between price of reference policy and marked-up price of first best policy
-pm_taxCO2eq(ttot,regi)$(ttot.val > s45_stagestart AND ttot.val < s45_stageend )  
-  = (s45_stageend - ttot.val) / (s45_stageend - s45_stagestart) * p45_tauCO2_ref(ttot,regi) 
-  + (ttot.val - s45_stagestart)	/ (s45_stageend - s45_stagestart) * p45_tauCO2_opt(ttot,regi);
-
-*** calculate carbon price for period of comprehensive cooperation (after staged accession): price path from first best (e.g. SPA0) with markup factor
-pm_taxCO2eq(ttot,regi)$(ttot.val >= s45_stageend) =  p45_tauCO2_opt(ttot,regi);
-
-*** assign carbon price for period after 2100 to that of 2100 (that is needed when the input_opt is from runs with no carbon price after 2100 e.g. budget runs)
-pm_taxCO2eq(ttot,regi)$(ttot.val > 2100) = pm_taxCO2eq("2100",regi);
-
-display p45_tauCO2_ref, p45_tauCO2_opt, pm_taxCO2eq;
-
-*** EOF ./modules/45_carbonprice/linadjust/datainput.gms
diff --git a/modules/45_carbonprice/linadjust/declarations.gms b/modules/45_carbonprice/linadjust/declarations.gms
deleted file mode 100644
index 4bd8137..0000000
--- a/modules/45_carbonprice/linadjust/declarations.gms
+++ /dev/null
@@ -1,22 +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
-*** SOF ./modules/45_carbonprice/linadjust/declarations.gms
-***-------------------------------------------------------------------------------
-*** *IM* 20140402 declaration of parameters
-***-------------------------------------------------------------------------------
-
-parameters
-p45_tauCO2_ref(ttot, all_regi)              "CO2 tax path of reference policy (e.g. exogMod2)"
-p45_tauCO2_opt(ttot, all_regi)              "CO2 tax path of first best policy (e.g. SPA0)"
-p45_pvpRegi_ref(ttot,all_regi,all_enty)     "prices of traded commodities from reference gdx - regional"
-p45_pvpRegi_opt(ttot,all_regi,all_enty)     "prices of traded commodities from first best gdx - regional"
-;
-scalars
-s45_stagestart                              "first time-step of staged accession period"
-s45_stageend                                "first time-step of comprehensive cooperation period (first time-step after the end of the staged accession period)"
-;
-*** EOF ./modules/45_carbonprice/linadjust/declarations.gms
diff --git a/modules/45_carbonprice/linadjust/not_used.txt b/modules/45_carbonprice/linadjust/not_used.txt
deleted file mode 100644
index b052b9f..0000000
--- a/modules/45_carbonprice/linadjust/not_used.txt
+++ /dev/null
@@ -1,38 +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
-name,type,reason
-cm_emiscen, switch, ???
-cm_co2_tax_2020, switch, ???
-sm_c_2_co2,switch, ???
-vm_cesIO,variable,???
-vm_prodSe,variable,???
-vm_prodFe,variable,???
-pm_pvp,parameter,???
-pm_ttot_val,parameter,???
-pm_ts,parameter,???
-cm_co2_tax_growth,switch,???
-cm_startyear,switch,???
-cm_iterative_target_adj,switch,???
-cm_expoLinear_yearStart,switch,???
-pm_prodCouple,parameter,???
-pm_bunker_share_in_nonldv_fe,parameter,???
-vm_co2eq,variable,???
-sm_DptCO2_2_TDpGtC,scalar,???
-vm_emiFgas,input,questionnaire
-pm_globalMeanTemperature,input,questionnaire
-pm_temperatureImpulseResponseCO2,input,questionnaire
-pm_consPC,input,questionnaire
-pm_GDPGross,input,questionnaire
-pm_prtp,input,questionnaire
-cm_carbonprice_temperatureLimit,input,questionnaire
-pm_ttot_2_tall,input,questionnaire
-pm_shPPPMER,input,questionnaire
-pm_pop,input,questionnaire
-pm_gdp,input,questionnaire
-cm_CO2priceRegConvEndYr,input,questionnaire
-cm_peakBudgYr,input,questionnaire
-cm_taxCO2inc_after_peakBudgYr,input,questionnaire
diff --git a/modules/45_carbonprice/linadjust/postsolve.gms b/modules/45_carbonprice/linadjust/postsolve.gms
deleted file mode 100644
index d7603a2..0000000
--- a/modules/45_carbonprice/linadjust/postsolve.gms
+++ /dev/null
@@ -1,22 +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
-*** SOF ./modules/45_carbonprice/linadjust/postsolve.gms
-*** calculate carbon price path for period of staged accession: linear interpolation between price of reference policy and marked-up price of first best policy as calculated from iterative adjustment
-
-*#' @equations
-*#' calculate carbon price path for period of staged accession: 
-*#' linear interpolation between price of reference policy and marked-up price of first best policy as calculated from iterative adjustment
-pm_taxCO2eq(ttot,regi)$(ttot.val > s45_stagestart AND ttot.val < s45_stageend )  
-  = (s45_stageend - ttot.val) / (s45_stageend - s45_stagestart) * p45_tauCO2_ref(ttot,regi) +
-	(ttot.val - s45_stagestart)	/ (s45_stageend - s45_stagestart) * p45_tauCO2_opt(ttot,regi) * 
-	sum(ttot2$(ttot2.val eq s45_stageend),
-        pm_taxCO2eq(ttot2,regi)/ p45_tauCO2_opt(ttot2,regi)
-    ) 
-;
-
-display pm_taxCO2eq;
-*** EOF ./modules/45_carbonprice/linadjust/postsolve.gms
diff --git a/modules/45_carbonprice/linadjust/realization.gms b/modules/45_carbonprice/linadjust/realization.gms
deleted file mode 100644
index 10a8993..0000000
--- a/modules/45_carbonprice/linadjust/realization.gms
+++ /dev/null
@@ -1,18 +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
-*** SOF ./modules/45_carbonprice/linadjust.gms
-
-*#' @description This realization increases the carbon price linearly over time. In the period of staged accession, the carbon price is the linear interpolation
-*#' between the reference policy and the first-best policy as calculated from iterative adjustment. 
-
-
-*####################### R SECTION START (PHASES) ##############################
-$Ifi "%phase%" == "declarations" $include "./modules/45_carbonprice/linadjust/declarations.gms"
-$Ifi "%phase%" == "datainput" $include "./modules/45_carbonprice/linadjust/datainput.gms"
-$Ifi "%phase%" == "postsolve" $include "./modules/45_carbonprice/linadjust/postsolve.gms"
-*######################## R SECTION END (PHASES) ###############################
-*** EOF ./modules/45_carbonprice/linadjust.gms
diff --git a/modules/45_carbonprice/linear/not_used.txt b/modules/45_carbonprice/linear/not_used.txt
index bd1c667..ca87567 100644
--- a/modules/45_carbonprice/linear/not_used.txt
+++ b/modules/45_carbonprice/linear/not_used.txt
@@ -1,9 +1,3 @@
-# |  (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
 name,type,reason
 cm_emiscen, switch, ???
 sm_c_2_co2,switch, ???
@@ -14,8 +8,6 @@ pm_pvp,parameter,???
 pm_ttot_val,parameter,???
 pm_ts,parameter,???
 cm_co2_tax_growth,switch,???
-cm_stagestart,switch,???
-cm_stageend,switch,???
 cm_iterative_target_adj,switch,???
 cm_expoLinear_yearStart,switch,???
 pm_prodCouple,parameter,???
diff --git a/modules/45_carbonprice/module.gms b/modules/45_carbonprice/module.gms
index f604d8f..e0985e2 100644
--- a/modules/45_carbonprice/module.gms
+++ b/modules/45_carbonprice/module.gms
@@ -28,7 +28,6 @@ $Ifi "%carbonprice%" == "diffPriceSameCost" $include "./modules/45_carbonprice/d
 $Ifi "%carbonprice%" == "exogenous" $include "./modules/45_carbonprice/exogenous/realization.gms"
 $Ifi "%carbonprice%" == "expoLinear" $include "./modules/45_carbonprice/expoLinear/realization.gms"
 $Ifi "%carbonprice%" == "exponential" $include "./modules/45_carbonprice/exponential/realization.gms"
-$Ifi "%carbonprice%" == "linadjust" $include "./modules/45_carbonprice/linadjust/realization.gms"
 $Ifi "%carbonprice%" == "linear" $include "./modules/45_carbonprice/linear/realization.gms"
 $Ifi "%carbonprice%" == "none" $include "./modules/45_carbonprice/none/realization.gms"
 $Ifi "%carbonprice%" == "temperatureNotToExceed" $include "./modules/45_carbonprice/temperatureNotToExceed/realization.gms"
diff --git a/modules/45_carbonprice/none/not_used.txt b/modules/45_carbonprice/none/not_used.txt
index f67030f..d844dc7 100644
--- a/modules/45_carbonprice/none/not_used.txt
+++ b/modules/45_carbonprice/none/not_used.txt
@@ -1,9 +1,3 @@
-# |  (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
 name,type,reason
 cm_emiscen, switch, ???
 cm_co2_tax_2020, switch, ???
@@ -16,8 +10,6 @@ pm_ttot_val,parameter,???
 pm_ts,parameter,???
 cm_co2_tax_growth,switch,???
 cm_startyear,switch,???
-cm_stagestart,switch,???
-cm_stageend,switch,???
 cm_iterative_target_adj,switch,???
 cm_expoLinear_yearStart,switch,???
 pm_prodCouple,parameter,???
diff --git a/modules/45_carbonprice/temperatureNotToExceed/not_used.txt b/modules/45_carbonprice/temperatureNotToExceed/not_used.txt
index 0ee27e8..916ee78 100644
--- a/modules/45_carbonprice/temperatureNotToExceed/not_used.txt
+++ b/modules/45_carbonprice/temperatureNotToExceed/not_used.txt
@@ -1,9 +1,3 @@
-# |  (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
 name,type,reason
 sm_c_2_co2,input,questionnaire
 sm_DptCO2_2_TDpGtC,input,questionnaire
@@ -18,8 +12,6 @@ pm_ts,input,questionnaire
 cm_co2_tax_2020,input,questionnaire
 cm_co2_tax_growth,input,questionnaire
 cm_startyear,input,questionnaire
-cm_stagestart,input,questionnaire
-cm_stageend,input,questionnaire
 cm_iterative_target_adj,input,questionnaire
 cm_expoLinear_yearStart,input,questionnaire
 pm_prodCouple,input,questionnaire
diff --git a/scripts/start_functions.R b/scripts/start_functions.R
index b8bfb4e..bab6e76 100644
--- a/scripts/start_functions.R
+++ b/scripts/start_functions.R
@@ -60,13 +60,7 @@ start_run <- function(cfg, scenario = NULL, report = NULL, sceninreport = NULL,
   # reportCEScalib only works with the calibrate module
   if ( cfg$gms$CES_parameters != "calibrate" ) cfg$output <- setdiff(cfg$output,"reportCEScalib")
   
-  # Replace :title: and :date: tokens in results directory name
-  rundate <- Sys.time()
-  date <- format(rundate, "_%Y-%m-%d_%H.%M.%S")
-  cfg$results_folder <- gsub(":date:", date, cfg$results_folder, fixed = TRUE)
-  cfg$results_folder <- gsub(":title:", cfg$title, cfg$results_folder, fixed = TRUE)
-
-    #AJS quit if title is too long - GAMS can't handle that
+  #AJS quit if title is too long - GAMS can't handle that
   if( nchar(cfg$title) > 75 | grepl("\\.",cfg$title) ) {
       stop("This title is too long or the name contains dots - GAMS would not tolerate this, and quit working at a point where you least expect it. Stopping now. ")
   }
@@ -80,40 +74,35 @@ start_run <- function(cfg, scenario = NULL, report = NULL, sceninreport = NULL,
                                          "GDP_", cfg$gms$cm_GDPscen, "-",
                                          "Kap_", cfg$gms$capitalMarket, "-",
                                          "Reg_", substr(regionscode(cfg$regionmapping),1,10))
-   # adjust GDPpcScen based on GDPscen
+  
+  # write name of corresponding CES file to datainput.gms
+  replace_in_file(file    = "./modules/29_CES_parameters/load/datainput.gms",
+                  content = paste0('$include "./modules/29_CES_parameters/load/input/',cfg$gms$cm_CES_configuration,'.inc"'),
+                  subject = "CES INPUT")
+ 
+  # adjust GDPpcScen based on GDPscen
   cfg$gms$c_GDPpcScen <- gsub("gdp_","",cfg$gms$cm_GDPscen) 
 
+  # Make sure all MAGICC files have LF line endings, so Fortran won't crash
+  if (on_cluster)
+    system("find ./core/magicc/ -type f | xargs dos2unix -q")
+  
+  # Set source_include so that loaded scripts know they are included as 
+  # source (instead a load from command line)
+  source_include <- TRUE
+   
   ################## M O D E L   L O C K ###################################
   # Lock the directory for other instances of the start scritps
   lock_id <- model_lock(timeout1 = 1, oncluster=on_cluster)
   on.exit(model_unlock(lock_id, oncluster=on_cluster))  
   ################## M O D E L   L O C K ###################################
 
-  # Make sure all MAGICC files have LF line endings, so Fortran won't crash
-  if (on_cluster)
-    system("find ./core/magicc/ -type f | xargs dos2unix -q")
-  
-  # Create output folder
-  if (!file.exists(cfg$results_folder)) {
-    dir.create(cfg$results_folder, recursive = TRUE, showWarnings = FALSE)
-  } else if (!force) {
-    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")
-    unlink(cfg$results_folder, recursive = TRUE)
-    dir.create(cfg$results_folder, recursive = TRUE, showWarnings = FALSE)
-  }
-  
   # If report and scenname are supplied the data of this scenario in the report will be converted to REMIND input
+  # Used for REMIND-MAgPIE coupling
   if (!is.null(report) && !is.null(sceninreport)) {
-    #cfg$gms$biomass <- "magpie_linear" # is already set in start_couple.R
     getReportData(report,sceninreport,inputpath_mag=cfg$gms$biomass,inputpath_acc=cfg$gms$agCosts)
   }
   
-  # Set source_include so that loaded scripts know they are included as 
-  # source (instead a load from command line)
-  source_include <- TRUE
-   
   # Update module paths in GAMS code
   update_modules_embedding()
 
@@ -123,16 +112,6 @@ start_run <- function(cfg, scenario = NULL, report = NULL, sceninreport = NULL,
   if(is.null(cfg$model)) cfg$model <- "main.gms"
   manipulateConfig(cfg$model, cfg$gms)
   
-  # Configure input.gms in all modules based on settings of cfg file
-  l1 <- path("modules", list.dirs("modules/"))
-  for(l in l1) {
-    l2 <- path(l, list.dirs(l))
-    for(ll in l2) {
-      if (file.exists(path(ll, "input.gms")))
-        manipulateConfig(path(ll, "input.gms"), cfg$gms)
-      }
-    }
-  
   # Check all setglobal settings for consistency
   settingsCheck()
   
@@ -188,7 +167,7 @@ start_run <- function(cfg, scenario = NULL, report = NULL, sceninreport = NULL,
     content <- c(content, '      /')
     content <- c(content, ' ')
     # iso countries set
-	content <- c(content,'   iso "list of iso countries" /')
+	  content <- c(content,'   iso "list of iso countries" /')
     content <- c(content, .tmp(map$CountryCode, suffix1=",", suffix2=" /"),'')
     content <- c(content,'   regi2iso(all_regi,iso) "mapping regions to iso countries"','      /')
     for(i in levels(map$RegionCode)) {
@@ -204,7 +183,6 @@ start_run <- function(cfg, scenario = NULL, report = NULL, sceninreport = NULL,
     content <- c(content,'      /',';') 
     replace_in_file('core/sets.gms',content,"SETS",comment="***")
   }
-  ###################################################################### 
   
   ############### download and distribute input data ################### 
   # check wheather the regional resolution and input data revision are outdated and update data if needed
@@ -222,7 +200,6 @@ start_run <- function(cfg, scenario = NULL, report = NULL, sceninreport = NULL,
                           modelfolder  = ".",
                           debug        = FALSE)
   }
-  ######################################################################
   
   ##################### update information #############################
   # update_info, which regional resolution and input data revision in cfg$model
@@ -231,7 +208,6 @@ start_run <- function(cfg, scenario = NULL, report = NULL, sceninreport = NULL,
   #-- load new mapping information
   map <- read.csv(cfg$regionmapping,sep=";")  
   update_sets(map)
-  ######################################################################
   
   ###########################################################################################################
   ############# PROCESSING INPUT DATA ###################### END ############################################
@@ -247,47 +223,21 @@ start_run <- function(cfg, scenario = NULL, report = NULL, sceninreport = NULL,
     content <- c(modification_warning,'','sets')
     content <- c(content,'','       modules "all the available modules"')
     content <- c(content,'       /',paste0("       ",getModules("modules/")[,"name"]),'       /')
-#    content <- c(content,'','       realisation "all the active realisations"')
-#    content <- c(content,'       /',paste0("       ",unlist(unique(cfg$gms[getModules("modules/")[,"name"]]))),"       /")
     content <- c(content,'','module2realisation(modules,*) "mapping of modules and active realisations" /')
     content <- c(content,paste0("       ",getModules("modules/")[,"name"]," . %",getModules("modules/")[,"name"],"%"))
     content <- c(content,'      /',';')
     replace_in_file('core/sets.gms',content,"MODULES",comment="***")
   ############# ADD MODULE INFO IN SETS  ###################### END ############################################
       
-  # For the performance tests create the workspace for validation
-  tmp <- strsplit(cfg$results_folder, "/")[[1]] # take name of output folder without "output/"
-  cfg$val_workspace <- paste(cfg$results_folder, "/", tmp[length(tmp)],".RData", sep = "")
-  validation <- list()
-  validation$technical <- list()
-  validation$technical$time <- list()
-  save(validation, file = cfg$val_workspace)
-  
-  # Delete unneeded gdx from files2export
-  tmp <- cfg$files2export$start
-#  if (cfg$gms$cm_startyear < 2020 && !is.null(names(tmp))) { # < 2020
-#    tmp <- tmp[!grepl("input_ref.gdx",names(tmp))]
-#	  cat("Removed input_ref.gdx from cfg$files2export$start.\n")
-#	}
-#  if ((cfg$gms$cm_emiscen == 1 | cfg$gms$cm_startyear < 2010) && !is.null(names(tmp))) { # < 2010
-#    tmp <- tmp[!grepl("input_bau.gdx",names(tmp))]
-#	  cat("Removed input_bau.gdx from cfg$files2export$start.\n")
-#	}
-  if ((cfg$gms$cm_emiscen != 9 | cfg$gms$cm_startyear < 2025) && !is.null(names(tmp))) {
-    tmp <- tmp[!grepl("input_opt.gdx",names(tmp))]
-    cat("Removed input_opt.gdx from cfg$files2export$start.\n")
-  }
-  cfg$files2export$start <- tmp
-
   # Replace load leveler-script with appropriate version
   if (cfg$gms$optimization == "nash" && cfg$gms$cm_nash_mode == "parallel") {
-	if(length(unique(map$RegionCode)) <= 12) { 
-		cfg$files2export$start[cfg$files2export$start == "scripts/run_submit/submit.cmd"] <- 
-      "scripts/run_submit/submit_par.cmd"
-	} else { # use max amount of cores if regions number is greater than 12 
-		cfg$files2export$start[cfg$files2export$start == "scripts/run_submit/submit.cmd"] <- 
-      "scripts/run_submit/submit_par16.cmd"
-	}
+    if(length(unique(map$RegionCode)) <= 12) {
+      cfg$files2export$start[cfg$files2export$start == "scripts/run_submit/submit.cmd"] <- 
+        "scripts/run_submit/submit_par.cmd"
+    } else { # use max amount of cores if regions number is greater than 12 
+      cfg$files2export$start[cfg$files2export$start == "scripts/run_submit/submit.cmd"] <- 
+        "scripts/run_submit/submit_par16.cmd"
+    }
   } else if (cfg$gms$optimization == "testOneRegi") {
     cfg$files2export$start[cfg$files2export$start == "scripts/run_submit/submit.cmd"] <- 
       "scripts/run_submit/submit_short.cmd"
@@ -296,6 +246,22 @@ start_run <- function(cfg, scenario = NULL, report = NULL, sceninreport = NULL,
   # choose which conopt files to copy
   cfg$files2export$start <- sub("conopt3",cfg$gms$cm_conoptv,cfg$files2export$start)
   
+  # Create name of output folder and output folder itself
+  rundate <- Sys.time()
+  date <- format(rundate, "_%Y-%m-%d_%H.%M.%S")
+  cfg$results_folder <- gsub(":date:", date, cfg$results_folder, fixed = TRUE)
+  cfg$results_folder <- gsub(":title:", cfg$title, cfg$results_folder, fixed = TRUE)
+  # Create output folder
+  if (!file.exists(cfg$results_folder)) {
+    dir.create(cfg$results_folder, recursive = TRUE, showWarnings = FALSE)
+  } else if (!force) {
+    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")
+    unlink(cfg$results_folder, recursive = TRUE)
+    dir.create(cfg$results_folder, recursive = TRUE, showWarnings = FALSE)
+  }
+  
   # Copy important files into output_folder (before REMIND execution)
   .copy.fromlist(cfg$files2export$start,cfg$results_folder)
 
@@ -305,26 +271,9 @@ start_run <- function(cfg, scenario = NULL, report = NULL, sceninreport = NULL,
   # Save configuration
   save(cfg, file = path(cfg$results_folder, "config.Rdata"))
 
-  if (grepl("_UBA_Sust",cfg$title)){
-    replace_in_file(file    = "./modules/29_CES_parameters/load/datainput.gms",
-                    content = paste0('$include "./modules/29_CES_parameters/load/input/',cfg$gms$cm_CES_configuration,'_UBA.inc"'),
-                    subject = "CES INPUT")
-  } else {
-    replace_in_file(file    = "./modules/29_CES_parameters/load/datainput.gms",
-                    content = paste0('$include "./modules/29_CES_parameters/load/input/',cfg$gms$cm_CES_configuration,'.inc"'),
-                    subject = "CES INPUT")
-  }
- 
   # Merge GAMS files
   singleGAMSfile(mainfile=cfg$model,output = path(cfg$results_folder, "full.gms"))
   
-#   # Check for illegal declaration - e.g. regi instead of all_regi 
-#   a <- codeExtract(path(cfg$results_folder, "full.gms"),"code")
-#   regi <- found <- grep("(^|,)regi(,|$)",a$declarations[,"sets"])
-#   if(length(regi <- found)>0) {
-#       stop("Some objects are declared over regi instead of regi_all! This is illegal, stopping. Check these declarations please: (",   paste(a$declarations[regi <- found,"names"],collapse=", "),")")
-#   }
-  
   # Collect run statistics (will be saved to central database in submit.R)
   lucode::runstatistics(file = paste0(cfg$results_folder,"/runstatistics.rda"),
                         user = Sys.info()[["user"]],
@@ -345,21 +294,21 @@ start_run <- function(cfg, scenario = NULL, report = NULL, sceninreport = NULL,
   
   setwd(cfg$results_folder)
   
-  # Determine if REMIND is to be run in sequential order or not
-  if (is.na(cfg$sequential)) {
+  # Decide whether the runs should be send to slurm (TRUE) or executed directly (FALSE)
+  if (is.na(cfg$sendToSlurm)) {
     if (on_cluster) {
-      cfg$sequential <- FALSE
+      cfg$sendToSlurm <- TRUE
     } else {
-      cfg$sequential <- TRUE
+      cfg$sendToSlurm <- FALSE
     }
   }
 
-  # "Compilation only" is always sequential
-  if (cfg$action == "c") cfg$sequential <- TRUE
+  # "Compilation only" is always executed directly
+  if (cfg$action == "c") cfg$sendToSlurm <- FALSE
   
   # Call appropriate submit script
-  if (!cfg$sequential) {
-      # parallel
+  if (cfg$sendToSlurm) {
+      # send to slurm
       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"))
@@ -380,7 +329,7 @@ start_run <- function(cfg, scenario = NULL, report = NULL, sceninreport = NULL,
           }
       }
   } else {
-      # sequential
+      # execute directly
       system("Rscript submit.R")
   }
   
diff --git a/standalone/MOFEX/MOFEX.gms b/standalone/MOFEX/MOFEX.gms
index 57b17aa..0422399 100644
--- a/standalone/MOFEX/MOFEX.gms
+++ b/standalone/MOFEX/MOFEX.gms
@@ -134,8 +134,6 @@ cm_bioenergymaxscen   "bound on global pebiolc production excluding residues"
 c_tradecost_bio       "choose financal tradecosts for biomass (purpose grown pebiolc)"
 c_1stgen_phaseout    "choose if 1st generation biofuels should phase out after 2030 (vm_deltaCap=0)"
 cm_startyear          "first optimized modelling time step"
-cm_stagestart             "start of staged accession for delay runs"
-cm_stageend                       "end of staged accession for delay runs"
 c_start_budget        "start of GHG budget limit"
 cm_prtpScen            "pure rate of time preference standard values"
 cm_fetaxscen          "choice of final energy tax path, subsidy path and inconvenience cost path, values other than 0 make setting module 21_tax on"
@@ -229,8 +227,6 @@ $setglobal c_GDPpcScen  SSP2     !! def = gdp_SSP2   (automatically adjusted in
 
 *AG* and *CB* for cm_startyear greater than 2005, you have to copy the fulldata.gdx (rename it to: input_ref.gdx) from the run you want to build your new run onto.
 cm_startyear      = 2005;      !! def = 2005 for a BAU, 2015 for policy runs
-cm_stagestart     = 2020;      !! def = 2020
-cm_stageend       = 2040;      !! def = 2040
 c_start_budget    = 2100;      !! def = 2100
 
 cm_prtpScen         = 3;         !! def = 3
diff --git a/standalone/template.gms b/standalone/template.gms
index 2465aa9..598d8ba 100644
--- a/standalone/template.gms
+++ b/standalone/template.gms
@@ -142,8 +142,6 @@ cm_bioenergymaxscen   "bound on global pebiolc production excluding residues"
 c_tradecost_bio       "choose financal tradecosts for biomass (purpose grown pebiolc)"
 c_1stgen_phaseout    "choose if 1st generation biofuels should phase out after 2030 (vm_deltaCap=0)"
 cm_startyear          "first optimized modelling time step"
-cm_stagestart             "start of staged accession for delay runs"
-cm_stageend                       "end of staged accession for delay runs"
 c_start_budget        "start of GHG budget limit"
 cm_prtpScen            "pure rate of time preference standard values"
 cm_fetaxscen          "choice of final energy tax path, subsidy path and inconvenience cost path, values other than 0 make setting module 21_tax on"
@@ -237,8 +235,6 @@ $setglobal c_GDPpcScen  SSP2     !! def = gdp_SSP2   (automatically adjusted in
 
 *AG* and *CB* for cm_startyear greater than 2005, you have to copy the fulldata.gdx (rename it to: input_ref.gdx) from the run you want to build your new run onto.
 cm_startyear      = 2005;      !! def = 2005 for a BAU, 2015 for policy runs
-cm_stagestart     = 2020;      !! def = 2020
-cm_stageend       = 2040;      !! def = 2040
 c_start_budget    = 2100;      !! def = 2100
 
 cm_prtpScen         = 3;         !! def = 3
diff --git a/start_bundle.R b/start_bundle.R
index 085d4db..75cb017 100644
--- a/start_bundle.R
+++ b/start_bundle.R
@@ -101,8 +101,7 @@ for (scen in rownames(scenarios)) {
   # Define path where the GDXs will be taken from
   gdxlist <- c(input.gdx     = settings[scen, "path_gdx"],
                input_ref.gdx = settings[scen, "path_gdx_ref"],
-               input_bau.gdx = settings[scen, "path_gdx_bau"],
-               input_opt.gdx = settings[scen, "path_gdx_opt"])
+               input_bau.gdx = settings[scen, "path_gdx_bau"])
 
   # Remove potential elements that contain ".gdx" and append gdxlist
   cfg$files2export$start <- .setgdxcopy(".gdx", cfg$files2export$start, gdxlist)
diff --git a/start_bundle_climate.R b/start_bundle_climate.R
index e42b728..fbbffd3 100644
--- a/start_bundle_climate.R
+++ b/start_bundle_climate.R
@@ -104,8 +104,7 @@ for (scen in rownames(scenarios)) {
   # Define path where the GDXs will be taken from
   gdxlist <- c(input.gdx     = settings[scen, "path_gdx"],
                input_ref.gdx = settings[scen, "path_gdx_ref"],
-               input_bau.gdx = settings[scen, "path_gdx_bau"],
-               input_opt.gdx = settings[scen, "path_gdx_opt"])
+               input_bau.gdx = settings[scen, "path_gdx_bau"])
 
   # Remove potential elements that contain ".gdx" and append gdxlist
   cfg$files2export$start <- .setgdxcopy(".gdx", cfg$files2export$start, gdxlist)
diff --git a/start_bundle_coupled.R b/start_bundle_coupled.R
index c5ff1e4..f0bc632 100644
--- a/start_bundle_coupled.R
+++ b/start_bundle_coupled.R
@@ -248,8 +248,7 @@ for(scen in common){
   # Create list of previously defined paths to gdxs
   gdxlist <- c(input.gdx     = settings_remind[scen, "path_gdx"], # eventually this was updated if older runs exists in this folder (see above)
                input_ref.gdx = settings_remind[scen, "path_gdx_ref"],
-               input_bau.gdx = settings_remind[scen, "path_gdx_bau"],
-               input_opt.gdx = settings_remind[scen, "path_gdx_opt"])
+               input_bau.gdx = settings_remind[scen, "path_gdx_bau"])
 
   # Remove potential elements that contain ".gdx" and append gdxlist
   cfg_rem$files2export$start <- .setgdxcopy(".gdx",cfg_rem$files2export$start,gdxlist)
@@ -267,7 +266,6 @@ for(scen in common){
       # using the scenario names given in the columns path_gdx_ref and path_gdx_ref in the REMIND standalone scenario config
       cfg_rem$files2export$start['input_ref.gdx'] <- paste0(path_remind,"output/",prefix_runname,settings_remind[scen,"path_gdx_ref"],"-rem-",max_iterations,"/fulldata.gdx")
       cfg_rem$files2export$start['input_bau.gdx'] <- paste0(path_remind,"output/",prefix_runname,settings_remind[scen,"path_gdx_bau"],"-rem-",max_iterations,"/fulldata.gdx")
-      cfg_rem$files2export$start['input_opt.gdx'] <- paste0(path_remind,"output/",prefix_runname,settings_remind[scen,"path_gdx_opt"],"-rem-",max_iterations,"/fulldata.gdx")
       
       # If the preceding run has already finished (= their gdx files exist) start the current run immediately.
       # This might be the case e.g. if you started the baseline and NDC runs in a first batch and now want to start the subsequent policy runs by hand after the baselines have finished
@@ -297,7 +295,6 @@ for(scen in common){
   cat("remind gdx  : ",ifelse(file.exists(cfg_rem$files2export$start["input.gdx"]),green,red), cfg_rem$files2export$start["input.gdx"], NC, "\n",sep="")
   cat("ref_gdx     : ",ifelse(file.exists(cfg_rem$files2export$start["input_ref.gdx"]),green,red), cfg_rem$files2export$start["input_ref.gdx"], NC, "\n",sep="")
   cat("bau_gdx     : ",ifelse(file.exists(cfg_rem$files2export$start["input_bau.gdx"]),green,red), cfg_rem$files2export$start["input_bau.gdx"], NC, "\n",sep="")
-  cat("opt_gdx     : ",ifelse(file.exists(cfg_rem$files2export$start["input_opt.gdx"]),green,red), cfg_rem$files2export$start["input_opt.gdx"], NC, "\n",sep="")
   cat("path_report : ",ifelse(file.exists(path_report),green,red), path_report, NC, "\n",sep="")
   cat("LU_pricing  :",LU_pricing,"\n")
  
-- 
GitLab