diff --git a/README.md b/README.md
index d725c948a03811f839528ec3976cb828b75d1ea4..54db8cd5e4d2385fc9b2004c87e9fbbe0cf3f133 100644
--- a/README.md
+++ b/README.md
@@ -67,7 +67,7 @@ In addition *R* (https://www.r-project.org/) is required for pre- and
 postprocessing and run management (needs to be added to the PATH variable
 as well).
 
-For R some packages are required to run REMIND. All except of one (`gdxrrw`) are
+Some R packages are required to run REMIND. All except of one (`gdxrrw`) are
 either distributed via the offical R CRAN or via a separate repository hosted at
 PIK (PIK-CRAN). Before proceeding PIK-CRAN should be added to the list of
 available repositories via:
@@ -114,20 +114,20 @@ Make sure that the config file has been set correctly before
 starting the model.
 
 ## HOW TO CONTRIBUTE
-We are interested in working with you! Just contact us through GitHub
-(https://github.com/remindmodel) or by mail (remind@pik-potsdam.de) if you have
+We are interested in working with you! Contact us through GitHub
+(https://github.com/remindmodel) or by E-mail (remind@pik-potsdam.de) if you have
 found and/or fixed a bug, developed a new model feature, have ideas for further
-model development, suggestions for improvements or anything else. We are open to
+model development or suggestions for improvements. We are open to
 any kind of contribution. Our aim is to develop an open, transparent and
-meaningful energy-economy-model to get a better
-understanding of the underlying processes and possible futures. Join us doing
+meaningful energy-economy-model, and to get a better
+understanding of the underlying processes and possible futures. Join us in doing
 so!
 
 ## DEPENDENCIES
 Model dependencies **must be publicly available** and should be Open Source.
 Development aim is to rather minimize than expand dependencies on non-free
 and/or non open source software. That means that besides currently existing
-dependencies on GAMS, the GDXRRW R package and the corresponding solvers there
+dependencies on GAMS, the `gdxrrw` R package and the corresponding solvers there
 should be no additional dependencies of this kind and that these existing
 dependencies should be resolved in the future if possible.
 
diff --git a/cluster_start_bundle.cmd b/cluster_start_bundle.cmd
deleted file mode 100644
index 246d9e9de1bb35a7ce39b889b81f34db4a6e8f70..0000000000000000000000000000000000000000
--- a/cluster_start_bundle.cmd
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-#SBATCH --qos=short
-#SBATCH --job-name=start_bundle
-#SBATCH --output=log.txt
-#SBATCH --mail-type=END
-
-Rscript start_bundle.R
diff --git a/cluster_start_coupled.cmd b/cluster_start_coupled.cmd
deleted file mode 100644
index 9d90fff0944e05ddb22cf0adc9e117bbf070423b..0000000000000000000000000000000000000000
--- a/cluster_start_coupled.cmd
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/bash
-
-#--- New Cluster Job Submission parameters ------
-#SBATCH --qos=priority
-#SBATCH --job-name=start_coupled
-#SBATCH --output=log.txt
-#SBATCH --nodes=1
-#SBATCH --tasks-per-node=1
-#SBATCH --mail-type=END
-#------------------------------------------------
-
-Rscript start_coupled.R coupled_config=SSP1_RCP45_nash.RData
diff --git a/config/conopt3.op4 b/config/conopt3.op4
deleted file mode 100644
index ee300d6cc82e50b1377f83b4c3e0a7db523a9fce..0000000000000000000000000000000000000000
--- a/config/conopt3.op4
+++ /dev/null
@@ -1,10 +0,0 @@
-rtnwtr = 1.e-7;
-lfnicr = 1000;
-lfstal = 1000;
-lfilog = 500;
-rtredg = 1.d-7;
-rvhess 100;
-lfdegi 500;
-lfnsup 7000;
-rtmins 0.0009765625;
-rtnwmi = 1.d-9;
diff --git a/config/conopt3.op5 b/config/conopt3.op5
deleted file mode 100644
index ee300d6cc82e50b1377f83b4c3e0a7db523a9fce..0000000000000000000000000000000000000000
--- a/config/conopt3.op5
+++ /dev/null
@@ -1,10 +0,0 @@
-rtnwtr = 1.e-7;
-lfnicr = 1000;
-lfstal = 1000;
-lfilog = 500;
-rtredg = 1.d-7;
-rvhess 100;
-lfdegi 500;
-lfnsup 7000;
-rtmins 0.0009765625;
-rtnwmi = 1.d-9;
diff --git a/config/conopt3.op8 b/config/conopt3.op8
deleted file mode 100644
index b3cd02178303ff4acab07d07ce2c828e7598c4a0..0000000000000000000000000000000000000000
--- a/config/conopt3.op8
+++ /dev/null
@@ -1,10 +0,0 @@
-rtnwtr = 1.e-7;
-lfnicr = 1000;
-lfstal = 1000;
-lfilog = 500;
-rtredg = 1.d-8;
-rvhess 100;
-lfdegi 500;
-lfnsup 7000;
-rtmins 0.0009765625;
-rtnwmi = 1.d-9;
diff --git a/config/conopt4.op2 b/config/conopt4.op2
deleted file mode 100644
index 0bd27e75f4598e4854169c14683ac57ea368e768..0000000000000000000000000000000000000000
--- a/config/conopt4.op2
+++ /dev/null
@@ -1,10 +0,0 @@
-rtnwtr = 1.e-7;
-lfnicr = 1000;
-lfstal = 1000;
-lfilog = 500;
-rtredg = 1.d-6;
-rvhess 100;
-lfdegi 500;
-lfnsup 7000;
-rtmins 0.0009765625;
-rtnwmi = 1.d-9;
diff --git a/config/conopt4.op3 b/config/conopt4.op3
deleted file mode 100644
index ee300d6cc82e50b1377f83b4c3e0a7db523a9fce..0000000000000000000000000000000000000000
--- a/config/conopt4.op3
+++ /dev/null
@@ -1,10 +0,0 @@
-rtnwtr = 1.e-7;
-lfnicr = 1000;
-lfstal = 1000;
-lfilog = 500;
-rtredg = 1.d-7;
-rvhess 100;
-lfdegi 500;
-lfnsup 7000;
-rtmins 0.0009765625;
-rtnwmi = 1.d-9;
diff --git a/config/conopt4.op4 b/config/conopt4.op4
deleted file mode 100644
index ee300d6cc82e50b1377f83b4c3e0a7db523a9fce..0000000000000000000000000000000000000000
--- a/config/conopt4.op4
+++ /dev/null
@@ -1,10 +0,0 @@
-rtnwtr = 1.e-7;
-lfnicr = 1000;
-lfstal = 1000;
-lfilog = 500;
-rtredg = 1.d-7;
-rvhess 100;
-lfdegi 500;
-lfnsup 7000;
-rtmins 0.0009765625;
-rtnwmi = 1.d-9;
diff --git a/config/conopt4.op5 b/config/conopt4.op5
deleted file mode 100644
index ee300d6cc82e50b1377f83b4c3e0a7db523a9fce..0000000000000000000000000000000000000000
--- a/config/conopt4.op5
+++ /dev/null
@@ -1,10 +0,0 @@
-rtnwtr = 1.e-7;
-lfnicr = 1000;
-lfstal = 1000;
-lfilog = 500;
-rtredg = 1.d-7;
-rvhess 100;
-lfdegi 500;
-lfnsup 7000;
-rtmins 0.0009765625;
-rtnwmi = 1.d-9;
diff --git a/config/conopt4.op8 b/config/conopt4.op8
deleted file mode 100644
index b3cd02178303ff4acab07d07ce2c828e7598c4a0..0000000000000000000000000000000000000000
--- a/config/conopt4.op8
+++ /dev/null
@@ -1,10 +0,0 @@
-rtnwtr = 1.e-7;
-lfnicr = 1000;
-lfstal = 1000;
-lfilog = 500;
-rtredg = 1.d-8;
-rvhess 100;
-lfdegi 500;
-lfnsup 7000;
-rtmins 0.0009765625;
-rtnwmi = 1.d-9;
diff --git a/config/conopt4.op9 b/config/conopt4.op9
deleted file mode 100644
index f2a6e21babc280337a33da66d054a9687d13522b..0000000000000000000000000000000000000000
--- a/config/conopt4.op9
+++ /dev/null
@@ -1,10 +0,0 @@
-rtnwtr = 1.e-7;
-lfnicr = 1000;
-lfstal = 1000;
-lfilog = 500;
-rtredg = 1.d-9;
-rvhess 100;
-lfdegi 500;
-lfnsup 7000;
-rtmins 0.0009765625;
-rtnwmi = 1.d-9;
diff --git a/config/conopt4.opt b/config/conopt4.opt
deleted file mode 100644
index 81e2b17d47959027cb52c29499dbb785c5c07ce7..0000000000000000000000000000000000000000
--- a/config/conopt4.opt
+++ /dev/null
@@ -1,10 +0,0 @@
-rtnwtr = 1.e-7;
-lfnicr = 1000;
-lfstal = 1000;
-lfilog = 500;
-rtredg = 1.d-5;
-rvhess 100;
-lfdegi 500;
-lfnsup 7000;
-rtmins 0.0009765625;
-rtnwmi = 1.d-9;
diff --git a/config/default.cfg b/config/default.cfg
index 1306d4315a095088ea60636ae810f8f0b3f55918..0e3d8fb200289b5abda3f310dec91808c45beee8 100755
--- a/config/default.cfg
+++ b/config/default.cfg
@@ -22,11 +22,14 @@ cfg$title <- "default"
 cfg$regionmapping <- "config/regionmappingH12.csv"
 
 #### Current input data revision (<mainrevision>.<subrevision>) ####
-cfg$revision <- 5.937
+cfg$revision <- 5.938
 
 #### Force the model to download new input data ####
 cfg$force_download <- FALSE
 
+# Should an existing output folder be replaced if a new run with the same name is started?
+cfg$force_replace <- FALSE
+
 #### list of repositories containing input data
 # defined in your local .Rprofile or on the cluster /p/projects/rd3mod/R/.Rprofile
 cfg$repositories <- getOption("remind_repos")
@@ -280,7 +283,7 @@ cfg$gms$cm_bioenergy_tax     <- 1.5     # def <- 1.5
 cfg$gms$cm_bioenergymaxscen  <- 0       # def <- 0
 cfg$gms$cm_tradecost_bio      <- 2       # def <- 2
 cfg$gms$cm_LU_emi_scen       <- "SSP2"  # def <- "SSP2"
-cfg$gms$c_1stgen_phaseout   <- 0       # def <- 0
+cfg$gms$cm_1stgen_phaseout   <- 0       # def <- 0
 cfg$gms$cm_cprice_red_factor <- 0.5  	# def = 0.5
 
 cfg$gms$cm_POPscen            <- "pop_SSP2"     # def <- "pop_SSP2"
@@ -354,7 +357,7 @@ cfg$gms$cm_CO2priceRegConvEndYr         <- 2050     # def <- 2050
 cfg$gms$c_regi_nucscen <- "all" # def <- "all"
 cfg$gms$c_regi_capturescen <- "all" # def <- "all"
 
-cfg$gms$cm_EDGEtr_scen       <- "Conservative_liquids"     # def <- "conservative"
+cfg$gms$cm_EDGEtr_scen       <- "Conservative_liquids"     # def <- "Conservative_liquids"
 
 #-----------------------------------------------------------------------------
 #                          FLAGS
@@ -376,7 +379,7 @@ cfg$gms$cm_APscen              <- "SSP2"  # def <- SSP2
 cfg$gms$cm_Full_Integration    <- "off"   # def = off
 
 cfg$gms$c_CO2priceDependent_AdjCosts    <- "on"   # def = on
-cfg$gms$c_scaleEmiHistorical   <- "off"    # def = off
+cfg$gms$c_scaleEmiHistorical   <- "on"    # def = on
 
 # MAGICC configuration (AJS)
 # Calibrate year 2000 temperature to HADCRUT4 data (which is very close to AR5).
@@ -413,9 +416,8 @@ 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 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
+# Specify the way REMIND will be run on the cluster (job class, number of nodes, ...) or locally  ("direct")
+cfg$slurmConfig <- "direct"
 
 # Should REMIND output be shown in console? (0:no, 2:logfile, 3:yes)
 cfg$logoption <- 2
@@ -433,22 +435,17 @@ cfg$files2export <- list()
 cfg$files2export$start <- c("config/conopt3.opt",
                             "config/conopt3.op2",
                             "config/conopt3.op3",
-                            "config/conopt3.op4",
-                            "config/conopt3.op5",
-                            "config/conopt3.op8",
                             "config/conopt3.op9",
-                            "scripts/run_submit/submit.cmd",
-                            "scripts/run_submit/submit.R",
-                            "scripts/run_submit/run_magicc.R",
-                            "scripts/run_submit/run_magicc_temperatureImpulseResponse.R",
-                            "scripts/run_submit/read_DAT_TOTAL_ANTHRO_RF.R",
-                            "scripts/run_submit/read_DAT_SURFACE_TEMP.R",
+                            "core/magicc/run_magicc.R",
+                            "core/magicc/run_magicc_temperatureImpulseResponse.R",
+                            "core/magicc/read_DAT_TOTAL_ANTHRO_RF.R",
+                            "core/magicc/read_DAT_SURFACE_TEMP.R",
                             "core/input/historical/historical.mif",
                             "scripts/input/exoGAINSAirpollutants.R",
-			    "scripts/iterative/EDGE_transport.R",
+                            "scripts/iterative/EDGE_transport.R",
                             "config/input.gdx",
                             "config/input_ref.gdx",
-			    "core/magicc",
+                            "core/magicc",
                             ".Rprofile",
                             "config/mappingEDGEtoREMINDsectors.csv")
 
@@ -551,7 +548,7 @@ cfg$RunsUsingTHISgdxAsBAU <- NA
 #  (SSP1): emissions (from SSP1 scenario in MAgPIE)
 #  (SSP2): emissions (from SSP2 scenario in MAgPIE)
 #  (SSP5): emissions (from SSP5 scenario in MAgPIE)
-# c_1stgen_phaseout "choose if 1st generation biofuels should phase out after 2030 (deltacap=0)"
+# cm_1stgen_phaseout "choose if 1st generation biofuels should phase out after 2030 (deltacap=0)"
 #  (0): 1st generation biofuels after 2020 are fixed at upper limit of resource potential (maxprod)
 #  (1): no new capacities for 1st generation biofuel technologies may be built after 2030 -> phaseout until ~2060
 # cm_POPscen      "Population growth scenarios from UN data and IIASA projection used in SSP"
diff --git a/config/old_scenario_config/scenario_config_EMF33.csv b/config/old_scenario_config/scenario_config_EMF33.csv
index 83f74a86d9731423832973e3da7eed90a379456c..04e2fec706af0666e619eceba012dfb855b3a59e 100644
--- a/config/old_scenario_config/scenario_config_EMF33.csv
+++ b/config/old_scenario_config/scenario_config_EMF33.csv
@@ -1,4 +1,4 @@
-title;start;cm_iteration_max;c_solver_try_max;cm_bioenergy_tax;cm_SlowConvergence;optimization;cm_postproc;climate;cm_emiscen;cm_iterative_target_adj;cm_gdximport_target;c_budgetCO2FFI;carbonprice;cm_co2_tax_2020;cm_co2_tax_growth;cm_rcp_scen;cm_POPscen;cm_GDPscen;cm_oil_scen;cm_gas_scen;cm_coal_scen;c_feintensscen;c_techAssumptScen;cm_nucscen;c_abtrdy;c_abtcst;cm_ccsscen;c_bioliqscen;c_bioh2scen;c_ccscapratescen;c_biocostscen;c_1stgen_phaseout;cm_bioenergymaxscen;cm_fetaxscen;cm_so2tax_scen;cm_multigasscen;c_EARLYRETIRE;cm_OILRETIRE;cm_LU_emi_scen;cm_tradecost_bio;c_SSP_forcing_adjust;cm_APscen;cm_startyear;path_gdx;path_gdx_bau;path_gdx_ref;path_gdx_opt;path_mif_bau
+title;start;cm_iteration_max;c_solver_try_max;cm_bioenergy_tax;cm_SlowConvergence;optimization;cm_postproc;climate;cm_emiscen;cm_iterative_target_adj;cm_gdximport_target;c_budgetCO2FFI;carbonprice;cm_co2_tax_2020;cm_co2_tax_growth;cm_rcp_scen;cm_POPscen;cm_GDPscen;cm_oil_scen;cm_gas_scen;cm_coal_scen;c_feintensscen;c_techAssumptScen;cm_nucscen;c_abtrdy;c_abtcst;cm_ccsscen;c_bioliqscen;c_bioh2scen;c_ccscapratescen;c_biocostscen;cm_1stgen_phaseout;cm_bioenergymaxscen;cm_fetaxscen;cm_so2tax_scen;cm_multigasscen;c_EARLYRETIRE;cm_OILRETIRE;cm_LU_emi_scen;cm_tradecost_bio;c_SSP_forcing_adjust;cm_APscen;cm_startyear;path_gdx;path_gdx_bau;path_gdx_ref;path_gdx_opt;path_mif_bau
 SSP2-R1-BASE-0-full;1;6;3;1.5;on;negishi;0;magicc;1;0;0;0;none;-1;1;rcp26;pop_SSP2;gdp_SSP2;2;2;2;0;1;2;2015;1;1;1;1;1;2;0;0;3;2;2;on;on;SSP2;2;forcing_SSP2;SSP2;2005;;;;;
 SSP2-R1-BASE-0-full-nash;1;6;3;1.5;on;nash;0;magicc;1;0;0;0;none;-1;1;rcp26;pop_SSP2;gdp_SSP2;2;2;2;0;1;2;2015;1;1;1;1;1;2;0;0;3;2;2;on;on;SSP2;2;forcing_SSP2;SSP2;2005;;;;;
 SSP2-R1-P-lo-full;1;6;3;1.5;on;negishi;0;magicc;9;0;0;0;exponential;20;1.03;rcp37;pop_SSP2;gdp_SSP2;2;2;2;0;1;2;2015;1;1;1;1;1;2;0;0;3;2;2;on;on;SSP2;2;forcing_SSP2;SSP2;2020;;;;;
diff --git a/config/old_scenario_config/scenario_config_SSP.csv b/config/old_scenario_config/scenario_config_SSP.csv
index 4e8a2169774250815e3f5a4a5431ea0c7dafc2d2..b09dcd0d085fd14fb75999c684cca42543c98c96 100644
--- a/config/old_scenario_config/scenario_config_SSP.csv
+++ b/config/old_scenario_config/scenario_config_SSP.csv
@@ -1,4 +1,4 @@
-title;start;cm_iteration_max;c_solver_try_max;cm_bioenergy_tax;cm_SlowConvergence;climate;cm_iterative_target_adj;cm_gdximport_target;optimization;cm_postproc;cm_emiscen;carbonprice;cm_co2_tax_2020;cm_rcp_scen;cm_POPscen;cm_GDPscen;cm_oil_scen;cm_gas_scen;cm_coal_scen;c_feintensscen;c_techAssumptScen;cm_nucscen;c_ccscapratescen;c_biocostscen;c_1stgen_phaseout;cm_bioenergymaxscen;cm_fetaxscen;cm_so2tax_scen;cm_multigasscen;c_EARLYRETIRE;cm_OILRETIRE;cm_LU_emi_scen;cm_tradecost_bio;c_SSP_forcing_adjust;cm_APscen;cm_startyear;cm_stagestart;cm_stageend;c_refcapbnd;c_tau_so2_xmpt;path_gdx;path_gdx_bau;path_gdx_ref;path_gdx_opt;path_mif_bau;path_gdx_SSP2ref
+title;start;cm_iteration_max;c_solver_try_max;cm_bioenergy_tax;cm_SlowConvergence;climate;cm_iterative_target_adj;cm_gdximport_target;optimization;cm_postproc;cm_emiscen;carbonprice;cm_co2_tax_2020;cm_rcp_scen;cm_POPscen;cm_GDPscen;cm_oil_scen;cm_gas_scen;cm_coal_scen;c_feintensscen;c_techAssumptScen;cm_nucscen;c_ccscapratescen;c_biocostscen;cm_1stgen_phaseout;cm_bioenergymaxscen;cm_fetaxscen;cm_so2tax_scen;cm_multigasscen;c_EARLYRETIRE;cm_OILRETIRE;cm_LU_emi_scen;cm_tradecost_bio;c_SSP_forcing_adjust;cm_APscen;cm_startyear;cm_stagestart;cm_stageend;c_refcapbnd;c_tau_so2_xmpt;path_gdx;path_gdx_bau;path_gdx_ref;path_gdx_opt;path_mif_bau;path_gdx_SSP2ref
 SSP1-Ref-SPA0;1;8;3;1.75;on;off;0;0;negishi;0;1;none;-1;none;pop_SSP1;gdp_SSP1;1;1;1;1;2;2;1;1;1;0;2;4;2;on;off;SSP1;1;forcing_SSP1;SSP1;2005;2020;2040;0;0;/p/projects/ssp/submission_v15_v16/remind16_v15_r6192/output/rem6192_SSP1-Ref-SPA0-rem-5/fulldata.gdx;;;;;
 SSP1-20-SPA0;1;8;3;1.75;on;magicc;2;1;negishi;0;6;none;-1;rcp20;pop_SSP1;gdp_SSP1;1;1;1;1;2;2;1;1;1;0;2;4;2;on;on;SSP1;1;forcing_SSP1;SSP1;2015;2020;2040;0;0;/p/projects/ssp/submission_v15_v16/remind16_v15_r6192/output/rem6192_SSP1-20-SPA0-rem-5/fulldata.gdx;/p/projects/ssp/submission_v15_v16/remind16_v15_r6192/output/rem6192_SSP1-Ref-SPA0-rem-5/fulldata.gdx;;;;
 SSP1-26-SPA0;1;8;3;1.75;on;magicc;2;1;negishi;0;6;none;-1;rcp26;pop_SSP1;gdp_SSP1;1;1;1;1;2;2;1;1;1;0;2;4;2;on;on;SSP1;1;forcing_SSP1;SSP1;2015;2020;2040;0;0;/p/projects/ssp/submission_v15_v16/remind16_v15_r6192/output/rem6192_SSP1-26-SPA0-rem-5/fulldata.gdx;/p/projects/ssp/submission_v15_v16/remind16_v15_r6192/output/rem6192_SSP1-Ref-SPA0-rem-5/fulldata.gdx;;;;
diff --git a/config/old_scenario_config/scenario_config_Validation2018.csv b/config/old_scenario_config/scenario_config_Validation2018.csv
index 2052302f98fea9008e22fa9a07918bef4630ca1f..dd6ef253219c9e925f4018995d8ff0f98907e3a7 100644
--- a/config/old_scenario_config/scenario_config_Validation2018.csv
+++ b/config/old_scenario_config/scenario_config_Validation2018.csv
@@ -1,4 +1,4 @@
-title;start;cm_iteration_max;cm_bioenergy_tax;climate;c_budgetCO2;cm_iterative_target_adj;optimization;transport;buildings;industry;stationary;cm_emiscen;carbonprice;cm_co2_tax_2020;cm_rcp_scen;techpol;cm_multigasscen;cm_POPscen;cm_GDPscen;cm_oil_scen;cm_gas_scen;cm_coal_scen;c_feintensscen;c_techAssumptScen;cm_nucscen;c_ccscapratescen;c_1stgen_phaseout;cm_fetaxscen;cm_so2tax_scen;cm_OILRETIRE;cm_LU_emi_scen;cm_tradecost_bio;c_SSP_forcing_adjust;cm_APscen;c_refcapbnd;c_tau_so2_xmpt;cm_startyear;path_gdx;path_gdx_ref;path_gdx_bau;path_gdx_opt
+title;start;cm_iteration_max;cm_bioenergy_tax;climate;c_budgetCO2;cm_iterative_target_adj;optimization;transport;buildings;industry;stationary;cm_emiscen;carbonprice;cm_co2_tax_2020;cm_rcp_scen;techpol;cm_multigasscen;cm_POPscen;cm_GDPscen;cm_oil_scen;cm_gas_scen;cm_coal_scen;c_feintensscen;c_techAssumptScen;cm_nucscen;c_ccscapratescen;cm_1stgen_phaseout;cm_fetaxscen;cm_so2tax_scen;cm_OILRETIRE;cm_LU_emi_scen;cm_tradecost_bio;c_SSP_forcing_adjust;cm_APscen;c_refcapbnd;c_tau_so2_xmpt;cm_startyear;path_gdx;path_gdx_ref;path_gdx_bau;path_gdx_opt
 SSP1-Base;0;8;1.75;off;0;0;nash;complex;simple;fixed_shares;off;1;none;-1;none;none;2;pop_SSP1;gdp_SSP1;lowOil;lowGas;lowCoal;1;2;2;1;1;2;4;off;SSP1;1;forcing_SSP1;SSP1;0;0;2005;/p/projects/remind/runs/r7745/output/BAU_Nash_2018-01-18_14.42.32/fulldata.gdx;;;
 SSP1-Ref;0;8;1.75;off;0;3;nash;complex;simple;fixed_shares;off;9;RefPolicies;1;rcp60;RefPolicies;3;pop_SSP1;gdp_SSP1;lowOil;lowGas;lowCoal;1;2;2;1;1;2;4;off;SSP1;1;forcing_SSP1;SSP1;0;0;2025;/p/projects/remind/runs/r7745/output/BAU_Nash_2018-01-18_14.42.32/fulldata.gdx;SSP1-INDC;BAU;
 SSP1-INDC;0;8;1.75;off;0;3;nash;complex;simple;fixed_shares;off;9;NDC;1;rcp45;NDC;3;pop_SSP1;gdp_SSP1;lowOil;lowGas;lowCoal;1;2;2;1;1;2;4;off;SSP1;1;forcing_SSP1;SSP1;0;0;2015;/p/projects/remind/runs/r7745/output/BAU_Nash_2018-01-18_14.42.32/fulldata.gdx;SSP1-Base;REF;
diff --git a/config/old_scenario_config/scenario_config_calibrateSSPs.csv b/config/old_scenario_config/scenario_config_calibrateSSPs.csv
index 4497b436a7bfbe0588afcef1a2a92714bf8c6756..464f42f3d14cd0e8879984be1563f841cf6cad32 100644
--- a/config/old_scenario_config/scenario_config_calibrateSSPs.csv
+++ b/config/old_scenario_config/scenario_config_calibrateSSPs.csv
@@ -1,4 +1,4 @@
-title;start;CES_parameters;regionmapping;capitalMarket;c_CES_calibration_new_structure;c_CES_calibration_iterations;cm_iteration_max;c_solver_try_max;cm_bioenergy_tax;climate;c_budgetCO2;cm_iterative_target_adj;optimization;transport;buildings;industry;stationary;cm_emiscen;carbonprice;cm_co2_tax_2020;cm_rcp_scen;techpol;cm_multigasscen;cm_POPscen;cm_GDPscen;cm_oil_scen;cm_gas_scen;cm_coal_scen;c_techAssumptScen;cm_nucscen;c_ccscapratescen;c_biocostscen;c_1stgen_phaseout;cm_fetaxscen;cm_so2tax_scen;cm_OILRETIRE;cm_LU_emi_scen;cm_tradecost_bio;c_SSP_forcing_adjust;c_refcapbnd;c_tau_so2_xmpt;cm_startyear;path_gdx;path_gdx_ref;path_gdx_bau;path_gdx_opt
+title;start;CES_parameters;regionmapping;capitalMarket;c_CES_calibration_new_structure;c_CES_calibration_iterations;cm_iteration_max;c_solver_try_max;cm_bioenergy_tax;climate;c_budgetCO2;cm_iterative_target_adj;optimization;transport;buildings;industry;stationary;cm_emiscen;carbonprice;cm_co2_tax_2020;cm_rcp_scen;techpol;cm_multigasscen;cm_POPscen;cm_GDPscen;cm_oil_scen;cm_gas_scen;cm_coal_scen;c_techAssumptScen;cm_nucscen;c_ccscapratescen;c_biocostscen;cm_1stgen_phaseout;cm_fetaxscen;cm_so2tax_scen;cm_OILRETIRE;cm_LU_emi_scen;cm_tradecost_bio;c_SSP_forcing_adjust;c_refcapbnd;c_tau_so2_xmpt;cm_startyear;path_gdx;path_gdx_ref;path_gdx_bau;path_gdx_opt
 calibrate_SSP1_bit;0;calibrate;config/regionmappingH12.csv;perfect;0;10;8;3;1.75;off;0;0;nash;complex;simple;fixed_shares;off;1;none;-1;none;none;2;pop_SSP1;gdp_SSP1;lowOil;lowGas;lowCoal;2;2;1;1;1;2;4;off;SSP1;1;forcing_SSP1;0;0;2005;/p/tmp/levesque/Remind/r_6651_SSP/output/calibrate_SSP1_postIIASA_2016-09-01_16.46.27/fulldata.gdx;;;
 calibrate_SSP2_bit;1;calibrate;config/regionmappingREMIND.csv;perfect;0;10;8;3;1;off;0;0;nash;complex;simple;fixed_shares;off;1;none;-1;none;none;2;pop_SSP2;gdp_SSP2;medOil;medGas;medCoal;1;2;1;2;0;3;1;off;SSP2;2;forcing_SSP2;0;0;2005;config/input_H12.gdx;;;
 calibrate_SSP2_bit_H12;0;calibrate;config/regionmappingH12.csv;perfect;0;10;8;3;1;off;0;0;nash;complex;simple;fixed_shares;off;1;none;-1;none;none;2;pop_SSP2;gdp_SSP2;medOil;medGas;medCoal;1;2;1;2;0;3;1;off;SSP2;2;forcing_SSP2;0;0;2005;config/input_H12.gdx;;;
diff --git a/config/old_scenario_config/scenario_config_calibrateSSPs_H12.csv b/config/old_scenario_config/scenario_config_calibrateSSPs_H12.csv
index 85de3744ad43269ad43400b0d016ec9588ec5a6f..0e19c5844fc46a53128a7e35e635cd5aa24e7fa9 100644
--- a/config/old_scenario_config/scenario_config_calibrateSSPs_H12.csv
+++ b/config/old_scenario_config/scenario_config_calibrateSSPs_H12.csv
@@ -1,4 +1,4 @@
-title;start;CES_parameters;regionmapping;capitalMarket;c_CES_calibration_new_structure;c_CES_calibration_iterations;cm_iteration_max;c_solver_try_max;cm_bioenergy_tax;climate;c_budgetCO2;cm_iterative_target_adj;optimization;transport;buildings;industry;stationary;cm_emiscen;carbonprice;cm_co2_tax_2020;cm_rcp_scen;techpol;cm_multigasscen;cm_POPscen;cm_GDPscen;cm_oil_scen;cm_gas_scen;cm_coal_scen;c_techAssumptScen;cm_nucscen;c_ccscapratescen;c_1stgen_phaseout;cm_fetaxscen;cm_so2tax_scen;cm_OILRETIRE;cm_LU_emi_scen;cm_tradecost_bio;c_SSP_forcing_adjust;c_refcapbnd;c_tau_so2_xmpt;cm_startyear;path_gdx;path_gdx_ref;path_gdx_bau;path_gdx_opt
+title;start;CES_parameters;regionmapping;capitalMarket;c_CES_calibration_new_structure;c_CES_calibration_iterations;cm_iteration_max;c_solver_try_max;cm_bioenergy_tax;climate;c_budgetCO2;cm_iterative_target_adj;optimization;transport;buildings;industry;stationary;cm_emiscen;carbonprice;cm_co2_tax_2020;cm_rcp_scen;techpol;cm_multigasscen;cm_POPscen;cm_GDPscen;cm_oil_scen;cm_gas_scen;cm_coal_scen;c_techAssumptScen;cm_nucscen;c_ccscapratescen;cm_1stgen_phaseout;cm_fetaxscen;cm_so2tax_scen;cm_OILRETIRE;cm_LU_emi_scen;cm_tradecost_bio;c_SSP_forcing_adjust;c_refcapbnd;c_tau_so2_xmpt;cm_startyear;path_gdx;path_gdx_ref;path_gdx_bau;path_gdx_opt
 calibrate_SSP1_bit;1;calibrate;config/regionmappingH12.csv;perfect;0;10;8;3;1.75;off;0;0;nash;complex;simple;fixed_shares;off;1;none;-1;none;none;2;pop_SSP1;gdp_SSP1;lowOil;lowGas;lowCoal;2;2;1;1;2;4;off;SSP1;1;forcing_SSP1;0;0;2005;/home/levesque/gdx/r8018_H12_SSP1.gdx;;;
 calibrate_SSP2_bit;1;calibrate;config/regionmappingH12.csv;perfect;0;10;8;3;1;off;0;0;nash;complex;simple;fixed_shares;off;1;none;-1;none;none;2;pop_SSP2;gdp_SSP2;medOil;medGas;medCoal;2;2;1;0;3;1;off;SSP2;2;forcing_SSP2;0;0;2005;/home/levesque/gdx/r8018_H12_SSP2.gdx;;;
 calibrate_SSP5_bit;1;calibrate;config/regionmappingH12.csv;perfect;0;10;8;3;1.75;off;0;0;nash;complex;simple;fixed_shares;off;1;none;-1;none;none;2;pop_SSP5;gdp_SSP5;highOil;highGas;highCoal;3;6;2;1;1;4;off;SSP5;1;forcing_SSP5;1;0.5;2005;/home/levesque/gdx/r8018_H12_SSP5.gdx;;;
diff --git a/config/oneRegi.cfg b/config/oneRegi.cfg
deleted file mode 100644
index eda20deb98c2831e72e864fa550b8d27888a28a3..0000000000000000000000000000000000000000
--- a/config/oneRegi.cfg
+++ /dev/null
@@ -1,783 +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
-#################
-#### SETTINGS ####
-##################
-
-cfg <- list()
-
-#### Main settings ####
-
-#short description of the actual run
-cfg$title <- "testOneRegi"
-
-# path to the submodel to be used relative to main model folder (e.g."standalone/template.gms")
-#cfg$model <- "main.gms"   #def = "main.gms"
-
-#### region settings ####
-cfg$regionmapping <- "config/regionmappingH12.csv"
-
-#### Current input data revision (<mainrevision>.<subrevision>) ####
-cfg$revision <- 5.935
-
-#### Force the model to download new input data ####
-cfg$force_download <- FALSE
-
-#### list of repositories containing input data
-# defined in your local .Rprofile or on the cluster /p/projects/rd3mod/R/.Rprofile
-cfg$repositories <- getOption("remind_repos")
-
-#### Folder run statistics should be submitted to
-cfg$runstatistics <- "/p/projects/rd3mod/models/statistics/remind"
-
-#### name of the overall model (used for run statistics only)
-# should usually not be changed
-cfg$model_name <- "REMIND"
-
-#### model version of the overall model (used for run statistics only).
-# Use extension "-rc" for release candidate and "-dev" for developer version
-cfg$model_version <- "2.0-dev"
-
-#### settings ####
-cfg$gms <- list()
-
-# ***------------------------------------------------------------------------------
-# ***                           MODULES                   START
-# ***------------------------------------------------------------------------------
-
-# ***---------------------    04_PE_FE_parameters    ----------------------------
-# * (iea2014): new PE-FE parameters based on IEA 2014
-cfg$gms$PE_FE_parameters  <- "iea2014"   # def = iea2014
-
-# ***---------------------    05_initialCap    ----------------------------
-# * (on):      load existing CES parameters matching model configuration
-cfg$gms$initialCap  <- "on"   # def = on
-
-# ***---------------------    11_aerosols    ----------------------------------------
-# * (exoGAINS)   :
-cfg$gms$aerosols <- "exoGAINS"                 # def = exoGAINS
-
-# ***---------------------    15_climate    ----------------------------------------
-# * (off): no climate coupling
-# * (magicc): MAGICC - iterative mode, outside of optimization.
-# * (box): Petschel-Held
-cfg$gms$climate <- "off"                 # def = off
-
-# ***---------------------    16_downscaleTemperature    ----------------------------------------
-# * (off)
-# * (CMIP5): downscale GMT to regional temperature based on CMIP5 data (between iterations, no runtime impact). Requires climate='magicc' and cm_rcp_scen={rcp26,rcp85}
-cfg$gms$downscaleTemperature <- "off"                 # def = off
-
-# ***---------------------    20_growth    ------------------------------------------
-# * (exogenous): exogenous growth
-# * (endogenous): endogenous growth !!Warning: still experimental stuff!!
-# * (spillover): endogenous growth with spillover externality !!Warning: not yet calibrated!!
-cfg$gms$growth <- "exogenous"                 # def = exogenous
-
-# ***---------------------    21_tax    ------------------------------------------
-# * (on): tax mechanism active
-# * (off): no tax mechanism
-cfg$gms$tax  <- "on"           # def = on
-
-# ***---------------------    22_subsidizeLearning    -----------------------------
-# * (globallyOptimal): Only works with Nash, gives cooperative solution w.r.t. the learning spillover - this should then be equivalent to the Negishi solution.
-# * (off): do not subsidize learning. Default setting for Negishi. With Nash, this gives the non-cooperative solution w.r.t. the learning spillover.
-cfg$gms$subsidizeLearning  <- "off"           # def = off
-
-# ***----------------------    23_capitalMarket    -------------------------------
-# * (imperfect): Imperfect capital market: brings initial consumption shares closer to empirical data
-# * (perfect):   Perfect capital market (results in large short-term capital flows from North to South)
-cfg$gms$capitalMarket  <- "perfect"           # def = perfect
-
-
-# ***----------------------   26_agCosts  ----------------------------------------
-# * (off): agricultural costs zero, no trade taken into account
-# * (costs): includes total landuse costs
-# * (costs_trade): includes agricultural production costs and the MAgPIE trade balance
-cfg$gms$agCosts  <- "costs"       # def = costs
-
-# ***---------------------    29_CES_parameters    ----------------------------
-# * (load):      load existing CES parameters matching model configuration
-# * (calibrate): calculate new CES parameters based on v_cesIO trajectories -- under development!
-cfg$gms$CES_parameters  <- "load"   # def = load
-
-# ***---------------------    30_biomass    ----------------------------------------
-# * (exogenous):     exogenous biomass extraction and costs
-# * (magpie_40): using supplycurved derived from MAgpIE 4.0
-cfg$gms$biomass <- "magpie_40"              # def = magpie_hightccost
-
-# ***---------------------    31_fossil    ----------------------------------------
-# * (timeDepGrades): time-dependent grade stucture of fossil resources (oil & gas only)
-# * (grades2poly)  : simplified version of the time-dependent grade realization (using polynomial functions)
-# * (exogenous)    : exogenous fossil extraction and costs
-cfg$gms$fossil <- "grades2poly"        # def = grades2poly
-
-# ***---------------------    32_power    ----------------------------------------
-# * (IntC)	:	Power sector formulation with Integration Cost (IntC) markups and curtailment for VRE integration - linearly increasing with VRE share -, and fixed capacity factors for dispatchable power plants
-# * (RLDC)	:	Power sector formulation with Residual Load Duration Curve (RLDC) formulation for VRE power integration, and flexible capacity factors for dispatchable power plants
-cfg$gms$power <- "IntC"        # def = IntC
-
-# ***---------------------    33_CDR       ----------------------------------------
-# * (off)        : no carbon dioxide removal technologies except BECCS
-# * (weathering) : includes enhanced weathering
-# * (DAC) : 	   includes direct air capture
-# * (all) : 	   includes all CDR technologies
-cfg$gms$CDR <- "DAC"        # def = DAC
-
-# ***---------------------    35_transport    ----------------------------------------
-# * (complex):  transport realization including electricity in the transport sector (*RP*)
-cfg$gms$transport <- "complex"           # def = complex
-
-# ***---------------------    36_buildings    ---------------------------------
-# * (simple): representation of the demand in terms of energy carriers
-# * (services_with_capital): representation of the demand by energy service with capital
-# * (services_putty): representation of the demand by energy service with capital and with putty-clay for buildings insulation
-# * (off): no buildings representation
-cfg$gms$buildings  <- "simple"      # def = simple
-
-# ***---------------------    37_industry    ----------------------------------
-# * (fixed_shares): fixed shares of industry sub-sectors (cement, chemicals,
-#                   steel, other) in industry FE use
-# * (off): no industry representation
-cfg$gms$industry  <- "fixed_shares"   # def = fixed_shares
-
-# ***---------------------    38_stationary    ---------------------------------
-# * (simple): simple representation of the stationary sector (buildings and industry are represented together)
-# * (off): no stationary representation (split between buildings and industry
-cfg$gms$stationary  <- "off"      # def = off
-
-# ***---------------------    39_CCU    ---------------------------------
-# * (on): simple representation of carbon capture and utilization technologies, first only example of syngas (H22CH4)
-# * (off): no representation of carbon caputre and utilization technologies.
-cfg$gms$CCU  <- "off"      # def = off
-
-# ***---------------------    40_techpol  ----------------------------------------
-# * (none): no technology policies
-# * (lowCarbonPush): [works only with Negishi] global low-carbon push until 2030: PV, CSP, Wind, Gas-CCS, Bio-CCS and Electromobility
-# * (coalPhaseout): [works only with Negishi] global phase-out of new freely-emitting coal conversion, caps all coal routes with the exception of coaltr: coal solids can still expand
-# * (coalPhaseoutRegional): [works only with Negishi] global phase-out of new freely-emitting coal conversion, caps all coal routes with the exception of coaltr: coal solids can still expand
-# * (CombLowCandCoalPO): [works only with Negishi] combination of lowCarbonPush and coalPhaseout
-# * (NDC2018): Technology targets for 2030 for spv,wind,tnrs.
-# * (NPi): Reference technology targets, mostly already enacted (N)ational (P]ol(i)cies, mostly for 2020
-# * (EVmandates): mandate for electric vehicles - used for UBA project
-cfg$gms$techpol <- "none"           # def = none
-
-# ***---------------------    41_emicapregi  ----------------------------------------
-# * (none): no regional emission caps
-# * (CandC):  contraction and convergence allocation (under construction)
-# * (GDPint):  GDP intensity allocation (under construction)
-# * (POPint):  sovereignity (per cap.) allocation (under construction)
-# * (exog):   exogenous emission cap path (generic)  (under construction)
-# * (PerCapitaConvergence):   based on CandC: convergence, to be run with emiscen = 4
-# * (AbilityToPay):   mitigation requirement shared based on per-capita GDP, to be run with emiscen = 4
-cfg$gms$emicapregi <- "none"           # def = none
-
-# ***---------------------    42_banking  ----------------------------------------
-# * (off): no banking and borrowing of emission permits, no when-flexibility
-# * (banking):  only banking allowed, no borrowing at all
-cfg$gms$banking  <- "off"           # def = off
-
-# ***---------------------    45_carbonprice  ----------------------------------------
-# * (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
-# * (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)
-# * (diffPhaseIn2Constant): linearly phase in global constant price, with starting values differentiated by GDP/cap (Robert's proposal)
-
-cfg$gms$carbonprice <- "none"           # def = none
-
-# ***---------------------    47_regipol  ----------------------------------------
-# * (none): no regional policies
-# * (regiCarbonPrice): Region specific or region group independent carbon price.
-# * the target is defined in the cm_regiCO2target switch, for year target e.g. "2050.EUR.year.netCO2 0.7, 2050.USA.year.grossFFaI 1.0" sets a 0.7GtCO2 net CO2 target for EUR in 2050 and a 1GtCO2 gross Fossil Fuel and Industry CO2 emissions target for USA
-# * for budget target: "2050.EUR.budget.netCO2 70, 2050.USA.budget.grossFFaI 100" sets a netCO2/grossFFaI budget from 2020-2050 correspondingly
-cfg$gms$regipol <- "none"           # def = none
-
-# ***---------------------    50_damages  ----------------------------------------
-# * (off): no damages on GDP
-# * (DiceLike): DICE-like damages (linear-quadratic damages on GDP). Choose specification via cm_damage_DiceLike_specification
-# * (BurkeLike): Burke-like damages (growth rate damages on GDP). Choose specification via cm_damage_BurkeLike_specification and cm_damage_BurkeLike_persistenceTime
-cfg$gms$damages  <- "off"           # def = off
-
-# ***---------------------    51_internalizeDamages  ----------------------------------------
-# * (off):
-# * (DiceLikeItr): Internalize DICE-like damages (calculate the SCC) adjust cm_damages_SccHorizon. Requires cm_emiscen=9 for now.
-# * (BurkeLikeItr): Internalize Burke-like damages (calculate the SCC) adjust cm_damages_SccHorizo. Requires cm_emiscen=9 for now.
-cfg$gms$internalizeDamages  <- "off"           # def = off
-
-
-# ***---------------------    70_water  ----------------------------------------
-# * (off): no water demand taken into account
-# * (exogenous): exogenous water demand is calculated based on data on water demand coefficients and cooling shares
-# * (heat): as exogenous only that vintage structure in combination with time dependent cooling shares as vintages and efficiency factors are also considered and demand is a function of excess heat as opposed to electricity output
-cfg$gms$water <- "off"        # def = off
-
-# ***---------------------    80_optimization    ----------------------------------------
-# * (nash): Nash solution. Adjust cm_nash_autoconverge to needs.
-# * (negishi): calculates a Negishi solution (social planner)
-# * (testOneRegi):  solves the problem for one region for given prices (taken from gdx).
-# *                ! Warning:  For development purposes only !
-cfg$gms$optimization <- "testOneRegi"        # def = nash
-
-# ***---------------------    81_codePerformance  ----------------------------------------
-# * (off): nothing happens
-# * (on):  noumerous (30) succesive runs performed in a triangle: tax0, tax30, tax150 ,all growing exponentially,
-#                     therefore use carbonprice|exponential, c_emiscen|9, and cm_co2_tax_2020|0. also "long" as loadleveler class option (node = not_shared is recommended, too). test code performance
-cfg$gms$codePerformance <- "off"        # def = off
-
-# ***------------------------------------------------------------------------------
-# ***                           MODULES                   END
-# ***------------------------------------------------------------------------------
-
-#-----------------------------------------------------------------------------
-#                          SWITCHES
-#-----------------------------------------------------------------------------
-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_MAgPIE_coupling     <- "off"   # def <- "off"
-
-cfg$gms$cm_emiscen              <- 1     # def <- 1
-cfg$gms$cm_rcp_scen             <- "none"  # def <- "none"
-cfg$gms$cm_iterative_target_adj <- 0     # def <- 0
-cfg$gms$cm_co2_tax_2020         <- -1    # def <- -1
-cfg$gms$cm_co2_tax_growth       <- 1.05  # def <- 1.05
-cfg$gms$c_macscen               <- 1     # def <- 1
-
-cfg$gms$cm_nucscen             <-  2  #  def  <-  2
-cfg$gms$cm_ccapturescen        <-  1  #  def  <-  1
-cfg$gms$c_bioliqscen           <-  1  #  def  <-  1
-cfg$gms$c_bioh2scen            <-  1  #  def  <-  1
-cfg$gms$cm_IndCCSscen          <-  1  #  def  <-  1
-cfg$gms$cm_optimisticMAC       <-  0  #  def  <-  0
-cfg$gms$cm_CCS_cement          <-  1  #  def  <-  1
-cfg$gms$cm_CCS_chemicals       <-  1  #  def  <-  1
-cfg$gms$cm_CCS_steel           <-  1  #  def  <-  1
-cfg$gms$c_solscen              <-  1  #  def  <-  1
-
-cfg$gms$cm_bioenergy_tax     <- 1.5     # def <- 1.5
-cfg$gms$cm_bioenergymaxscen  <- 0       # def <- 0
-cfg$gms$cm_tradecost_bio      <- 2       # def <- 2
-cfg$gms$cm_LU_emi_scen       <- "SSP2"  # def <- "SSP2"
-cfg$gms$c_1stgen_phaseout   <- 0       # def <- 0
-
-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$c_start_budget        <- 2100    # def <- 2100
-
-cfg$gms$cm_prtpScen           <- 3       # def <- 3
-cfg$gms$cm_fetaxscen          <- 3       # def <- 3
-cfg$gms$cm_multigasscen       <- 2       # def <- 2
-cfg$gms$cm_permittradescen    <- 1       # def <- 1
-cfg$gms$cm_limit_peur_scen    <- 1       # def <- 1
-cfg$gms$cm_oil_scen           <- "medOil"       # def <- "medOil"
-cfg$gms$cm_gas_scen           <- "medGas"       # def <- "medGas"
-cfg$gms$cm_coal_scen          <- "medCoal"      # def <- "medCoal"
-cfg$gms$cm_rentdiscoil        <- 0.2     # def 0.2
-cfg$gms$cm_rentdiscoil2       <- 0.9     # def 0.9
-cfg$gms$cm_rentconvoil        <- 50      # def 50
-cfg$gms$cm_rentdiscgas        <- 0.6     # def 0.6
-cfg$gms$cm_rentdiscgas2       <- 0.8     # def 0.8
-cfg$gms$cm_rentconvgas        <- 50      # def 50
-cfg$gms$cm_rentdisccoal       <- 0.4     # def 0.4
-cfg$gms$cm_rentdisccoal2      <- 0.6     # def 0.6
-cfg$gms$cm_rentconvcoal       <- 50      # def 50
-cfg$gms$cm_earlyreti_rate     <- 0.09    # def 0.09
-
-cfg$gms$c_cint_scen           <- 1       # def <- 1
-cfg$gms$cm_so2tax_scen        <- 1       # def <- 1
-cfg$gms$cm_damage              <- 0.005   # def <- 0.005
-cfg$gms$cm_solwindenergyscen   <- 1       # def <- 1
-cfg$gms$c_techAssumptScen     <- 1       # def <- 1
-cfg$gms$c_ccsinjecratescen    <- 1       # def <- 1
-cfg$gms$c_ccscapratescen      <- 1       # def <- 1
-cfg$gms$c_export_tax_scen     <- 0       # def <- 0
-cfg$gms$cm_gdximport_target   <- 0       # def <- 0
-cfg$gms$c_SSP_forcing_adjust <- "forcing_SSP2"   # def <- "forcing_SSP2"
-cfg$gms$c_delayPolicy         <- "SPA0"           # def <- "SPA0"
-cfg$gms$cm_gs_ew              <- 20      # def <- 20
-cfg$gms$cm_LimRock             <- 1000    # def <- 1000
-cfg$gms$c_tau_so2_xmpt       <- 0       # def <- 0
-cfg$gms$cm_expoLinear_yearStart <- 2050  # def <- 2050
-cfg$gms$c_budgetCO2FFI       <- 1000     # def <- 1000
-cfg$gms$c_budgetCO2          <- 1350     # def <- 1350
-cfg$gms$c_abtrdy             <- 2010     # def <- 2010
-cfg$gms$c_abtcst             <- 1        # def <- 1
-cfg$gms$cm_regiCO2target  	 <- "off"    # def <- "off"
-
-cfg$gms$c_CES_calibration_iterations      <-  10       # def <- 10
-cfg$gms$c_CES_calibration_new_structure   <-   0       # def <-  0
-cfg$gms$c_CES_calibration_write_prices    <-   0       # def <-  0
-cfg$gms$cm_CES_calibration_default_prices <-   0       # def <-  0
-
-cfg$gms$c_testOneRegi_region  <- "EUR"   # def <- "EUR"
-cfg$gms$cm_DiscRateScen         <- 0 #def <- 0
-cfg$gms$cm_noReboundEffect         <- 0 #def <- 0
-cfg$gms$cm_esubGrowth         <- "low" #def <- "low"
-
-cfg$gms$cm_cooling_shares               <- "static"   # def <- "static", or "dynamic"
-cfg$gms$cm_techcosts                    <- "REG"      # def <- "REG", or "GLO"
-cfg$gms$cm_trdcst                        <- 1.5     # def <- 1.5
-cfg$gms$cm_trdadj                       <- 2.0     # def <- 2.0
-cfg$gms$c_refcapbnd                     <- 0       # def <- 0
-cfg$gms$cm_frac_CCS                     <- 10      # def <- 10
-cfg$gms$cm_frac_NetNegEmi               <- 0.5     # def <- 0.5
-cfg$gms$cm_regNetNegCO2                 <- "on"     # def <- "on"
-cfg$gms$cm_peakBudgYr                   <- 2050     # def <- 2050
-cfg$gms$cm_taxCO2inc_after_peakBudgYr   <- 2     # def <- 2
-cfg$gms$cm_CO2priceRegConvEndYr         <- 2050     # def <- 2050
-
-#-----------------------------------------------------------------------------
-#                          FLAGS
-#-----------------------------------------------------------------------------
-cfg$gms$cm_SlowConvergence     <- "off"   # def = off
-cfg$gms$cm_nash_mode           <- "parallel" # def = parallel ; Choices: parallel, serial, debug.
-cfg$gms$cm_OILRETIRE           <- "off"   # def = off
-
-cfg$gms$cm_INCONV_PENALTY       <- "on"    # def = on
-cfg$gms$cm_so2_out_of_opt      <- "on"    # def = on      ask Jessi
-cfg$gms$cm_MOFEX               <- "off"   # def = off
-
-cfg$gms$cm_less_TS             <- "on"    # def = on
-cfg$gms$c_skip_output          <- "off"   # def <- off    DELETE
-cfg$gms$cm_ccsfosall           <- "off"   # def <- off
-
-cfg$gms$cm_APscen              <- "SSP2"  # def <- SSP2
-
-cfg$gms$cm_Full_Integration    <- "off"   # def = off
-
-cfg$gms$c_CO2priceDependent_AdjCosts    <- "on"   # def = on
-
-# MAGICC configuration (AJS)
-# Calibrate year 2000 temperature to HADCRUT4 data (which is very close to AR5).
-cfg$gms$cm_magicc_calibrateTemperature2000 <- "uncalibrated" # def = uncalibrated;  {uncalibrated, HADCRUT4  }
-
-# MAGICC configuration
-# roughly comparable to TCRE value, or even more roughly, equivalent climate sensitivity
-# choose from OLDDEFAULT (REMIND1.7 legacy file); or different percentiles of RCP26 or generic TCRE outcomes calibrated to CMIP5 (see Schultes et al. (2018) for details)
-cfg$gms$cm_magicc_config <- "OLDDEFAULT" # def = OLDDEFAULT ; {OLDDEFAULT, RCP26_[5,15,..,95], TCRE_[LOWEST,LOW,MEDIUM,HIGH,HIGHEST] }
-
-# Derive temperature impulse response to CO2 emissions, based on MAGICC. Adds around 10min runtime.
-cfg$gms$cm_magicc_temperatureImpulseResponse <- "off" # def = off; {off,on }
-
-cfg$gms$cm_carbonprice_temperatureLimit <- 1.8 # def = 1.8; not-to-exceed temperature target in degree above pre-industrial
-
-# climate damages
-cfg$gms$cm_damage_DiceLike_specification <- "HowardNonCatastrophic" # def = "HowardNonCatastrophic"; {DICE2013R,DICE2016,HowardNonCatastrophic,HowardInclCatastrophic}
-cfg$gms$cm_damages_BurkeLike_specification <- 0 # def = 0; {0,5} Selects the main Burke specification "pooled, short-run" (0) or an alternative one "pooled, long-run "(5)
-cfg$gms$cm_damages_BurkeLike_persistenceTime <- 30 # def = 30; Persistence time (half-time) in years. Highly uncertain, but may be in between 5 and 55 years.
-cfg$gms$cm_damages_SccHorizon <- 100   # def = 100; Horizon for SCC calculation. Damages cm_damagesSccHorizon years into the future are internalized.
-#### Other settings (e.g. clustering, gdx files, ...): ####
-
-# Choose which GAMS version to use (choosing the default option "gams" uses the GAMS system in your PATH variable - in both UNIX and Windows)
-# Cluster Example: if you want GAMS version 24.0, use "/p/system/packages/gams/24.0.1/gams"
-# Local machine Example: use your GAMS path, e.g. "C:\\GAMS\\win32\\24.3\\gams.exe" (please note the double backslashes)
-cfg$gamsv <- "gams" # def = gams
-
-#*ag* set conopt version. Warning: conopt4 is in beta
-cfg$gms$cm_conoptv <- "conopt3" # def = conopt3
-
-# Action that should be performed ("ce": compile and run, "c": compile)
-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 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
-
-# Just list the name of the output scripts that should be used by output.R
-# At the moment there are several R-scripts located in scripts/output/
-cfg$output <- 'reporting' # c("reporting","validation","emulator","reportCEScalib","rds_report","validationSummary","dashboard")
-
-# Set the format for the results folder, type string :date: in order to use the current time stamp in the folder name (e.g. "results:date:") use :title: to use the current title in the folder name
-cfg$results_folder <- "output/:title:" # :date:"
-
-# Which files should be copied into the output folder?
-cfg$files2export <- list()
-# Files that should be copied before REMIND is started
-cfg$files2export$start <- c("config/conopt3.opt",
-                            "config/conopt3.op2",
-                            "config/conopt3.op3",
-                            "config/conopt3.op4",
-                            "config/conopt3.op5",
-                            "config/conopt3.op8",
-                            "config/conopt3.op9",
-                            "scripts/run_submit/submit.cmd",
-                            "scripts/run_submit/submit.R",
-                            "scripts/run_submit/run_magicc.R",
-                            "scripts/run_submit/run_magicc_temperatureImpulseResponse.R",
-                            "scripts/run_submit/read_DAT_TOTAL_ANTHRO_RF.R",
-                            "scripts/run_submit/read_DAT_SURFACE_TEMP.R",
-                            "core/input/historical/historical.mif",
-                            "scripts/input/exoGAINSAirpollutants.R",
-                            "config/input.gdx",
-                            "config/input_ref.gdx",
-                            "core/magicc",
-                            ".Rprofile",
-                            "config/mappingEDGEtoREMINDsectors.csv")
-
-# Files that should be copied after the REMIND run is finished
-cfg$files2export$end <- NULL
-
-# There is the converted data located?
-cfg$converted_input_folder <- "config"
-
-# placeholder for storing information on subsequent runs
-cfg$subsequentruns <- character(0)
-
-# List of runs that use the fulldata.gdx of this run as input_bau.gdx
-cfg$RunsUsingTHISgdxAsBAU <- NA
-
-############################################################
-##### explanations of switches and flags ###################
-############################################################
-
-#-------------------- switches ----------------------------------------------------
-# cm_iteration_max    "number of Negishi iterations (up to 49)"
-# c_solver_try_max      "maximum number of inner iterations within one Negishi iteration (<10)"
-#*** Careful: for each inner_itr_count, the size of remind.lst can increase by 50MB!
-# cm_nash_autoconverge "choice of nash convergence mode"
-#  (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_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)
-# cm_emiscen       "policy scenario choice"
-#  (0): no global budget. Policy may still be prescribed by 41_emicaprei module.
-#  (1): BAU
-#  (2): temperature cap
-#  (3): CO2 concentration cap
-#  (4): emission time path
-#  (5): forcing target from 2010 (not to exceed)
-#  (6): budget
-#  (8): forcing target from 2100 onwards (overshoot scen)
-#  (9): tax scenario (requires running module 21_tax "on"), tax level controlled by module 45_carbonprice and cm_co2_tax_2020, other ghg etc. controlled by cm_rcp_scen
-#*RP* WARNING: cm_emiscen 3 should not be used anymore, as the MACs are not updated anymore.
-#*JeS* WARNING: data for cm_emiscen 4 only exists for multigas_scen 2 bau scenarios and for multigas_scen 1
-# cm_rcp_scen     "chooses RCP scenario"
-#  (none): no RCP scenario, standard setting
-#  (rcp20): RCP2.0
-#  (rcp26): RCP2.6
-#  (rcp37): RCP3.7
-#  (rcp45): RCP4.5
-#  (rcp60): RCP6.0
-#  (rcp85): RCP8.5
-# 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"
-#  (-1): default setting equivalent to no carbon tax
-#  (any number >= 0): tax level in 2020, with 5% exponential increase over time
-# cm_co2_tax_growth    "yearly growth rate of co2 tax"
-#  (any number >= 0): rate of exponential increase over time
-# c_macscen       "use of mac"
-#  (1): on
-#  (2): off
-# cm_nucscen       "nuclear option choice"
-#  (1): no fnrs, tnrs completely free after 2020
-#  (2): no fnrs, tnrs with restricted new builds until 2030 (based on current data on plants under construction, planned or proposed)
-#  (3): no tnrs no fnrs
-#  (4): fix at bau level
-#  (5): no new nuclear investments after 2020
-#  (6): +33% investment costs (tnrs) & uranium resources increased by a factor of 10
-# cm_limit_peur_scen   "limit total uranium production"
-#  (0): off
-#  (1): on
-# cm_ccapturescen       "carbon capture option choice, no carbon capture only if CCS and CCU are switched off!"
-#  (1): yes
-#  (2): no carbon capture (only if CCS and CCU are switched off!)
-#  (3): no bio carbon capture
-#  (4): no carbon capture in the electricity sector
-# c_bioliqscen       "switch liquids producing technology on or off"
-#  (0): no technologies
-#  (1): all technologies
-# c_bioh2scen       "switch hydrogen producing technology on or off"
-#  (0): no technologies
-#  (1): all technologies
-# c_solscen      "solar option choice"
-#  (1): yes
-#  (2): no solar
-#  (3): fix at bau level
-# cm_bioenergy_tax    "level of bioenergy tax in fraction of bioenergy price"
-#  (0): default setting equivalent to no tax
-#  (any number >= 0): tax level, e.g. for a 100% tax cm_bioenergy_tax has to be 1
-# cm_bioenergymaxscen   "bound on global pebiolc production excluding residues"
-# optional scaling of bioenergy costs in generisdata.inc (at the moment: no scaling for both cases)
-#  (0): no bound
-#  (1): 100 EJ global bioenergy potential (bound in boundsextra.inc)
-#  (2): 200 EJ global bioenergy potential (bound in boundsextra.inc)
-#  (3): 300 EJ global bioenergy potential (bound in boundsextra.inc)
-#  (4): 152 EJ global bioenergy potential, i.e. 100 EJ 2nd generation (bound in boundsextra.inc)
-# cm_tradecost_bio  "choose financal tradecosts for biomass (purpose grown pebiolc)"
-#  (1): low   tradecosts (for other SSP scenarios than SSP2)
-#  (2): high  tradecosts (default and SSP2)
-# cm_LU_emi_scen   "choose emission baseline for CO2, CH4, and N2O land use emissions from MAgPIE"
-#  (SSP1): emissions (from SSP1 scenario in MAgPIE)
-#  (SSP2): emissions (from SSP2 scenario in MAgPIE)
-#  (SSP5): emissions (from SSP5 scenario in MAgPIE)
-# c_1stgen_phaseout "choose if 1st generation biofuels should phase out after 2030 (deltacap=0)"
-#  (0): 1st generation biofuels after 2020 are fixed at upper limit of resource potential (maxprod)
-#  (1): no new capacities for 1st generation biofuel technologies may be built after 2030 -> phaseout until ~2060
-# cm_POPscen      "Population growth scenarios from UN data and IIASA projection used in SSP"
-# pop_SSP1    "SSP1 population scenario"
-# pop_SSP2    "SSP2 population scenario"
-# pop_SSP3    "SSP3 population scenario"
-# pop_SSP4    "SSP4 population scenario"
-# pop_SSP5    "SSP5 population scenario"
-# cm_GDPscen  "assumptions about future GDP development, linked to population development (cm_POPscen)"
-#  (gdp_SSP1):  SSP1 fastGROWTH medCONV
-#  (gdp_SSP2):  SSP2 medGROWTH medCONV
-#  (gdp_SSP3):  SSP3 slowGROWTH slowCONV
-#  (gdp_SSP4):  SSP4  medGROWTH mixedCONV
-#  (gdp_SSP5):  SSP5 fastGROWTH fastCONV
-# cm_startyear "first free (or pseudo-free in case of 2005) modelling time step";
-#  (2005): standard for BAU to check if model is well calibrated
-#  (2015): standard for all policy runs (eq. to fix2010) and production baselines, especially if various baselines with varying parameters are explored
-#  (....): later start for delay policy runs, eg. 2025 for what used to be delay2020
-# cm_prtpScen      "pure rate of time preference standard values"
-#  (1): 1 %
-#  (3): 3 %
-# cm_fetaxscen  "choice of final energy tax path, subsidy path and inconvenience cost path, values other than 0 make setting module 21_tax on";
-#*RP* even if set to 0, the PE inconvenience cost/SO2-cost for coal are always on if module 21_tax is on
-#  (0): no tax, sub, inconv
-#  (1): constant t,s,i (used in SSP 5 and ADVANCE WP3.1 HighOilSub)
-#  (2): converging tax, phased out sub (-2030), no inconvenience cost so far (used in SSP 1)
-#  (3): constant tax, phased out sub (-2050), no inconvenience cost so far (used in SSP 2)
-#  (4): constant tax, phased out sub (-2030), no inconvenience cost so far (used in SDP)
-# cm_multigasscen  "scenario on GHG portfolio to be included in permit trading scheme"
-#  (1): CO2 only
-#  (2): all GHG
-#  (3): all GHG excl CO2 emissions from LULUCF
-# cm_permittradescen  "scenario assumption on permit trades"
-#  (1): full permit trade (no restrictions)
-#  (2): no permit trade (only domestic mitigation)
-#  (3): limited trade (certain percentage of GDP)
-# c_limit_peur_scen  "limit total uranium production"
-#  (0): no
-#  (1): yes (the exact amount is specified in boundsextra)
-# cm_oil_scen      "assumption on oil availability"
-#  (lowOil): low
-#  (medOil): medium (this is the new case)
-#  (highOil): high (formerly this has been the "medium" case; RoSE relevant difference)
-#  (4): very high (formerly this has been the "high" case; RoSE relevant difference)
-# cm_gas_scen      "assumption on gas availability"
-#  (lowGas): low
-#  (medGas): medium
-#  (highGas): high
-# cm_coal_scen     "assumption on coal availability"
-#  (0): very low (this has been the "low" case; RoSE relevant difference)
-#  (lowCoal): low (this is the new case)
-#  (medCoal): medium
-#  (highCoal): high
-#  cm_earlyreti_rate     "maximum portion of capital stock that can be retired in one year"
-#  0.09 default value: (full retirement after 11 years, 10% standing after 10 years)
-#  0.06 default value before 2019-02-18 (full retirement after 16 years, 10% standing after 15 years)
-#  0.04 default value before 2016-12-06
-#  0.001 lowest possible value: basically no early retirement
-# c_cint_scen        "additional GHG emissions from mining fossil fuels"
-#  (0): switch is off (emissions are not accounted)
-#  (1): switch is on (emissions are accounted)
-# cm_so2tax_scen  "level of SO2 tax"
-#  (0): so2 tax is set to zero
-#  (1): so2 tax is low
-#  (2): so2 tax is standard
-#  (3): so2 tax is high
-#  (4): so2 tax intermediary between 1 and 2, multiplying (1) tax by the ratio (3)/(2)
-# cm_damage      "cm_damage factor for forcing overshoot"
-#*JeS* can be used to lower forcing overshoot in cm_emiscen 8 scenarios, use only with box model!
-# cm_solwindenergyscen "scenario for fluctuating renewables, 1 is reference, 2 is pessimistic with limits to fluctuating SE el share"
-#  (0) advanced - cheap investment costs, higher learning rates for pv, csp and wind
-#  (1) reference - normal investment costs & learning rates for pv, csp and wind     EMF27-3nd round Adv scenario
-#  (2) pessimistic EMF27 and AWP 2 - share of PV, wind&CSP limited to 20%. Learning rates reduced by 20%, floor costs increased by 40%. EMF27-3nd round Cons scenario
-#  (3) frozen - no learning after 2010, share of PV, wind&CSP limited to 20%. EMF27-3rd round Frozen scenario
-#  (4) pessimistic SSP: pessimistic techno-economic assumptions
-# c_techAssumptScen "scenario for assumptions of energy technologies based on SSP scenarios, 1: SSP2 (default), 2: SSP1, 3: SSP5"
-#*JH* This flag defines an energy technology scenario
-#  (1) SSP2: reference scenario - default investment costs & learning rates for pv, csp and wind
-#  (2) SSP1: advanced renewable energy techno., pessimistic for nuclear and CCS
-#  (3) SSP5: pessimistic techno-economic assumptions
-# c_ccsinjecratescen "CCS injection rate factor, 0.5% by default yielding a 60 Mt per year IR"
-#*JH* This flag determines the upper bound of the CCS injection rate
-#*LP* CCS refers to carbon sequestration, carbon capture is modelled separately
-#  (0) no "CCS" as in no carbon sequestration at all
-#  (1) reference case: 0.005
-#  (2) lower estimate: 0.0025
-#  (3) upper estimate: 0.01
-#  (4) unconstrained: 1
-#  (5) sustainability case: 0.001
-# c_ccscapratescen "CCS capture rate"
-#*JH*  This flag determines the CO2 capture rate of CCS technologies
-#  (1) reference
-#  (2) increased capture rate
-# c_export_tax_scen "choose which oil export tax is used in the model. 0 = none, 1 = fix"
-#c_SSP_forcing_adjust "chooses forcing target and budget according to SSP scenario such that magicc forcing meets the target";
-#  ("forcing_SSP1") settings consistent with SSP 1
-#  ("forcing_SSP2") settings consistent with SSP 2
-#  ("forcing_SSP5") settings consistent with SSP 5
-#cm_iterative_target_adj             "whether or not a tax or a budget target should be iteratively adjusted depending on actual emission or forcing level";
-# (0): no iterative adjustment
-# (1): iterative adjustment I for tax based on 2030 emissions or for 2150 budget based on 2100 budget result, see core/postsolve.gms for direct algorithms of adjustment
-# (2): iterative adjustment II based on magicc calculated forcing (for both budget and tax runs), see modules/climate/magicc/postsolve.gms for direct algorithms of adjustment
-# (3): [requires 45_carbonprice = "INDC" or "NDC" or "NDCEU" and emiscen = 9] iterative adjustment III for tax based on 2025 or 2030 regionally differentiated emissions, see module/45_carbonprice/<INDC/NDC/NDCEU90>/postsolve.gms for algorithm of adjustment
-# (4): iterative adjustment IV for both budget and tax runs based on CO2 FF&I emissions 2010-2100, see core/postsolve.gms for direct algorithms of adjustment
-# (5): iterative adjustment V for both budget and tax runs based on CO2 emissions 2011-2100, see core/postsolve.gms for direct algorithms of adjustment
-# (6): iterative adjustment VI for both budget and tax runs based on peak CO2 emissions budget, without changing temporal profile (i.e. with overshoot), see core/postsolve.gms for direct algorithms of adjustment
-# (7): iterative adjustment VII for tax runs based on peak CO2 emissions, with change of temporal tax profile after time of peak budget, aiming for net-zero thereafter, see core/postsolve.gms for direct algorithms of adjustment
-#c_budgetCO2 "cumulative CO2|Total emissions budget 2011-2100, Gt CO2"
-# budgets from 1.5°C report, chapter 2, Table 2.2: 67% 1.5°C GSAT budget 2018-2100 = 420 Gt CO2, 67% 2.0°C GSAT budget 2018-2100 = 1170
-# add emissions 2011-2018 = 290 Gt CO2, subtract emissions from feedbacks (e.g. thawing permafrost) 100 Gt CO2
-# budget 2011-2100 for 2°C = 1170 + 290 - 100 = 1350 Gt CO2; for 1.5°C 420 + 290 - 100 = 600 Gt CO2
-#cm_regiCO2target "budget or year target for specific region or region group. Ex.: '2050.EUR_regi.budget 72, 2050.DEU.year 0.1' sets a 72 GtCO2eq budget target for European countries for emissions between 2020 and 2050, and a 100 MtCO2 CO2eq emission target for the 2050 year for Germany (only used if regipol model regiCarbonPrice realization is active)"
-#cm_gdximport_target             "whether or not the starting value for iteratively adjusted budgets, tax scenarios, or forcing targets (emiscen 5,6,7,8,9) should be read in from the input.gdx";
-# (0): no import, the default starting value as specified in modules/21_tax/on/input/tax_CO2.inc, core/input/data_emibudget.inc, modules/15_climate/box/datainput.gms is used
-# (1): the values from the gdx are read in (works only if the gdx has a parameter value) ATTENTION: make sure that the values from the gdx have the right structure (e.g. regionally differentiated or not)
-#
-# cm_cooling_shares
-#    use "static" or "dynamic" cooling shares in module 70_water/heat
-#
-# cm_regNetNegCO2
-#    default "on" allows for regionally netNegative CO2 emissions, setting "off" activates bound in core/bounds.gms that disallows net negative CO2 emissions at the regional level
-## cm_peakBudgYr
-#    time of net-zero CO2 emissions (peak budget), requires emiscen = 9 and cm_iterative_target_adj = 7, will potentially be adjusted by algorithms
-#
-# cm_techcosts
-#    use regionalized or globally homogenous technology costs for certain technologies
-#
-# cm_Full_Integration
-#    use "on" to treat wind and solar as fully dispatchable electricity production technologies
-# 
-# c_CO2priceDependent_AdjCosts
-#    default "on" changes adjustment costs for advanced vehicles in dependence of CO2 prices
-#
-#cm_DiscRateScen            "Implicit additional discount rate on investment in energy efficiency"
-#(0) Baseline without higher discount rate: No additional discount rate
-#(1) Baseline with higher discount rate: Increase the discount rate by 10%pts from 2005 until the end
-#(2) Energy Efficiency policy: 10%pts higher discount rate until cm_start_year and 0 afterwards.
-#cm_esubGrowth            "long term growth of the elasticity of substitution"
-#(low) 1.3
-#(middle) 1.5
-#(high) 2
-##-------------------- flags --------------------------------------------------
-# cm_SlowConvergence  off       !! def = off
-#*RP* Turn on a slower convergence scheme where each conopt file is used twice, thus conopt1 is used for itr 1+2, conopt.op2 for itr 3+4, conopt.op3 for itr 5+6, conopt.op4 for itr 7+8, conopt.op5 from itr 9 on.
-#*RP* from my own experience, this improves convergence and actually decreases total runtime, even if you start from a gdx with good convergence. But, as always, feelings about REMIND runtimes can be misleading :-)
-# cm_OILRETIRE  off           !! def = off
-#*RP* Flag to allow the model to not extract oil, even though the eq_fuelex_dec would force it to extract.
-# cm_INCONV_PENALTY  on     !! def = on
-#*RP* 2012-03-06 Flag to turn on inconvenience penalties, e.g. for air pollution
-# cm_so2_out_of_opt  on       !! def = on
-#*JeS* Flag to exclude aerosols from optimization routine, should be used especially for temperature targets
-# c_skip_output  off
-#*** This flag turns off output production
-# ap_scenarios  off!! def = off
-#*JeS* Report aerosol and precursor emissions using exogenous emission factor scenarios
-# cm_MOFEX  off    !! def=off
-#*JH/LB* Activate MOFEX partial fossil fuel extraction cost minimization model
-#* Warning: Use a well-converged run since the model uses vm_prodPe from the input GDX
-# cfg$gms$c_skip_output            <- "off"    # def <- off
-# Skip output? (Useful for development)
-# cfg$gms$cm_ccsfosall             <- "off"    # def <- off
-############################################################
-# here you find old and new names of the latest renaming
-#-----------------------------------------------------------
-# magicc_emi into pm_MAGICC_emi, pm_MAGICC_emi into p_MAGICC_emi and ts into pm_ts
-# s_earlyreti into sm_earlyreti, s_tgn2pgc into s_tgn_2_pgc, regi2RCP_region into p_regi_2_MAGICC_regionsv, s_tgch42pg into sm_tgch42pg, s_tmp into sm_tmp, s_c_so2 into sm_c_so2, s_tax_time into s21_tax_time, s_tax_value into s21_tax_value,  conv_cap_2_MioLDV into  pm_conv_cap_2_MioLDV, s_before into s80_before, s_after inot s80_after
-# p_limits_wp4_rcp into pm_emiAPexo, p_ratio_ppp into pm_shPPPMER, p_vintage_in into pm_vintage_in,sm_c_so2 into s_c_so2
-# p_datafe into pm_dataFE, p_w into pm_w
-# p_ttot_val into pm_ttot_val, p_t_interpolate into p80_t_interpolate, c_iterative_target_adj into cm_iterative_target_adj, c_co2_tax_2020 into cm_co2_tax_2020, c_macscen into c_macscen, c_bioenergy_tax into cm_bioenergy_tax, c_startyear into cm_startyear, c_export_tax_scen into c_export_tax_scen, c_gdximport_target into cm_gdximport_target, c_SSP_forcing_adjust into c_SSP_forcing_adjust
-# p_share_ind_fesos into pm_share_ind_fesos, p_share_ind_fesos_bio into pm_share_ind_fesos_bio, p_share_ind_fehos into pm_share_ind_fehos, p_share_trans into pm_share_trans
-# p_petradecost_Mp_en into pm_costsPEtradeMp, f_data_weathering_graderegi into f33_data_weathering_graderegi
-# v_emicap    = "vm_perm",
-# v_co2eqGlob = "vm_co2eqGlob",
-# v_banking   = "vm_banking",
-# v_vari      = "vm_cesIO",
-# v_invest    = "vm_invMacro",
-# v_deltacap  = "vm_deltaCap",
-# v_pedem     = "vm_demPe",
-# v_seprod    = "vm_prodSe",
-# v_feprod    = "vm_prodFe",
-# v_fedem     = "v_demFe",v_demFe = "v_demFe",
-# vm_peprod   = "vm_prodPe",
-# v_sedem     = "v_demSe,v_demSe = "vm_demSe"
-# p_nw into p80_nw,c_nucscen into cm_nucscen, q_co2eq into qm_co2eq. qm_co2eq into q_co2eq
-# pm_costsPEtradeMp into pm_costsPEtradeMp, vm_welfare into v_welfare
-# pm_tau_fe_sub into p21_tau_fe_sub, pm_tau_fe_tax into p21_tau_fe_tax
-# pm_datapop into pm_pop, p_datalab into p_lab, p_lab into pm_lab
-# p80_pvp into pm_pvp, p80_pvpRegi into pm_pvpRegi
-# pm_pvp_perm into pm_pricePerm, s_c2co2 into s_c_2_co2, s_dpy into s_year_2_day, s_hpd into s_day_2_hour
-# s_m2n into sm_mega_2_non, sm_g2n into sm_giga_2_non, s_zj2twyr into s_zj_2_twa, sm_ej2twyr into sm_EJ_2_TWa, sm_gj2twyr into sm_GJ_2_TWa, s_twa2mwh into s_TWa_2_MWh
-# s_dpkwa2tdptwyr into s_DpKWa_2_TDpTWa, s_dpkw2tdptw into sm_DpKW_2_TDpTW, sm_dpgj2tdptwyr into sm_DpGJ_2_TDpTWa
-# s_GWP_CH4 into s_gwpCH4, s_GWP_N2O into s_gwpN2O, sm_tgn2pgc into s_tgn_2_pgc, sm_tgch42pg into s_tgch4_2_pgc
-# v_ccs into v_co2CCS, v_co2CCS into vm_co2CCS, vm_costfu into vm_costFu, v_costin into v_costInv, v_costom into v_costOM, vm_costfu_bio into vm_costFuBio, vm_costfu_ex into vm_costFuEx
-# v_adjustteinv into v_costInvTeAdj, v_adj into v_adjFactor, v_adj_glob into v_adjFactorGlob, v_directteinv into v_costInvTeDir
-# vm_capCum into vm_capCum, v_inconvpen into v_inconvPen, v_invest_adjcosts into v01_invMacroAdj
-# v_capini into v_INIcap0, v_earlyreti into v_capEarlyReti, v_emi into vm_emiTeDetail, v_gridshare into v_shGrid, v_shareseel into v_shSeEl, v_shSeEl into v32_shSeEl
-# v_investcost into v_costTeCapital, v_storshare into v_shStor, v_shStor into v32_shStor, v_edemini into v_INIdemEn0, vm_esprod into vm_prodEs, vm_forc_os into vm_forcOS
-# vm_fuelex into vm_fuExtr, vm_taxrev into vm_taxRev, v_capEarlyReti into vm_capEarlyReti
-# testor into teVRE, stor into teStor, tegrid into teLoc, learnte into teLearn, teAdj into teAdj, terenew into teRe, terenew_nobio into teReNoBio, te_bio into teBio
-# trade_macro into tradeMacro, trade_pe into tradePe, trade_se into tradeSe
-# grid into teGrid, s_c_2_co2 into sm_c_2_co2, s_TWa_2_MWh into sm_TWa_2_MWh, c_postproc into cm_postproc, p11_scale_rcp into pm_scale_rcp, p11_emi_postrun into pm_emi_postrun
-# s80_fadeoutPriceAnticip into sm_fadeoutPriceAnticip
-# v10_CONBOX into v10_conc, v10_EMI into v10_emi, v10_RADBOX into v10_forcComp, v10_RADBOX_kyo into v10_forcKyo, v10_RADBOX_rcp into v10_forcRcp,
-# v10_temp1 into v_tempFast, v10_temp2 into v_tempSlow, v10_slack_os into v10_slackForc, v35_share_espet into v35_shEsPeT
-# nolearnte into teNoLearn, teccs into teCCS, tenoccs into teNoCCS, techp into teChp, te_pebiolc into teBioPebiolc
-# p_emi_fgas into p_emiFgas, p_datachp into p_shCHP, p_shCHP into p32_shCHP, pebio into peBio, perenew into peRe
-# emismac into emiMacSector, emismacmagpie into emiMacMagpie, emismacmagpien2o into emiMacMagpieN2O, emismacmagpiech4 into emiMacMagpieCH4, emismacmagpieco2 into emiMacMagpieCO2
-# sector into sectorEndoEmi , sector_exo into sectorExogEmi, sector2te into sectorEndoEmi2te, charpot into charPot, charperen into charPeRe, magicc_units into unitsMagicc
-# ceslev into cesLevel2cesIO, tenr into teNoRe, pety into entyPe, sety into entySe, fety  into entyFe, esty into entyEs
-# tenotransform into teNoTransform, fetransform into feForEs, ppfenfromes into ppfEnFromEs, petyf into peFos, petyex into peEx, petyrog into peExPol, petystepex into peExGrade
-# petyrencompgeopot into peReComp, teeta into teEtaIncr, teneta into teEtaConst, ccsco2 into ccsCo2, xirog into xirog
-# RCP_emissions into emiRCP, RCP_emissions_n into numberEmiRCP, RCP_emissions_order into emiRCP2order
-# v31_fuelex_mc_dummy into v31_fuExtrMC, v31_fuelex_cum_dummy into v31_fuExtrCumMax, v31_fuelex_cum into v31_fuExtrCum, v31_fuelslack into v31_fuSlack, v_usablese into v_usableSe, v_usableSe into vm_usableSe, v_usablese_te into v_usableSeTe, v_usableSeTe into vm_usableSeTe
-# vm_emiengregi into vm_emiTe, vm_eminegregi into vm_emiMacSector, vm_sumeminegregi into vm_emiMac, vm_emissions into vm_emiAll, vm_emicdrregi into vm_emiCdr, vm_emissionsGlob into vm_emiAllGlob
-# emisnegall into emiMac, emiseng into emiTe, emisfuelex into emiFuEx, emis into emi, ppfen into ppfEn, tefosnoccs into teFosNoCCS, tefosccs into teFosCCS, s_tech_stat into s_statusTe
-# ppfka into ppfKap, pm_tau_CO2_tax into pm_taxCO2eq, pm_emi_budget1 into sm_budgetCO2eqGlob, pm_emi_budget1_reg into pm_budgetCO2eq, p_t_budget1 into sm_endBudgetCO2eq
-# pm_emishare into pm_shPerm,  p_dataoc into p_prodCouple, p31_datarog into p31_costExPoly, pm_capcum0 into pm_capCum0,
-# pm_capcumForeign into pm_capCumForeign, p_emimac0 into p_macBase2005, p_emimac1990 into p_macBase1990
-# te2stor into VRE2teStor, te2teVRElinked into VRE2teVRElinked, te2grid into VRE2teGrid, ccs2tele into ccs2Leak, petyren2ter into teReComp2pe
-# emismac2mac into emiMac2mac, RCP_units into emiRCP2unitsMagicc, petyric into peRicardian
-# Emissions|F-Gases into emiFgasTotal, Emissions|PFC into emiFgasPFC, Emissions|CF4 into emiFgasCF4, Emissions|C2F6 into emiFgasC2F6, Emissions|C6F14 into emiFgasC6F14, Emissions|HFC into emiFgasHFC
-# Emissions|HFC|HFC23 into emiFgasHFC23, Emissions|HFC|HFC32 into emiFgasHFC32, Emissions|HFC|HFC43-10 into emiFgasHFC43-10, Emissions|HFC|HFC125 into emiFgasHFC125, Emissions|HFC|HFC134a into emiFgasHFC134a
-# Emissions|HFC|HFC143a into emiFgasHFC143a, Emissions|HFC|HFC227ea into emiFgasHFC227ea, Emissions|HFC|HFC245fa into emiFgasHFC245fa, Emissions|SF6 into emiFgasSF6
-# tlt_year into opTimeYr, tlt_5 into opTime5, balfinen_domain into feForCes, oc2te into pc2te, tlt_year2te into opTimeYr2te, tsu2tlt_5 into tsu2opTime5, ttot2tlt_year into tsu2opTimeYr,
-# cesrev into cesRev2cesIO, ces into cesOut2cesIn, tese2rlf into teSe2rlf, tefe2rlf into teFe2rlf, tese2rlfDistr into teRe2rlfDetail, temapall into en2en, temapse into en2se, teall2rlf into te2rlf
-# finenbal into fe2ppfEn, cintbyfuel into emi2fuelMine, enty2rlf into pe2rlf
-# q_ccostfu into q_costFu, q_ccostin into q_costInv, q_cdirectteinv into q_costInvTeDir, q_cadjustteinv into q_costInvTeAdj, q_ccostom into q_costOM, qm_pebal into q_balPe, q_usablese into q_usableSe, q_usableSe into q32_usableSe
-# q_usablese_te into q_usableSeTe, q_usableSeTe into q32_usableSeTe, q_sebal into q_balSe and q32_balSe, q_pe2setrans into q_transPe2se, q_se2fetrans into q_transSe2fe, q_febal into q_balFe, q_se2setrans into q_transSe2se, q_fe2estrans into q_transFe2es
-# q_balfinen into q_balFeForCes, q_capconstes into q_limitCapEs, q_capconstse into q_limitCapSe, q_capconstse2se into q_limitCapSe2se, q_capconststor into q_limitCapTeStor, q_limitCapTeStor into q32_limitCapTeStor, q_capconstfe into q_limitCapFe
-# q_capconstccs into q_limitCapCCS, q_capconstchp into q_limitCapTeChp, q_limitCapTeChp into q32_limitCapTeChp, q_ccap into q_cap, q_distrCap into q_capDistr, q_capcummo into qm_deltaCapCumNet, q_capcum0 into q_capCumNet
-# q_fuelconst2 into q_fuel2pe, q_renconst into q_limitProd, q_geopot into q_limitGeopot, q_storshare into q_shStor, q_shStor into q32_shStor, q_shareseel into q_shSeEl, q_shSeEl into q32_shSeEl, q_llearn into q_costTeCapital,
-# q_limit_pvwindcsp_share_EMF27 into q_limitSolarWind, q_limitSolarWind into q32_limitSolarWind, q_limit_biotrmod into q_limitBiotrmod, q_capconstgrid into q_limitCapTeGrid, q_limitCapTeGrid into q32_limitCapTeGrid, q_gridshare into q_shGrid, q_emi into q_emiTeDetail
-# q_emissengregi into q_emiTe, q_eminegregi into q_emiMacSector, q_co2bioexp into q_macBaseCo2bioexp, q_sumeminegregi into q_emiMac, q_emissions into q_emiAll, q_emissionsGlob into q_emiAllGlob
-# q_emiconst into q_emiCap, q_emibudget1Glob into q_budgetCO2eqGlob, q_ccsbal ionto q_balCCS, q_ccstrans into q_transCCS, q_ccsconst itnto q_limitCCS, q_so2constraint into q_limitSo2
-# q_co2constraint into q_limitCO2, q_eqadj into q_adjFactor, q_operating_reserve into q_operatingReserve, q_operatingReserve into q32_operatingReserve, q_nocoldreserve into q_limitCapEarlyReti, q_smoothphaseout into q_smoothphaseoutCapEarlyReti
-# q_inconvpen into q_inconvPen, q_labbal into q01_balLab, q_production into q01_cesIO, q_kapmo into q01_kapMo, q_invest_adjcosts into q01_invMacroAdj, q_limit_ppfen_shares into q01_limitShPpfen
-# q_limit_ppfen_ratios into q01_limtRatioPpfen, q_limit_seel2fehes into q_limitSeel2fehes, q_min_oil_share into q_limitShOil, q80_tradebal into q80_balTrade, q35_share_espet into q35_shEsPeT
-# q31_costfu_ex into q31_costFuExPol q31_costfu_ex_step into q31_costFuExGrade, q31_fuelex_cum into q31_fuExtrCum, q31_fuelex_dec into q31_fuExtrDec, q31_fuelex_inc into q31_fuExtrInc,
-# q30_costfu_bio into q30_costFuBio, q30_limit_bioexport into q30_limitXpBio, q30_limit_bio into q30_limitTeBio, p35_bunker_share_in_nonldv_fe into pm_bunker_share_in_nonldv_fe
-# v_tempSlow into v10_tempSlow,f_dataemiglob into fm_dataemiglob, f_dataglob into fm_dataglob, p_dt into pm_dt, p_prodCouple into pm_prodCouple, p_dataeta into pm_dataeta,p_eta_conv into pm_eta_conv
-# p_emiFgas into pm_emiFgas and then into vm_emiFgas, v_costTeCapital into vm_costTeCapital, v_capCum into vm_capCum, v_co2eq into vm_co2eq, p11_emiAP_endu into pm_emiAP_endu, q_fuel2pe into qm_fuel2pe
-# p_priceCO2 into pm_priceCO2, c_GDPscen into cm_GDPscen, v_INIdemEn0 into v05_INIdemEn0, v_INIcap0 into v05_INIcap0, f33_data_weathering_graderegi into f33_maxProdGradeRegiWeathering
-# pm_dataemi into pm_emifac, f_co2magpietax50 into p_macPolCO2luc
-# p_dataren into pm_dataren
-# v_capDistr into vm_capDistr, v_storloss into v32_storloss
-# p_storexp into p32_storexp, p_gridexp into p32_gridexp, p_grid_factor into p32_grid_factor, p_factorStorage into p32_factorStorage, p_correct into pm_correct, pm_data|nu into pm_cf
-# p_factorStorage into f32_factorStorage, p_shCHP into f_shCHP, f_shCHP into f32_shCHP
-# q_storloss into q32_storloss
-############################################################
diff --git a/config/scenario_config_SSPSDP.csv b/config/scenario_config_SSPSDP.csv
index 52b781725e20807d9c994072cf16a934a701861b..14fe386d7cb39f1568e56ef6087319b99d2509d2 100644
--- a/config/scenario_config_SSPSDP.csv
+++ b/config/scenario_config_SSPSDP.csv
@@ -1,4 +1,4 @@
-title;start;regionmapping;CES_parameters;cm_bioenergy_tax;cm_rcp_scen;cm_iterative_target_adj;cm_nash_autoconverge;cm_iteration_max;c_budgetCO2;carbonprice;cm_co2_tax_2020;cm_peakBudgYr;cm_taxCO2inc_after_peakBudgYr;cm_CO2priceRegConvEndYr;cm_emiscen;cm_earlyreti_rate;cm_fetaxscen;cm_co2_tax_growth;cm_bioenergymaxscen;c_ccsinjecratescen;c_ccscapratescen;techpol;cm_POPscen;cm_GDPscen;cm_oil_scen;cm_gas_scen;cm_coal_scen;c_techAssumptScen;cm_nucscen;cm_so2tax_scen;cm_multigasscen;cm_OILRETIRE;cm_LU_emi_scen;cm_tradecost_bio;c_1stgen_phaseout;c_SSP_forcing_adjust;cm_APscen;cm_startyear;path_gdx;path_gdx_ref;path_gdx_bau
+title;start;regionmapping;CES_parameters;cm_bioenergy_tax;cm_rcp_scen;cm_iterative_target_adj;cm_nash_autoconverge;cm_iteration_max;c_budgetCO2;carbonprice;cm_co2_tax_2020;cm_peakBudgYr;cm_taxCO2inc_after_peakBudgYr;cm_CO2priceRegConvEndYr;cm_emiscen;cm_earlyreti_rate;cm_fetaxscen;cm_co2_tax_growth;cm_bioenergymaxscen;c_ccsinjecratescen;c_ccscapratescen;techpol;cm_POPscen;cm_GDPscen;cm_oil_scen;cm_gas_scen;cm_coal_scen;c_techAssumptScen;cm_nucscen;cm_so2tax_scen;cm_multigasscen;cm_OILRETIRE;cm_LU_emi_scen;cm_tradecost_bio;cm_1stgen_phaseout;c_SSP_forcing_adjust;cm_APscen;cm_startyear;path_gdx;path_gdx_ref;path_gdx_bau
 SSP1-calibrate;0;./config/regionmappingH12.csv;calibrate;1.75;none;0;1;1;0;none;-1;2100;3;2050;1;0.09;2;1.025;0;2;1;none;pop_SSP1;gdp_SSP1;lowOil;lowGas;lowCoal;2;2;4;2;off;SSP1;1;1;forcing_SSP1;SSP1;2005;./config/input.gdx;;
 SSP1-Base;1;./config/regionmappingH12.csv;load;1.75;none;0;1;1;0;none;-1;2100;3;2050;1;0.09;2;1.025;0;2;1;none;pop_SSP1;gdp_SSP1;lowOil;lowGas;lowCoal;2;2;4;2;off;SSP1;1;1;forcing_SSP1;SSP1;2005;./config/input.gdx;;
 SSP1-NDC;1;./config/regionmappingH12.csv;load;1.75;rcp45;3;1;1;0;NDC2018;1;2100;3;2050;9;0.09;2;1.025;0;2;1;NDC2018;pop_SSP1;gdp_SSP1;lowOil;lowGas;lowCoal;2;2;4;3;off;SSP1;1;1;forcing_SSP1;SSP1;2015;./config/input.gdx;SSP2-NDC;SSP1-Base
diff --git a/core/bounds.gms b/core/bounds.gms
index caa86b3a1a6d8fa339f2291ccbf95905fcfcefe6..b84c883e8065a23ce1b98317c9dc5416bef89c86 100755
--- a/core/bounds.gms
+++ b/core/bounds.gms
@@ -235,7 +235,7 @@ if (cm_nucscen eq 7,
 *** -------------------------------------------------------------
 *** *DK* Phaseout of 1st generation biofuel technologies
 *** -------------------------------------------------------------
-if(c_1stgen_phaseout=1,
+if(cm_1stgen_phaseout=1,
    vm_deltaCap.up(t,regi,"bioeths",rlf)$(t.val gt 2030)   = 0;
    vm_deltaCap.up(t,regi,"biodiesel",rlf)$(t.val gt 2030) = 0;
 );
diff --git a/core/datainput.gms b/core/datainput.gms
index c66719be62df33cd0bfb19db1afae2f72a9ca7be..e1071c09080f68ae9fe9cc354124838336a941b9 100644
--- a/core/datainput.gms
+++ b/core/datainput.gms
@@ -112,15 +112,10 @@ p_developmentState(tall,all_regi) = f_developmentState(tall,all_regi,"%c_GDPpcSc
 
 
 *** Load information from BAU run
-$ifthen.cm_compile_main %cm_compile_main% == "TRUE"
-pm_gdp_gdx(ttot,regi) = 0;
-p_inv_gdx(ttot,regi)  = 0;
-$else.cm_compile_main
 Execute_Loadpoint 'input'      vm_cesIO, vm_invMacro;
 
 pm_gdp_gdx(ttot,regi)    = vm_cesIO.l(ttot,regi,"inco");
 p_inv_gdx(ttot,regi)     = vm_invMacro.l(ttot,regi,"kap");
-$endif.cm_compile_main
 
 *** permit price initilization
 pm_pricePerm(ttot) = 0;
diff --git a/core/declarations.gms b/core/declarations.gms
index 24c678af81d2a9e61fcf1ed4c81db2fb1a5deb96..70d781ed938afa6c42072fac42eef3620f256150 100644
--- a/core/declarations.gms
+++ b/core/declarations.gms
@@ -261,9 +261,7 @@ vm_emiFgas(tall,all_regi,all_enty)                   "F-gas emissions by single
 positive variables
 ***----------------------------------------------------------------------------------------
 ***-------------------------------------------------MACRO module---------------------------
-vm_effGr(ttot,all_regi,all_in)                       "growth of factor efficiency"
 vm_enerSerAdj(tall,all_regi,all_in)                  "adjustment costs for energy service transformations"
-vm_damageFactor(ttot,all_regi)                       "damage factor reducing GDP"
 vm_esCapInv(ttot,all_regi,all_teEs)                   "investment for energy end-use capital at the energy service level"
 ***----------------------------------------------------------------------------------------
 *-----------------------------------------------ESM module---------------------------------
diff --git a/core/equations.gms b/core/equations.gms
index 310c89bd965601911427b71734538226be8e636a..a9647754c0bffa6573ca78bb749d4db0c48b69bc 100644
--- a/core/equations.gms
+++ b/core/equations.gms
@@ -467,12 +467,13 @@ q_costTeCapital(t,regi,teLearn) ..
 ***---------------------------------------------------------------------------
 *** this is to prevent that in the long term, all solids are supplied by biomass. Residential solids can be fully supplied by biomass (-> wood pellets), so the FE residential demand is subtracted
 *** vm_cesIO(t,regi,"fesob") will be 0 in the stationary realization
-q_limitBiotrmod(t,regi)$(t.val > 2050).. 
+q_limitBiotrmod(t,regi)$(t.val > 2020).. 
     vm_prodSe(t,regi,"pebiolc","sesobio","biotrmod") 
    - sum (in$sameAs("fesob",in), vm_cesIO(t,regi,in)) 
    - sum (fe2es(entyFe,esty,teEs)$buildMoBio(esty), vm_demFeForEs(t,regi,entyFe,esty,teEs) )
     =l=
-    3 * vm_prodSe(t,regi,"pecoal","sesofos","coaltr") 
+    (2 +  max(0,min(1,( 2100 - pm_ttot_val(t)) / ( 2100 - 2020 ))) * 3) !! 5 in 2020 and 2 in 2100
+    * vm_prodSe(t,regi,"pecoal","sesofos","coaltr") 
 ;
 
 ***-----------------------------------------------------------------------------
diff --git a/scripts/run_submit/read_DAT_SURFACE_TEMP.R b/core/magicc/read_DAT_SURFACE_TEMP.R
similarity index 100%
rename from scripts/run_submit/read_DAT_SURFACE_TEMP.R
rename to core/magicc/read_DAT_SURFACE_TEMP.R
diff --git a/scripts/run_submit/read_DAT_TOTAL_ANTHRO_RF.R b/core/magicc/read_DAT_TOTAL_ANTHRO_RF.R
similarity index 100%
rename from scripts/run_submit/read_DAT_TOTAL_ANTHRO_RF.R
rename to core/magicc/read_DAT_TOTAL_ANTHRO_RF.R
diff --git a/scripts/run_submit/run_magicc.R b/core/magicc/run_magicc.R
similarity index 100%
rename from scripts/run_submit/run_magicc.R
rename to core/magicc/run_magicc.R
diff --git a/scripts/run_submit/run_magicc_temperatureImpulseResponse.R b/core/magicc/run_magicc_temperatureImpulseResponse.R
similarity index 100%
rename from scripts/run_submit/run_magicc_temperatureImpulseResponse.R
rename to core/magicc/run_magicc_temperatureImpulseResponse.R
diff --git a/main.gms b/main.gms
index 28d1f96390b904de9ea78836e88eab65fdf265e2..9b4d5af16797b890dbd87125a02340e04faff2f3 100644
--- a/main.gms
+++ b/main.gms
@@ -74,7 +74,7 @@
 * 
 * Input data revision: 5.937
 * 
-* Last modification (input data): Wed Jan 15 14:19:35 2020
+* Last modification (input data): Wed Jan 29 14:50:17 2020
 * 
 *###################### R SECTION END (VERSION INFO) ###########################
 
@@ -120,7 +120,7 @@ option profile = 0;
 
 
 ***---------------------    Run name    -----------------------------------------
-$setGlobal c_expname  default
+$setGlobal c_expname  Base_Conservative_liquids
 
 ***------------------------------------------------------------------------------
 ***                           MODULES
@@ -219,7 +219,7 @@ c_solscen             "solar option choice"
 cm_bioenergy_tax      "level of bioenergy tax in fraction of bioenergy price"
 cm_bioenergymaxscen   "choose bound on global pebiolc production excluding residues"
 cm_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_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]"
 c_start_budget        "start of GHG budget limit"
@@ -312,7 +312,7 @@ cm_bioenergy_tax    = 1.5;       !! def = 1.5
 cm_bioenergymaxscen = 0;         !! def = 0
 cm_tradecost_bio     = 2;         !! def = 2
 $setglobal cm_LU_emi_scen  SSP2   !! def = SSP2
-c_1stgen_phaseout  = 0;         !! def = 0
+cm_1stgen_phaseout  = 0;         !! def = 0
 cm_cprice_red_factor  = 0.5;         !! def = 0.5
 
 $setglobal cm_POPscen  pop_SSP2  !! def = pop_SSP2
@@ -344,7 +344,7 @@ cm_earlyreti_rate   = 0.09;      !! def 0.09
 
 cm_so2tax_scen        = 1;         !! def =
 c_cint_scen           = 1;         !! def = 1
-cm_damage              = 0.005;     !! def = 0.005
+cm_damage             = 0.005;     !! def = 0.005
 cm_solwindenergyscen  = 1;         !! def = 1
 c_techAssumptScen     = 1;         !! def = 1
 c_ccsinjecratescen    = 1;         !! def = 1
@@ -361,14 +361,14 @@ cm_expoLinear_yearStart  = 2050;   !! def = 2050
 c_budgetCO2FFI           = 1000;   !! def = 1000
 c_abtrdy                 = 2010;   !! def = 2010
 c_abtcst                 = 1;      !! def = 1
-c_budgetCO2              = 1350;   !! def = 1300
+c_budgetCO2              = 0;   !! def = 1300
 $setGlobal cm_regiCO2target  off       !! def = off
 cm_peakBudgYr                 = 2050;    !! def = 2050
 cm_taxCO2inc_after_peakBudgYr = 2;      !! def = 2
 cm_CO2priceRegConvEndYr       = 2050;   !! def = 2050
 
 cm_trdadj            = 2;    !! def = 2.0
-cm_trdcst             = 1.5;  !! def = 1.5
+cm_trdcst            = 1.5;  !! def = 1.5
 c_refcapbnd          = 0;    !! def = 0
 cm_frac_CCS          = 10;   !! def = 10
 cm_frac_NetNegEmi    = 0.5;  !! def = 0.5
@@ -379,10 +379,10 @@ cm_damages_SccHorizon                 = 100;   !! def = 100
 cm_carbonprice_temperatureLimit       = 1.8;   !! def = 1.8
 
 
-cm_DiscRateScen = 0;!! def = 0
-cm_noReboundEffect = 0;
-$setGlobal cm_EsubGrowth  low  !! def = low
-$setGlobal c_scaleEmiHistorical  off  !! def = off
+cm_DiscRateScen        = 0;!! def = 0
+cm_noReboundEffect     = 0;
+$setGlobal cm_EsubGrowth         low  !! def = low
+$setGlobal c_scaleEmiHistorical  on  !! def = on
 
 $setGlobal cm_EDGEtr_scen  Conservative_liquids  !! def = Conservative_liquids
 
@@ -394,8 +394,8 @@ $setGlobal c_regi_capturescen  all !! def = all
 *** --------------------------------------------------------------------------------------------------------------------------------------------------------------------
 *--------------------flags------------------------------------------------------------
 $SETGLOBAL cm_SlowConvergence  off        !! def = off
-$setGlobal cm_nash_mode  parallel   !! def = parallel
-$setGlobal c_EARLYRETIRE        on         !! def = on
+$setGlobal cm_nash_mode  parallel      !! def = parallel
+$setGlobal c_EARLYRETIRE       on         !! def = on
 $setGlobal cm_OILRETIRE  off        !! def = off
 $setglobal cm_INCONV_PENALTY  on         !! def = on
 $setGlobal cm_so2_out_of_opt  on         !! def = on
@@ -411,8 +411,6 @@ $setGlobal cm_magicc_temperatureImpulseResponse  off           !! def = off
 
 $setGlobal cm_damage_DiceLike_specification  HowardNonCatastrophic   !! def = HowardNonCatastrophic
 
-
-$setglobal cm_compile_main       TRUE     !! this will be changed by submit.R
 $setglobal cm_CES_configuration  stat_off-indu_fixed_shares-buil_simple-tran_edge_esm-POP_pop_SSP2-GDP_gdp_SSP2-Kap_perfect-Reg_690d3718e1   !! this will be changed by start_run()
 
 $setglobal c_CES_calibration_new_structure  0    !! def =  0
diff --git a/modules/04_PE_FE_parameters/iea2014/realization.gms b/modules/04_PE_FE_parameters/iea2014/realization.gms
index 68d3d7ab4bc5b58a65e5d437a55d3c41ac9076a5..ba858b8f411d7bd0098bca57992281884eda9ee3 100644
--- a/modules/04_PE_FE_parameters/iea2014/realization.gms
+++ b/modules/04_PE_FE_parameters/iea2014/realization.gms
@@ -7,6 +7,15 @@
 
 
 *' @description This realization used IEA data from 2014.
+*' The realization iea2014 serves to caliibrate the conversion efficiencies 
+*' to be consistent with predefined dataset (here iea2014, but it is flexible for up-dates). 
+*' The module realization starts with the final energy demands and then derives backwards
+*' what the secondary and primary energy demands have been. 
+*' The file datainput.gms reads in the energy data related to each process. The process related inputs are
+*' contained in input/f04_IO_input.cs4r and the output are contained in input/f04_IO_output.cs4r.
+*' These files also contain all information about existing and statistically reported joint production processes.
+*' Based on these energy flows the corresponding conversion efficiencies that replicate these energy flows.
+*' The efficiencies are assigned to the parameter pm_data(*,"eta",*).
 
 *####################### R SECTION START (PHASES) ##############################
 $Ifi "%phase%" == "sets" $include "./modules/04_PE_FE_parameters/iea2014/sets.gms"
diff --git a/modules/20_growth/exogenous/declarations.gms b/modules/20_growth/exogenous/declarations.gms
new file mode 100644
index 0000000000000000000000000000000000000000..ef1c82f9ba6a80be290a38e3548755f2e864e88d
--- /dev/null
+++ b/modules/20_growth/exogenous/declarations.gms
@@ -0,0 +1,11 @@
+*** |  (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/20_growth/exogenous/declarations.gms
+positive variables
+vm_effGr(ttot,all_regi,all_in)            "growth of factor efficiency"
+;
+*** EOF ./modules/20_growth/exogenous/declarations.gms
diff --git a/modules/20_growth/exogenous/realization.gms b/modules/20_growth/exogenous/realization.gms
index 026e242d0b41ea4b0e22e127a179eb31019fc764..6afbb3dffe95d18476a3ac597d19b39044930002 100644
--- a/modules/20_growth/exogenous/realization.gms
+++ b/modules/20_growth/exogenous/realization.gms
@@ -16,6 +16,7 @@
 *' growth paths in reaction of policy shocks. This correction is done by an adjustment of capital accumulation.
 
 *####################### R SECTION START (PHASES) ##############################
+$Ifi "%phase%" == "declarations" $include "./modules/20_growth/exogenous/declarations.gms"
 $Ifi "%phase%" == "bounds" $include "./modules/20_growth/exogenous/bounds.gms"
 *######################## R SECTION END (PHASES) ###############################
 *** EOF ./modules/20_growth/exogenous.gms
diff --git a/modules/20_growth/spillover/declarations.gms b/modules/20_growth/spillover/declarations.gms
index d861ca228be5700d05f46f1b5489661f84173560..6333cbadddc64714a75768dc129a87968c25408e 100644
--- a/modules/20_growth/spillover/declarations.gms
+++ b/modules/20_growth/spillover/declarations.gms
@@ -24,6 +24,7 @@ Parameters
 
 *mlb*  vm_invInno and  vm_invImi and pm_cumEff shifted to the core folder
 Positive variables
+ vm_effGr(ttot,all_regi,all_in)            "growth of factor efficiency"
  v20_effInno(ttot,all_regi,all_in)         "efficiency improvement by innovation"
  v20_effImi(ttot,all_regi,all_in)          "efficiency improvement by imitation"
 ;
diff --git a/modules/29_CES_parameters/calibrate/declarations.gms b/modules/29_CES_parameters/calibrate/declarations.gms
index 945ae9204a872fec74c62f8c1bf25e1f9bd3ff4b..f9bb79e053211486f55083e22aaa73cb1e3ab29e 100644
--- a/modules/29_CES_parameters/calibrate/declarations.gms
+++ b/modules/29_CES_parameters/calibrate/declarations.gms
@@ -17,7 +17,7 @@ Parameters
   p29_effGr(tall,all_regi,all_in)                                   "growth of factor efficiency from input.gdx"
   p29_fedemand(tall,all_regi,all_GDPscen,all_in)                  "final energy demand"
   p29_cesdata_price(tall,all_regi,all_in)                          "exogenous prices in case they are needed"
-  p29_trpdemand(tall,all_regi,all_GDPscen,all_in)                 "transport demand for the edge_esm transport module"
+  p29_trpdemand(tall,all_regi,all_GDPscen,EDGE_scenario_all,all_in) "transport demand for the edge_esm transport module, unit: trillion passenger/ton km"
   p29_esdemand(tall,all_regi,all_GDPscen,all_in)                  "energy service demand"
   p29_efficiency_growth(tall,all_regi,all_GDPscen,all_in)         "efficency level paths for ppf beyond calibration"
   p29_capitalQuantity(tall,all_regi,all_GDPscen,all_in)            "capital quantities"
diff --git a/modules/29_CES_parameters/calibrate/preloop.gms b/modules/29_CES_parameters/calibrate/preloop.gms
index 1459222a2ad32e46f6a4d01a5d95bd859e9be3f5..52e1e4977b5a78b411b0bc899002c3d075cb291a 100644
--- a/modules/29_CES_parameters/calibrate/preloop.gms
+++ b/modules/29_CES_parameters/calibrate/preloop.gms
@@ -309,9 +309,35 @@ pm_cesdata(t,regi,in_29,"price") $ (( not ((ord(t) le 1) or (ord(t) eq card(t)))
 
   Display p29_alpha, p29_beta;
 
+*** for entrp_frgt_lo
 *** pass on to pm_cesdata and ensure the resulting price is positive
   loop (ttot$( ttot.val ge 2005 AND ttot.val lt 2020),
-    pm_cesdata(ttot,regi_dyn29(regi),in_29,"price")$(ppf_29(in_29))
+    pm_cesdata(ttot,regi_dyn29(regi),"entrp_frgt_lo","price")
+    = max(
+    1e-3,
+    ( pm_cesdata(ttot,regi,"entrp_frgt_lo","price")
+      + p29_alpha(regi,"entrp_frgt_lo") + p29_beta(regi,"entrp_frgt_lo") * ttot.val
+      )
+    / 2
+    );
+  );
+
+*** Set minimal price for all periods
+  loop (ttot$( ttot.val ge 2005),
+    pm_cesdata(ttot,regi_dyn29(regi),"entrp_frgt_lo","price")
+    = max(
+    1e-3,
+    pm_cesdata(ttot,regi,"entrp_frgt_lo","price")
+    );
+  );
+
+display "after entrp_frgt_lo smoothening", pm_cesdata;
+
+
+*** for all other modes
+*** pass on to pm_cesdata and ensure the resulting price is positive
+  loop (ttot$( ttot.val ge 2005 AND ttot.val lt 2020),
+    pm_cesdata(ttot,regi_dyn29(regi),in_29,"price")$(ppf_29(in_29) AND (NOT sameas(in_29, "entrp_frgt_lo")))
     = max(
     1e-2,
     ( pm_cesdata(ttot,regi,in_29,"price")
@@ -323,14 +349,14 @@ pm_cesdata(t,regi,in_29,"price") $ (( not ((ord(t) le 1) or (ord(t) eq card(t)))
 
 *** Set minimal price for all periods
   loop (ttot$( ttot.val ge 2005),
-    pm_cesdata(ttot,regi_dyn29(regi),in_29,"price")$(ppf_29(in_29))
+    pm_cesdata(ttot,regi_dyn29(regi),in_29,"price")$(ppf_29(in_29) AND (NOT sameas(in_29, "entrp_frgt_lo")))
     = max(
     1e-2,
     pm_cesdata(ttot,regi,in_29,"price")
     );
   );
 
-
+display "after all but entrp_frgt_lo smoothening", pm_cesdata;
 
 *** Smooth prices for the whole period for elements in or below the putty-clay structure
 ***Problem if there are several ppfIO_putty below each other, prices are then smoothed twice
diff --git a/modules/30_biomass/exogenous/not_used.txt b/modules/30_biomass/exogenous/not_used.txt
index f87fe85e940c5f8a320d5d61e5ad78e6a0ee7034..2092da81065d77d93a2487c88b48cfec24605557 100644
--- a/modules/30_biomass/exogenous/not_used.txt
+++ b/modules/30_biomass/exogenous/not_used.txt
@@ -15,3 +15,4 @@ pm_costsTradePeFinancial,parameter,???
 sm_eps,scalar,???
 sm_EJ_2_TWa,input,questionnaire
 pm_ts,input,questionnaire
+cm_1stgen_phaseout,input,questionnaire
diff --git a/modules/30_biomass/magpie_40/bounds.gms b/modules/30_biomass/magpie_40/bounds.gms
index 6cb6344c2643989654940bf52b340572d0546f8a..b64fdf33713d8aeb11e212a03d9ade2ae70c2ef5 100644
--- a/modules/30_biomass/magpie_40/bounds.gms
+++ b/modules/30_biomass/magpie_40/bounds.gms
@@ -24,8 +24,13 @@
 vm_fuExtr.up(t,regi,"pebios","5")$(t.val ge 2045)  = p30_datapebio(regi,"pebios","5","maxprod",t);
 vm_fuExtr.up(t,regi,"pebioil","5")$(t.val ge 2030) = p30_datapebio(regi,"pebioil","5","maxprod",t);
 
-vm_fuExtr.lo(t,regi,"pebios","5")$(t.val ge 2030)  = p30_datapebio(regi,"pebios","5","maxprod",t)*0.9;
-vm_fuExtr.lo(t,regi,"pebioil","5")$(t.val ge 2030) = p30_datapebio(regi,"pebioil","5","maxprod",t)*0.9;
+if(cm_1stgen_phaseout=0,
+    vm_fuExtr.lo(t,regi,"pebios","5")$(t.val ge 2030)  = p30_datapebio(regi,"pebios","5","maxprod",t)*0.9;
+    vm_fuExtr.lo(t,regi,"pebioil","5")$(t.val ge 2030) = p30_datapebio(regi,"pebioil","5","maxprod",t)*0.9;
+else
+    vm_fuExtr.lo(t,regi,"pebios","5")$(t.val eq 2030)  = p30_datapebio(regi,"pebios","5","maxprod",t)*0.9;
+    vm_fuExtr.lo(t,regi,"pebioil","5")$(t.val eq 2030) = p30_datapebio(regi,"pebioil","5","maxprod",t)*0.9;
+);
 
 *** -------------------------------------------------------------
 *** Bounds on 2nd generation biomass annual production
diff --git a/modules/32_power/IntC/realization.gms b/modules/32_power/IntC/realization.gms
index 268ee0445d0d02a64a36624f42ce551e79f29acd..9acb0a5a87a9e1480f6f767a9e1f5d85d9e274a6 100644
--- a/modules/32_power/IntC/realization.gms
+++ b/modules/32_power/IntC/realization.gms
@@ -8,17 +8,17 @@
 
 *' @description  
 *'
-*'The `IntC` realization (Integrated Costs) assume a single electricity market balance.
+*'The `IntC` realization (Integrated Costs) assumes a single electricity market balance.
 *'
-*'This module determine power system supply specific technology behavior, which summs up to the general core capacity equations to define the power sector operation and investment decisions.
+*'This module determines power system supply specific technology behavior, which sums up to the general core capacity equations to define the power sector operation and investment decisions.
 *'
-*'Contrary to other secondary energies in REMIND, this requires to move the electricity secondary energy balance (supply = demand) from the core to the module code.
+*'Contrary to other secondary energy types in REMIND, this requires to move the electricity secondary energy balance (supply = demand) from the core to the module code.
 *'
 *'
 *'In summary, the specific power technology equations found in this module reflect the points below.
 *'
 *'
-*'Storage requirements are based on intermittent renewables share, sinergies between different renewables production profiles and curtailment.
+*'Storage requirements are based on intermittent renewables share, synergies between different renewables production profiles and curtailment.
 *'
 *'Additional grid capacities are calculated for high intermittent renewable capacity (solar and wind) and regional spatial differences. 
 *'
diff --git a/modules/35_transport/edge_esm/datainput.gms b/modules/35_transport/edge_esm/datainput.gms
index f3afadf5b27b95bcd54c352cba233fd2c7bebc38..65600afadc45a0ee6eb92ff0efc163157feb54f9 100644
--- a/modules/35_transport/edge_esm/datainput.gms
+++ b/modules/35_transport/edge_esm/datainput.gms
@@ -8,9 +8,9 @@
 Parameter
   p35_cesdata_sigma(all_in)  "substitution elasticities"
   /
-    entrp           1.3
-      entrp_pass    1.1
-      entrp_frgt    1.1
+    entrp           0.8
+      entrp_pass    1.3
+      entrp_frgt    1.3
   /
 ;
 pm_cesdata_sigma(ttot,in)$p35_cesdata_sigma(in) = p35_cesdata_sigma(in);
diff --git a/modules/35_transport/edge_esm/declarations.gms b/modules/35_transport/edge_esm/declarations.gms
index ba00f04b5b1412c4d996d034c3ce9f8de211ec3c..ddfaab6c774e84cbd2e41de1089f76a035982279 100644
--- a/modules/35_transport/edge_esm/declarations.gms
+++ b/modules/35_transport/edge_esm/declarations.gms
@@ -12,6 +12,6 @@ vm_shSynSe(ttot,all_regi)   "Share of synthetic liquids in all fossil liquids. V
 
 Equations
 q35_shBioFe(ttot,all_regi)  "Define the share of biofuels in all final energies for transportation."
-q35_shSynSe(ttot,all_regi)  "Define share of synthetic liquids in all fossil liquids."
+*q35_shSynSe(ttot,all_regi)  "Define share of synthetic liquids in all fossil liquids."
 ;
 *** EOF ./modules/35_transport/edge_esm/declarations.gms
diff --git a/modules/50_damages/BurkeLike/declarations.gms b/modules/50_damages/BurkeLike/declarations.gms
index 2091c966591ca726878654e0341aa6d28f3ea6f5..8d886c33e816d59ce709b3853c31fcfd4d72c8c3 100644
--- a/modules/50_damages/BurkeLike/declarations.gms
+++ b/modules/50_damages/BurkeLike/declarations.gms
@@ -4,8 +4,13 @@
 *** |  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/50_damages/BurkeLike/declarations.gms
 parameters
 p50_damageFuncCoef1     "coef1 of damamge function",
 p50_damageFuncCoef2     "coef2 of damamge function"
 ;
+
+positive variable
+vm_damageFactor(ttot,all_regi)      "damage factor reducing GDP"
+;
+*** EOF ./modules/50_damages/BurkeLike/declarations.gms
diff --git a/modules/50_damages/DiceLike/declarations.gms b/modules/50_damages/DiceLike/declarations.gms
index a3e8cc1f0dc90ec1efb1a1029b8966804b99ffb1..d03b467b44a81ef0daa5cb34da9abb661c4ae8b3 100644
--- a/modules/50_damages/DiceLike/declarations.gms
+++ b/modules/50_damages/DiceLike/declarations.gms
@@ -4,7 +4,13 @@
 *** |  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/50_damages/DiceLike/declarations.gms
 parameters
 p50_damageFuncCoef1			"damage function coefficient, linear in temperature"
 p50_damageFuncCoef2 			"damage function coefficient, quadratic in temperture"
 ;
+
+positive variable
+vm_damageFactor(ttot,all_regi)      "damage factor reducing GDP"
+;
+*** EOF ./modules/50_damages/DiceLike/declarations.gms
diff --git a/modules/50_damages/off/declarations.gms b/modules/50_damages/off/declarations.gms
new file mode 100644
index 0000000000000000000000000000000000000000..dea6d758d1441423be0db207919b74fabdd583a4
--- /dev/null
+++ b/modules/50_damages/off/declarations.gms
@@ -0,0 +1,11 @@
+*** |  (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/50_damages/off/declarations.gms
+positive variable
+vm_damageFactor(ttot,all_regi)      "damage factor reducing GDP"
+;
+*** EOF ./modules/50_damages/off/declarations.gms
diff --git a/modules/50_damages/off/realization.gms b/modules/50_damages/off/realization.gms
index 1db5be04680fb06f3d5573228a5ca1be579f353f..af494173342dc89198d68b6cb760fe90297a06ab 100644
--- a/modules/50_damages/off/realization.gms
+++ b/modules/50_damages/off/realization.gms
@@ -9,6 +9,7 @@
 *' @description The off-realization of the damage module sets the damage factor on output to 1, meaning no damage.
 
 *####################### R SECTION START (PHASES) ##############################
+$Ifi "%phase%" == "declarations" $include "./modules/50_damages/off/declarations.gms"
 $Ifi "%phase%" == "bounds" $include "./modules/50_damages/off/bounds.gms"
 *######################## R SECTION END (PHASES) ###############################
 *** EOF ./modules/50_damages/off.gms
diff --git a/modules/80_optimization/negishi/datainput.gms b/modules/80_optimization/negishi/datainput.gms
index 4a8c2b62946d15c4e80ed4df753425fcbc6d409e..3644ed887487047d62fba5308abc953957671a43 100644
--- a/modules/80_optimization/negishi/datainput.gms
+++ b/modules/80_optimization/negishi/datainput.gms
@@ -9,15 +9,12 @@
 pm_pvp(ttot,trade)$(ttot.val ge 2005)               = 1;
 p80_trade(ttot,regi,trade)$(ttot.val ge 2005)       = 0;
 
-$ifthen.cm_compile_main %cm_compile_main% == "FALSE"
-
 if (cm_emiscen eq 1,
   Execute_Loadpoint "./input.gdx", p80_currentaccount_bau = p80_curracc;
 else
   Execute_Loadpoint "./input_ref.gdx", p80_currentaccount_bau = p80_curracc;
 );
 
-$endif.cm_compile_main
 
 p80_defic_sum("1") = 1;
 
diff --git a/modules/80_optimization/negishi/solve.gms b/modules/80_optimization/negishi/solve.gms
index 1178dd7d28756047691d964349c65cd043806859..867a525c94c72ae133d2ff4db551168c151e1de8 100644
--- a/modules/80_optimization/negishi/solve.gms
+++ b/modules/80_optimization/negishi/solve.gms
@@ -24,20 +24,20 @@ if(o_modelstat eq 2,
 
 IF(o_modelstat eq 2, 
 *AJS*2013-05* Default Negishi convergence scheme:
-    if (ord(iteration) eq 1, s80_cnptfile = 2);
-    if (ord(iteration) eq 2, s80_cnptfile = 3);
-    if (ord(iteration) eq 3, s80_cnptfile = 4);
-    if (ord(iteration) eq 4, s80_cnptfile = 5);
+    if (ord(iteration) eq 1, s80_cnptfile = 2); !! rtredg = 1.d-6
+    if (ord(iteration) eq 2, s80_cnptfile = 3); !! rtredg = 1.d-7
+    if (ord(iteration) eq 3, s80_cnptfile = 3); !! rtredg = 1.d-7
+    if (ord(iteration) eq 4, s80_cnptfile = 3); !! rtredg = 1.d-7
 *RP* Slower convergence scheme
 $IFTHEN.cm_SlowConvergence %cm_SlowConvergence% == "on"
-    if (ord(iteration) eq 1, s80_cnptfile = 1);
-    if (ord(iteration) eq 2, s80_cnptfile = 2);
-    if (ord(iteration) eq 3, s80_cnptfile = 2);
-    if (ord(iteration) eq 4, s80_cnptfile = 3);
-    if (ord(iteration) eq 5, s80_cnptfile = 3);
-    if (ord(iteration) eq 6, s80_cnptfile = 4);
-    if (ord(iteration) eq 7, s80_cnptfile = 4);
-    if (ord(iteration) eq 8, s80_cnptfile = 5);
+    if (ord(iteration) eq 1, s80_cnptfile = 1); !! rtredg = 1.d-5
+    if (ord(iteration) eq 2, s80_cnptfile = 2); !! rtredg = 1.d-6
+    if (ord(iteration) eq 3, s80_cnptfile = 2); !! rtredg = 1.d-6
+    if (ord(iteration) eq 4, s80_cnptfile = 3); !! rtredg = 1.d-7
+    if (ord(iteration) eq 5, s80_cnptfile = 3); !! rtredg = 1.d-7
+    if (ord(iteration) eq 6, s80_cnptfile = 3); !! rtredg = 1.d-7
+    if (ord(iteration) eq 7, s80_cnptfile = 3); !! rtredg = 1.d-7
+    if (ord(iteration) eq 8, s80_cnptfile = 3); !! rtredg = 1.d-7
 $ENDIF.cm_SlowConvergence
 );
 *** EOF ./modules/80_optimization/negishi/solve.gms
diff --git a/modules/80_optimization/testOneRegi/solve.gms b/modules/80_optimization/testOneRegi/solve.gms
index 870fece4e18ba1f3b89858487fae3f9c25dcfbe7..d411b54c7499de847cc6e27bedb33a6a4014407e 100644
--- a/modules/80_optimization/testOneRegi/solve.gms
+++ b/modules/80_optimization/testOneRegi/solve.gms
@@ -6,8 +6,7 @@
 *** |  Contact: remind@pik-potsdam.de
 *** SOF ./modules/80_optimization/testOneRegi/solve.gms
 
-$IFI %optimization% == "testOneRegi" s80_cnptfile = 9;
-hybrid.optfile = s80_cnptfile;
+hybrid.optfile = 9;
 
 ***reduce the problem to one region
 regi(all_regi) = NO;
diff --git a/oneRegi.R b/oneRegi.R
deleted file mode 100644
index 98fa3f5ca4d5913a62bedb66074a237f618ff3d9..0000000000000000000000000000000000000000
--- a/oneRegi.R
+++ /dev/null
@@ -1,30 +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
-#! /usr/bin/Rscript
-
-##########################################################
-#### Script to start a REMIND run ####
-##########################################################
-
-library(lucode, quietly = TRUE, warn.conflicts = FALSE)
-library(magclass, quietly = TRUE, warn.conflicts = FALSE)
-
-#Here the function start_run(cfg) is loaded which is needed to start REMIND runs
-#The function needs information about the configuration of the run. This can be either supplied as a list of settings or as a file name of a config file
-source("scripts/start_functions.R")
-
-if (file.exists("./output/testOneRegi/"))
-    unlink("./output/testOneRegi/", recursive = TRUE)
-
-#Load config-file
-cfg_REMIND <- "oneRegi.cfg"
-readArgs("cfg")
-
-# start REMIND run
-start_run(cfg_REMIND)
-#rep = read.report("coupling.mif")
-#start_reportrun(rep)
diff --git a/scripts/output/comparison/compareScenarios.R b/scripts/output/comparison/compareScenarios.R
index b94620870fad0274945ed2df4c64a510934d6921..4019b2c2ff2d9094f29a3d423dd6fefd46b90e33 100644
--- a/scripts/output/comparison/compareScenarios.R
+++ b/scripts/output/comparison/compareScenarios.R
@@ -52,11 +52,12 @@ start_comp <- function(outputdirs,shortTerm,outfilename) {
   cat("Starting ",jobname,"\n")
   on_cluster <- file.exists("/p/projects/")
   if (on_cluster) {
-    system(paste0("srun --qos=standby --job-name=",jobname," --output=",jobname,".out --error=",jobname,".err --mail-type=END --time=200 --mem-per-cpu=8000 Rscript scripts/run_submit/run_compareScenarios.R outputdirs=",paste(outputdirs,collapse=",")," shortTerm=",shortTerm," outfilename=",jobname," &"))
+    clcom <- paste0("sbatch --qos=standby --job-name=",jobname," --output=",jobname,".out --error=",jobname,".err --mail-type=END --time=200 --mem-per-cpu=8000 --wrap=\"Rscript scripts/utils/run_compareScenarios.R outputdirs=",paste(outputdirs,collapse=",")," shortTerm=",shortTerm," outfilename=",jobname,"\"")
+    system(clcom)
   } else {
     outfilename    <- jobname
     tmp.env <- new.env()
-    script <- "scripts/run_submit/run_compareScenarios.R"
+    script <- "scripts/utils/run_compareScenarios.R"
     tmp.error <- try(sys.source(script,envir=tmp.env))
     if(!is.null(tmp.error)) warning("Script ",script," was stopped by an error and not executed properly!")
     rm(tmp.env)
diff --git a/scripts/output/comparison/multiComparison.R b/scripts/output/comparison/multiComparison.R
index 44b05cf5abc547f444ddd435251e85897a96da79..c8f173e759fbdcca412bce556c0598509043d923 100644
--- a/scripts/output/comparison/multiComparison.R
+++ b/scripts/output/comparison/multiComparison.R
@@ -66,7 +66,7 @@ compareScenTable <- function(listofruns){
 
   if(system("hash sbatch 2>/dev/null") == 0){
     cat("Submitting comparison Jobs:\n")
-    system("sbatch scripts/run_submit/submit_compare.cmd")
+     system(paste0("sbatch --job-name=rem-compare --output=log-%j.out --mail-type=END --cpus-per-task=2 --qos=priority --wrap=\"Rscript scripts/utils/compareParallel.R \""))
   }else{
     source("scripts/utils/compareParallel.R")
   }
diff --git a/scripts/performance_test.R b/scripts/performance_test.R
deleted file mode 100644
index df4ca2f0e108d664d0e0a0dd1c9cf075db62ddf5..0000000000000000000000000000000000000000
--- a/scripts/performance_test.R
+++ /dev/null
@@ -1,277 +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
-source("scripts/start_functions.R")
-
-
-performance_start <- function(cfg="default.cfg",modulepath="modules/",id="performance",sequential=NULL) {
-  require(lucode)
-  
-  if(!is.list(cfg)) {
-    if(is.character(cfg)) {
-      source(path("config",cfg),local=TRUE)
-      if(!is.list(cfg)) stop("Wrong input file format: config file does not contain a cfg list!")
-    } else {
-      stop("Wrong input format: cfg is neither a list nor a character!")
-    }
-  }
-  
-  cfg$results_folder <- "output/:title:"
-
-  cfg$sequential <- sequential
-  cfg$logoption <- 2
-  
-  #LB# funzt erstmal nicht in REMIND
-  #svn <- system("svn info",intern=TRUE) 
-  #save(svn,file="svn.rda")
-  #cfg$files2export$start <- c(cfg$files2export$start,"svn.rda")
- 
-  #start default run
-  cfg$title <- paste(id,"default",sep="__")
-  cat(cfg$title,"\n")
-  start_run(cfg) 
- 
-  m <- getModules(modulepath)
-  for(i in 1:dim(m)[1]) {
-  #for(i in c(1,3,4)) {    
-    default <- cfg$gms[[m[i,"name"]]]
-    r <- strsplit(m[i,"realizations"],",")[[1]]
-    r <- r[r!=default]  #remove default case
-    for(j in r) {
-      cfg$gms[[m[i,"name"]]] <- j
-      cfg$title <- paste(id,m[i,"name"],j,sep="__")
-      cat(cfg$title,"\n")
-      start_functions(cfg)  # for REMIND
-      # start_run(cfg)  # for MAGPIE
-    }
-    cfg$gms[[m[i,"name"]]] <- default  
-  } 
-}
-
-performance_collect <- function(id="performance",results_folder="output/",plot=TRUE) {
-  require(magpie)
-  require(lucode)
-  maindir <- getwd()
-  cat("\n wir sind in ", maindir,"\n")
-  on.exit(setwd(maindir))
-  setwd(results_folder) 
-  cat("\n wir sind in ",results_folder,"\n")
-  folders <- grep(paste("^",id,"__",sep=""),list.dirs(),value=TRUE)
-  tmp <- grep(paste("^",id,"__default",sep=""),folders)
-  default <- folders[tmp]
-  if(length(default)==0) stop("No default folder found which fits to the given id (",id,")")
-  folders <- folders[-tmp]
-  if(length(folders)==0) stop("No folders found which fit to the given id (",id,")")
- 
-  .modelstats <- function(f,colMeans=TRUE) {
-#    logfile <- path(f,"log.txt")   # for MAGPIE
-    logfile <- path(f,"full.log")   # for REMIND
-    tmp <- readLines(logfile)
-    l1 <- grep("rows",tmp,value=TRUE)
-    l2 <- grep("nl-code",tmp,value=TRUE)
-    
-    if(length(l1)==0 & length(l2)==0) return(NA)
-    
-    p1 <- "---   ([^ ]*) rows  ([^ ]*) columns  ([^ ]*) non-zeroes"
-    rows <- as.integer(gsub(",","",gsub(p1,"\\1",l1)))
-    columns <- as.integer(gsub(",","",gsub(p1,"\\2",l1)))
-    nonzeroes <- as.integer(gsub(",","",gsub(p1,"\\3",l1)))
-    
-    p2 <- "---   ([^ ]*) nl-code  ([^ ]*) nl-non-zeroes"
-    nlcode <- as.integer(gsub(",","",gsub(p2,"\\1",l2)))
-    nlnonzeroes <- as.integer(gsub(",","",gsub(p2,"\\2",l2)))
-    
-    out <- cbind(rows,columns,nonzeroes,nlcode,nlnonzeroes)
-    rownames(out) <- paste("t",1:dim(out)[1],sep="")
-    if(colMeans) out <- colMeans(out)
-    return(out)
-    
-  }
-  
-  .infescheck <- function(gdx) {
-    if(!file.exists(gdx)) return(3)
-    tmp <- modelstat(gdx)
-    if(any(tmp!=2 & tmp!=7)) {
-      x <- 2
-    } else if(any(tmp!=2 & tmp==7)) {
-      x <- 1      
-    } else {
-      x <- 0            
-    }
-    return(x)
-    
-  }
-  
-  .gettime <- function(rdata) {
-    load(rdata)   
-   # tmp <- as.double(validation$technical$time$magpie.gms,unit="mins") # for MAGPIE
-    tmp <- as.double(validation$technical$time$full.gms,unit="mins") # for REMIND
-    return(tmp)
-   
-  }
-  
-  
-  results <- NULL
-  infes <- list()
-  cat("\n folgende folder werden gleich bearbeitet ",folders,"\n")
-  for(f in folders){
-    tmp <- strsplit(f,"__")[[1]]
-    ms <- .modelstats(f,colMeans=TRUE) 
-    cat("\n module ",tmp[2],"\n")
-    cat("\n realization ",tmp[3],"\n")
-    # for MAGPIE
-    #tmp2 <- data.frame(module=tmp[2],realization=tmp[3],default=FALSE,runtime=.gettime(path(f,f,ftype="RData")),infes=.infescheck(path(f,"fulldata.gdx")),
-    #                   rows=ms["rows"],columns=ms["columns"],nonzeroes=ms["nonzeroes"],nlcode=ms["nlcode"],nlnonzeroes=ms["nlnonzeroes"])
-    # for REMIND
-    tmp2 <- data.frame(module=tmp[2],realization=tmp[3],default=FALSE,runtime=.gettime(path(f,f,ftype="RData")),infes=.infescheck(path(f,"optim.gdx")),
-                       rows=ms["rows"],columns=ms["columns"],nonzeroes=ms["nonzeroes"],nlcode=ms["nlcode"],nlnonzeroes=ms["nlnonzeroes"])
-    results <- rbind(results,tmp2)
-  }
-  
-  load(path(default,"config.Rdata"))
-  for(n in unique(results$module)) {
-    ms <- .modelstats(default,colMeans=TRUE)
-    # for MAGPIE
-    # tmp <- data.frame(module=n,realization=cfg$gms[[n]],default=TRUE,runtime=.gettime(path(default,default,ftype="RData")),infes=.infescheck(path(default,"fulldata.gdx")),
-    #                  rows=ms["rows"],columns=ms["columns"],nonzeroes=ms["nonzeroes"],nlcode=ms["nlcode"],nlnonzeroes=ms["nlnonzeroes"])
-    # for REMIND
-    tmp <- data.frame(module=n,realization=cfg$gms[[n]],default=TRUE,runtime=.gettime(path(default,default,ftype="RData")),infes=.infescheck(path(default,"optim.gdx")),
-                      rows=ms["rows"],columns=ms["columns"],nonzeroes=ms["nonzeroes"],nlcode=ms["nlcode"],nlnonzeroes=ms["nlnonzeroes"])
-    results <- rbind(results,tmp)    
-  }  
-  
-  results$info <- paste(results$module,results$realization,sep=": ")
-  results$relative_runtime <- results$runtime/results[results$default,"runtime"][1] - 1
-  results$more_info[results$default] <- "default"
-  results$more_info[results$infes==0 & !results$default] <- paste(round(results$relative_runtime[results$infes==0 & !results$default]*100),"%",sep="")
-  results$more_info[results$infes==1] <- "non-optimal solution"
-  results$more_info[results$infes==2] <- "infeasible solution"
-  results$more_info[results$infes==3] <- "compilation error"
-  results$relative_rows <- results$rows/results[results$default,"rows"][1] - 1
-  results$relative_columns <- results$columns/results[results$default,"columns"][1] - 1
-  results$relative_nonzeroes <- results$nonzeroes/results[results$default,"nonzeroes"][1] - 1
-  results$relative_nlcode <- results$nlcode/results[results$default,"nlcode"][1] - 1
-  results$relative_nlnonzeroes <- results$nlnonzeroes/results[results$default,"nlnonzeroes"][1] - 1
-  attr(results,"default_cfg") <- cfg
-  attr(results,"id") <- id
-  
-  #if(file.exists(path(default,"svn.rda"))) {
-  #  load(path(default,"svn.rda"))
-  #  attr(results,"svn") <- svn
-  #}
-  
-  setwd(maindir)
-  if(plot) performance_plot(results)
-  return(results)
-}
-
-
-performance_plot <- function(x) {
-  require(ggplot2)
-  require(lusweave)
-  
-  .create_plot <- function(x,weight="relative_runtime",label="runtime/default_runtime2") {
-    p <- ggplot(x, aes_string(x="info",weight=weight,fill="module")) + geom_bar(position="dodge")+coord_flip()+labs(y=label,x="",size=2)
-    p <- p +  geom_text(aes(y=0,label=more_info), hjust=0, size = 3) + theme(legend.position="none")
-    print(p)
-  }
-  
-  .tmptable <- function(sw,tmp) {
-    nrow <- ceiling(length(tmp)/2)
-    if(nrow*2 > length(tmp)) tmp <- c(tmp,"")
-    swtable(sw,matrix(tmp,nrow),align="l",include.colnames=FALSE,include.rownames=FALSE,vert.lines=0,hor.lines=0)
-    return(sw)
-  }
-  
-  sw_option <- "width=11,height=12"
-  
-  sw <- swopen(paste("performance_check_",attr(x,"id"),".pdf",sep=""))
-  swlatex(sw,c("\\title{Performance test results}","\\author{Model Operations Group}","\\maketitle","\\tableofcontents"))
-
-  swlatex(sw,"\\newpage")
-  
-  swlatex(sw,"\\section{General information}")
-  swlatex(sw,"\\subsection{Settings default run}")
-  
-  sw <- .tmptable(sw,x$info[x$more_info =="default"])
-  
-  swlatex(sw,"\\subsection{Run information default run}")
-  tmp <- x[x$more_info=="default",][1,c("runtime","rows","columns","nonzeroes","nlcode","nlnonzeroes")]
-  tmp2 <- cbind(format(round(as.vector(as.matrix(tmp)),2),nsmall=2),names(tmp))
-  rownames(tmp2) <- names(tmp)
-  colnames(tmp2) <- c("data","description")
-  tmp2[,"description"] <- c(" minutes (total runtime)",
-                            " (average over all optimizations)",
-                            " (average over all optimizations)",
-                            " (average over all optimizations)",
-                            " (average over all optimizations)",
-                            " (average over all optimizations)")
-  
-  swtable(sw,tmp2,align="r")
-  
-  
-  swlatex(sw,"\\newpage")
-  
-  #remove default run from results
-  x <- x[x$more_info!="default",]
-  
-  tmp <- x$info[x$more_info =="compilation error"]
-  if(length(tmp)>0){
-    swlatex(sw,"\\subsection{Compilation errors}")
-    sw <- .tmptable(sw,tmp)
-    #remove runs with compilation error from results
-    x <- x[x$more_info!="compilation error",]
-  }
-
-  tmp <- x$info[x$more_info =="infeasible solution"]
-  if(length(tmp)>0){
-    swlatex(sw,"\\subsection{Infeasible solutions}")
-    sw <- .tmptable(sw,tmp)
-  }
-  
-  .tmp <- function(sw,x) {
-     swlatex(sw,"\\subsection{relative runtime}")
-     swfigure(sw,.create_plot,x,weight="relative_runtime",label="runtime relative to default run",sw_option=sw_option)
-     swlatex(sw,"\\subsection{relative number of rows}")
-     swfigure(sw,.create_plot,x,weight="relative_rows",label="No. of rows relative to default",sw_option=sw_option)
-     swlatex(sw,"\\subsection{relative number of columns}")
-     swfigure(sw,.create_plot,x,weight="relative_columns",label="No. of columns relative to default",sw_option=sw_option)
-     swlatex(sw,"\\subsection{relative number of nonzeroes}")
-     swfigure(sw,.create_plot,x,weight="relative_nonzeroes",label="No. of nonzeroes relative to default",sw_option=sw_option)
-     swlatex(sw,"\\subsection{relative number of nl code}")
-     swfigure(sw,.create_plot,x,weight="relative_nlcode",label="Lines of NL code relative to default",sw_option=sw_option)
-     swlatex(sw,"\\subsection{relative number of nl nonzeroes}")
-     swfigure(sw,.create_plot,x,weight="relative_nlnonzeroes",label="No. of NL nonzeroes relative to default",sw_option=sw_option)
-    return(sw)
-  }
-  
-  swlatex(sw,"\\section{Results sorted by module}")
-  sw <- .tmp(sw,x)
-  
-  x <- x[order(x$runtime,decreasing=TRUE),]
-  x$info <- factor(x$info,x$info)
-  
-  swlatex(sw,"\\section{Results sorted by runtime}")
-  sw <- .tmp(sw,x)
-
-  if(!is.null(attr(x,"svn"))){ 
-    swlatex(sw,"\\section{SVN info}")
-    sw <- .tmptable(sw,c(attr(x,"svn"),rep("",length(attr(x,"svn")))))
-  }
-
-  swlatex(sw,"\\newpage\\section{Full default config}")
-  tmp <- unlist(attr(x,"default_cfg"))
-  n <- 35
-  while(length(tmp)>n) {
-    sw <- .tmptable(sw,c(names(tmp)[1:n],tmp[1:n]))
-    tmp <- tmp[-(1:n)]
-  }
-  sw <- .tmptable(sw,c(names(tmp),tmp))
- 
-
-  swclose(sw)
-}
-
diff --git a/scripts/run_submit/submit.R b/scripts/run_submit/submit.R
deleted file mode 100644
index 0f3f49bc130768e9aca91a7e5d2bd7aa21ffc562..0000000000000000000000000000000000000000
--- a/scripts/run_submit/submit.R
+++ /dev/null
@@ -1,423 +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)
-library(dplyr, quietly = TRUE,warn.conflicts =FALSE)
-require(gdx)
-
-
-
-# Function to create the levs.gms, fixings.gms, and margs.gms files, used in 
-# delay scenarios.
-create_fixing_files <- function(cfg, input_ref_file = "input_ref.gdx") {
-  
-  # Start the clock.
-  begin <- Sys.time()
-  
-  # Extract data from input_ref.gdx file and store in levs_margs_ref.gms. 
-  system(paste("gdxdump", 
-               input_ref_file, 
-               "Format=gamsbas Delim=comma FilterDef=N Output=levs_margs_ref.gms", 
-               sep = " "))
-  
-  # Read data from levs_margs_ref.gms.
-  ref_gdx_data <- suppressWarnings(readLines("levs_margs_ref.gms"))
-  
-  # Create fixing files.
-  cat("\n")
-  create_standard_fixings(cfg, ref_gdx_data)
-  
-  # Stop the clock.
-  cat("Time it took to create the fixing files: ")
-  manipulate_runtime <- Sys.time()-begin
-  print(manipulate_runtime)
-  cat("\n")
-  
-  
-  # Delete file.
-  file.remove("levs_margs_ref.gms")
-  
-}
-
-
-# Function to create the levs.gms, fixings.gms, and margs.gms files, used in 
-# the standard (i.e. the non-macro stand-alone) delay scenarios.
-create_standard_fixings <- function(cfg, ref_gdx_data) {
-  
-  # Declare empty lists to hold the strings for the 'manipulateFile' functions. 
-  full_manipulateThis <- NULL
-  levs_manipulateThis <- NULL
-  fixings_manipulateThis <- NULL
-  margs_manipulateThis <- NULL
-
-  str_years <- c()
-  no_years  <- (cfg$gms$cm_startyear - 2005) / 5  
-  
-  # Write level values to file
-  levs <- c()
-  for (i in 1:no_years) {
-    str_years[i] <- paste("L \\('", 2000 + i * 5, sep = "")
-    levs         <- c(levs, grep(str_years[i], ref_gdx_data, value = TRUE))
-  }
-  
-  writeLines(levs, "levs.gms")
-  
-  # Replace fixing.gms with level values
-  file.copy("levs.gms", "fixings.gms", overwrite = TRUE)
-
-  fixings_manipulateThis <- c(fixings_manipulateThis, list(c(".L ", ".FX ")))
-  #cb q_co2eq is only "static" equation to be active before cm_startyear, as multigasscen could be different from a scenario to another that is fixed on the first  
-  #cb therefore, vm_co2eq cannot be fixed, otherwise infeasibilities would result. vm_co2eq.M is meaningless, is never used in the code (a manipulateFile delete line command would be even better)
-  #  manipulateFile("fixings.gms", list(c("vm_co2eq.FX ", "vm_co2eq.M ")))
-  
-  # Write marginal values to file
-  margs <- c()
-  str_years    <- c()
-  for (i in 1:no_years) {
-    str_years[i] <- paste("M \\('", 2000 + i * 5, sep = "")
-    margs        <- c(margs, grep(str_years[i], ref_gdx_data, value = TRUE))
-  }
-  writeLines(margs, "margs.gms")
-   # temporary fix so that you can use older gdx for fixings - will become obsolete in the future and can be deleted once the next variable name change is done
-  margs_manipulateThis <- c(margs_manipulateThis, list(c("q_taxrev","q21_taxrev")))
-  # fixing for SPA runs based on ModPol input data
-  margs_manipulateThis <- c(margs_manipulateThis, 
-                            list(c("q41_emitrade_restr_mp.M", "!!q41_emitrade_restr_mp.M")),
-                            list(c("q41_emitrade_restr_mp2.M", "!!q41_emitrade_restr_mp2.M"))) 
-  
-  #AJS this symbol is not known and crashes the run - is it depreciated? TODO 
-  levs_manipulateThis <- c(levs_manipulateThis, 
-                           list(c("vm_pebiolc_price_base.L", "!!vm_pebiolc_price_base.L")))
-  
-  #AJS filter out nash marginals in negishi case, as they would lead to a crash when trying to fix on them:
-  if(cfg$gms$optimization == 'negishi'){
-    margs_manipulateThis <- c(margs_manipulateThis, list(c("q80_costAdjNash.M", "!!q80_costAdjNash.M")))
-  }
-  if(cfg$gms$subsidizeLearning == 'off'){
-    levs_manipulateThis <- c(levs_manipulateThis, 
-                             list(c("v22_costSubsidizeLearningForeign.L",
-                                    "!!v22_costSubsidizeLearningForeign.L")))
-    margs_manipulateThis <- c(margs_manipulateThis, 
-                              list(c("q22_costSubsidizeLearning.M", "!!q22_costSubsidizeLearning.M")),
-                              list(c("v22_costSubsidizeLearningForeign.M",
-                                     "!!v22_costSubsidizeLearningForeign.M")),
-                              list(c("q22_costSubsidizeLearningForeign.M",
-                                     "!!q22_costSubsidizeLearningForeign.M")))
-    fixings_manipulateThis <- c(fixings_manipulateThis, 
-                                list(c("v22_costSubsidizeLearningForeign.FX",
-                                       "!!v22_costSubsidizeLearningForeign.FX")))
-    
-  }
-  
-  #JH filter out negishi marginals in nash case, as they would lead to a crash when trying to fix on them:
-  if(cfg$gms$optimization == 'nash'){
-    margs_manipulateThis <- c(margs_manipulateThis, 
-                              list(c("q80_balTrade.M", "!!q80_balTrade.M")),
-                              list(c("q80_budget_helper.M", "!!q80_budget_helper.M")))
-  }
-  #RP filter out module 40 techpol fixings 
-  if(cfg$gms$techpol == 'none'){
-    margs_manipulateThis <- c(margs_manipulateThis, 
-                              list(c("q40_NewRenBound.M", "!!q40_NewRenBound.M")),
-                              list(c("q40_CoalBound.M", "!!q40_CoalBound.M")),
-                              list(c("q40_LowCarbonBound.M", "!!q40_LowCarbonBound.M")),
-                              list(c("q40_FE_RenShare.M", "!!q40_FE_RenShare.M")),
-                              list(c("q40_trp_bound.M", "!!q40_trp_bound.M")),
-                              list(c("q40_TechBound.M", "!!q40_TechBound.M")),
-                              list(c("q40_ElecBioBound.M", "!!q40_ElecBioBound.M")),
-                              list(c("q40_PEBound.M", "!!q40_PEBound.M")),
-                              list(c("q40_PEcoalBound.M", "!!q40_PEcoalBound.M")),
-                              list(c("q40_PEgasBound.M", "!!q40_PEgasBound.M")),
-                              list(c("q40_PElowcarbonBound.M", "!!q40_PElowcarbonBound.M")),
-                              list(c("q40_EV_share.M", "!!q40_EV_share.M")),
-                              list(c("q40_TrpEnergyRed.M", "!!q40_TrpEnergyRed.M")),
-                              list(c("q40_El_RenShare.M", "!!q40_El_RenShare.M")),
-                              list(c("q40_BioFuelBound.M", "!!q40_BioFuelBound.M")))
-
-  }
-  
-  if(cfg$gms$techpol == 'NPi2018'){
-    margs_manipulateThis <- c(margs_manipulateThis, 
-                              list(c("q40_El_RenShare.M", "!!q40_El_RenShare.M")),
-                              list(c("q40_CoalBound.M", "!!q40_CoalBound.M")))
-  }
-  
-  # Include fixings (levels) and marginals in full.gms at predefined position 
-  # in core/loop.gms.
-  full_manipulateThis <- c(full_manipulateThis, 
-                           list(c("cb20150605readinpositionforlevelfile",
-                                  paste("first offlisting inclusion of levs.gms so that level value can be accessed",
-                                        "$offlisting",
-                                        "$include \"levs.gms\";",
-                                        "$onlisting", sep = "\n"))))
-  full_manipulateThis <- c(full_manipulateThis, list(c("cb20140305readinpositionforfinxingfiles",
-                                                       paste("offlisting inclusion of levs.gms, fixings.gms, and margs.gms",
-                                                             "$offlisting",
-                                                             "$include \"levs.gms\";",
-                                                             "$include \"fixings.gms\";",
-                                                             "$include \"margs.gms\";",
-                                                             "$onlisting", sep = "\n"))))
-  
-  
-  # Perform actual manipulation on levs.gms, fixings.gms, and margs.gms in 
-  # single, respective, parses of the texts.
-  manipulateFile("levs.gms", levs_manipulateThis)
-  manipulateFile("fixings.gms", fixings_manipulateThis)
-  manipulateFile("margs.gms", margs_manipulateThis)
-  
-  # Perform actual manipulation on full.gms, in single parse of the text.
-  manipulateFile("full.gms", full_manipulateThis)
-}
-
-
-
-
-
-# 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")
-
-
-#AJS set MAGCFG file
-magcfgFile = paste0('./magicc/MAGCFG_STORE/','MAGCFG_USER_',toupper(cfg$gms$cm_magicc_config),'.CFG')
-if(!file.exists(magcfgFile)){
-    stop(paste('ERROR in MAGGICC configuration: Could not find file ',magcfgFile))
-}
-system(paste0('cp ',magcfgFile,' ','./magicc/MAGCFG_USER.CFG'))
-
-# 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")))
-
-# Prepare the files containing the fixings for delay scenarios (for fixed runs)
-if (  cfg$gms$cm_startyear > 2005  & (!file.exists("levs.gms.gz") | !file.exists("levs.gms"))) {
-  create_fixing_files(cfg = cfg, input_ref_file = "input_ref.gdx")
-}
-
- 
-# 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...\n")
-
-# Save start time
-begin <- Sys.time()
-
-# Call GAMS
-if (cfg$gms$CES_parameters == "load") {
-
-  system(paste0(cfg$gamsv, " full.gms -errmsg=1 -a=", cfg$action, 
-                " -ps=0 -pw=185 -gdxcompress=1 -logoption=", cfg$logoption))
-
-} else if (cfg$gms$CES_parameters == "calibrate") {
-
-  # Remember file modification time of fulldata.gdx to see if it changed
-  fulldata_m_time <- Sys.time();
-
-  # Save original input
-  file.copy("input.gdx", "input_00.gdx", overwrite = TRUE)
-
-  # Iterate calibration algorithm
-  for (cal_itr in 1:cfg$gms$c_CES_calibration_iterations) {
-    cat("CES calibration iteration: ", cal_itr, "\n")
-
-    # Update calibration iteration in GAMS file
-    system(paste0("sed -i 's/^\\(\\$setglobal c_CES_calibration_iteration ", 
-                  "\\).*/\\1", cal_itr, "/' full.gms"))
-
-    system(paste0(cfg$gamsv, " full.gms -errmsg=1 -a=", cfg$action, 
-                  " -ps=0 -pw=185 -gdxcompress=1 -logoption=", cfg$logoption))
-
-    # If GAMS found a solution
-    if (   file.exists("fulldata.gdx")
-        && file.info("fulldata.gdx")$mtime > fulldata_m_time) {
-      
-      #create the file to be used in the load mode
-      getLoadFile <- function(){
-        
-        file_name = paste0(cfg$gms$cm_CES_configuration,"_ITERATION_",cal_itr,".inc")
-        ces_in = system("gdxdump fulldata.gdx symb=in NoHeader Format=CSV", intern = TRUE) %>% gsub("\"","",.) #" This comment is just to obtain correct syntax highlighting
-        expr_ces_in = paste0("(",paste(ces_in, collapse = "|") ,")")
-
-        
-        tmp = system("gdxdump fulldata.gdx symb=pm_cesdata", intern = TRUE)[-(1:2)] %>% 
-          grep("(quantity|price|eff|effgr|xi|rho|offset_quantity|compl_coef)", x = ., value = TRUE)
-        tmp = tmp %>% grep(expr_ces_in,x = ., value = T)
-        
-        tmp %>%
-          sub("'([^']*)'.'([^']*)'.'([^']*)'.'([^']*)' (.*)[ ,][ /];?",
-              "pm_cesdata(\"\\1\",\"\\2\",\"\\3\",\"\\4\") = \\5;", x = .) %>%
-          write(file_name)
-        
-        
-        pm_cesdata_putty = system("gdxdump fulldata.gdx symb=pm_cesdata_putty", intern = TRUE)
-        if (length(pm_cesdata_putty) == 2){
-          tmp_putty =  gsub("^Parameter *([A-z_(,)])+cesParameters\\).*$",'\\1"quantity")  =   0;',  pm_cesdata_putty[2])
-        } else {
-          tmp_putty = pm_cesdata_putty[-(1:2)] %>%
-            grep("quantity", x = ., value = TRUE) %>%
-            grep(expr_ces_in,x = ., value = T)
-        }
-        tmp_putty %>%
-          sub("'([^']*)'.'([^']*)'.'([^']*)'.'([^']*)' (.*)[ ,][ /];?",
-              "pm_cesdata_putty(\"\\1\",\"\\2\",\"\\3\",\"\\4\") = \\5;", x = .)%>% write(file_name,append =T)
-      }
-      
-      getLoadFile()
-
-      # Store all the interesting output
-      file.copy("full.lst", sprintf("full_%02i.lst", cal_itr), overwrite = TRUE)
-      file.copy("full.log", sprintf("full_%02i.log", cal_itr), overwrite = TRUE)
-      file.copy("fulldata.gdx", "input.gdx", overwrite = TRUE)
-      file.copy("fulldata.gdx", sprintf("input_%02i.gdx", cal_itr), 
-                overwrite = TRUE)
-
-      # Update file modification time
-      fulldata_m_time <- file.info("fulldata.gdx")$mtime
-
-    } else {
-      break
-    }
-  }
-} else {
-  stop("unknown realisation of 29_CES_parameters")
-}
-
-# Calculate run time
-gams_runtime <- Sys.time() - begin
-
-# If REMIND actually did run
-if (cfg$action == "ce" && cfg$gms$c_skip_output != "on") {
-
-  # Print Message
-  cat("\nREMIND run finished!\n")
-
-  # Create solution report for Nash runs
-  if (cfg$gms$optimization == "nash" && cfg$gms$cm_nash_mode != "debug" && file.exists("fulldata.gdx")) {
-    system("gdxdump fulldata.gdx Format=gamsbas Delim=comma Output=output_nash.gms")
-    file.append("full.lst", "output_nash.gms")
-    file.remove("output_nash.gms")
-  }
-}
-
-# Collect and submit run statistics to central data base
-lucode::runstatistics(file       = "runstatistics.rda",
-                      modelstat  = readGDX(gdx="fulldata.gdx","o_modelstat", format="first_found"),
-                      config     = cfg,
-                      runtime    = gams_runtime,
-                      setup_info = lucode::setup_info(),
-                      submit     = cfg$runstatistics)
-
-# Compress files with the fixing-information
-if (cfg$gms$cm_startyear > 2005) 
-  system("gzip -f levs.gms margs.gms fixings.gms")
-
-# go up to the main folder, where the cfg files for subsequent runs are stored
-setwd(cfg$remind_folder)
-
-#====================== Subsequent runs ===========================
-
-# 1. Save the path to the fulldata.gdx of the current run to the cfg files 
-# of the runs that use it as 'input_bau.gdx'
-
-# 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)
-
-no_ref_runs <- identical(cfg$RunsUsingTHISgdxAsBAU,character(0)) | all(is.na(cfg$RunsUsingTHISgdxAsBAU)) | coupled_run
-
-if(!no_ref_runs) {
-  source("scripts/start_functions.R")
-  # Save the current cfg settings into a different data object, so that they are not overwritten
-  cfg_main <- cfg
-  
-  for(run in seq(1,length(cfg_main$RunsUsingTHISgdxAsBAU))){
-    # for each of the runs that use this gdx as bau, read in the cfg, ...
-    cat("Writing the path for input_bau.gdx to ",paste0(cfg_main$RunsUsingTHISgdxAsBAU[run],".RData"),"\n")
-    load(paste0(cfg_main$RunsUsingTHISgdxAsBAU[run],".RData"))
-    # ...change the path_gdx_bau field of the subsequent run to the fulldata gdx of the current run ...
-    cfg$files2export$start['input_bau.gdx'] <- paste0(cfg_main$remind_folder,"/",cfg_main$results_folder,"/fulldata.gdx")
-    save(cfg, file = paste0(cfg_main$RunsUsingTHISgdxAsBAU[run],".RData"))
-  }
-  # Set cfg back to original
-  cfg <- cfg_main
-}
-
-# 2. Save the path to the fulldata.gdx of the current run to the cfg files 
-# of the subsequent runs that use it as 'input_ref.gdx' and start these runs 
-
-no_subsequent_runs <- identical(cfg$subsequentruns,character(0)) | identical(cfg$subsequentruns,NULL) | coupled_run
-
-if(no_subsequent_runs){
-  cat('\nNo subsequent run was set for this scenario\n')
-} else {
-  # Save the current cfg settings into a different data object, so that they are not overwritten
-  cfg_main <- cfg
-  source("scripts/start_functions.R")
-  
-  for(run in seq(1,length(cfg_main$subsequentruns))){
-    # for each of the subsequent runs, read in the cfg, ...
-    cat("Writing the path for input_ref.gdx to ",paste0(cfg_main$subsequentruns[run],".RData"),"\n")
-    load(paste0(cfg_main$subsequentruns[run],".RData"))
-    # ...change the path_gdx_ref field of the subsequent run to the fulldata gdx of the current (preceding) run ...
-    cfg$files2export$start['input_ref.gdx'] <- paste0(cfg_main$remind_folder,"/",cfg_main$results_folder,"/fulldata.gdx")
-    save(cfg, file = paste0(cfg_main$subsequentruns[run],".RData"))
-    
-    # Subsequent runs will be started in submit.R using the RData files written above 
-    # after the current run has finished.
-    cat("Starting subsequent run ",cfg_main$subsequentruns[run],"\n")
-    start_run(cfg)
-  }
-  # Set cfg back to original
-  cfg <- cfg_main
-}
-
-# 3. Create script file that can be used later to restart the subsequent runs manually.
-# In case there are no subsequent runs (or it's coupled runs), the file contains only 
-# a small message.
-
-subseq_start_file  <- paste0(cfg$results_folder,"/start_subsequentruns.R")
-
-if(no_subsequent_runs){
-  write("cat('\nNo subsequent run was set for this scenario\n')",file=subseq_start_file)
-} else {
-  #  go up to the main folder, where the cfg. files for subsequent runs are stored
-  filetext <- paste0("setwd('",cfg$remind_folder,"')\n")
-  filetext <- paste0(filetext,"source('scripts/start_functions.R')\n")
-  for(run in seq(1,length(cfg$subsequentruns))){
-    filetext <- paste0(filetext,"\n")
-    filetext <- paste0(filetext,"load('",cfg$subsequentruns[run],".RData')\n")
-    filetext <- paste0(filetext,"cat('",cfg$subsequentruns[run],"')\n")
-    filetext <- paste0(filetext,"start_run(cfg)\n")
-  }
-  # Write the text to the file
-  write(filetext,file=subseq_start_file)
-}
-
-#=================== END - Subsequent runs ========================
-  
-# Print REMIND runtime
-cat("\n gams_runtime is ", gams_runtime, "\n")
-
-# 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())
-
diff --git a/scripts/run_submit/submit.cmd b/scripts/run_submit/submit.cmd
deleted file mode 100644
index 0204d41e0177bbdf917ce7a029dcb5a7f8fb62b7..0000000000000000000000000000000000000000
--- a/scripts/run_submit/submit.cmd
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-
-#--- Job Submission parameters ------
-#SBATCH --qos=medium
-#SBATCH --job-name=__JOB_NAME__
-#SBATCH --output=log.txt
-#SBATCH --tasks-per-node=2
-#SBATCH --mail-type=END
-#------------------------------------------------
-
-# report git revision info and changes in the files
-git rev-parse --short HEAD
-git status
-
-# start gams job
-Rscript submit.R
diff --git a/scripts/run_submit/submit_compare.cmd b/scripts/run_submit/submit_compare.cmd
deleted file mode 100644
index da97267709652632aa95f4731a7bef0e2fe84973..0000000000000000000000000000000000000000
--- a/scripts/run_submit/submit_compare.cmd
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/bash
-#SBATCH --qos=priority
-#SBATCH --job-name=rem-compare
-#SBATCH --output=log-%j.out
-#SBATCH --mail-type=END
-#SBATCH --mem=32000
-#SBATCH --cpus-per-task=2
-
-Rscript scripts/utils/compareParallel.R
diff --git a/scripts/run_submit/submit_par.cmd b/scripts/run_submit/submit_par.cmd
deleted file mode 100644
index efba22061431d14c7a7cd440913341692f0db0e9..0000000000000000000000000000000000000000
--- a/scripts/run_submit/submit_par.cmd
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/bash
-
-#--- Job Submission parameters ------
-#SBATCH --qos=short
-#SBATCH --job-name=__JOB_NAME__
-#SBATCH --output=log.txt
-#SBATCH --nodes=1
-#SBATCH --tasks-per-node=12
-#SBATCH --mail-type=END
-#------------------------------------------------
-
-# report git revision info and changes in the files
-git rev-parse --short HEAD
-git status
-
-# start gams job
-Rscript submit.R
diff --git a/scripts/run_submit/submit_par16.cmd b/scripts/run_submit/submit_par16.cmd
deleted file mode 100644
index 8018105bd0fae66f6fbf748902200916334f4af1..0000000000000000000000000000000000000000
--- a/scripts/run_submit/submit_par16.cmd
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/bash
-
-#--- Job Submission parameters ------
-#SBATCH --qos=short
-#SBATCH --job-name=__JOB_NAME__
-#SBATCH --output=log.txt
-#SBATCH --nodes=1
-#SBATCH --tasks-per-node=16
-#SBATCH --mail-type=END
-#------------------------------------------------
-
-# report git revision info and changes in the files
-git rev-parse --short HEAD
-git status
-
-# start gams job
-Rscript submit.R
diff --git a/scripts/run_submit/submit_short.cmd b/scripts/run_submit/submit_short.cmd
deleted file mode 100644
index da6cbea681316cab992b2162fc7bb08430f7fa19..0000000000000000000000000000000000000000
--- a/scripts/run_submit/submit_short.cmd
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/bash
-
-#--- Job Submission parameters ------
-#SBATCH --qos=short
-#SBATCH --job-name=__JOB_NAME__
-#SBATCH --output=log.txt
-#SBATCH --mail-type=END
-#------------------------------------------------
-
-# report git revision info and changes in the files
-git rev-parse --short HEAD
-git status
-
-# start gams job
-Rscript submit.R
diff --git a/scripts/start/choose_slurmConfig.R b/scripts/start/choose_slurmConfig.R
new file mode 100644
index 0000000000000000000000000000000000000000..f384c4eab22e2ec6f5db7d96b196250f216e8829
--- /dev/null
+++ b/scripts/start/choose_slurmConfig.R
@@ -0,0 +1,66 @@
+#######################################################################
+############### Select slurm partitiion ###############################
+#######################################################################
+
+get_line <- function(){
+  # gets characters (line) from the terminal or from a connection
+  # and returns it
+  if(interactive()){
+    s <- readline()
+  } else {
+    con <- file("stdin")
+    s <- readLines(con, 1, warn=FALSE)
+    on.exit(close(con))
+  }
+  return(s);
+}
+
+choose_slurmConfig <- function() {
+  
+  slurm <- suppressWarnings(ifelse(system2("srun",stdout=FALSE,stderr=FALSE) != 127, TRUE, FALSE))
+  if (slurm) {
+    modes <- c(" SLURM standby  - task per node: 12 (nash H12) [recommended]",
+               " SLURM standby  - task per node: 13 (nash H12 coupled)",
+               " SLURM standby  - task per node: 16 (nash H12+)",
+               " SLURM standby  - task per node:  1 (nash debug, test one regi)",
+               " SLURM priority - task per node: 12 (nash H12) [recommended]",
+               " SLURM priority - task per node: 13 (nash H12 coupled)",
+               " SLURM priority - task per node: 16 (nash H12+)",
+               " SLURM priority - task per node:  1 (nash debug, test one regi)",
+               " SLURM short    - task per node: 12 (nash H12)",
+               "SLURM short    - task per node: 16 (nash H12+)",
+               "SLURM short    - task per node:  1 (nash debug, test one regi)",
+               "SLURM medium   - task per node:  1 (negishi)",
+               "SLURM long     - task per node:  1 (negishi)")
+
+    cat("\nCurrent cluster utilization:\n")
+    system("sclass")
+    cat("\n")
+
+    cat("\nPlease choose run submission type:\n")
+    cat(paste(1:length(modes), modes, sep=": " ),sep="\n")
+    cat("Number: ")
+    identifier <- get_line()
+    identifier <- as.numeric(strsplit(identifier,",")[[1]])
+    comp <- switch(identifier,
+                   "1" = "--qos=standby --nodes=1 --tasks-per-node=12"  , # SLURM standby  - task per node: 12 (nash H12) [recommended]
+                   "2" = "--qos=standby --nodes=1 --tasks-per-node=13"  , # SLURM standby  - task per node: 13 (nash H12 coupled)
+                   "3" = "--qos=standby --nodes=1 --tasks-per-node=16"  , # SLURM standby  - task per node: 16 (nash H12+)
+                   "4" = "--qos=standby --nodes=1 --tasks-per-node=1"   , # SLURM standby  - task per node:  1 (nash debug, test one regi)
+                   "5" = "--qos=priority --nodes=1 --tasks-per-node=12" , # SLURM priority - task per node: 12 (nash H12) [recommended]
+                   "6" = "--qos=priority --nodes=1 --tasks-per-node=13" , # SLURM priority - task per node: 13 (nash H12 coupled)
+                   "7" = "--qos=priority --nodes=1 --tasks-per-node=16" , # SLURM priority - task per node: 16 (nash H12+)
+                   "8" = "--qos=priority --nodes=1 --tasks-per-node=1"  , # SLURM priority - task per node:  1 (nash debug, test one regi)
+                   "9" = "--qos=short --nodes=1 --tasks-per-node=12"    , # SLURM short    - task per node: 12 (nash H12)
+                  "10" = "--qos=short --nodes=1 --tasks-per-node=16"    , # SLURM short    - task per node: 16 (nash H12+)
+                  "11" = "--qos=short --nodes=1 --tasks-per-node=1"     , # SLURM short    - task per node:  1 (nash debug, test one regi)
+                  "12" = "--qos=medium --nodes=1 --tasks-per-node=1"    , # SLURM medium   - task per node:  1 (negishi)
+                  "13" = "--qos=long --nodes=1 --tasks-per-node=1"      ) # SLURM long     - task per node:  1 (negishi)
+                  
+    if(is.null(comp)) stop("This type is invalid. Please choose a valid type")
+  } else {
+    comp <- "direct"
+  }
+
+  return(comp)
+}
diff --git a/scripts/start_functions.R b/scripts/start/prepare_and_run.R
similarity index 51%
rename from scripts/start_functions.R
rename to scripts/start/prepare_and_run.R
index bab6e7630d707f3f4a90960705c4daacd4bcbcf4..a1346dab09f3c020da84b80c2dc0dc83bbbf683b 100644
--- a/scripts/start_functions.R
+++ b/scripts/start/prepare_and_run.R
@@ -1,10 +1,148 @@
-# |  (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
-start_run <- function(cfg, scenario = NULL, report = NULL, sceninreport = NULL, coupled = F, force = FALSE) {
+library(lucode, quietly = TRUE,warn.conflicts =FALSE)
+library(dplyr, quietly = TRUE,warn.conflicts =FALSE)
+require(gdx)
+
+getReportData <- function(path_to_report,inputpath_mag="magpie",inputpath_acc="costs") {
+	require(lucode, quietly = TRUE,warn.conflicts =FALSE)
+  require(magclass, quietly = TRUE,warn.conflicts =FALSE)
+  .bioenergy_price <- function(mag){
+    notGLO <- getRegions(mag)[!(getRegions(mag)=="GLO")]
+    if("Demand|Bioenergy|++|2nd generation (EJ/yr)" %in% getNames(mag)) {
+      # MAgPIE 4
+      out <- mag[,,"Prices|Bioenergy (US$05/GJ)"]*0.0315576 # with transformation factor from US$2005/GJ to US$2005/Wa
+    } else {
+      # MAgPIE 3
+      out <- mag[,,"Price|Primary Energy|Biomass (US$2005/GJ)"]*0.0315576 # with transformation factor from US$2005/GJ to US$2005/Wa
+    }
+    out["JPN",is.na(out["JPN",,]),] <- 0
+    dimnames(out)[[3]] <- NULL #Delete variable name to prevent it from being written into output file
+    write.magpie(out[notGLO,,],paste0("./modules/30_biomass/",inputpath_mag,"/input/p30_pebiolc_pricemag_coupling.csv"),file_type="csvr")
+  }  
+  .bioenergy_costs <- function(mag){
+    notGLO <- getRegions(mag)[!(getRegions(mag)=="GLO")]
+    if ("Production Cost|Agriculture|Biomass|Energy Crops (million US$2005/yr)" %in% getNames(mag)) {
+      out <- mag[,,"Production Cost|Agriculture|Biomass|Energy Crops (million US$2005/yr)"]/1000/1000 # with transformation factor from 10E6 US$2005 to 10E12 US$2005
+    }
+    else {
+      # in old MAgPIE reports the unit is reported to be "billion", however the values are in million
+      out <- mag[,,"Production Cost|Agriculture|Biomass|Energy Crops (billion US$2005/yr)"]/1000/1000 # with transformation factor from 10E6 US$2005 to 10E12 US$2005
+    }
+    out["JPN",is.na(out["JPN",,]),] <- 0
+    dimnames(out)[[3]] <- NULL
+    write.magpie(out[notGLO,,],paste0("./modules/30_biomass/",inputpath_mag,"/input/p30_pebiolc_costsmag.csv"),file_type="csvr")
+  }  
+  .bioenergy_production <- function(mag){
+    notGLO <- getRegions(mag)[!(getRegions(mag)=="GLO")]
+    if("Demand|Bioenergy|2nd generation|++|Bioenergy crops (EJ/yr)" %in% getNames(mag)) {
+      # MAgPIE 4
+      out <- mag[,,"Demand|Bioenergy|2nd generation|++|Bioenergy crops (EJ/yr)"]/31.536 # EJ to TWa
+    } else {
+      # MAgPIE 3
+      out <- mag[,,"Primary Energy Production|Biomass|Energy Crops (EJ/yr)"]/31.536 # EJ to TWa
+    }
+    out[which(out<0)] <- 0 # set negative values to zero since they cause errors in GMAS power function
+    out["JPN",is.na(out["JPN",,]),] <- 0
+    dimnames(out)[[3]] <- NULL
+    write.magpie(out[notGLO,,],paste0("./modules/30_biomass/",inputpath_mag,"/input/p30_pebiolc_demandmag_coupling.csv"),file_type="csvr")
+  }  
+  .emissions_mac <- function(mag) {
+    # define three columns of dataframe: 
+    #   emirem (remind emission names)
+    #   emimag (magpie emission names)
+    #   factor_mag2rem (factor for converting magpie to remind emissions)
+    #   1/1000*28/44, # kt N2O/yr -> Mt N2O/yr -> Mt N/yr
+    #   28/44,        # Tg N2O/yr =  Mt N2O/yr -> Mt N/yr
+    #   1/1000*12/44, # Mt CO2/yr -> Gt CO2/yr -> Gt C/yr
+    map <- data.frame(emirem=NULL,emimag=NULL,factor_mag2rem=NULL,stringsAsFactors=FALSE)
+    if("Emissions|N2O|Land|Agriculture|+|Animal Waste Management (Mt N2O/yr)" %in% getNames(mag)) {
+      # MAgPIE 4
+      map <- rbind(map,data.frame(emimag="Emissions|CO2|Land (Mt CO2/yr)",                                                                 emirem="co2luc",    factor_mag2rem=1/1000*12/44,stringsAsFactors=FALSE))
+      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land|Agriculture|+|Animal Waste Management (Mt N2O/yr)",                           emirem="n2oanwstm", factor_mag2rem=28/44,stringsAsFactors=FALSE))
+      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land|Agriculture|Agricultural Soils|+|Inorganic Fertilizers (Mt N2O/yr)",          emirem="n2ofertin", factor_mag2rem=28/44,stringsAsFactors=FALSE))
+      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land|Agriculture|Agricultural Soils|+|Manure applied to Croplands (Mt N2O/yr)",    emirem="n2oanwstc", factor_mag2rem=28/44,stringsAsFactors=FALSE))
+      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land|Agriculture|Agricultural Soils|+|Decay of Crop Residues (Mt N2O/yr)",         emirem="n2ofertcr", factor_mag2rem=28/44,stringsAsFactors=FALSE))
+      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land|Agriculture|Agricultural Soils|+|Soil Organic Matter Loss (Mt N2O/yr)",       emirem="n2ofertsom",factor_mag2rem=28/44,stringsAsFactors=FALSE))
+      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land|Agriculture|Agricultural Soils|+|Pasture (Mt N2O/yr)",                        emirem="n2oanwstp", factor_mag2rem=28/44,stringsAsFactors=FALSE))
+      map <- rbind(map,data.frame(emimag="Emissions|CH4|Land|Agriculture|+|Rice (Mt CH4/yr)",                                              emirem="ch4rice",   factor_mag2rem=1,stringsAsFactors=FALSE))
+      map <- rbind(map,data.frame(emimag="Emissions|CH4|Land|Agriculture|+|Animal waste management (Mt CH4/yr)",                           emirem="ch4anmlwst",factor_mag2rem=1,stringsAsFactors=FALSE))
+      map <- rbind(map,data.frame(emimag="Emissions|CH4|Land|Agriculture|+|Enteric fermentation (Mt CH4/yr)",                              emirem="ch4animals",factor_mag2rem=1,stringsAsFactors=FALSE))
+    } else {
+      # MAgPIE 3
+      map <- rbind(map,data.frame(emimag="Emissions|CO2|Land Use (Mt CO2/yr)",                                                        emirem="co2luc",    factor_mag2rem=1/1000*12/44,stringsAsFactors=FALSE))
+      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land Use|Agriculture|AWM (kt N2O/yr)",                                        emirem="n2oanwstm", factor_mag2rem=1/1000*28/44,stringsAsFactors=FALSE))
+      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land Use|Agriculture|Cropland Soils|Inorganic Fertilizers (kt N2O/yr)",       emirem="n2ofertin", factor_mag2rem=1/1000*28/44,stringsAsFactors=FALSE))
+      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land Use|Agriculture|Cropland Soils|Manure applied to Croplands (kt N2O/yr)", emirem="n2oanwstc", factor_mag2rem=1/1000*28/44,stringsAsFactors=FALSE))
+      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land Use|Agriculture|Cropland Soils|Decay of crop residues (kt N2O/yr)",      emirem="n2ofertcr", factor_mag2rem=1/1000*28/44,stringsAsFactors=FALSE))
+      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land Use|Agriculture|Cropland Soils|Soil organic matter loss (kt N2O/yr)",    emirem="n2ofertsom",factor_mag2rem=1/1000*28/44,stringsAsFactors=FALSE))
+      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land Use|Agriculture|Cropland Soils|Lower N2O emissions of rice (kt N2O/yr)", emirem="n2ofertrb", factor_mag2rem=1/1000*28/44,stringsAsFactors=FALSE))
+      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land Use|Agriculture|Pasture (kt N2O/yr)",                                    emirem="n2oanwstp", factor_mag2rem=1/1000*28/44,stringsAsFactors=FALSE))
+      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land Use|Biomass Burning|Forest Burning (kt N2O/yr)",                         emirem="n2oforest", factor_mag2rem=1/1000*28/44,stringsAsFactors=FALSE))
+      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land Use|Biomass Burning|Savannah Burning (kt N2O/yr)",                       emirem="n2osavan",  factor_mag2rem=1/1000*28/44,stringsAsFactors=FALSE))
+      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land Use|Biomass Burning|Agricultural Waste Burning (kt N2O/yr)",             emirem="n2oagwaste",factor_mag2rem=1/1000*28/44,stringsAsFactors=FALSE))
+      map <- rbind(map,data.frame(emimag="Emissions|CH4|Land Use|Agriculture|Rice (Mt CH4/yr)",                                       emirem="ch4rice",   factor_mag2rem=1,stringsAsFactors=FALSE))
+      map <- rbind(map,data.frame(emimag="Emissions|CH4|Land Use|Agriculture|AWM (Mt CH4/yr)",                                        emirem="ch4anmlwst",factor_mag2rem=1,stringsAsFactors=FALSE))
+      map <- rbind(map,data.frame(emimag="Emissions|CH4|Land Use|Agriculture|Enteric Fermentation (Mt CH4/yr)",                       emirem="ch4animals",factor_mag2rem=1,stringsAsFactors=FALSE))
+      map <- rbind(map,data.frame(emimag="Emissions|CH4|Land Use|Biomass Burning|Forest Burning (Mt CH4/yr)",                         emirem="ch4forest", factor_mag2rem=1,stringsAsFactors=FALSE))
+      map <- rbind(map,data.frame(emimag="Emissions|CH4|Land Use|Biomass Burning|Savannah Burning (Mt CH4/yr)",                       emirem="ch4savan",  factor_mag2rem=1,stringsAsFactors=FALSE))
+      map <- rbind(map,data.frame(emimag="Emissions|CH4|Land Use|Biomass Burning|Agricultural Waste Burning (Mt CH4/yr)",             emirem="ch4agwaste",factor_mag2rem=1,stringsAsFactors=FALSE))
+    }
+
+    # Read data from MAgPIE report and convert to REMIND data, collect in 'out' object
+    out<-NULL
+    for (i in 1:nrow(map)) {
+        tmp<-setNames(mag[,,map[i,]$emimag],map[i,]$emirem)
+        tmp<-tmp*map[i,]$factor_mag2rem
+        #tmp["JPN",is.na(tmp["JPN",,]),] <- 0
+        # preliminary fix 20160111
+        #cat("Preliminary quick fix: filtering out NAs for all and negative values for almost all landuse emissions except for co2luc and n2ofertrb\n")
+        #tmp[is.na(tmp)] <- 0
+        # preliminary 20160114: filter out negative values except for co2luc and n2ofertrb
+        #if (map[i,]$emirem!="co2luc" &&  map[i,]$emirem!="n2ofertrb") {
+        # tmp[tmp<0] <- 0
+        #}
+        out<-mbind(out,tmp)
+    }
+    
+    # Write REMIND input file
+    notGLO   <- getRegions(mag)[!(getRegions(mag)=="GLO")]
+    filename <- paste0("./core/input/f_macBaseMagpie_coupling.cs4r")
+    write.magpie(out[notGLO],filename)
+    write(paste0("*** EOF ",filename," ***"),file=filename,append=TRUE)
+  }	
+  .agriculture_costs <- function(mag){
+    notGLO <- getRegions(mag)[!(getRegions(mag)=="GLO")]
+    out <- mag[,,"Costs|MainSolve w/o GHG Emissions (million US$05/yr)"]/1000/1000 # with transformation factor from 10E6 US$2005 to 10E12 US$2005
+    out["JPN",is.na(out["JPN",,]),] <- 0
+    dimnames(out)[[3]] <- NULL #Delete variable name to prevent it from being written into output file
+    write.magpie(out[notGLO,,],paste0("./modules/26_agCosts/",inputpath_acc,"/input/p26_totLUcost_coupling.csv"),file_type="csvr")
+  }
+  .agriculture_tradebal <- function(mag){
+    notGLO <- getRegions(mag)[!(getRegions(mag)=="GLO")]
+    out <- mag[,,"Trade|Agriculture|Trade Balance (billion US$2005/yr)"]/1000 # with transformation factor from 10E9 US$2005 to 10E12 US$2005
+    out["JPN",is.na(out["JPN",,]),] <- 0
+    dimnames(out)[[3]] <- NULL
+    write.magpie(out[notGLO,,],paste0("./modules/26_agCosts/",inputpath_acc,"/input/trade_bal_reg.rem.csv"),file_type="csvr")
+  }
+  
+  rep <- read.report(path_to_report,as.list=FALSE)
+  if (length(getNames(rep,dim="scenario"))!=1) stop("getReportData: MAgPIE data contains more or less than 1 scenario.")
+  rep <- collapseNames(rep) # get rid of scenrio and model dimension if they exist
+  years <- 2000+5*(1:30)
+  mag <- time_interpolate(rep,years)
+  .bioenergy_price(mag)
+  #.bioenergy_costs(mag) # Obsolete since bioenergy costs are not calculated by MAgPIE anymore but by integrating the supplycurve
+  .bioenergy_production(mag)
+  .emissions_mac(mag)
+  .agriculture_costs(mag)
+  # need to be updated to MAgPIE 4 interface
+  #.agriculture_tradebal(mag)
+}
+
+###############################################################################
+###############################################################################
+###############################################################################
+
+prepare_and_run <- function() {
   
   # Load libraries
   require(lucode, quietly = TRUE,warn.conflicts =FALSE)
@@ -25,22 +163,19 @@ start_run <- function(cfg, scenario = NULL, report = NULL, sceninreport = NULL,
 	  }
   }
  
-  # Store REMIND-root directory
-  maindir <- getwd()
-  on.exit(setwd(maindir))
+  load("config.Rdata")
   
-  # Is the run performed on the cluster?
-  on_cluster    <- file.exists('/p')
+  # Store results folder of current scenario
+  on.exit(setwd(cfg$results_folder))
   
-  # Adapt configuration to predifined scenario, if given
-  if(!is.null(scenario))
-    cfg <- setScenario(cfg, scenario)
+  # change to REMIND main folder
+  setwd(cfg$remind_folder)
   
   # Check configuration for consistency
-  cfg <- check_config(cfg, settings_config = "config/settings_config.csv")
+  cfg <- check_config(cfg, reference_file="config/default.cfg", settings_config = "config/settings_config.csv")
   
   
-###-------- do update of input files based on previous runs if applicable ------###
+  ###-------- do update of input files based on previous runs if applicable ------###
   if(!is.null(cfg$gms$carbonprice) && (cfg$gms$carbonprice == "NDC2018")){
     source("scripts/input/prepare_NDC2018.R")
     prepare_NDC2018(as.character(cfg$files2export$start["input_ref.gdx"]))
@@ -83,6 +218,9 @@ start_run <- function(cfg, scenario = NULL, report = NULL, sceninreport = NULL,
   # adjust GDPpcScen based on GDPscen
   cfg$gms$c_GDPpcScen <- gsub("gdp_","",cfg$gms$cm_GDPscen) 
 
+  # Is the run performed on the cluster?
+  on_cluster    <- file.exists('/p')
+  
   # 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")
@@ -99,22 +237,22 @@ start_run <- function(cfg, scenario = NULL, report = NULL, sceninreport = NULL,
 
   # 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)) {
-    getReportData(report,sceninreport,inputpath_mag=cfg$gms$biomass,inputpath_acc=cfg$gms$agCosts)
+  if (!is.null(cfg$pathToMagpieReport)) {
+    getReportData(path_to_report = cfg$pathToMagpieReport,inputpath_mag=cfg$gms$biomass,inputpath_acc=cfg$gms$agCosts)
   }
   
   # Update module paths in GAMS code
   update_modules_embedding()
 
+  # Check all setglobal settings for consistency
+  settingsCheck()
+
   # configure main model gms file (cfg$model) based on settings of cfg file
   cfg$gms$c_expname <- cfg$title
   # run main.gms if not further specified
   if(is.null(cfg$model)) cfg$model <- "main.gms"
   manipulateConfig(cfg$model, cfg$gms)
   
-  # Check all setglobal settings for consistency
-  settingsCheck()
-  
   ###########################################################################################################
   ############# PROCESSING INPUT DATA ###################### START ##########################################
   ###########################################################################################################
@@ -213,71 +351,38 @@ start_run <- function(cfg, scenario = NULL, report = NULL, sceninreport = NULL,
   ############# PROCESSING INPUT DATA ###################### END ############################################
   ###########################################################################################################
 
-
-  ############# ADD MODULE INFO IN SETS  ###################### START ##########################################
-    content <- NULL
-    modification_warning <- c(
-      '*** THIS CODE IS CREATED AUTOMATICALLY, DO NOT MODIFY THESE LINES DIRECTLY',
-      '*** ANY DIRECT MODIFICATION WILL BE LOST AFTER NEXT MODEL START',
-      '*** CHANGES CAN BE DONE USING THE RESPECTIVE LINES IN scripts/start_functions.R')
-    content <- c(modification_warning,'','sets')
-    content <- c(content,'','       modules "all the available modules"')
-    content <- c(content,'       /',paste0("       ",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 ############################################
+  ############# ADD MODULE INFO IN SETS  ###################### START #######################################
+  content <- NULL
+  modification_warning <- c(
+    '*** THIS CODE IS CREATED AUTOMATICALLY, DO NOT MODIFY THESE LINES DIRECTLY',
+    '*** ANY DIRECT MODIFICATION WILL BE LOST AFTER NEXT MODEL START',
+    '*** CHANGES CAN BE DONE USING THE RESPECTIVE LINES IN scripts/start_functions.R')
+  content <- c(modification_warning,'','sets')
+  content <- c(content,'','       modules "all the available modules"')
+  content <- c(content,'       /',paste0("       ",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 #########################################
       
-  # 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"
-    }
-  } else if (cfg$gms$optimization == "testOneRegi") {
-    cfg$files2export$start[cfg$files2export$start == "scripts/run_submit/submit.cmd"] <- 
-      "scripts/run_submit/submit_short.cmd"
-  }
-
   # 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)
 
-  # Store main folder to make it accessible in submit.R
-  cfg$remind_folder <- getwd()
-  
   # Save configuration
   save(cfg, file = path(cfg$results_folder, "config.Rdata"))
 
   # Merge GAMS files
+  cat("Creating full.gms\n")
   singleGAMSfile(mainfile=cfg$model,output = path(cfg$results_folder, "full.gms"))
   
   # 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"]],
-                        date = rundate,
+                        date = Sys.time(),
                         version_management = "git",
                         revision = try(system("git rev-parse --short HEAD", intern=TRUE), silent=TRUE),
                         #revision_date = try(as.POSIXct(system("git show -s --format=%ci", intern=TRUE), silent=TRUE)),
@@ -289,202 +394,415 @@ start_run <- function(cfg, scenario = NULL, report = NULL, sceninreport = NULL,
   # Prevent model_unlock from being executed again at the end
   on.exit()
   # Repeat command since on.exit was cleared
-  on.exit(setwd(maindir))
+  on.exit(setwd(cfg$results_folder))
   ################## M O D E L   U N L O C K ###################################
   
   setwd(cfg$results_folder)
-  
-  # Decide whether the runs should be send to slurm (TRUE) or executed directly (FALSE)
-  if (is.na(cfg$sendToSlurm)) {
-    if (on_cluster) {
-      cfg$sendToSlurm <- TRUE
-    } else {
-      cfg$sendToSlurm <- FALSE
+  ###########################################################################################################################################################
+  #################################################### Copied from submit.R #################################################################################
+  ###########################################################################################################################################################
+
+  # Function to create the levs.gms, fixings.gms, and margs.gms files, used in 
+  # delay scenarios.
+  create_fixing_files <- function(cfg, input_ref_file = "input_ref.gdx") {
+    
+    # Start the clock.
+    begin <- Sys.time()
+    
+    # Extract data from input_ref.gdx file and store in levs_margs_ref.gms. 
+    system(paste("gdxdump", 
+                 input_ref_file, 
+                 "Format=gamsbas Delim=comma FilterDef=N Output=levs_margs_ref.gms", 
+                 sep = " "))
+    
+    # Read data from levs_margs_ref.gms.
+    ref_gdx_data <- suppressWarnings(readLines("levs_margs_ref.gms"))
+    
+    # Create fixing files.
+    cat("\n")
+    create_standard_fixings(cfg, ref_gdx_data)
+    
+    # Stop the clock.
+    cat("Time it took to create the fixing files: ")
+    manipulate_runtime <- Sys.time()-begin
+    print(manipulate_runtime)
+    cat("\n")
+    
+    
+    # Delete file.
+    file.remove("levs_margs_ref.gms")
+    
+  }
+
+
+  # Function to create the levs.gms, fixings.gms, and margs.gms files, used in 
+  # the standard (i.e. the non-macro stand-alone) delay scenarios.
+  create_standard_fixings <- function(cfg, ref_gdx_data) {
+    
+    # Declare empty lists to hold the strings for the 'manipulateFile' functions. 
+    full_manipulateThis <- NULL
+    levs_manipulateThis <- NULL
+    fixings_manipulateThis <- NULL
+    margs_manipulateThis <- NULL
+
+    str_years <- c()
+    no_years  <- (cfg$gms$cm_startyear - 2005) / 5  
+    
+    # Write level values to file
+    levs <- c()
+    for (i in 1:no_years) {
+      str_years[i] <- paste("L \\('", 2000 + i * 5, sep = "")
+      levs         <- c(levs, grep(str_years[i], ref_gdx_data, value = TRUE))
+    }
+    
+    writeLines(levs, "levs.gms")
+    
+    # Replace fixing.gms with level values
+    file.copy("levs.gms", "fixings.gms", overwrite = TRUE)
+
+    fixings_manipulateThis <- c(fixings_manipulateThis, list(c(".L ", ".FX ")))
+    #cb q_co2eq is only "static" equation to be active before cm_startyear, as multigasscen could be different from a scenario to another that is fixed on the first  
+    #cb therefore, vm_co2eq cannot be fixed, otherwise infeasibilities would result. vm_co2eq.M is meaningless, is never used in the code (a manipulateFile delete line command would be even better)
+    #  manipulateFile("fixings.gms", list(c("vm_co2eq.FX ", "vm_co2eq.M ")))
+    
+    # Write marginal values to file
+    margs <- c()
+    str_years    <- c()
+    for (i in 1:no_years) {
+      str_years[i] <- paste("M \\('", 2000 + i * 5, sep = "")
+      margs        <- c(margs, grep(str_years[i], ref_gdx_data, value = TRUE))
     }
+    writeLines(margs, "margs.gms")
+     # temporary fix so that you can use older gdx for fixings - will become obsolete in the future and can be deleted once the next variable name change is done
+    margs_manipulateThis <- c(margs_manipulateThis, list(c("q_taxrev","q21_taxrev")))
+    # fixing for SPA runs based on ModPol input data
+    margs_manipulateThis <- c(margs_manipulateThis, 
+                              list(c("q41_emitrade_restr_mp.M", "!!q41_emitrade_restr_mp.M")),
+                              list(c("q41_emitrade_restr_mp2.M", "!!q41_emitrade_restr_mp2.M"))) 
+    
+    #AJS this symbol is not known and crashes the run - is it depreciated? TODO 
+    levs_manipulateThis <- c(levs_manipulateThis, 
+                             list(c("vm_pebiolc_price_base.L", "!!vm_pebiolc_price_base.L")))
+    
+    #AJS filter out nash marginals in negishi case, as they would lead to a crash when trying to fix on them:
+    if(cfg$gms$optimization == 'negishi'){
+      margs_manipulateThis <- c(margs_manipulateThis, list(c("q80_costAdjNash.M", "!!q80_costAdjNash.M")))
+    }
+    if(cfg$gms$subsidizeLearning == 'off'){
+      levs_manipulateThis <- c(levs_manipulateThis, 
+                               list(c("v22_costSubsidizeLearningForeign.L",
+                                      "!!v22_costSubsidizeLearningForeign.L")))
+      margs_manipulateThis <- c(margs_manipulateThis, 
+                                list(c("q22_costSubsidizeLearning.M", "!!q22_costSubsidizeLearning.M")),
+                                list(c("v22_costSubsidizeLearningForeign.M",
+                                       "!!v22_costSubsidizeLearningForeign.M")),
+                                list(c("q22_costSubsidizeLearningForeign.M",
+                                       "!!q22_costSubsidizeLearningForeign.M")))
+      fixings_manipulateThis <- c(fixings_manipulateThis, 
+                                  list(c("v22_costSubsidizeLearningForeign.FX",
+                                         "!!v22_costSubsidizeLearningForeign.FX")))
+      
+    }
+    
+    #JH filter out negishi marginals in nash case, as they would lead to a crash when trying to fix on them:
+    if(cfg$gms$optimization == 'nash'){
+      margs_manipulateThis <- c(margs_manipulateThis, 
+                                list(c("q80_balTrade.M", "!!q80_balTrade.M")),
+                                list(c("q80_budget_helper.M", "!!q80_budget_helper.M")))
+    }
+    #RP filter out module 40 techpol fixings 
+    if(cfg$gms$techpol == 'none'){
+      margs_manipulateThis <- c(margs_manipulateThis, 
+                                list(c("q40_NewRenBound.M", "!!q40_NewRenBound.M")),
+                                list(c("q40_CoalBound.M", "!!q40_CoalBound.M")),
+                                list(c("q40_LowCarbonBound.M", "!!q40_LowCarbonBound.M")),
+                                list(c("q40_FE_RenShare.M", "!!q40_FE_RenShare.M")),
+                                list(c("q40_trp_bound.M", "!!q40_trp_bound.M")),
+                                list(c("q40_TechBound.M", "!!q40_TechBound.M")),
+                                list(c("q40_ElecBioBound.M", "!!q40_ElecBioBound.M")),
+                                list(c("q40_PEBound.M", "!!q40_PEBound.M")),
+                                list(c("q40_PEcoalBound.M", "!!q40_PEcoalBound.M")),
+                                list(c("q40_PEgasBound.M", "!!q40_PEgasBound.M")),
+                                list(c("q40_PElowcarbonBound.M", "!!q40_PElowcarbonBound.M")),
+                                list(c("q40_EV_share.M", "!!q40_EV_share.M")),
+                                list(c("q40_TrpEnergyRed.M", "!!q40_TrpEnergyRed.M")),
+                                list(c("q40_El_RenShare.M", "!!q40_El_RenShare.M")),
+                                list(c("q40_BioFuelBound.M", "!!q40_BioFuelBound.M")))
+
+    }
+    
+    if(cfg$gms$techpol == 'NPi2018'){
+      margs_manipulateThis <- c(margs_manipulateThis, 
+                                list(c("q40_El_RenShare.M", "!!q40_El_RenShare.M")),
+                                list(c("q40_CoalBound.M", "!!q40_CoalBound.M")))
+    }
+    
+    # Include fixings (levels) and marginals in full.gms at predefined position 
+    # in core/loop.gms.
+    full_manipulateThis <- c(full_manipulateThis, 
+                             list(c("cb20150605readinpositionforlevelfile",
+                                    paste("first offlisting inclusion of levs.gms so that level value can be accessed",
+                                          "$offlisting",
+                                          "$include \"levs.gms\";",
+                                          "$onlisting", sep = "\n"))))
+    full_manipulateThis <- c(full_manipulateThis, list(c("cb20140305readinpositionforfinxingfiles",
+                                                         paste("offlisting inclusion of levs.gms, fixings.gms, and margs.gms",
+                                                               "$offlisting",
+                                                               "$include \"levs.gms\";",
+                                                               "$include \"fixings.gms\";",
+                                                               "$include \"margs.gms\";",
+                                                               "$onlisting", sep = "\n"))))
+    
+    
+    # Perform actual manipulation on levs.gms, fixings.gms, and margs.gms in 
+    # single, respective, parses of the texts.
+    manipulateFile("levs.gms", levs_manipulateThis)
+    manipulateFile("fixings.gms", fixings_manipulateThis)
+    manipulateFile("margs.gms", margs_manipulateThis)
+    
+    # Perform actual manipulation on full.gms, in single parse of the text.
+    manipulateFile("full.gms", full_manipulateThis)
   }
 
-  # "Compilation only" is always executed directly
-  if (cfg$action == "c") cfg$sendToSlurm <- FALSE
-  
-  # Call appropriate submit script
-  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"))
-           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(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")
+
+  # 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")
+
+  #AJS set MAGCFG file
+  magcfgFile = paste0('./magicc/MAGCFG_STORE/','MAGCFG_USER_',toupper(cfg$gms$cm_magicc_config),'.CFG')
+  if(!file.exists(magcfgFile)){
+      stop(paste('ERROR in MAGGICC configuration: Could not find file ',magcfgFile))
+  }
+  system(paste0('cp ',magcfgFile,' ','./magicc/MAGCFG_USER.CFG'))
+
+  # Prepare the files containing the fixings for delay scenarios (for fixed runs)
+  if (  cfg$gms$cm_startyear > 2005  & (!file.exists("levs.gms.gz") | !file.exists("levs.gms"))) {
+    create_fixing_files(cfg = cfg, input_ref_file = "input_ref.gdx")
+  }
+   
+  # Print message
+  cat("\nStarting REMIND...\n")
+
+  # Save start time
+  begin <- Sys.time()
+
+  # Call GAMS
+  if (cfg$gms$CES_parameters == "load") {
+
+    system(paste0(cfg$gamsv, " full.gms -errmsg=1 -a=", cfg$action, 
+                  " -ps=0 -pw=185 -gdxcompress=1 -logoption=", cfg$logoption))
+
+  } else if (cfg$gms$CES_parameters == "calibrate") {
+
+    # Remember file modification time of fulldata.gdx to see if it changed
+    fulldata_m_time <- Sys.time();
+
+    # Save original input
+    file.copy("input.gdx", "input_00.gdx", overwrite = TRUE)
+
+    # Iterate calibration algorithm
+    for (cal_itr in 1:cfg$gms$c_CES_calibration_iterations) {
+      cat("CES calibration iteration: ", cal_itr, "\n")
+
+      # Update calibration iteration in GAMS file
+      system(paste0("sed -i 's/^\\(\\$setglobal c_CES_calibration_iteration ", 
+                    "\\).*/\\1", cal_itr, "/' full.gms"))
+
+      system(paste0(cfg$gamsv, " full.gms -errmsg=1 -a=", cfg$action, 
+                    " -ps=0 -pw=185 -gdxcompress=1 -logoption=", cfg$logoption))
+
+      # If GAMS found a solution
+      if (   file.exists("fulldata.gdx")
+          && file.info("fulldata.gdx")$mtime > fulldata_m_time) {
+        
+        #create the file to be used in the load mode
+        getLoadFile <- function(){
+          
+          file_name = paste0(cfg$gms$cm_CES_configuration,"_ITERATION_",cal_itr,".inc")
+          ces_in = system("gdxdump fulldata.gdx symb=in NoHeader Format=CSV", intern = TRUE) %>% gsub("\"","",.) #" This comment is just to obtain correct syntax highlighting
+          expr_ces_in = paste0("(",paste(ces_in, collapse = "|") ,")")
+
+          
+          tmp = system("gdxdump fulldata.gdx symb=pm_cesdata", intern = TRUE)[-(1:2)] %>% 
+            grep("(quantity|price|eff|effgr|xi|rho|offset_quantity|compl_coef)", x = ., value = TRUE)
+          tmp = tmp %>% grep(expr_ces_in,x = ., value = T)
+          
+          tmp %>%
+            sub("'([^']*)'.'([^']*)'.'([^']*)'.'([^']*)' (.*)[ ,][ /];?",
+                "pm_cesdata(\"\\1\",\"\\2\",\"\\3\",\"\\4\") = \\5;", x = .) %>%
+            write(file_name)
+          
+          
+          pm_cesdata_putty = system("gdxdump fulldata.gdx symb=pm_cesdata_putty", intern = TRUE)
+          if (length(pm_cesdata_putty) == 2){
+            tmp_putty =  gsub("^Parameter *([A-z_(,)])+cesParameters\\).*$",'\\1"quantity")  =   0;',  pm_cesdata_putty[2])
           } else {
-              system("sbatch submit.cmd")
+            tmp_putty = pm_cesdata_putty[-(1:2)] %>%
+              grep("quantity", x = ., value = TRUE) %>%
+              grep(expr_ces_in,x = ., value = T)
           }
+          tmp_putty %>%
+            sub("'([^']*)'.'([^']*)'.'([^']*)'.'([^']*)' (.*)[ ,][ /];?",
+                "pm_cesdata_putty(\"\\1\",\"\\2\",\"\\3\",\"\\4\") = \\5;", x = .)%>% write(file_name,append =T)
+        }
+        
+        getLoadFile()
+
+        # Store all the interesting output
+        file.copy("full.lst", sprintf("full_%02i.lst", cal_itr), overwrite = TRUE)
+        file.copy("full.log", sprintf("full_%02i.log", cal_itr), overwrite = TRUE)
+        file.copy("fulldata.gdx", "input.gdx", overwrite = TRUE)
+        file.copy("fulldata.gdx", sprintf("input_%02i.gdx", cal_itr), 
+                  overwrite = TRUE)
+
+        # Update file modification time
+        fulldata_m_time <- file.info("fulldata.gdx")$mtime
+
+      } else {
+        break
       }
+    }
   } else {
-      # execute directly
-      system("Rscript submit.R")
+    stop("unknown realisation of 29_CES_parameters")
   }
-  
-  # on.exit sets working directory back to REMIND main folder   
-  return(cfg$results_folder)
-}
 
-getReportData <- function(rep,scen,inputpath_mag="magpie",inputpath_acc="costs") {
-	require(lucode, quietly = TRUE,warn.conflicts =FALSE)
-  require(magclass, quietly = TRUE,warn.conflicts =FALSE)
-  .bioenergy_price <- function(mag){
-    notGLO <- getRegions(mag)[!(getRegions(mag)=="GLO")]
-    if("Demand|Bioenergy|++|2nd generation (EJ/yr)" %in% getNames(mag)) {
-      # MAgPIE 4
-      out <- mag[,,"Prices|Bioenergy (US$05/GJ)"]*0.0315576 # with transformation factor from US$2005/GJ to US$2005/Wa
-    } else {
-      # MAgPIE 3
-      out <- mag[,,"Price|Primary Energy|Biomass (US$2005/GJ)"]*0.0315576 # with transformation factor from US$2005/GJ to US$2005/Wa
-    }
-    out["JPN",is.na(out["JPN",,]),] <- 0
-    dimnames(out)[[3]] <- NULL #Delete variable name to prevent it from being written into output file
-    write.magpie(out[notGLO,,],paste0("./modules/30_biomass/",inputpath_mag,"/input/p30_pebiolc_pricemag_coupling.csv"),file_type="csvr")
-  }  
-  .bioenergy_costs <- function(mag){
-    notGLO <- getRegions(mag)[!(getRegions(mag)=="GLO")]
-    if ("Production Cost|Agriculture|Biomass|Energy Crops (million US$2005/yr)" %in% getNames(mag)) {
-      out <- mag[,,"Production Cost|Agriculture|Biomass|Energy Crops (million US$2005/yr)"]/1000/1000 # with transformation factor from 10E6 US$2005 to 10E12 US$2005
-    }
-    else {
-      # in old MAgPIE reports the unit is reported to be "billion", however the values are in million
-      out <- mag[,,"Production Cost|Agriculture|Biomass|Energy Crops (billion US$2005/yr)"]/1000/1000 # with transformation factor from 10E6 US$2005 to 10E12 US$2005
-    }
-    out["JPN",is.na(out["JPN",,]),] <- 0
-    dimnames(out)[[3]] <- NULL
-    write.magpie(out[notGLO,,],paste0("./modules/30_biomass/",inputpath_mag,"/input/p30_pebiolc_costsmag.csv"),file_type="csvr")
-  }  
-  .bioenergy_production <- function(mag){
-    notGLO <- getRegions(mag)[!(getRegions(mag)=="GLO")]
-    if("Demand|Bioenergy|2nd generation|++|Bioenergy crops (EJ/yr)" %in% getNames(mag)) {
-      # MAgPIE 4
-      out <- mag[,,"Demand|Bioenergy|2nd generation|++|Bioenergy crops (EJ/yr)"]/31.536 # EJ to TWa
-    } else {
-      # MAgPIE 3
-      out <- mag[,,"Primary Energy Production|Biomass|Energy Crops (EJ/yr)"]/31.536 # EJ to TWa
-    }
-    out[which(out<0)] <- 0 # set negative values to zero since they cause errors in GMAS power function
-    out["JPN",is.na(out["JPN",,]),] <- 0
-    dimnames(out)[[3]] <- NULL
-    write.magpie(out[notGLO,,],paste0("./modules/30_biomass/",inputpath_mag,"/input/p30_pebiolc_demandmag_coupling.csv"),file_type="csvr")
-  }  
-  .emissions_mac <- function(mag) {
-    # define three columns of dataframe: 
-    #   emirem (remind emission names)
-    #   emimag (magpie emission names)
-    #   factor_mag2rem (factor for converting magpie to remind emissions)
-    #   1/1000*28/44, # kt N2O/yr -> Mt N2O/yr -> Mt N/yr
-    #   28/44,        # Tg N2O/yr =  Mt N2O/yr -> Mt N/yr
-    #   1/1000*12/44, # Mt CO2/yr -> Gt CO2/yr -> Gt C/yr
-    map <- data.frame(emirem=NULL,emimag=NULL,factor_mag2rem=NULL,stringsAsFactors=FALSE)
-    if("Emissions|N2O|Land|Agriculture|+|Animal Waste Management (Mt N2O/yr)" %in% getNames(mag)) {
-      # MAgPIE 4
-      map <- rbind(map,data.frame(emimag="Emissions|CO2|Land (Mt CO2/yr)",                                                                 emirem="co2luc",    factor_mag2rem=1/1000*12/44,stringsAsFactors=FALSE))
-      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land|Agriculture|+|Animal Waste Management (Mt N2O/yr)",                           emirem="n2oanwstm", factor_mag2rem=28/44,stringsAsFactors=FALSE))
-      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land|Agriculture|Agricultural Soils|+|Inorganic Fertilizers (Mt N2O/yr)",          emirem="n2ofertin", factor_mag2rem=28/44,stringsAsFactors=FALSE))
-      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land|Agriculture|Agricultural Soils|+|Manure applied to Croplands (Mt N2O/yr)",    emirem="n2oanwstc", factor_mag2rem=28/44,stringsAsFactors=FALSE))
-      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land|Agriculture|Agricultural Soils|+|Decay of Crop Residues (Mt N2O/yr)",         emirem="n2ofertcr", factor_mag2rem=28/44,stringsAsFactors=FALSE))
-      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land|Agriculture|Agricultural Soils|+|Soil Organic Matter Loss (Mt N2O/yr)",       emirem="n2ofertsom",factor_mag2rem=28/44,stringsAsFactors=FALSE))
-      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land|Agriculture|Agricultural Soils|+|Pasture (Mt N2O/yr)",                        emirem="n2oanwstp", factor_mag2rem=28/44,stringsAsFactors=FALSE))
-      map <- rbind(map,data.frame(emimag="Emissions|CH4|Land|Agriculture|+|Rice (Mt CH4/yr)",                                              emirem="ch4rice",   factor_mag2rem=1,stringsAsFactors=FALSE))
-      map <- rbind(map,data.frame(emimag="Emissions|CH4|Land|Agriculture|+|Animal waste management (Mt CH4/yr)",                           emirem="ch4anmlwst",factor_mag2rem=1,stringsAsFactors=FALSE))
-      map <- rbind(map,data.frame(emimag="Emissions|CH4|Land|Agriculture|+|Enteric fermentation (Mt CH4/yr)",                              emirem="ch4animals",factor_mag2rem=1,stringsAsFactors=FALSE))
-    } else {
-      # MAgPIE 3
-      map <- rbind(map,data.frame(emimag="Emissions|CO2|Land Use (Mt CO2/yr)",                                                        emirem="co2luc",    factor_mag2rem=1/1000*12/44,stringsAsFactors=FALSE))
-      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land Use|Agriculture|AWM (kt N2O/yr)",                                        emirem="n2oanwstm", factor_mag2rem=1/1000*28/44,stringsAsFactors=FALSE))
-      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land Use|Agriculture|Cropland Soils|Inorganic Fertilizers (kt N2O/yr)",       emirem="n2ofertin", factor_mag2rem=1/1000*28/44,stringsAsFactors=FALSE))
-      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land Use|Agriculture|Cropland Soils|Manure applied to Croplands (kt N2O/yr)", emirem="n2oanwstc", factor_mag2rem=1/1000*28/44,stringsAsFactors=FALSE))
-      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land Use|Agriculture|Cropland Soils|Decay of crop residues (kt N2O/yr)",      emirem="n2ofertcr", factor_mag2rem=1/1000*28/44,stringsAsFactors=FALSE))
-      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land Use|Agriculture|Cropland Soils|Soil organic matter loss (kt N2O/yr)",    emirem="n2ofertsom",factor_mag2rem=1/1000*28/44,stringsAsFactors=FALSE))
-      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land Use|Agriculture|Cropland Soils|Lower N2O emissions of rice (kt N2O/yr)", emirem="n2ofertrb", factor_mag2rem=1/1000*28/44,stringsAsFactors=FALSE))
-      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land Use|Agriculture|Pasture (kt N2O/yr)",                                    emirem="n2oanwstp", factor_mag2rem=1/1000*28/44,stringsAsFactors=FALSE))
-      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land Use|Biomass Burning|Forest Burning (kt N2O/yr)",                         emirem="n2oforest", factor_mag2rem=1/1000*28/44,stringsAsFactors=FALSE))
-      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land Use|Biomass Burning|Savannah Burning (kt N2O/yr)",                       emirem="n2osavan",  factor_mag2rem=1/1000*28/44,stringsAsFactors=FALSE))
-      map <- rbind(map,data.frame(emimag="Emissions|N2O|Land Use|Biomass Burning|Agricultural Waste Burning (kt N2O/yr)",             emirem="n2oagwaste",factor_mag2rem=1/1000*28/44,stringsAsFactors=FALSE))
-      map <- rbind(map,data.frame(emimag="Emissions|CH4|Land Use|Agriculture|Rice (Mt CH4/yr)",                                       emirem="ch4rice",   factor_mag2rem=1,stringsAsFactors=FALSE))
-      map <- rbind(map,data.frame(emimag="Emissions|CH4|Land Use|Agriculture|AWM (Mt CH4/yr)",                                        emirem="ch4anmlwst",factor_mag2rem=1,stringsAsFactors=FALSE))
-      map <- rbind(map,data.frame(emimag="Emissions|CH4|Land Use|Agriculture|Enteric Fermentation (Mt CH4/yr)",                       emirem="ch4animals",factor_mag2rem=1,stringsAsFactors=FALSE))
-      map <- rbind(map,data.frame(emimag="Emissions|CH4|Land Use|Biomass Burning|Forest Burning (Mt CH4/yr)",                         emirem="ch4forest", factor_mag2rem=1,stringsAsFactors=FALSE))
-      map <- rbind(map,data.frame(emimag="Emissions|CH4|Land Use|Biomass Burning|Savannah Burning (Mt CH4/yr)",                       emirem="ch4savan",  factor_mag2rem=1,stringsAsFactors=FALSE))
-      map <- rbind(map,data.frame(emimag="Emissions|CH4|Land Use|Biomass Burning|Agricultural Waste Burning (Mt CH4/yr)",             emirem="ch4agwaste",factor_mag2rem=1,stringsAsFactors=FALSE))
+  # Calculate run time
+  gams_runtime <- Sys.time() - begin
+
+  # If REMIND actually did run
+  if (cfg$action == "ce" && cfg$gms$c_skip_output != "on") {
+
+    # Print Message
+    cat("\nREMIND run finished!\n")
+
+    # Create solution report for Nash runs
+    if (cfg$gms$optimization == "nash" && cfg$gms$cm_nash_mode != "debug" && file.exists("fulldata.gdx")) {
+      system("gdxdump fulldata.gdx Format=gamsbas Delim=comma Output=output_nash.gms")
+      file.append("full.lst", "output_nash.gms")
+      file.remove("output_nash.gms")
     }
+  }
 
-    # Read data from MAgPIE report and convert to REMIND data, collect in 'out' object
-    out<-NULL
-    for (i in 1:nrow(map)) {
-        tmp<-setNames(mag[,,map[i,]$emimag],map[i,]$emirem)
-        tmp<-tmp*map[i,]$factor_mag2rem
-        #tmp["JPN",is.na(tmp["JPN",,]),] <- 0
-        # preliminary fix 20160111
-        #cat("Preliminary quick fix: filtering out NAs for all and negative values for almost all landuse emissions except for co2luc and n2ofertrb\n")
-        #tmp[is.na(tmp)] <- 0
-        # preliminary 20160114: filter out negative values except for co2luc and n2ofertrb
-        #if (map[i,]$emirem!="co2luc" &&  map[i,]$emirem!="n2ofertrb") {
-        # tmp[tmp<0] <- 0
-        #}
-        out<-mbind(out,tmp)
+  # Print REMIND runtime
+  cat("\n gams_runtime is ", gams_runtime, "\n")
+
+  # Collect and submit run statistics to central data base
+  lucode::runstatistics(file       = "runstatistics.rda",
+                        modelstat  = readGDX(gdx="fulldata.gdx","o_modelstat", format="first_found"),
+                        config     = cfg,
+                        runtime    = gams_runtime,
+                        setup_info = lucode::setup_info(),
+                        submit     = cfg$runstatistics)
+
+  # Compress files with the fixing-information
+  if (cfg$gms$cm_startyear > 2005) 
+    system("gzip -f levs.gms margs.gms fixings.gms")
+
+  # go up to the main folder, where the cfg files for subsequent runs are stored
+  setwd(cfg$remind_folder)
+
+  #====================== Subsequent runs ===========================
+
+  # 1. Save the path to the fulldata.gdx of the current run to the cfg files 
+  # of the runs that use it as 'input_bau.gdx'
+
+  # 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)
+
+  no_ref_runs <- identical(cfg$RunsUsingTHISgdxAsBAU,character(0)) | all(is.na(cfg$RunsUsingTHISgdxAsBAU)) | coupled_run
+
+  if(!no_ref_runs) {
+    source("scripts/start/submit.R")
+    # Save the current cfg settings into a different data object, so that they are not overwritten
+    cfg_main <- cfg
+    
+    for(run in seq(1,length(cfg_main$RunsUsingTHISgdxAsBAU))){
+      # for each of the runs that use this gdx as bau, read in the cfg, ...
+      cat("Writing the path for input_bau.gdx to ",paste0(cfg_main$RunsUsingTHISgdxAsBAU[run],".RData"),"\n")
+      load(paste0(cfg_main$RunsUsingTHISgdxAsBAU[run],".RData"))
+      # ...change the path_gdx_bau field of the subsequent run to the fulldata gdx of the current run ...
+      cfg$files2export$start['input_bau.gdx'] <- paste0(cfg_main$remind_folder,"/",cfg_main$results_folder,"/fulldata.gdx")
+      save(cfg, file = paste0(cfg_main$RunsUsingTHISgdxAsBAU[run],".RData"))
     }
+    # Set cfg back to original
+    cfg <- cfg_main
+  }
+
+  # 2. Save the path to the fulldata.gdx of the current run to the cfg files 
+  # of the subsequent runs that use it as 'input_ref.gdx' and start these runs 
+
+  no_subsequent_runs <- identical(cfg$subsequentruns,character(0)) | identical(cfg$subsequentruns,NULL) | coupled_run
+
+  if(no_subsequent_runs){
+    cat('\nNo subsequent run was set for this scenario\n')
+  } else {
+    # Save the current cfg settings into a different data object, so that they are not overwritten
+    cfg_main <- cfg
+    source("scripts/start/submit.R")
     
-    # Write REMIND input file
-    notGLO   <- getRegions(mag)[!(getRegions(mag)=="GLO")]
-    filename <- paste0("./core/input/f_macBaseMagpie_coupling.cs4r")
-    write.magpie(out[notGLO],filename)
-    write(paste0("*** EOF ",filename," ***"),file=filename,append=TRUE)
-  }	
-  .agriculture_costs <- function(mag){
-    notGLO <- getRegions(mag)[!(getRegions(mag)=="GLO")]
-    out <- mag[,,"Costs|MainSolve w/o GHG Emissions (million US$05/yr)"]/1000/1000 # with transformation factor from 10E6 US$2005 to 10E12 US$2005
-    out["JPN",is.na(out["JPN",,]),] <- 0
-    dimnames(out)[[3]] <- NULL #Delete variable name to prevent it from being written into output file
-    write.magpie(out[notGLO,,],paste0("./modules/26_agCosts/",inputpath_acc,"/input/p26_totLUcost_coupling.csv"),file_type="csvr")
+    for(run in seq(1,length(cfg_main$subsequentruns))){
+      # for each of the subsequent runs, read in the cfg, ...
+      cat("Writing the path for input_ref.gdx to ",paste0(cfg_main$subsequentruns[run],".RData"),"\n")
+      load(paste0(cfg_main$subsequentruns[run],".RData"))
+      # ...change the path_gdx_ref field of the subsequent run to the fulldata gdx of the current (preceding) run ...
+      cfg$files2export$start['input_ref.gdx'] <- paste0(cfg_main$remind_folder,"/",cfg_main$results_folder,"/fulldata.gdx")
+      save(cfg, file = paste0(cfg_main$subsequentruns[run],".RData"))
+      
+      # Subsequent runs will be started in submit.R using the RData files written above 
+      # after the current run has finished.
+      cat("Starting subsequent run ",cfg_main$subsequentruns[run],"\n")
+      submit(cfg)
+    }
+    # Set cfg back to original
+    cfg <- cfg_main
   }
-  .agriculture_tradebal <- function(mag){
-    notGLO <- getRegions(mag)[!(getRegions(mag)=="GLO")]
-    out <- mag[,,"Trade|Agriculture|Trade Balance (billion US$2005/yr)"]/1000 # with transformation factor from 10E9 US$2005 to 10E12 US$2005
-    out["JPN",is.na(out["JPN",,]),] <- 0
-    dimnames(out)[[3]] <- NULL
-    write.magpie(out[notGLO,,],paste0("./modules/26_agCosts/",inputpath_acc,"/input/trade_bal_reg.rem.csv"),file_type="csvr")
+
+  # 3. Create script file that can be used later to restart the subsequent runs manually.
+  # In case there are no subsequent runs (or it's coupled runs), the file contains only 
+  # a small message.
+
+  subseq_start_file  <- paste0(cfg$results_folder,"/start_subsequentruns.R")
+
+  if(no_subsequent_runs){
+    write("cat('\nNo subsequent run was set for this scenario\n')",file=subseq_start_file)
+  } else {
+    #  go up to the main folder, where the cfg. files for subsequent runs are stored
+    filetext <- paste0("setwd('",cfg$remind_folder,"')\n")
+    filetext <- paste0(filetext,"source('scripts/start/submit.R')\n")
+    for(run in seq(1,length(cfg$subsequentruns))){
+      filetext <- paste0(filetext,"\n")
+      filetext <- paste0(filetext,"load('",cfg$subsequentruns[run],".RData')\n")
+      filetext <- paste0(filetext,"cat('",cfg$subsequentruns[run],"')\n")
+      filetext <- paste0(filetext,"submit(cfg)\n")
+    }
+    # Write the text to the file
+    write(filetext,file=subseq_start_file)
   }
-  
-  if (length(scen)!=1) stop("getReportData: 'scen' does not contain exactly one scenario:",scen)
-  if (length(intersect(scen,getNames(rep,dim="scenario")))!=1) stop("getReportData: 'scen'",scen," not contained in 'rep'.")
-  rep <- collapseNames(rep) # get rid of scenrio and model dimension if they exist
-  years <- 2000+5*(1:30)
-  mag <- time_interpolate(rep,years)
-  .bioenergy_price(mag)
-  #.bioenergy_costs(mag) # Obsolete since bioenergy costs are not calculated by MAgPIE anymore but by integrating the supplycurve
-  .bioenergy_production(mag)
-  .emissions_mac(mag)
-  .agriculture_costs(mag)
-  # need to be updated to MAgPIE 4 interface
-  #.agriculture_tradebal(mag)
-}
 
-start_reportrun <- function (cfg,path_report,sceninreport=NULL){
-  rep <- convert.report(path_report,outmodel="REMIND")
-  write.report(rep,"report.mif")
-  if (!is.null(sceninreport))
-      sceninreport <- intersect(sceninreport,names(rep))
-  else
-      sceninreport <- names(rep)
+  #=================== END - Subsequent runs ========================
     
-  for(scen in sceninreport) {
-	cfg$title <- scen
-	# If REMIND had pre-defined scenarios like MAgPIE they must be set here according to the scenario read in from the MAgPIE reporting
-	# cfg <- setScenario(cfg,strsplit(scen,"_")[[1]][1])
-	start_run(cfg, report=rep, sceninreport=scen)
-  }
+  # 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())
+    
+  ###########################################################################################################################################################
+  ###########################################################################################################################################################
+  ###########################################################################################################################################################
+  
+  return(cfg$results_folder)
+  
+  # on.exit sets working directory back to results folder
+  
 }
+
+# call prepare and run (always without cfg, because cfg is always read from results folder, where it has been copied by submit(cfg))
+prepare_and_run()
\ No newline at end of file
diff --git a/scripts/start/readme.txt b/scripts/start/readme.txt
new file mode 100644
index 0000000000000000000000000000000000000000..b51f0d41cb03b99448e7540a0c93a5381cb488b9
--- /dev/null
+++ b/scripts/start/readme.txt
@@ -0,0 +1,57 @@
+Documentation of the new procedure of starting REMIND runs (DK, LB, January 2020)
+
+Why did we redesign the procedure?
+
+The old code was spread across more files, the user needed to edit files in order to provide the SLURM options, and a substantial part of the code was run on the login node before finally submiting the job to SLURM. The new structure lets the user choose the SLURM options interactively when starting the runs. The amount of code that is executed on the login node was minimized. Most of the work load that is required to set up a run is included in the SLURM batch job. Finally, the code is strucutred more clearly and spread across less files.
+
+To start a run type in the main directory of REMIND:
+
+Rscript start.R [path to a config file]
+
+optionally providing a path to a config file, e.g. config/scenario_config.csv. If no config file is provided REMIND will use the settings in the default.cfg
+
+The procedure in short:
+
+start.R -------> submit(cfg) ----------------------------------------------> prepare_and_run()
+
+                 - create output folder                                      - fetch input data
+                 - copy config and prepare_and_run.R into output folder      - prepare NDCs
+                 - send slurm job to cluster                                 - create single GAMS file
+                                                                             - run GAMS
+                                                                             - reporting
+|---------------------------------------------------------------------------|--------------------------|
+                          login node                                                 slurm job
+
+
+The procedure in detail:
+
+Rscript start.R -----> choose_slurmConfig()               [scripts/start/choose_slurmConfig.R] 
+                       configure_cfg(cfg, scenario, ...)  [start.R]                            
+                       submit(cfg)                        [scripts/start/submit.R]               
+                        - create output folder                                                                     
+                        - save cfg to runtitlte.RData                                                                     
+                        - copy scripts/start/prepare_and_run.R into results folder                                                                     
+                        - move runtitle.RData into results folder                                                                     
+                        - change to results folder                                                                       
+                        - send job to cluster: sbatch Rscript prepare_and_run.R ----->  prepare_and_run() [scripts/start/prepare_and_run.R]                                                                    
+                        - change to main folder                                          - load config.RData
+                                                                                         - cd mainfolder
+                                                                                         - prepare NDC [scripts/input/prepareNDC2018.R]
+                                                                                         - prepare calibration
+                                                                                         - LOCK model
+                                                                                         - download and distribute input data
+                                                                                         - if coupled get MAgPIE data
+                                                                                         - put together single GAMS file
+                                                                                         - UNLOCK
+                                                                                         - cd resultsfolder
+                                                                                         - create fixings
+                                                                                         - call GAMS full.gms
+                                                                                         - submit runstatistics
+                                                                                         - cd mainfolder
+                                                                                         - start subsequent runs submit(cfg) [scripts/start/submit.R]
+                                                                                         - reporting [output.R]
+                                                                                         - cd resultsfolder
+                    
+                    
+
+
diff --git a/scripts/start/submit.R b/scripts/start/submit.R
new file mode 100644
index 0000000000000000000000000000000000000000..25d3db720391d8b7b0cd6fcfb76c63975127e605
--- /dev/null
+++ b/scripts/start/submit.R
@@ -0,0 +1,63 @@
+############## Define function: .copy.fromlist #########################
+
+.copy.fromlist <- function(filelist,destfolder) {
+  if(is.null(names(filelist))) names(filelist) <- rep("",length(filelist))
+  for(i in 1:length(filelist)) {
+    if(!is.na(filelist[i])) {
+      to <- paste0(destfolder,"/",names(filelist)[i])
+      if(!file.copy(filelist[i],to=to,recursive=dir.exists(to),overwrite=T))
+        cat(paste0("Could not copy ",filelist[i]," to ",to,"\n"))
+    }
+  }
+}
+
+############## Define function: runsubmit #########################
+
+submit <- function(cfg) {
+  
+  # Create name of output folder and output folder itself
+  date <- format(Sys.time(), "_%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 (!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")
+    unlink(cfg$results_folder, recursive = TRUE)
+    dir.create(cfg$results_folder, recursive = TRUE, showWarnings = FALSE)
+  }
+  
+  # save main folder
+  cfg$remind_folder <- getwd()
+ 
+  # save the cfg data before moving it into the results folder
+  cat("Writing cfg to file\n")
+  save(cfg,file=paste0(cfg$title,".RData"))
+  
+  # Copy files required to confiugre and start a run
+  filelist <- c("config.Rdata" = paste0(cfg$title,".RData"),
+                "prepare_and_run.R" = "scripts/start/prepare_and_run.R")
+  .copy.fromlist(filelist,cfg$results_folder)
+  
+  # remove config in main folder (after copying into results folder)
+  file.remove(paste0(cfg$title,".RData"))
+
+  # change to run folder
+  setwd(cfg$results_folder)
+  on.exit(setwd(cfg$remind_folder))
+
+  # send prepare_and_run.R to cluster 
+  cat("Executing prepare_and_run.R for",cfg$title,"\n")
+  if(cfg$slurmConfig=="direct") {
+    log <- format(Sys.time(), paste0(cfg$title,"-%Y-%H-%M-%S-%OS3.log"))
+    system("Rscript prepare_and_run.R")
+  } else {
+    system(paste0("sbatch --job-name=",cfg$title," --output=log.txt --mail-type=END --comment=REMIND --wrap=\"Rscript prepare_and_run.R \" ",cfg$slurmConfig))
+    Sys.sleep(1)
+  }
+    
+  return(cfg$results_folder)
+}
diff --git a/scripts/run_submit/run_compareScenarios.R b/scripts/utils/run_compareScenarios.R
similarity index 100%
rename from scripts/run_submit/run_compareScenarios.R
rename to scripts/utils/run_compareScenarios.R
diff --git a/standalone/MOFEX/MOFEX.gms b/standalone/MOFEX/MOFEX.gms
index 085e2dae678de1597e0ca472278e2f69ef012721..fa53981532169345adb0456965de2bfcfc45868c 100644
--- a/standalone/MOFEX/MOFEX.gms
+++ b/standalone/MOFEX/MOFEX.gms
@@ -132,7 +132,7 @@ c_solscen             "solar option choice"
 cm_bioenergy_tax      "level of bioenergy tax in fraction of bioenergy price"
 cm_bioenergymaxscen   "bound on global pebiolc production excluding residues"
 cm_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_1stgen_phaseout    "choose if 1st generation biofuels should phase out after 2030 (vm_deltaCap=0)"
 cm_startyear          "first optimized modelling time step"
 c_start_budget        "start of GHG budget limit"
 cm_prtpScen            "pure rate of time preference standard values"
@@ -219,7 +219,7 @@ cm_bioenergy_tax    = 1.5;       !! def = 1.5
 cm_bioenergymaxscen = 0;         !! def = 0
 cm_tradecost_bio     = 2;         !! def = 2
 $setglobal cm_LU_emi_scen  SSP2   !! def = SSP2
-c_1stgen_phaseout  = 0;         !! def = 0
+cm_1stgen_phaseout  = 0;         !! def = 0
 
 $setglobal cm_POPscen  pop_SSP2  !! def = pop_SSP2
 $setglobal cm_GDPscen  gdp_SSP2  !! def = gdp_SSP2
@@ -305,8 +305,6 @@ $setGlobal cm_magicc_temperatureImpulseResponse  off           !! def = off
 
 $setGlobal cm_damage_DiceLike_specification  HowardNonCatastrophic   !! def = HowardNonCatastrophic
 
-
-$setglobal cm_compile_main       TRUE     !! this will be changed by submit.R
 $setglobal cm_CES_configuration  stat_off-indu_fixed_shares-buil_simple-tran_complex-POP_pop_SSP2-GDP_gdp_SSP2-Kap_perfect-Reg_ccd632d33a   !! this will be changed by start_run()
 
 $setglobal c_CES_calibration_new_structure  0    !! def =  0
diff --git a/standalone/template.gms b/standalone/template.gms
index c507c11a06e8fae6677fda2487a09781a2b42318..737ce60da022ee181081b4d18775813ab2aba74d 100644
--- a/standalone/template.gms
+++ b/standalone/template.gms
@@ -140,7 +140,7 @@ c_solscen             "solar option choice"
 cm_bioenergy_tax      "level of bioenergy tax in fraction of bioenergy price"
 cm_bioenergymaxscen   "bound on global pebiolc production excluding residues"
 cm_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_1stgen_phaseout    "choose if 1st generation biofuels should phase out after 2030 (vm_deltaCap=0)"
 cm_startyear          "first optimized modelling time step"
 c_start_budget        "start of GHG budget limit"
 cm_prtpScen            "pure rate of time preference standard values"
@@ -227,7 +227,7 @@ cm_bioenergy_tax    = 1.5;       !! def = 1.5
 cm_bioenergymaxscen = 0;         !! def = 0
 cm_tradecost_bio     = 2;         !! def = 2
 $setglobal cm_LU_emi_scen  SSP2   !! def = SSP2
-c_1stgen_phaseout  = 0;         !! def = 0
+cm_1stgen_phaseout  = 0;         !! def = 0
 
 $setglobal cm_POPscen  pop_SSP2  !! def = pop_SSP2
 $setglobal cm_GDPscen  gdp_SSP2  !! def = gdp_SSP2
@@ -313,8 +313,6 @@ $setGlobal cm_magicc_temperatureImpulseResponse  off           !! def = off
 
 $setGlobal cm_damage_DiceLike_specification  HowardNonCatastrophic   !! def = HowardNonCatastrophic
 
-
-$setglobal cm_compile_main       TRUE     !! this will be changed by submit.R
 $setglobal cm_CES_configuration  stat_off-indu_fixed_shares-buil_simple-tran_complex-POP_pop_SSP2-GDP_gdp_SSP2-Kap_perfect-Reg_690d3718e1   !! this will be changed by start_run()
 
 $setglobal c_CES_calibration_new_structure  0    !! def =  0
diff --git a/start.R b/start.R
index e4de54407db13cf456651344ec7b02e2f6715090..cc4cfc2b99c577b0c87960ccd7b7c1c1b0b42b5a 100644
--- a/start.R
+++ b/start.R
@@ -1,26 +1,163 @@
-# |  (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
-
-##########################################################
-#### Script to start a REMIND run ####
-##########################################################
-
-library(lucode, quietly = TRUE,warn.conflicts =FALSE)
-library(magclass, quietly = TRUE,warn.conflicts =FALSE)
-
-#Here the function start_run(cfg) is loaded which is needed to start REMIND runs
-#The function needs information about the configuration of the run. This can be either supplied as a list of settings or as a file name of a config file
-source("scripts/start_functions.R")
-
-#Load config-file
-cfg_REMIND <- "default.cfg"
-readArgs("cfg_REMIND")
-
-#start REMIND run
-start_run(cfg_REMIND)
-#rep = read.report("coupling.mif")
-#start_reportrun(rep)
+library(lucode)
+
+source("scripts/start/submit.R")
+source("scripts/start/choose_slurmConfig.R")
+
+############## Define function: configure_cfg #########################
+
+configure_cfg <- function(icfg, iscen, iscenarios, isettings) {
+
+    .setgdxcopy <- function(needle, stack, new) {
+      # delete entries in stack that contain needle and append new
+      out <- c(stack[-grep(needle, stack)], new)
+      return(out)
+    }
+
+    # Edit run title
+    icfg$title <- iscen
+    cat("\n", iscen, "\n")
+
+    # Edit main file of model
+    if( "model" %in% names(iscenarios)){
+      icfg$model <- iscenarios[iscen,"model"]
+    }
+
+    # Edit regional aggregation
+    if( "regionmapping" %in% names(iscenarios)){
+      icfg$regionmapping <- iscenarios[iscen,"regionmapping"]
+    }
+
+    # Edit input data revision
+    if( "revision" %in% names(iscenarios)){
+      icfg$revision <- iscenarios[iscen,"revision"]
+    }
+
+    # Edit switches in default.cfg according to the values given in the scenarios table
+    for (switchname in intersect(names(icfg$gms), names(iscenarios))) {
+      icfg$gms[[switchname]] <- iscenarios[iscen,switchname]
+    }
+
+    # Set reporting script
+    if( "output" %in% names(iscenarios)){
+      icfg$output <- paste0("c(\"",gsub(",","\",\"",gsub(", ",",",iscenarios[iscen,"output"])),"\")")
+    }
+
+    # check if full input.gdx path is provided and, if not, search for correct path
+    if (!substr(isettings[iscen,"path_gdx"], nchar(isettings[iscen,"path_gdx"])-3, nchar(isettings[iscen,"path_gdx"])) == ".gdx"){
+      #if there is no correct scenario folder within the output folder path provided, take the config/input.gdx
+      if(length(grep(iscen,list.files(path=isettings[iscen,"path_gdx"]),value=T))==0){
+        isettings[iscen,"path_gdx"] <- "config/input.gdx"
+      #if there is only one instance of an output folder with that name, take the fulldata.gdx from this
+      } else if (length(grep(iscen,list.files(path=isettings[iscen,"path_gdx"]),value=T))==1){
+        isettings[iscen,"path_gdx"] <- paste0(isettings[iscen,"path_gdx"],"/",
+                                            grep(iscen,list.files(path=isettings[iscen,"path_gdx"]),value=T),"/fulldata.gdx")
+      } else {
+        #if there are multiple instances, take the newest one
+        isettings[iscen,"path_gdx"] <- paste0(isettings[iscen,"path_gdx"],"/",
+                                            substr(grep(iscen,list.files(path=isettings[iscen,"path_gdx"]),value=T),1,
+                                                   nchar(grep(iscen,list.files(path=isettings[iscen,"path_gdx"]),value=T))-19)[1],
+        max(substr(grep(iscen,list.files(path=isettings[iscen,"path_gdx"]),value=T),
+                                 nchar(grep(iscen,list.files(path=isettings[iscen,"path_gdx"]),value=T))-18,
+                                 nchar(grep(iscen,list.files(path=isettings[iscen,"path_gdx"]),value=T)))),"/fulldata.gdx")
+      }
+    }
+
+    # if the above has not created a path to a valid gdx, take config/input.gdx
+    if (!file.exists(isettings[iscen,"path_gdx"])){
+      isettings[iscen,"path_gdx"] <- "config/input.gdx"
+      #if even this is not existent, stop
+      if (!file.exists(isettings[iscen,"path_gdx"])){
+      stop("Cant find a gdx under path_gdx, please specify full path to gdx or else location of output folder that contains previous run")
+      }
+    }
+
+    # Define path where the GDXs will be taken from
+    gdxlist <- c(input.gdx     = isettings[iscen, "path_gdx"],
+                 input_ref.gdx = isettings[iscen, "path_gdx_ref"],
+                 input_bau.gdx = isettings[iscen, "path_gdx_bau"])
+
+    # Remove potential elements that contain ".gdx" and append gdxlist
+    icfg$files2export$start <- .setgdxcopy(".gdx", icfg$files2export$start, gdxlist)
+
+    # add gdx information for subsequent runs
+    icfg$subsequentruns        <- rownames(isettings[isettings$path_gdx_ref == iscen & !is.na(isettings$path_gdx_ref) & isettings$start == 1,])
+    icfg$RunsUsingTHISgdxAsBAU <- rownames(isettings[isettings$path_gdx_bau == iscen & !is.na(isettings$path_gdx_bau) & isettings$start == 1,])
+
+    return(icfg)
+}
+
+###################### Choose submission type #########################
+slurmConfig <- choose_slurmConfig()
+
+###################### Load csv if provided  ##########################
+
+# If testOneRegi was selected, set up a testOneRegi run.  IF a
+# scenario_config.csv file was provided, set cfg according to it (copy from
+# start_bundle).
+
+# check command-line arguments for testOneRegi and scenario_config file
+argv <- commandArgs(trailingOnly = TRUE)
+config.file <- argv[1]
+if ('--testOneRegi' %in% argv) {
+  testOneRegi <- TRUE
+  config.file <- NA
+} else {
+  testOneRegi <- FALSE
+}
+
+if (!is.na(config.file)) {
+  cat(paste("reading 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 = "")
+
+  # Select scenarios that are flagged to start
+  scenarios  <- settings[settings$start==1,]
+  if (length(grep("\\.",rownames(scenarios))) > 0) stop("One or more titles contain dots - GAMS would not tolerate this, and quit working at a point where you least expect it. Stopping now. ")
+} else {
+  # if no csv was provided create dummy list with default as the only scenario
+  scenarios <- data.frame("default" = "default",row.names = "default")
+}
+
+###################### Loop over csv ###############################
+
+# Modify and save cfg for all runs
+for (scen in rownames(scenarios)) {
+  #source cfg file for each scenario to avoid duplication of gdx entries in files2export
+  source("config/default.cfg")
+
+  # Have the log output written in a file (not on the screen)
+  cfg$slurmConfig <- slurmConfig
+  cfg$logoption   <- 2
+  start_now       <- TRUE
+
+  # testOneRegi settings
+  if (testOneRegi) {
+    cfg$title            <- 'testOneRegi'
+    cfg$gms$optimization <- 'testOneRegi'
+    cfg$output           <- NA
+    cfg$results_folder   <- 'output/testOneRegi'
+
+    # delete existing Results directory
+    cfg$force_replace    <- TRUE
+  }
+
+  # configure cfg based on settings from csv if provided
+  if (!is.na(config.file)) {
+
+  cfg <- configure_cfg(cfg, scen, scenarios, settings)
+
+  # Directly start runs that have a gdx file location given as path_gdx_ref or where this field is empty
+  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)
+  cat("Writing cfg to file\n")
+  save(cfg,file=paste0(scen,".RData"))
+
+  if (start_now){
+   cat("Creating and starting: ",cfg$title,"\n")
+   submit(cfg)
+   }
+}
diff --git a/start_bundle.R b/start_bundle.R
deleted file mode 100644
index 75cb0179beb53b9fb2619d56aca9436f2ebc137f..0000000000000000000000000000000000000000
--- a/start_bundle.R
+++ /dev/null
@@ -1,126 +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
-source("scripts/start_functions.R")
-
-require(lucode, quietly = TRUE, warn.conflicts = FALSE)
-
-.setgdxcopy <- function(needle, stack, new) {
-  # delete entries in stack that contain needle and append new
-  out <- c(stack[-grep(needle, stack)], new)
-  return(out)
-}
-
-# check for config file parameter
-config.file <- commandArgs(trailingOnly = TRUE)[1]
-if (  is.na(config.file)                          # no parameter given
-    | -1 == file.access(config.file, mode = 4))   # if file can't be read
-  config.file <- "config/scenario_config.csv" 
-
-cat(paste("reading 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 = "")
-
-# Select scenarios that are flagged to start
-scenarios  <- settings[settings$start==1,]
-
-if (length(grep("\\.",rownames(scenarios))) > 0) stop("One or more titles contain dots - GAMS would not tolerate this, and quit working at a point where you least expect it. Stopping now. ")
-
-# Modify and save cfg for all runs
-for (scen in rownames(scenarios)) {
-  #source cfg file for each scenario to avoid duplication of gdx entries in files2export
-  source("config/default.cfg")
-  
-  # Have the log output written in a file (not on the screen)
-  cfg$logoption  <- 2
-  cfg$sequential <- NA
-  
-  # Edit run title
-  cfg$title <- scen
-  cat("\n", scen, "\n")
-
-  # Edit main file of model
-  if( "model" %in% names(scenarios)){
-    cfg$model <- scenarios[scen,"model"] 
-  }
-
-  # Edit regional aggregation
-  if( "regionmapping" %in% names(scenarios)){
-    cfg$regionmapping <- scenarios[scen,"regionmapping"] 
-  }
-  
-  # Edit input data revision
-  if( "revision" %in% names(scenarios)){
-    cfg$revision <- scenarios[scen,"revision"] 
-  }
-
-  # Edit switches in default.cfg according to the values given in the scenarios table
-  for (switchname in intersect(names(cfg$gms), names(scenarios))) {
-    cfg$gms[[switchname]] <- scenarios[scen,switchname]
-  }
-
-  # Set reporting script
-  if( "output" %in% names(scenarios)){
-    cfg$output <- paste0("c(\"",gsub(",","\",\"",gsub(", ",",",scenarios[scen,"output"])),"\")")
-  }
-  
-  # check if full input.gdx path is provided and, if not, search for correct path
-  if (!substr(settings[scen,"path_gdx"], nchar(settings[scen,"path_gdx"])-3, nchar(settings[scen,"path_gdx"])) == ".gdx"){
-    #if there is no correct scenario folder within the output folder path provided, take the config/input.gdx
-    if(length(grep(scen,list.files(path=settings[scen,"path_gdx"]),value=T))==0){
-      settings[scen,"path_gdx"] <- "config/input.gdx"
-    #if there is only one instance of an output folder with that name, take the fulldata.gdx from this 
-    } else if (length(grep(scen,list.files(path=settings[scen,"path_gdx"]),value=T))==1){
-      settings[scen,"path_gdx"] <- paste0(settings[scen,"path_gdx"],"/",
-                                          grep(scen,list.files(path=settings[scen,"path_gdx"]),value=T),"/fulldata.gdx")
-    } else {
-      #if there are multiple instances, take the newest one
-      settings[scen,"path_gdx"] <- paste0(settings[scen,"path_gdx"],"/",
-                                          substr(grep(scen,list.files(path=settings[scen,"path_gdx"]),value=T),1,
-                                                 nchar(grep(scen,list.files(path=settings[scen,"path_gdx"]),value=T))-19)[1],      
-      max(substr(grep(scen,list.files(path=settings[scen,"path_gdx"]),value=T),
-                               nchar(grep(scen,list.files(path=settings[scen,"path_gdx"]),value=T))-18,
-                               nchar(grep(scen,list.files(path=settings[scen,"path_gdx"]),value=T)))),"/fulldata.gdx")
-    }
-  }
-  
-  # if the above has not created a path to a valid gdx, take config/input.gdx
-  if (!file.exists(settings[scen,"path_gdx"])){
-    settings[scen,"path_gdx"] <- "config/input.gdx"
-    #if even this is not existent, stop
-    if (!file.exists(settings[scen,"path_gdx"])){
-    stop("Cant find a gdx under path_gdx, please specify full path to gdx or else location of output folder that contains previous run")
-    }
-  }
- 
-  # 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"])
-
-  # Remove potential elements that contain ".gdx" and append gdxlist
-  cfg$files2export$start <- .setgdxcopy(".gdx", cfg$files2export$start, gdxlist)
-
-  # add gdx information for subsequent runs
-  cfg$subsequentruns        <- rownames(settings[settings$path_gdx_ref == scen & !is.na(settings$path_gdx_ref) & settings$start == 1,])
-  cfg$RunsUsingTHISgdxAsBAU <- rownames(settings[settings$path_gdx_bau == scen & !is.na(settings$path_gdx_bau) & settings$start == 1,])
-  
-  # save the cfg data for later start of subsequent runs (after preceding run finished)
-  cat("Writing cfg to file\n")
-  save(cfg,file=paste0(scen,".RData"))
-}
-
-# Directly start runs that have a gdx file location given as path_gdx_ref or where this field is empty
-for (scen in rownames(scenarios)) {
-  if (substr(settings[scen,"path_gdx_ref"], nchar(settings[scen,"path_gdx_ref"])-3, nchar(settings[scen,"path_gdx_ref"])) == ".gdx" 
-     | is.na(settings[scen,"path_gdx_ref"])){
-   cat("Starting: ",scen,"\n")
-   load(paste0(scen,".RData"))
-   start_run(cfg)
-   }
-}
diff --git a/start_bundle_climate.R b/start_bundle_climate.R
index fbbffd327045790ef55b794813c13635ff37affe..ab33cec7f99dad2a4759f44115c6f7ca571acee6 100644
--- a/start_bundle_climate.R
+++ b/start_bundle_climate.R
@@ -4,10 +4,15 @@
 # |  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
-source("scripts/start_functions.R")
 
 require(lucode, quietly = TRUE, warn.conflicts = FALSE)
 
+source("scripts/start/submit.R")
+source("scripts/start/choose_slurmConfig.R")
+
+# Choose submission type
+slurmConfig <- choose_slurmConfig()
+
 .setgdxcopy <- function(needle, stack, new) {
   # delete entries in stack that contain needle and append new
   out <- c(stack[-grep(needle, stack)], new)
@@ -55,6 +60,7 @@ for (scen in rownames(scenarios)) {
   source("config/default.cfg")
   
   # Have the log output written in a file (not on the screen)
+  cfg$slurmConfig <- slurmConfig
   cfg$logoption  <- 2
   cfg$sequential <- NA
   
@@ -124,6 +130,6 @@ for (scen in rownames(scenarios)) {
      | is.na(settings[scen,"path_gdx_ref"])){
    cat("Starting: ",scen,"\n")
    load(paste0(scen,".RData"))
-   start_run(cfg)
+   submit(cfg)
    }
 }
diff --git a/start_bundle_coupled.R b/start_bundle_coupled.R
index f0bc63281aed2e23d41705cdb232042cb6b5bccc..b6ffed3bd70592288b61eae4fd1063cb6b2dec68 100644
--- a/start_bundle_coupled.R
+++ b/start_bundle_coupled.R
@@ -95,7 +95,7 @@ if (!identical(common,character(0))) {
 for(scen in common){
   cat(paste0("\n################################\nPreparing run ",scen,"\n"))
   
-  prefix_runname <- strsplit(path_remind,"/")[[1]][length(strsplit(path_remind,"/")[[1]])]
+  prefix_runname <- "C" #strsplit(path_remind,"/")[[1]][length(strsplit(path_remind,"/")[[1]])]
   prefix_runname <- paste0(prefix_runname,"_")
   
   runname      <- paste0(prefix_runname,scen)            # name of the run that is used for the folder names
@@ -239,11 +239,6 @@ for(scen in common){
 	  settings_remind[scen, "path_gdx_ref"] <- scenarios_coupled[scen, "path_gdx_ref"]
 	  cat("Replacing gdx_ref information with those specified in\n  ",path_settings_coupled,"\n  ",settings_remind[scen, "path_gdx_ref"],"\n")
   }
-
-  if (!is.na(scenarios_coupled[scen, "path_gdx_opt"])) {
-	  settings_remind[scen, "path_gdx_opt"] <- scenarios_coupled[scen, "path_gdx_opt"]
-	  cat("Replacing gdx_opt information with those specified in\n  ",path_settings_coupled,"\n  ",settings_remind[scen, "path_gdx_opt"],"\n")
-  }
  
   # 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)
@@ -255,7 +250,7 @@ for(scen in common){
   
   # add information on subsequent runs to start after the current run is finished
   # take rownames (which is the runname) of that row, that has the current scenario in its gdx_ref
-  cfg_rem$subsequentruns        <- intersect(rownames(settings_remind[settings_remind$path_gdx_ref == scen & !is.na(settings_remind$path_gdx_ref),]),common)
+  cfg_rem$subsequentruns <- intersect(rownames(settings_remind[settings_remind$path_gdx_ref == scen & !is.na(settings_remind$path_gdx_ref),]),common)
      
   # immediately start run if it has a real gdx file (not a runname) given (last four letters are ".gdx") in path_gdx_ref or where this field is empty (NA)
   start_now <- (substr(settings_remind[scen,"path_gdx_ref"], nchar(settings_remind[scen,"path_gdx_ref"])-3, nchar(settings_remind[scen,"path_gdx_ref"])) == ".gdx" 
@@ -298,24 +293,16 @@ for(scen in common){
   cat("path_report : ",ifelse(file.exists(path_report),green,red), path_report, NC, "\n",sep="")
   cat("LU_pricing  :",LU_pricing,"\n")
  
-  # create cluster_start_coupled_scen.cmd file
-  # 1. copy general cluster_start_coupled file
-  system(paste0("cp cluster_start_coupled.cmd cluster_start_coupled_",scen,".cmd"))
-  # 2. modify accordingly
-  manipulateConfig(paste0("cluster_start_coupled_",scen,".cmd"),coupled_config=paste0(runname,".RData"),line_endings = "NOTwin")
-  manipulateConfig(paste0("cluster_start_coupled_",scen,".cmd"),"--job-name"=runname,line_endings = "NOTwin")
-  manipulateConfig(paste0("cluster_start_coupled_",scen,".cmd"),"--output"=paste0(runname,".log"),line_endings = "NOTwin")
   if (cfg_rem$gms$optimization == "nash" && cfg_rem$gms$cm_nash_mode == "parallel") {
     # for nash: set the number of CPUs per node to number of regions + 1
     nr_of_regions <- length(levels(read.csv2(cfg_rem$regionmapping)$RegionCode)) + 1 
-    manipulateConfig(paste0("cluster_start_coupled_",scen,".cmd"),"--tasks-per-node"=nr_of_regions,line_endings = "NOTwin")
   } else {
     # for negishi: use only one CPU
-    manipulateConfig(paste0("cluster_start_coupled_",scen,".cmd"),"--tasks-per-node"=1,line_endings = "NOTwin")
+    nr_of_regions <- 1
   }
 
   if (start_now){
-      if (!exists("test")) system(paste0("sbatch cluster_start_coupled_",scen,".cmd"))
+      if (!exists("test")) system(paste0("sbatch --qos=standby --job-name=",runname," --output=",runname,".log --mail-type=END --comment=REMIND-MAgPIE --tasks-per-node=",nr_of_regions," --wrap=\"Rscript start_coupled.R coupled_config=",runname,".RData\""))
       else cat("Test mode: run NOT submitted to the cluster\n")
   } else {
      cat(paste0("Run ",runname," will start after preceding run ",prefix_runname,settings_remind[scen,"path_gdx_ref"]," has finished\n"))
diff --git a/start_coupled.R b/start_coupled.R
index ecff05e0d53b099629a58f55f5b93d856877e299..2a918eff313bd307894c9daa489299d621be87c0 100644
--- a/start_coupled.R
+++ b/start_coupled.R
@@ -52,10 +52,11 @@ start_coupled <- function(path_remind,path_magpie,cfg_rem,cfg_mag,runname,max_it
     cat("### COUPLING ### Set working directory from",getwd());
     setwd(path_remind)
     cat(" to",getwd(),"\n")
-    source("scripts/start_functions.R") # provide source of "get_magpie_data" and "start_run"
+    source("scripts/start/submit.R") # provide source of "get_magpie_data" and "start_run"
     
     cfg_rem$results_folder <- paste0("output/",runname,"-rem-",i)
     cfg_rem$title          <- paste0(runname,"-rem-",i)
+    cfg_rem$force_replace  <- TRUE # overwrite existing output folders
     #cfg_rem$gms$biomass    <- "magpie_linear"
 
     # define gdx paths
@@ -103,18 +104,17 @@ start_coupled <- function(path_remind,path_magpie,cfg_rem,cfg_mag,runname,max_it
       cfg_rem$gms$cm_MAgPIE_coupling <- "off"
       cat("### COUPLING ### No MAgPIE report for REMIND input provided.\n")
       cat("### COUPLING ### REMIND will be startet in stand-alone mode with\n    ",runname,"\n    ",cfg_rem$results_folder,"\n")
-      outfolder_rem <- start_run(cfg_rem,coupled=T,force=T)
+      outfolder_rem <- submit(cfg_rem)
     } else if (grepl(paste0("report.mif"),report)) { # if it is a MAgPIE report
       ######### S T A R T   R E M I N D   C O U P L E D ##############
       cfg_rem$gms$cm_MAgPIE_coupling <- "on"
       if (!file.exists(report)) stop(paste0("### COUPLING ### Could not find report: ", report,"\n"))
-      rep <- read.report(report,as.list=FALSE)
-      sceninreport <- getNames(rep,dim="scenario") # report must only contain ONE scenario
-      cat("### COUPLING ### Starting REMIND in coupled mode with\n    Report=",report,"\n    Scenario used as input=",sceninreport,"\n    Folder=",cfg_rem$results_folder,"\n")
+      cat("### COUPLING ### Starting REMIND in coupled mode with\n    Report=",report,"\n    Folder=",cfg_rem$results_folder,"\n")
       # Keep path to MAgPIE report in mind to have it availalbe after the coupling loop
       mag_report_keep_in_mind <- report
       ####### START REMIND #######
-      outfolder_rem <- start_run(cfg_rem, report=rep, sceninreport=sceninreport,coupled=T,force=T)
+      cfg_rem$pathToMagpieReport <- report
+      outfolder_rem <- submit(cfg_rem)
       ############################
     } else if (grepl("REMIND_generic_",report)) { # if it is a REMIND report
       ############### O M I T   R E M I N D  ###############################
@@ -201,10 +201,21 @@ start_coupled <- function(path_remind,path_magpie,cfg_rem,cfg_mag,runname,max_it
   setwd(mainwd)
   cat(" to",getwd(),"\n")
   
-  #start subsequent runs via cmd scripts created at the end of start_bundle_coupled.R
+  # for the sbatch command of the subsequent runs below set the number of tasks per node
+  # this not clean, because we use the number of regions of the *current* run to set the number of tasks for the *subsequent* runs
+  # but it is sufficiently clean, since the number of regions should not differ between current and subsequent
+  if (cfg_rem$gms$optimization == "nash" && cfg_rem$gms$cm_nash_mode == "parallel") {
+    # for nash: set the number of CPUs per node to number of regions + 1
+    nr_of_regions <- length(levels(read.csv2(cfg_rem$regionmapping)$RegionCode)) + 1 
+  } else {
+    # for negishi: use only one CPU
+    nr_of_regions <- 1
+  }
+
+  #start subsequent runs via sbatch
   for(run in cfg_rem$subsequentruns){
     cat("Submitting subsequent run",run,"\n")
-    system(paste0("sbatch cluster_start_coupled_",run,".cmd"))
+    system(paste0("sbatch --qos=standby --job-name=",run," --output=",run,".log --mail-type=END --comment=REMIND-MAgPIE --tasks-per-node=",nr_of_regions," --wrap=\"Rscript start_coupled.R coupled_config=C_",run,".RData\""))
   }
   
   # Read runtime of ALL coupled runs (not just the current scenario) and produce comparison pdf
@@ -214,6 +225,7 @@ start_coupled <- function(path_remind,path_magpie,cfg_rem,cfg_mag,runname,max_it
   runs <- findCoupledruns(resultsfolder=remindpath)
   ret  <- findIterations(runs,modelpath=c(remindpath,magpiepath),latest=FALSE)
   readRuntime(ret,plot=TRUE,coupled=TRUE)
+  unlink(c("runtime.log","runtime.out","runtime.rda"))
   
   # combine REMIND and MAgPIE reports of last coupling iteration (and REMIND water reporting if existing)
   report_rem <- paste0(path_remind,outfolder_rem,"/REMIND_generic_",cfg_rem$title,".mif")