diff --git a/.gitignore b/.gitignore
index 77a0a26259debe4a770ffc74e74213b07d78f378..bc0d096a297616a9a6a3b58d748025c180efaaeb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,20 +13,19 @@ core/input/f_cf.cs3r
 core/input/f_dataRegiSolar.cs3r
 core/input/f_emiFgas.cs4r
 core/input/f_gdp.cs3r
-core/input/f_IO_trade.cs4r
 core/input/f_lab.cs3r
 core/input/f_macBaseMagpie.cs4r
 core/input/f_maxProdGradeRegiHydro.cs3r
 core/input/f_maxProdGradeRegiWind.cs3r
 core/input/f_pop.cs3r
+core/input/f_IO_trade.cs4r
 core/input/p_abatparam_CH4.cs4r
 core/input/p_abatparam_N2O.cs4r
 core/input/p_abatparam_CO2.cs4r
 core/input/p_adj_deltacapoffset.cs4r
 core/input/p_boundEmi.cs4r
-core/input/p_boundInvMacro.cs4r
 core/input/pm_NuclearConstraint.cs4r
-core/input/p_costsPEtradeMp.cs4r
+core/input/pm_costsPEtradeMp.cs4r
 core/input/pm_dataccs.cs3r
 core/input/p_earlyRetirementAdjFactor.cs3r
 core/input/p_emiFossilFuelExtr.cs4r
@@ -43,7 +42,6 @@ core/input/p_share_ind_fesos.cs4r
 core/input/p_share_ind_fesos_bio.cs4r
 core/input/pm_boundCapCCS.cs4r
 core/input/pm_boundCapEV.cs4r
-core/input/pm_costsTradePeFinancial.cs3r
 core/input/pm_shPPPMER.cs4r
 core/input/p_inco0.cs4r
 core/input/p_boundCapCCSindicator.cs4r
@@ -55,6 +53,7 @@ core/input/
 core/input/core/input/p_NuclearConstraint.cs4r
 core/input/core/input/pm_inco0.cs4r
 core/input/historical/historical.mif
+modules/01_macro/singleSectorGr/input/p01_boundInvMacro.cs4r
 modules/04_PE_FE_parameters/iea2014/input/f04_IO_input.cs4r
 modules/04_PE_FE_parameters/iea2014/input/f04_IO_output.cs4r
 modules/04_PE_FE_parameters/iea2014/input/
@@ -81,6 +80,8 @@ modules/23_capitalMarket/imperfect/input/pm_ies.cs4r
 modules/23_capitalMarket/imperfect/input/pm_nfa_start.cs4r
 modules/23_capitalMarket/imperfect/input/pm_risk_premium.cs4r
 modules/23_capitalMarket/perfect/input/pm_nfa_start.cs4r
+modules/24_trade/standard/input/pm_costsPEtradeMp.cs4r
+modules/24_trade/standard/input/pm_costsTradePeFinancial.cs3r
 modules/26_agCosts/costs/input/p26_totLUcostLookup.cs4r
 modules/26_agCosts/costs/input/p26_macCostLuLookup.cs4r
 modules/26_agCosts/costs/input/
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 544c1c65e1fc0ceab019b270b8f840eea0ca6e28..f5fc570c23381d364efdc1173907891027993698 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.936
+cfg$revision <- 5.937
 
 #### 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")
@@ -49,6 +52,10 @@ cfg$gms <- list()
 # ***                           MODULES                   START
 # ***------------------------------------------------------------------------------
 
+# ***---------------------    01_macro    -----------------------------------------
+# * (singleSectorGr): 
+cfg$gms$macro  <- "singleSectorGr"   # def = singleSectorGr
+
 # ***---------------------    02_welfare    ---------------------------------------
 # * (utilitarian): 
 cfg$gms$welfare  <- "utilitarian"   # def = utilitarian
@@ -97,6 +104,9 @@ cfg$gms$subsidizeLearning  <- "off"           # def = off
 # * (perfect):   Perfect capital market (results in large short-term capital flows from North to South)
 cfg$gms$capitalMarket  <- "perfect"           # def = perfect
 
+# ***----------------------    24_trade    ---------------------------------------
+# * (standard):
+cfg$gms$trade  <- "standard"           # def = standard
 
 # ***----------------------   26_agCosts  ----------------------------------------
 # * (off): agricultural costs zero, no trade taken into account
@@ -134,7 +144,7 @@ cfg$gms$CDR <- "DAC"        # def = DAC
 
 # ***---------------------    35_transport    ----------------------------------------
 # * (complex):  transport realization including electricity in the transport sector (*RP*)
-cfg$gms$transport <- "edge_esm"           # def = complex
+cfg$gms$transport <- "complex"           # def = complex
 
 # ***---------------------    36_buildings    ---------------------------------
 # * (simple): representation of the demand in terms of energy carriers
@@ -157,7 +167,7 @@ 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  <- "on"      # def = off
+cfg$gms$CCU  <- "off"      # def = off
 
 # ***---------------------    40_techpol  ----------------------------------------
 # * (none): no technology policies
@@ -271,9 +281,9 @@ 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$c_tradecost_bio      <- 2       # def <- 2
+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"
@@ -334,7 +344,7 @@ 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$c_trdcst                        <- 1.5     # def <- 1.5
+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
@@ -347,8 +357,6 @@ 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"
-
 #-----------------------------------------------------------------------------
 #                          FLAGS
 #-----------------------------------------------------------------------------
@@ -369,7 +377,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).
@@ -406,9 +414,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
@@ -426,22 +433,16 @@ 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",
                             "config/input.gdx",
                             "config/input_ref.gdx",
-			    "core/magicc",
+                            "core/magicc",
                             ".Rprofile",
                             "config/mappingEDGEtoREMINDsectors.csv")
 
@@ -537,14 +538,14 @@ cfg$RunsUsingTHISgdxAsBAU <- NA
 #  (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)
-# c_tradecost_bio  "choose financal tradecosts for biomass (purpose grown pebiolc)"
+# 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)"
+# 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"
@@ -732,7 +733,7 @@ cfg$RunsUsingTHISgdxAsBAU <- NA
 # 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 p_costsPEtradeMp, vm_welfare into v_welfare
+# 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
@@ -742,7 +743,7 @@ cfg$RunsUsingTHISgdxAsBAU <- NA
 # 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 v_invMacroAdj
+# 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
@@ -783,8 +784,8 @@ cfg$RunsUsingTHISgdxAsBAU <- NA
 # 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 q_balLab, q_production into q_cesIO, q_kapmo into q_kapMo, q_invest_adjcosts into q_invMacroAdj, q_limit_ppfen_shares into q_limitShPpfen
-# q_limit_ppfen_ratios into q_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
+# 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
diff --git a/config/old_scenario_config/scenario_config_EMF33.csv b/config/old_scenario_config/scenario_config_EMF33.csv
index 8dd2f9d96d6a5ea2e93f770dbc5ffb159c4737bd..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;c_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_H12.csv b/config/old_scenario_config/scenario_config_H12.csv
index 58cef4f98f0a471c7a808e779d66761a88aa37f7..4627f7d3bbfb0a4cb083ceb638731ebf4c50ce3c 100644
--- a/config/old_scenario_config/scenario_config_H12.csv
+++ b/config/old_scenario_config/scenario_config_H12.csv
@@ -1,15 +1,15 @@
 title;start;cm_iteration_max;regionmapping;cm_techcosts;cm_rcp_scen;cm_iterative_target_adj;c_budgetCO2;carbonprice;cm_co2_tax_2020;climate;optimization;capitalMarket;buildings;cm_co2_tax_growth;cm_emiscen;techpol;cm_multigasscen;cm_startyear;path_gdx;path_gdx_ref;path_gdx_bau
-Base_Negishi;1;15;./config/regionmappingH12.csv;REG;none;0;0;none;-1;off;negishi;perfect;simple;1.05;1;none;2;2005;/p/projects/remind/runs/r8134/output/Base_Negishi_2018-09-23_09.10.05/fulldata.gdx;;
-NDC_Negishi;1;20;./config/regionmappingH12.csv;REG;rcp45;3;0;NDC2018;1;off;negishi;perfect;simple;1.05;9;NDC2018;3;2015;/p/projects/remind/runs/r8134/output/NDC_Negishi_2018-09-23_21.29.47/fulldata.gdx;Base_Negishi;Base_Negishi
-Budg600_Negishi;1;20;./config/regionmappingH12.csv;REG;rcp20;5;600;expoLinear;30;off;negishi;perfect;simple;1.05;9;NDC2018;2;2025;/p/projects/remind/runs/r8264/output/Budg600_Negishi_2019-01-07_23.04.43/fulldata.gdx;NDC_Negishi;Base_Negishi
-Budg950_Negishi;1;20;./config/regionmappingH12.csv;REG;rcp26;5;950;expoLinear;30;off;negishi;perfect;simple;1.05;9;NDC2018;2;2025;/p/projects/remind/runs/r8264/output/Budg950_Negishi_2019-01-07_23.08.02/fulldata.gdx;NDC_Negishi;Base_Negishi
-Budg1300_Negishi;1;20;./config/regionmappingH12.csv;REG;rcp26;5;1300;expoLinear;30;off;negishi;perfect;simple;1.05;9;NDC2018;2;2025;/p/projects/remind/runs/r8264/output/Budg1300_Negishi_2019-01-07_23.11.05/fulldata.gdx;NDC_Negishi;Base_Negishi
-Base;1;1;./config/regionmappingH12.csv;REG;none;0;0;none;-1;off;nash;perfect;simple;1.05;1;none;2;2005;./config/input.gdx;;
-NDC;1;1;./config/regionmappingH12.csv;REG;rcp45;3;0;NDC2018;1;off;nash;perfect;simple;1.05;9;NDC2018;3;2015;./config/input.gdx;Base;Base
-NPi;1;1;./config/regionmappingH12.csv;REG;rcp45;3;0;NPi2018;1;off;nash;perfect;simple;1.05;9;NPi2018;3;2025;./config/input.gdx;NDC;Base
-Budg600;1;1;./config/regionmappingH12.csv;REG;rcp20;5;600;expoLinear;30;off;nash;perfect;simple;1.05;9;NDC2018;2;2025;./config/input.gdx;NDC;Base
-Budg950;1;1;./config/regionmappingH12.csv;REG;rcp26;5;950;expoLinear;30;off;nash;perfect;simple;1.05;9;NDC2018;2;2025;./config/input.gdx;NDC;Base
-Budg1300;1;1;./config/regionmappingH12.csv;REG;rcp26;5;1300;expoLinear;30;off;nash;perfect;simple;1.05;9;NDC2018;2;2025;./config/input.gdx;NDC;Base
+Base_Negishi;0;15;./config/regionmappingH12.csv;REG;none;0;0;none;-1;off;negishi;perfect;simple;1.05;1;none;2;2005;/p/projects/remind/runs/r8134/output/Base_Negishi_2018-09-23_09.10.05/fulldata.gdx;;
+NDC_Negishi;0;20;./config/regionmappingH12.csv;REG;rcp45;3;0;NDC2018;1;off;negishi;perfect;simple;1.05;9;NDC2018;3;2015;/p/projects/remind/runs/r8134/output/NDC_Negishi_2018-09-23_21.29.47/fulldata.gdx;Base_Negishi;Base_Negishi
+Budg600_Negishi;0;20;./config/regionmappingH12.csv;REG;rcp20;5;600;expoLinear;30;off;negishi;perfect;simple;1.05;9;NDC2018;2;2025;/p/projects/remind/runs/r8264/output/Budg600_Negishi_2019-01-07_23.04.43/fulldata.gdx;NDC_Negishi;Base_Negishi
+Budg950_Negishi;0;20;./config/regionmappingH12.csv;REG;rcp26;5;950;expoLinear;30;off;negishi;perfect;simple;1.05;9;NDC2018;2;2025;/p/projects/remind/runs/r8264/output/Budg950_Negishi_2019-01-07_23.08.02/fulldata.gdx;NDC_Negishi;Base_Negishi
+Budg1300_Negishi;0;20;./config/regionmappingH12.csv;REG;rcp26;5;1300;expoLinear;30;off;negishi;perfect;simple;1.05;9;NDC2018;2;2025;/p/projects/remind/runs/r8264/output/Budg1300_Negishi_2019-01-07_23.11.05/fulldata.gdx;NDC_Negishi;Base_Negishi
+tm_Base;1;1;./config/regionmappingH12.csv;REG;none;0;0;none;-1;off;nash;perfect;simple;1.05;1;none;2;2005;./config/input.gdx;;
+tm_NDC;1;1;./config/regionmappingH12.csv;REG;rcp45;3;0;NDC2018;1;off;nash;perfect;simple;1.05;9;NDC2018;3;2015;./config/input.gdx;tm_Base;tm_Base
+tm_Npi;1;1;./config/regionmappingH12.csv;REG;rcp45;3;0;NPi2018;1;off;nash;perfect;simple;1.05;9;NPi2018;3;2025;./config/input.gdx;tm_NDC;tm_Base
+tm_Budg600;0;1;./config/regionmappingH12.csv;REG;rcp20;5;600;expoLinear;30;off;nash;perfect;simple;1.05;9;NDC2018;2;2025;./config/input.gdx;tm_NDC;tm_Base
+tm_Budg950;1;1;./config/regionmappingH12.csv;REG;rcp26;5;950;expoLinear;30;off;nash;perfect;simple;1.05;9;NDC2018;2;2025;./config/input.gdx;tm_NDC;tm_Base
+tm_Budg1300;0;1;./config/regionmappingH12.csv;REG;rcp26;5;1300;expoLinear;30;off;nash;perfect;simple;1.05;9;NDC2018;2;2025;./config/input.gdx;tm_NDC;tm_Base
 Base_imp;0;1;./config/regionmappingH12.csv;REG;none;0;0;none;-1;off;nash;imperfect;simple;1.05;1;none;2;2005;./config/input.gdx;;
 NDC_imp;0;1;./config/regionmappingH12.csv;REG;rcp45;3;0;NDC2018;1;off;nash;imperfect;simple;1.05;9;NDC2018;3;2015;./config/input.gdx;Base_imp;Base_imp
 Budg600_imp;0;1;./config/regionmappingH12.csv;REG;rcp20;5;600;expoLinear;30;off;nash;imperfect;simple;1.05;9;NDC2018;2;2025;./config/input.gdx;NDC_imp;Base_imp
diff --git a/config/old_scenario_config/scenario_config_SSP.csv b/config/old_scenario_config/scenario_config_SSP.csv
index d9fcc67588f755dc0b69a365de24843c2c7b5c9a..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;c_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_SSP_H12.csv b/config/old_scenario_config/scenario_config_SSP_H12.csv
index 5f6da1855b7588e843b3f341c6edb55b59a0d6bf..93ba1fd31bd28503b0b88b9051a80514adf667a2 100644
--- a/config/old_scenario_config/scenario_config_SSP_H12.csv
+++ b/config/old_scenario_config/scenario_config_SSP_H12.csv
@@ -1,4 +1,4 @@
-title;start;regionmapping;CES_parameters;cm_bioenergy_tax;cm_rcp_scen;cm_iterative_target_adj;c_budgetCO2;carbonprice;cm_co2_tax_2020;cm_emiscen;cm_earlyreti_rate;cm_fetaxscen;cm_co2_tax_growth;cm_bioenergymaxscen;c_ccsinjecratescen;techpol;cm_POPscen;cm_GDPscen;cm_oil_scen;cm_gas_scen;cm_coal_scen;c_techAssumptScen;cm_nucscen;cm_multigasscen;cm_OILRETIRE;cm_LU_emi_scen;c_tradecost_bio;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;c_budgetCO2;carbonprice;cm_co2_tax_2020;cm_emiscen;cm_earlyreti_rate;cm_fetaxscen;cm_co2_tax_growth;cm_bioenergymaxscen;c_ccsinjecratescen;techpol;cm_POPscen;cm_GDPscen;cm_oil_scen;cm_gas_scen;cm_coal_scen;c_techAssumptScen;cm_nucscen;cm_multigasscen;cm_OILRETIRE;cm_LU_emi_scen;cm_tradecost_bio;c_SSP_forcing_adjust;cm_APscen;cm_startyear;path_gdx;path_gdx_ref;path_gdx_bau
 SSP1-Base;1;./config/regionmappingH12.csv;load;1.75;none;0;0;none;-1;1;0.09;3;1.05;0;1;none;pop_SSP1;gdp_SSP1;lowOil;lowGas;lowCoal;2;2;2;off;SSP1;1;forcing_SSP1;SSP2;2005;./config/input.gdx;;
 SSP1-NDC;1;./config/regionmappingH12.csv;load;1.75;rcp45;3;0;NDC2018;1;9;0.09;3;1.05;0;1;NDC2018;pop_SSP1;gdp_SSP1;lowOil;lowGas;lowCoal;2;2;3;off;SSP1;1;forcing_SSP1;SSP2;2015;./config/input.gdx;SSP1-Base;SSP1-Base
 SSP1-NPi;0;./config/regionmappingH12.csv;load;1.75;rcp45;3;0;NPi2018;1;9;0.09;3;1.05;0;1;NPi2018;pop_SSP1;gdp_SSP1;lowOil;lowGas;lowCoal;2;2;3;off;SSP1;1;forcing_SSP1;SSP2;2025;./config/input.gdx;SSP1-NDC;SSP1-Base
diff --git a/config/old_scenario_config/scenario_config_Validation2018.csv b/config/old_scenario_config/scenario_config_Validation2018.csv
index 20dedffab9ce62ee65040c7d466090f789539cea..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;c_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 5343f274dc22da7b8fd7f5ab20cf89bfcda705d5..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;c_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 ad52fcd9d267a5b915c4ae02f04699edd5ea5ce8..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;c_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 6697230e831d956809cfc4daa01a04619d2898b4..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$c_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$c_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)
-# c_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 p_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 v_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 q_balLab, q_production into q_cesIO, q_kapmo into q_kapMo, q_invest_adjcosts into q_invMacroAdj, q_limit_ppfen_shares into q_limitShPpfen
-# q_limit_ppfen_ratios into q_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 54dedb928c35bb2f4a4ffab495f042730fdf0e6d..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;c_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 1f37ad4a337c948b3463d33b730d9bfa5072dfd0..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;
 );
@@ -255,18 +255,6 @@ if (cm_emiscen ne 1,
 );
 
 
-*** -----------------------------------------------------------
-*** no permit trade allowed in BAU and tax scenarios:
-*** -----------------------------------------------------------
-if (cm_emiscen = 1 or cm_emiscen = 9,
-   vm_Xport.fx(t,regi,"perm") = 0;
-   vm_Mport.fx(t,regi,"perm") = 0;
-else
-   vm_Xport.fx("2005",regi,"perm") = 0;
-   vm_Mport.fx("2005",regi,"perm") = 0;
-   vm_Xport.fx("2010",regi,"perm") = 0;
-   vm_Mport.fx("2010",regi,"perm") = 0;
-);
 
 *** -----------------------------------------------------------
 *mh bounds that narrow the solution space to help the conopt solver:
@@ -281,10 +269,7 @@ vm_costTeCapital.lo(t,regi,teLearn) = pm_data(regi,"floorcost",teLearn);
 *cb 20120319 avoid negative adjustment costs in 2005 (they would allow the model to artificially save money)
 v_adjFactor.fx("2005",regi,te)=0;
 
-*nb* lower bounds on CES values
-vm_cesIO.lo(t,regi,in) = 1e-6;
-vm_cesIOdelta.lo(t,regi,in_putty) = 1e-6;
-vm_cons.lo(t,regi)     = 1e-3;
+
 
 vm_emiMacSector.lo(t,regi,enty)    =  0;    
 vm_emiMacSector.lo(t,regi,"co2luc")= -5.0;  !! afforestation can lead to negative emissions
@@ -369,9 +354,6 @@ vm_capEarlyReti.lo(ttot,regi,"tnrs")$(ttot.val gt 2011 AND ttot.val lt 2111) = 0
 *cb 20120301 no early retirement for dot, they are used despite their economic non-competitiveness for various reasons.
 vm_capEarlyReti.fx(ttot,regi,"dot")=0;
 
-*nb fix energy inputs to CES structure in t0 to the parameter values
-vm_cesIO.fx(t0(tall),regi,in)$(ppfEn(in) OR ppfIO_putty(in)) = pm_cesdata(tall,regi,in,"quantity");
-vm_cesIOdelta.fx(t0(tall),regi,in)$(ppfEn(in) OR in_putty(in)) = pm_cesdata_putty(tall,regi,in,"quantity");
 *** -----------------------------------------------------------------------------
 *DK 20100929 Bound on CCS injection rate 
 *** -----------------------------------------------------------------------------
@@ -394,87 +376,9 @@ if ( c_ccsinjecratescen gt 0,
 *AJS*02122014 Exclude this bound in nash cases, as trying to limit global emissions there will lead to infeasibilities
 $ifi %optimization% == "negishi" if( (cm_startyear le 2010 AND cm_emiscen > 1), vm_emiAllGlob.fx('2010','co2') = 8.9 + 1.46; ); !! 8.9 is fossil emissions + cement, 1.4 land use
 
-*** set Mport and Xport positive
-vm_Mport.lo(ttot,regi,tradePe)$(ttot.val ge 2005) = 0;
-vm_Xport.lo(ttot,regi,tradePe)$(ttot.val ge 2005) = 0;
 
-*NB*110625 fix 2005 trade values to historic values
-*RR*Added correction factor to match fossil supply and internal region energy demand in the initial year if necessary
-*SB*190514 Made the correction factor for insufficient imports conditional on the fossil module realization
 
-*** Mports fixing for fossils in the initial year 
-loop( regi,
-    loop (enty$peFos(enty),
-*** if imports minus exports is higher than initial year demand there is a surplus of pe in the region. Correction -> set imports to 80% of the region pe demand plus Xports in the initial year
-        if ( (pm_EN_demand_from_initialcap2(regi,enty) < (1-p_costsPEtradeMp(regi,enty))*pm_IO_trade("2005",regi,enty,"Mport") -  pm_IO_trade("2005",regi,enty,"Xport")),     !!region has more available pe through trade than it needs
-            p_Mport2005correct(regi,enty) = (pm_EN_demand_from_initialcap2(regi,enty) + pm_IO_trade("2005",regi,enty,"Xport")) - pm_IO_trade("2005",regi,enty,"Mport");
-        );
-*** if internal region production (plus trade) is not enough to provide the energy demand. Correction ->  set imports to the difference between region energy demand (pm_EN_demand_from_initialcap2) and the internal production (pm_ffPolyCumEx(regi,enty,"max")) plus the trade balance (Mports-Xports) 
-$iftheni.fossil_realization %cfg$gms$fossil% == "timeDepGrades"
-        if ( pm_prodIni(regi,enty) + (1-p_costsPEtradeMp(regi,enty))*(pm_IO_trade("2005",regi,enty,"Mport")+ p_Mport2005correct(regi,enty)) -  pm_IO_trade("2005",regi,enty,"Xport") < pm_EN_demand_from_initialcap2(regi,enty),     !!region has a unbalance
-            p_Mport2005correct(regi,enty) = pm_EN_demand_from_initialcap2(regi,enty)  - ((1-p_costsPEtradeMp(regi,enty))*pm_IO_trade("2005",regi,enty,"Mport") -  pm_IO_trade("2005",regi,enty,"Xport")) - pm_prodIni(regi,enty) ;  !! SB: use pm_prodIni as an analog for pm_ffPolyCumEx(regi,enty,"max"), which does not exist in timeDepGrades
-        );
-$elseifi.fossil_realization %cfg$gms$fossil% == "grades2poly"
-        if ( (pm_ffPolyCumEx(regi,enty,"max") / (5*4)) + (1-p_costsPEtradeMp(regi,enty))*(pm_IO_trade("2005",regi,enty,"Mport")+ p_Mport2005correct(regi,enty)) -  pm_IO_trade("2005",regi,enty,"Xport") < pm_EN_demand_from_initialcap2(regi,enty),     !!region has a unbalance
-            p_Mport2005correct(regi,enty) = pm_EN_demand_from_initialcap2(regi,enty)  - ((1-p_costsPEtradeMp(regi,enty))*pm_IO_trade("2005",regi,enty,"Mport") -  pm_IO_trade("2005",regi,enty,"Xport")) - pm_ffPolyCumEx(regi,enty,"max") / (5*4) ;  !!pm_ffPolyCumEx(regi,enty,"max") is a 5 years value, so we dived by 5 to get the annual value and additionally we assume that if all the extraction is made in the first years, this would take a t least 4 time steps to completely exhaust the resources 
-        );
-$endif.fossil_realization
-    );
-);
-vm_Mport.fx(t0(tall),regi,peFos(enty)) = pm_IO_trade(t0,regi,enty,"Mport") + p_Mport2005correct(regi,enty);
-
-*** Xports fixing for fossils in the initial year (with added exports to compensate for the Mports corrections above)
-loop( regi,
-    loop (enty$peFos(enty),
-        if ( (p_Mport2005correct(regi,enty) = 0),
-            vm_Xport.fx(t0(tall),regi,peFos(enty)) = pm_IO_trade(t0,regi,enty,"Xport") +
-                   ( pm_IO_trade(t0,regi,enty,"Xport") / sum((regi2)$(NOT (p_Mport2005correct(regi,enty))),pm_IO_trade(t0,regi2,enty,"Xport")) ) !! share of region Xports between regions with no balance problems
-                   * sum((regi2),p_Mport2005correct(regi2,enty)) !! total unbalance problem
-            ;
-        else
-            vm_Xport.fx(t0(tall),regi,peFos(enty)) = pm_IO_trade(t0,regi,enty,"Xport") ;
-        );
-    );
-); 
-
-*** if region has no internal resources, demand must be entirely provided by trade (Switzerland problem). Correction ->  set imports free, exports zero. Warning: if the region is big enough this could cause a trade unbalance. The first best solution would be to calculate the exact imports amount needed and add extra exports to other countries to compensate for this exact amount.
-loop( regi,
-    loop (enty$peFos(enty),
-$iftheni.timeDepGrades %cfg$gms$fossil% == "timeDepGrades"
-        if ( (pm_fuelex_cum("2005",regi,enty,1) = 0),
-            vm_Xport.fx(t0(tall),regi,peFos(enty)) = 0;
-            vm_Mport.up(t0(tall),regi,peFos(enty)) = 1e10;
-            vm_Mport.lo(t0(tall),regi,peFos(enty)) = 1e-6;
-        );
-$elseifi.timeDepGrades %cfg$gms$fossil% == "grades2poly"
-        if ( (pm_ffPolyCumEx(regi,enty,"max") = 0),
-            vm_Xport.fx(t0(tall),regi,peFos(enty)) = 0;
-            vm_Mport.up(t0(tall),regi,peFos(enty)) = 1e10;
-            vm_Mport.lo(t0(tall),regi,peFos(enty)) = 1e-6;
-        );
-$endif.timeDepGrades
-    );
-);
-
-*** bounds on oil exports in 2010 and 2015
-vm_Xport.lo("2010",regi,"peoil") = 0.95 * pm_IO_trade("2010",regi,"peoil","Xport");
-vm_Xport.up("2010",regi,"peoil") = 1.05 * pm_IO_trade("2010",regi,"peoil","Xport");
-vm_Xport.lo("2015",regi,"peoil") = 0.95 * pm_IO_trade("2015",regi,"peoil","Xport");
-vm_Xport.up("2015",regi,"peoil") = 1.05 * pm_IO_trade("2015",regi,"peoil","Xport");
-
-*** upper bounds ( 1% yearly growth rate) on all big oil exporters (more than 15EJ in 2010) in 2020, 2025 and 2030
-loop(regi,
-      if( (pm_IO_trade("2010",regi,"peoil","Xport") ge (15*sm_EJ_2_TWa)),
-        vm_Xport.up("2020",regi,"peoil") = ((1 + 0.02) **  10) * pm_IO_trade("2010",regi,"peoil","Xport");
-        vm_Xport.up("2025",regi,"peoil") = ((1 + 0.02) **  15) * pm_IO_trade("2010",regi,"peoil","Xport");
-        vm_Xport.up("2030",regi,"peoil") = ((1 + 0.02) **  20) * pm_IO_trade("2010",regi,"peoil","Xport");
-      );
-);
 
-*** set macro investments to bound in 2005
-vm_invMacro.fx("2005",regi,"kap") = p_boundInvMacro(regi);
-*cb 2012-05-23 lower bound for capital investment to avoid "zero investment" problem for the conopt solver
-vm_invMacro.lo(t,regi,"kap")$(t.val gt 2005) = 0.01 * vm_invMacro.lo("2005",regi,"kap");
 
 *** strong reliance on coal-to-liquids is not consistent with SSP1 storyline, therefore limit their use in the SSP 1 and SSP2 policy scenarios
 $ifthen %c_SSP_forcing_adjust% == "forcing_SSP1"
diff --git a/core/datainput.gms b/core/datainput.gms
index d363a9618b03797cff28e134a8be06bb0ff6ec85..e1071c09080f68ae9fe9cc354124838336a941b9 100644
--- a/core/datainput.gms
+++ b/core/datainput.gms
@@ -110,42 +110,22 @@ $offdelim
 ;
 p_developmentState(tall,all_regi) = f_developmentState(tall,all_regi,"%c_GDPpcScen%");
 
-*** load data for macro investments in 2005, used as bound
-parameter p_boundInvMacro(all_regi)        "macro investments in 2005"
-/
-$ondelim
-$include "./core/input/p_boundInvMacro.cs4r"
-$offdelim
-/
-;
-p_boundInvMacro(all_regi) = p_boundInvMacro(all_regi) * pm_shPPPMER(all_regi);
-
-*ML* Reintroduction of trade cost for composite good (based on export/import value difference for non-energy goods in GTAP6)
-p_tradecostgood(regi)        = 0.03;
 
 *** 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;
 
-*** depreciation rate of capital
-pm_delta_kap(regi,"kap") = 0.05;
 
 *------------------------------------------------------------------------------------
 *------------------------------------------------------------------------------------
 ***                                ESM
 *------------------------------------------------------------------------------------
 *------------------------------------------------------------------------------------
-pm_Xport0("2005",regi,peFos) = 0;
 
 *** default conversion for energy services
 pm_fe2es(ttot,regi,teEs) = 1;
@@ -342,30 +322,6 @@ loop(emi2te(enty,enty2,te,enty3)$teCCS(te),
 p_boundtmp(ttot,all_regi,te,rlf)$(ttot.val ge 2005)       = 0;
 p_bound_cap(ttot,all_regi,te,rlf)$(ttot.val ge 2005)       = 0;
 
-*** load data on transportation costs
-parameter p_costsPEtradeMp(all_regi,all_enty)         "PE tradecosts (energy losses on import)"
-/
-$ondelim
-$include "./core/input/p_costsPEtradeMp.cs4r"
-$offdelim
-/
-;
-table pm_costsTradePeFinancial(all_regi,char,all_enty)        "Financial costs on import, export and use of primary energy"
-$ondelim
-$include "./core/input/pm_costsTradePeFinancial.cs3r"
-$offdelim
-;
-pm_costsTradePeFinancial(regi,"XportElasticity", tradePe(enty)) = 100;
-pm_costsTradePeFinancial(regi, "tradeFloor", tradePe(enty))     = 0.0125;
-
-*DK* Only for SSP cases other than SSP2: use default trade costs
-if(c_tradecost_bio = 1,
-pm_costsTradePeFinancial(regi,"Xport", "pebiolc") = pm_costsTradePeFinancial(regi,"Xport", "pebiolc")/2;
-);
-
-pm_costsTradePeFinancial(regi,"Xport", "pegas") = c_trdcst * pm_costsTradePeFinancial(regi,"Xport", "pegas") ;
-pm_costsTradePeFinancial(regi,"XportElasticity","pegas") = cm_trdadj *pm_costsTradePeFinancial(regi,"XportElasticity","pegas");
-
 *NB* include data and parameters for upper bounds on fossil fuel transport
 parameter f_IO_trade(tall,all_regi,all_enty,char)        "Energy trade bounds based on IEA data"
 /
diff --git a/core/declarations.gms b/core/declarations.gms
index b8334551080b002c09d949ae5a1d31b57977c610..70d781ed938afa6c42072fac42eef3620f256150 100644
--- a/core/declarations.gms
+++ b/core/declarations.gms
@@ -25,8 +25,8 @@ pm_pricePerm(ttot)                                   "permit price in special ca
                                                   
 p_share(ttot,all_regi,all_in,all_in)                 "share of production factors"
 pm_share_trans(tall,all_regi)                        "transportation share"
-pm_gdp_gdx(tall,all_regi)                            "GDP path from gdx, updated iteratively"
-p_inv_gdx(tall,all_regi)                             "macro-investments  path from gdx, updated iteratively"
+pm_gdp_gdx(tall,all_regi)                            "GDP path from gdx, updated iteratively."   
+p_inv_gdx(tall,all_regi)                            "macro-investments path from gdx, updated iteratively."
 pm_taxCO2eq(ttot,all_regi)                           "CO2 tax path in T$/GtC = $/kgC. To get $/tCO2, multiply with 272 [T$/GtC]"
 pm_taxCO2eqHist(ttot,all_regi)                       "Historic CO2 tax path in 2010 and 2015 (also in BAU!) in T$/GtC = $/kgC. To get $/tCO2, multiply with 272 [T$/GtC]"
 pm_taxCO2eq_iteration(iteration,ttot,all_regi)       "save CO2eq tax used in iteration"
@@ -35,10 +35,8 @@ p_taxCO2eq_iterationdiff_tmp(ttot,all_regi)          "help parameter for iterati
 o_taxCO2eq_iterDiff_Itr(iteration,all_regi) "track p_taxCO2eq_iterationdiff over iterations"
 pm_emissionsForeign(tall,all_regi,all_enty)          "total emissions of other regions (nash relevant)"
 pm_co2eqForeign(tall,all_regi)                       "emissions, which are part of the climate policy, of other regions (nash relevant)"
-pm_Xport0(tall,all_regi,all_enty)                    "reference level value of export"
 pm_cesdata(tall,all_regi,all_in,cesParameter)        "parameters of the CES function"
 pm_cesdata_putty(tall,all_regi,all_in,cesParameter)  "quantities for the putty clay factors"
-pm_delta_kap(all_regi,all_in)                        "depreciation rate of capital"
 pm_capital_lifetime_exp(all_regi,all_in)             "number of years for which 25% of the CES capital stocks remains"
 f_pop(tall,all_regi,all_POPscen)                     "population data for all possible scenarios"
 pm_pop(tall,all_regi)                                "population data [bn people]"
@@ -46,10 +44,7 @@ pm_gdp(tall,all_regi)                                "GDP data [trn US$ 2005]"
 p_developmentState(tall,all_regi)                    "level of development based on GDP per capita"
 f_lab(tall,all_regi,all_POPscen)                     "labour data for all possible scenarios"
 pm_lab(tall,all_regi)                                "data for labour [bn people]"
-pm_IO_trade(tall,all_regi,all_enty,char)             "Energy trade bounds based on IEA data"
 pm_esCapCost(tall,all_regi,all_teEs)                 "Capital energy cost per unit of consumption for end-use capital (energy service layer)"
-pm_ppfen_ratios(all_in,all_in)                       "limit ratio of two primary production factors of energy (ppfEn)"
-pm_ppfen_shares(all_in,all_in)                       "limit the share of one ppfEn in total CES nest inputs"
 
 
 pm_cesdata_sigma(ttot,all_in)                        "elasticities of substitution"
@@ -176,7 +171,6 @@ pm_damageGrowthRate(tall,all_regi)                   "damage function for growth
 pm_damageMarginal(tall,all_regi)                     "damage function derivative"
 pm_taxCO2eqSCC(ttot,all_regi)                        "carbon tax component due to damages (social cost of carbon) "
 
-pm_consPC(tall,all_regi)                             "consumption per capita"
 pm_GDPGross(tall,all_regi)                           "gross GDP (before damages)"
 ***----------------------------------------------------------------------------------------
 *** ----- Parameters needed for MAGICC ----------------------------------------------------
@@ -205,9 +199,7 @@ o_negitr_disc_cons_drInt_reg(iteration,all_regi)     "estimated discounted consu
 o_negitr_total_forc(iteration)                       "total forcing in 2100"
 
 ***----------------------------------------------------------------------------------------
-***------------------------------------------------trade module----------------------------
-p_tradecostgood(all_regi)                            "tradecosts (final good)"
-                               
+***------------------------------------------------trade module----------------------------                              
 pm_ttot_val(ttot)                                    "value of ttot set element"
 p_tall_val(tall)                                     "value of tall set element"
 pm_ts(tall)                                          "(t_n+1 - t_n-1)/2 for a timestep t_n"
@@ -223,11 +215,6 @@ p_share_seel_s(ttot,all_regi)                        "Share of electricity used
 p_discountedLifetime(all_te)                         "Sum over the discounted (@6%) depreciation factor (omega)"
 p_teAnnuity(all_te)                                  "Annuity factor of a technology"
 
-pm_cumDeprecFactor_old(ttot,all_regi,all_in)         "investment depreciation within a period, applied to the investment of t -1"
-pm_cumDeprecFactor_new(ttot,all_regi,all_in)         "investment depreciation within a period, applied to the investment of t"
-
-p_Mport2005correct(all_regi,all_enty)                "correction factor to match fossil supply and internal region energy demand in the initial year"
-
 p_histEmiMac(tall,all_regi,all_enty)                 "historical emissions per MAC; from Eurostat and CEDS, to correct CH4 and N2O reporting"
 p_histEmiSector(tall,all_regi,all_enty,emi_sectors,sector_types) "historical emissions per sector; from Eurostat and CEDS, to correct CH4 and N2O reporting"
 ;
@@ -274,19 +261,12 @@ vm_emiFgas(tall,all_regi,all_enty)                   "F-gas emissions by single
 positive variables
 ***----------------------------------------------------------------------------------------
 ***-------------------------------------------------MACRO module---------------------------
-vm_cesIO(tall,all_regi,all_in)                       "production factor"
-vm_invMacro(ttot,all_regi,all_in)                    "investment for capital for ttot"
-vm_cons(ttot,all_regi)                               "consumption"
-v_invMacroAdj(ttot,all_regi,all_in)                  "adjustment costs of macro economic investments"
-vm_effGr(ttot,all_regi,all_in)                       "growth of factor efficiency"
-vm_invInno(ttot,all_regi,all_in)                     "investment into innovation"
-vm_invImi(ttot, all_regi,all_in)                     "investment into imitation"
-vm_cesIOdelta(tall,all_regi,all_in)                  "putty-clay production factor"
 vm_enerSerAdj(tall,all_regi,all_in)                  "adjustment costs for energy service transformations"
-vm_damageFactor(ttot,all_regi)                       "damage factor reducing GDP"
-v_esCapInv(ttot,all_regi,all_teEs)                   "investment for energy end-use capital at the energy service level"
+vm_esCapInv(ttot,all_regi,all_teEs)                   "investment for energy end-use capital at the energy service level"
 ***----------------------------------------------------------------------------------------
 *-----------------------------------------------ESM module---------------------------------
+vm_costEnergySys(ttot,all_regi)                      "energy system costs"
+
 vm_cap(tall,all_regi,all_te,rlf)                     "net total capacities"
 vm_capDistr(tall,all_regi,all_te,rlf)                "net capacities, distributed to the different grades for renewables"
 vm_capFac(ttot,all_regi,all_te)                      "capacity factor of conversion technologies"
@@ -324,12 +304,6 @@ vm_prodSeOth(ttot,all_regi,all_enty,all_te)	         "other sety production from
 *** ES layer variables
 vm_demFeForEs(ttot,all_regi,all_enty,all_esty,all_teEs)     "Final energy which will be used in the ES layer."
 v_prodEs(ttot,all_regi,all_enty,all_esty,all_teEs)          "Energy services (unit determined by conversion factor pm_fe2es)."
-***----------------------------------------------------------------------------------------
-***------------------------------------------------trade module----------------------------
-vm_Xport(tall,all_regi,all_enty)                     "export of traded commodity [TWa]"
-vm_Mport(tall,all_regi,all_enty)                     "import of traded commodity [TWa]"
-*** Adjustment costs for Nash trade algorithm.  Only non-zero in the Nash_test realization of 80_optimization module.
-vm_costAdjNash(ttot,all_regi)                        "adjustment costs for deviation from the trade structure of the last iteration"
 ;
 ***----------------------------------------------------------------------------------------
 ***                                   EQUATIONS
@@ -337,31 +311,13 @@ vm_costAdjNash(ttot,all_regi)                        "adjustment costs for devia
 equations
 ***----------------------------------------------------------------------------------------
 ***------------------------------------------------MACRO module----------------------------
-qm_budget(ttot,all_regi)                             "budget balance"
-q_balLab(ttot,all_regi)                              "labour balance"
-q_cesIO(ttot,all_regi,all_in)                        "production function"
-q_prodCompl(ttot,all_regi,all_in,all_in)             "Constraints for perfect complements in the CES tree"
-
-q_kapMo(ttot,all_regi,all_in)                        "capital motion equation"
-q_kapMo0(t0,all_regi,all_in)                         "initial condition for capital"
-
-q_invMacroAdj(ttot,all_regi,all_in)                  "adjustment costs for macro economic investments"
-*** FIXME q_balFeForCes(ttot,all_regi,all_enty,all_in)         "balance of final energy to couple esm and mgm"
 qm_balFeForCesAndEs(ttot,all_regi,all_enty)          "FE balance coupling ESM and production function either directly (Pathway I) or Indirectly through Energy services (Pathway III)"
-*** perm_restr(ttot,all_regi)                                  "emission permit trade restriction"
-*** multistage(ttot)                                           "calculation of remaining permits in multistage approach"
-q_limtRatioPpfen(ttot,all_regi,all_in,all_in)        "limit the ratio of two ppfEn"
-q_limitShPpfen(ttot,all_regi,all_in,all_in)          "limit the share of one ppfEn in total CES nest inputs"
 q_limitSeel2fehes(ttot,all_regi)                     "equation to limit the share of electricity that can be used for fehes"
-*** putty-clay
-q_cesIO_puttyclay(ttot,all_regi,all_in)              "putty-clay production function"
-q_puttyclay(ttot,all_regi,all_in)                    "putty-clay Correspondance between variations in input and past stocks of input"
-q_prodCompl_putty(ttot,all_regi,all_in,all_in)       "Putty-Clay constraints for perfect complements in the CES tree"
-***q_puttykap(ttot,all_regi,all_in)                            "putty-clay Correspondance between variations in capital and past stocks of capital"
-q_kapMo_putty(ttot,all_regi,all_in)                  "putty-clay capital motion equation"
 q_esCapInv(ttot,all_regi,all_teEs)                   "investment equation for end-use capital investments (energy service layer)"
 ***----------------------------------------------------------------------------------------
 ***-----------------------------------------------ESM module-------------------------------
+q_costEnergySys(ttot,all_regi)                       "energy system costs"
+
 q_costFu(ttot,all_regi)                              "costs of fuels"
 q_costOM(ttot,all_regi)                              "costs of o&m"
 q_costInv(ttot,all_regi)                             "costs of investment"
diff --git a/core/equations.gms b/core/equations.gms
index 5ba731e10dde5310388be8a707682f91f88708be..a9647754c0bffa6573ca78bb749d4db0c48b69bc 100644
--- a/core/equations.gms
+++ b/core/equations.gms
@@ -387,7 +387,7 @@ q_capCumNet(t0,regi,teLearn)..
 qm_fuel2pe(t,regi,peRicardian(enty))..
   vm_prodPe(t,regi,enty)
   =e=
-  sum(pe2rlf(enty,rlf2),vm_fuExtr(t,regi,enty,rlf2))-(vm_Xport(t,regi,enty)-(1-p_costsPEtradeMp(regi,enty))*vm_Mport(t,regi,enty))$(tradePe(enty)) -
+  sum(pe2rlf(enty,rlf2),vm_fuExtr(t,regi,enty,rlf2))-(vm_Xport(t,regi,enty)-(1-pm_costsPEtradeMp(regi,enty))*vm_Mport(t,regi,enty))$(tradePe(enty)) -
                       sum(pe2rlf(enty2,rlf2), (pm_fuExtrOwnCons(regi, enty, enty2) * vm_fuExtr(t,regi,enty2,rlf2))$(pm_fuExtrOwnCons(regi, enty, enty2) gt 0));
 
 ***---------------------------------------------------------------------------
@@ -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") 
 ;
 
 ***-----------------------------------------------------------------------------
@@ -753,236 +754,32 @@ q_smoothphaseoutCapEarlyReti(ttot,regi,te)$(ttot.val lt 2120 AND pm_ttot_val(tto
 		+ 0.05$(sameas(te,"biodiesel") or sameas(te, "bioeths")));
 
 
-***---------------------------------------------------------------------------
-*' Usable macroeconomic output - net of climate change damages - is calculated from the macroeconomic output, 
-*' taking into account export and import of the final good, taking specific trade costs into account, 
-*' which are assigned to the importer. The resulting output is used for consumption, 
-*' for investments into the capital stock, and for the energy system cost components investments,
-*' fuel costs and operation & maintenance. 
-*' Other additional costs like non-energy related greenhouse gas abatement costs and
-*' agricultural costs, which are delivered by the land use model MAgPIE, are deduced from disposable output. 
-*' Net tax revenues and adjustment costs converge to zero in the optimal solution (equilibrium point).
-***---------------------------------------------------------------------------
-qm_budget(ttot,regi)$( ttot.val ge cm_startyear ) .. 
-    vm_cesIO(ttot,regi,"inco") * vm_damageFactor(ttot,regi) 
-  - vm_Xport(ttot,regi,"good") 
-  + vm_Mport(ttot,regi,"good") * (1 - p_tradecostgood(regi) - pm_risk_premium(regi))
-  =g=
-    vm_cons(ttot,regi)
-  + sum(ppfKap(in), vm_invMacro(ttot,regi,in))
-  + sum(in, vm_invInno(ttot,regi,in))
-  + sum(in, vm_invImi(ttot,regi,in))
-***   energy system costs
-  + ( v_costFu(ttot,regi) 
+
+*JK* Result of split of budget equation. Sum of all energy related costs. 
+q_costEnergySys(ttot,regi)$( ttot.val ge cm_startyear ) ..
+    vm_costEnergySys(ttot,regi)
+  =e=
+    ( v_costFu(ttot,regi) 
     + v_costOM(ttot,regi) 
     + v_costInv(ttot,regi)
     ) 
-***   agricultural MACs are part of pm_totLUcosts (see module 26_agCosts)
-  + sum(enty$(emiMacSector(enty) AND (NOT emiMacMagpie(enty))), pm_macCost(ttot,regi,enty))  
   + sum(emiInd37, vm_IndCCSCost(ttot,regi,emiInd37))
   + pm_CementDemandReductionCost(ttot,regi)
-  + sum(tradePe(enty), 
-      pm_costsTradePeFinancial(regi,"Mport",enty) 
-    * vm_Mport(ttot,regi,enty)
-    )
-  + sum(tradePe(enty),
-      (pm_costsTradePeFinancial(regi,"Xport",enty) * vm_Xport(ttot,regi,enty))
-    * ( 1
-      + (
-          ( pm_costsTradePeFinancial(regi,"XportElasticity",enty)
-          / sqr(pm_ttot_val(ttot)-pm_ttot_val(ttot-1))
-          * ( vm_Xport(ttot,regi,enty)
-            / ( vm_Xport(ttot-1,regi,enty) 
-              + pm_costsTradePeFinancial(regi, "tradeFloor",enty)
-              )
-            - 1
-            )
-          )$( ttot.val ge max(2010, cm_startyear) )
-        )
-      )
-    )
-  + vm_taxrev(ttot,regi)$(ttot.val ge 2010)
-  + sum(ppfKap(in),v_invMacroAdj(ttot,regi,in))
-  + sum(in_enerSerAdj(in), vm_enerSerAdj(ttot,regi,in))
-*** ES layer costs
-  + sum(teEs, v_esCapInv(ttot,regi,teEs))
-  + vm_costAdjNash(ttot,regi)
-  + vm_costpollution(ttot,regi)
-  + pm_totLUcosts(ttot,regi)
 ;
 
-***---------------------------------------------------------------------------
-*' The labor available in every time step and every region comes from exogenous data. 
-*' It is the population corrected by the population age structure,
-*' which results in the labour force of people agged 15 to 65. 
-*' The labor participation rate is not factored into the labour supply (as it would only imply a
-*' rescaling of parameters without consequences for the model's dynamic). 
-*' The labour market balance equation reads as follows:
-***---------------------------------------------------------------------------
-q_balLab(t,regi)..
-    vm_cesIO(t,regi,"lab") 
-    =e= 
-    pm_lab(t,regi);
-
-***---------------------------------------------------------------------------
-*' The production function is a nested CES (constant elasticity of substitution) production function. 
-*' The macroeconomic output is generated by the inputs capital, labor, and total final energy (as a macro-ecoomic
-*' aggregate in $US units). The generation of total final energy is described
-*' by a CES production function as well, whose input factors are CES function outputs again. 
-*' Hence, the outputs of CES nests are intermediates measured in $US units. 
-*' According to the Euler-equation the value of the intermediate equals the sum of expenditures for the inputs. 
-*' Sector-specific final energy types represent the bottom end of the `CES-tree'. These 'CES leaves' are
-*' measured in physical units and have a price in $US per physical unit. 
-*' The top of the tree is the total economic output measured in $US.
-*' The following equation is the generic form of the production function. 
-*' It treats the various CES nests separately and the nests are inter-connetected via mappings. 
-*' This equation calculates the amount of intermediate output in a time-step and region 
-*' from the associated factor input amounts according to:
-*** Keep in mind to adjust the calculation of derivatives and shares 
-*** in ./core/reswrite.inc if you change the structure of this function.
-***---------------------------------------------------------------------------
-q_cesIO(t,regi,ipf(out))$ ( NOT ipf_putty(out)) ..
-  vm_cesIO(t,regi,out)
-  =e=
-    sum(cesOut2cesIn(out,in),
-      pm_cesdata(t,regi,in,"xi")
-    * ( 
-        pm_cesdata(t,regi,in,"eff")
-      * vm_effGr(t,regi,in)
-      * vm_cesIO(t,regi,in)
-      )
-   ** pm_cesdata(t,regi,out,"rho")
-    )
- ** (1 / pm_cesdata(t,regi,out,"rho"))
-;
-
-***---------------------------------------------------------------------------
-*' Constraints for perfect complements in the CES tree
-***---------------------------------------------------------------------------
-q_prodCompl(t,regi,in,in2) $ (complements_ref(in,in2)
-                                 AND (( NOT in_putty(in2)) OR ppfIO_putty(in2))) ..
-      vm_cesIO(t,regi,in) 
-                              =e= pm_cesdata(t,regi,in2,"compl_coef")
-                                * vm_cesIO(t,regi,in2);
-                                
-***---------------------------------------------------------------------------                                
-*** Start of Putty-Clay equations 
-*' Putty-Clay production function:
-***---------------------------------------------------------------------------
-q_cesIO_puttyclay(t,regi,ipf_putty(out)) ..
-  vm_cesIOdelta(t,regi,out)
-  =e=
-    sum(cesOut2cesIn(out,in),
-      pm_cesdata(t,regi,in,"xi")
-    * ( 
-        pm_cesdata(t,regi,in,"eff")
-      * vm_effGr(t,regi,in)
-      * vm_cesIOdelta(t,regi,in)
-      )
-   ** pm_cesdata(t,regi,out,"rho")
-    )
- ** (1 / pm_cesdata(t,regi,out,"rho"))
-;
-
-*' Putty-Clay constraints for perfect complements in the CES tree:
-q_prodCompl_putty(t,regi,in,in2) $ (complements_ref(in,in2)
-                                 AND ( in_putty(in2) AND  ( NOT ppfIO_putty(in2)))) ..
-      vm_cesIOdelta(t,regi,in) =e=
-                                pm_cesdata(t,regi,in2,"compl_coef")
-                                * vm_cesIOdelta(t,regi,in2);
-
-*' Correspondance between vm_cesIO and vm_cesIOdelta:
-q_puttyclay(ttot,regi,in_putty(in))$(ord(ttot) lt card(ttot)  AND (pm_ttot_val(ttot+1) ge max(2010, cm_startyear)))..
-  vm_cesIO(ttot+1,regi,in)
-  =e=
-  vm_cesIO(ttot,regi,in)*(1- pm_delta_kap(regi,in))**(pm_ttot_val(ttot+1)-pm_ttot_val(ttot))
-           +  pm_cumDeprecFactor_old(ttot+1,regi,in)* vm_cesIOdelta(ttot,regi,in)
-           +  pm_cumDeprecFactor_new(ttot+1,regi,in)* vm_cesIOdelta(ttot+1,regi,in)
-;
 
-*' Capital motion equation for putty clay capital:
-q_kapMo_putty(ttot,regi,in_putty(in))$(ppfKap(in) AND (ord(ttot) le card(ttot)) AND (pm_ttot_val(ttot) ge max(2005, cm_startyear)) AND (pm_cesdata("2005",regi,in,"quantity") gt 0))..
-    vm_cesIOdelta(ttot,regi,in)
-    =e=
-             0
-$ifthen setGlobal END2110
-*gl* short time horizon requires investments to materialize in the same time step
-                  + pm_ts(ttot)*vm_invMacro(ttot,regi,in)*0.94**5 - (0.5*pm_ts(ttot)*vm_invMacro(ttot,regi,in)*0.94**5)$(ord(ttot) eq card(ttot));
-$else
-                  + vm_invMacro(ttot,regi,in)
-                   ;
-$endif
-;
-***---------------------------------------------------------------------------
-*** End of Putty-Clay equations
-***---------------------------------------------------------------------------
 ***---------------------------------------------------------------------------
 *' Investment equation for end-use capital investments (energy service layer):
 ***---------------------------------------------------------------------------
 q_esCapInv(ttot,regi,teEs)$pm_esCapCost(ttot,regi,teEs) ..
-    v_esCapInv(ttot,regi,teEs)
+    vm_esCapInv(ttot,regi,teEs)
     =e=
     sum (fe2es(entyFe,esty,teEs),
     pm_esCapCost(ttot,regi,teEs) * v_prodEs(ttot,regi,entyFe,esty,teEs)
     );
     ;
 
-***---------------------------------------------------------------------------    
-*' The capital stock is claculated recursively. Its amount in the previous time
-*' step is devaluated by an annual depreciation factor and enlarged by investments. 
-*' Both depreciation and investments are expressed as annual values,
-*' so the time step length is taken into account.
-***---------------------------------------------------------------------------
-q_kapMo(ttot,regi,ppfKap(in))$( ( NOT in_putty(in)) AND (ord(ttot) lt card(ttot)) AND (pm_ttot_val(ttot+1) ge max(2010, cm_startyear)) AND (pm_cesdata("2005",regi,in,"quantity") gt 0))..
-    vm_cesIO(ttot+1,regi,in)
-    =e=
-             (1- pm_delta_kap(regi,in))**(pm_ttot_val(ttot+1)-pm_ttot_val(ttot)) * vm_cesIO(ttot,regi,in)
-$ifthen setGlobal END2110
-*gl* short time horizon requires investments to materialize in the same time step
-                  + pm_ts(ttot)*vm_invMacro(ttot,regi,in)*0.94**5 - (0.5*pm_ts(ttot)*vm_invMacro(ttot,regi,in)*0.94**5)$(ord(ttot) eq card(ttot));
-$else
-                  + pm_cumDeprecFactor_old(ttot+1,regi,in) * vm_invMacro(ttot,regi,in)
-                  + pm_cumDeprecFactor_new(ttot+1,regi,in) * vm_invMacro(ttot+1,regi,in) ;
-$endif
-;
 
-***---------------------------------------------------------------------------
-*' Adjustment costs of macro economic investments:
-***---------------------------------------------------------------------------
-v_invMacroAdj.fx("2005",regi,ppfKap(in)) = 0;
-
-q_invMacroAdj(ttot,regi,ppfKap(in))$( ttot.val ge max(2010, cm_startyear))..
-    v_invMacroAdj(ttot,regi,in)
-    =e= 
-    sqr( (vm_invMacro(ttot,regi,in)-vm_invMacro(ttot-1,regi,in)) / (pm_ttot_val(ttot)-pm_ttot_val(ttot-1)) 
-        / (vm_invMacro(ttot,regi,in)+0.0001)
-    )
-    * vm_cesIO(ttot,regi,in) / 11
-*ML/RP* use "kap/11"  instead of "vm_invMacro" for the scaling to remove the "invest=0"-trap that sometimes appeared in delay scenarios; kap/11 corresponds to the global average ratio of investments to capital in 2005.
-*** In some regions the ratio kap:invest is higher, in some it is lower.
-;
-
-***---------------------------------------------------------------------------
-*' Initial conditions for capital:
-***---------------------------------------------------------------------------
-q_kapMo0(t0(t),regi,ppfKap(in))$(pm_cesdata(t,regi,in,"quantity") gt 0)..
-        vm_cesIO(t,regi,in) =e= pm_cesdata(t,regi,in,"quantity");
-
-*' Limit the share of one ppfEn in total CES nest inputs:
-q_limitShPpfen(t,regi,out,in)$( pm_ppfen_shares(out,in) ) ..
-  vm_cesIO(t,regi,in)
-  =l=
-    pm_ppfen_shares(out,in)
-  * sum(cesOut2cesIn(out,in2), vm_cesIO(t,regi,in2))
-;
-
-*' Limit the ratio of two ppfEn:
-q_limtRatioPpfen(t,regi,in,in2)$( pm_ppfen_ratios(in,in2) ) ..
-  vm_cesIO(t,regi,in)
-  =l=
-    pm_ppfen_ratios(in,in2)
-  * vm_cesIO(t,regi,in2)
-;
 
 *' Limit electricity use for fehes to 1/4th of total electricity use:
 q_limitSeel2fehes(t,regi)..
diff --git a/core/input/files b/core/input/files
index 2f62d20117a21f4b79ae254fb86306c5381ef7ad..510d2f10e7971fb8e2c2f99c0e832a94f8a16b72 100644
--- a/core/input/files
+++ b/core/input/files
@@ -2,25 +2,25 @@ f_cf.cs3r
 f_dataRegiSolar.cs3r
 f_emiFgas.cs4r
 f_gdp.cs3r
-f_IO_trade.cs4r
 f_lab.cs3r
 f_macBaseMagpie.cs4r
 f_maxProdGradeRegiHydro.cs3r
 f_maxProdGradeRegiWind.cs3r
 f_pop.cs3r
+f_IO_trade.cs4r
 p_abatparam_CH4.cs4r
 p_abatparam_N2O.cs4r
 p_abatparam_CO2.cs4r
 p_adj_deltacapoffset.cs4r
 p_boundEmi.cs4r
-p_boundInvMacro.cs4r
 pm_NuclearConstraint.cs4r
-p_costsPEtradeMp.cs4r
 pm_dataccs.cs3r
 p_earlyRetirementAdjFactor.cs3r
 p_emiFossilFuelExtr.cs4r
 p_emineg_econometric.cs3r
 p_histCap.cs3r
+p_histEmiMac.cs4r
+p_histEmiSector.cs4r
 p_PE_histCap.cs3r
 p_macBase1990.cs4r
 p_macBase2005.cs4r
@@ -32,7 +32,6 @@ p_share_ind_fesos.cs4r
 p_share_ind_fesos_bio.cs4r
 pm_boundCapCCS.cs4r
 pm_boundCapEV.cs4r
-pm_costsTradePeFinancial.cs3r
 pm_shPPPMER.cs4r
 p_inco0.cs4r
 p_boundCapCCSindicator.cs4r
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/core/postsolve.gms b/core/postsolve.gms
index d7d13b8280702abec9493fb52fbd4b071a59fe80..986af9aa57486b18c44799ca77abe8040a07a478 100644
--- a/core/postsolve.gms
+++ b/core/postsolve.gms
@@ -566,20 +566,6 @@ display p_bioshare;
 pm_gdp_gdx(ttot,regi)$(ttot.val ge 2005)    = vm_cesIO.l(ttot,regi,"inco");
 p_inv_gdx(ttot,regi)$(ttot.val ge 2005)     = vm_invMacro.l(ttot,regi,"kap");
 
-*consumption per capita
-pm_consPC(ttot,regi)$(ttot.val gt 2005 and ttot.val le 2150 and (pm_SolNonInfes(regi) eq 1) ) =
-    vm_cons.l(ttot,regi)/pm_pop(ttot,regi)
-;
-
-*interpolate years
-loop(ttot$(ttot.val ge 2005),
-	loop(tall$(pm_tall_2_ttot(tall, ttot)),
-		pm_consPC(tall,regi) =
-		    (1- pm_interpolWeight_ttot_tall(tall)) * pm_consPC(ttot,regi)
-		    + pm_interpolWeight_ttot_tall(tall) * pm_consPC(ttot + 1,regi);
-));
-pm_consPC(tall,regi)$(tall.val gt 2150) = pm_consPC("2150",regi);
-
 pm_GDPGross(ttot,regi)$( (pm_SolNonInfes(regi) eq 1) ) =  vm_cesIO.l(ttot,regi,"inco");
 
 
@@ -594,8 +580,6 @@ loop(ttot$(ttot.val ge 2005),
 * assume GDP is flat from 2150 on (only enters damage calculations in the far future)
 pm_GDPGross(tall,regi)$(tall.val ge 2150) = pm_GDPGross("2149",regi); 
 
-pm_Xport0(ttot,regi,tradePe)      = vm_Xport.l(ttot,regi,tradePe);
-
 
 
 ***------------ adjust adjustment costs for advanced vehicles according to CO2 price in the previous time step ----------------------
diff --git a/core/preloop.gms b/core/preloop.gms
index f1306937adb9a445e856771e70d0063126ab35b4..67954a8a93b88ef697d15bc8615475de61b182a0 100644
--- a/core/preloop.gms
+++ b/core/preloop.gms
@@ -6,42 +6,6 @@
 *** |  Contact: remind@pik-potsdam.de
 *** SOF ./core/preloop.gms
 
-loop ((t,counter),
-if ( pm_dt(t) eq 2 * counter.val,
-pm_cumDeprecFactor_old(t,regi,in)$(ppfKap(in) OR in_putty(in)) 
-=   ((1 - pm_delta_kap(regi,in)) ** (pm_dt(t)/2 )
-      - (1 - pm_delta_kap(regi,in)) ** (pm_dt(t) ))
-     /  pm_delta_kap(regi,in)
-    ;
-
-pm_cumDeprecFactor_new(t,regi,in)$(ppfKap(in) OR in_putty(in)) 
-=   ( 1 
-     - (1 - pm_delta_kap(regi,in)) ** (pm_dt(t)/2)
-      )
-     /  pm_delta_kap(regi,in)
-    ;
-
-);
-if ( pm_dt(t) eq (2 * counter.val -1),
-pm_cumDeprecFactor_old(t,regi,in)$(ppfKap(in) OR in_putty(in)) 
-=   ((1 - pm_delta_kap(regi,in)) ** (pm_dt(t)/2 - 0.5)
-      - (1 - pm_delta_kap(regi,in)) ** (pm_dt(t)))
-     /  pm_delta_kap(regi,in)
-    - 1/2 * (1 - pm_delta_kap(regi,in)) ** (pm_dt(t)/2 - 0.5 ) 
-    ;
-
-pm_cumDeprecFactor_new(t,regi,in)$(ppfKap(in) OR in_putty(in)) 
-=   ( 1 
-     - (1 - pm_delta_kap(regi,in)) ** (pm_dt(t)/2 - 0.5 + 1)
-      )
-     /  pm_delta_kap(regi,in)
-    - 1/2 * (1 - pm_delta_kap(regi,in)) ** (pm_dt(t)/2 - 0.5) 
-    ;
-    
-);
-); 
-display "test Deprec", pm_cumDeprecFactor_new,pm_cumDeprecFactor_old;
-
 ***------------------------------------------------------------------------------
 ***------------------------------------------------------------------------------
 ***                   MODEL             HYBRID
diff --git a/core/presolve.gms b/core/presolve.gms
index 65e53a0a46d43105c3d32500df44c8c705b90fa5..4629f60437462b4a5f7260a4d963197da3571245 100644
--- a/core/presolve.gms
+++ b/core/presolve.gms
@@ -8,7 +8,6 @@
 *JeS* calculate share of transport fuels in liquids
 pm_share_trans(ttot,regi)$(ttot.val ge 2005) = sum(se2fe(entySe,entyFe,te)$(seAgg2se("all_seliq",entySe) AND ( sameas(entyFe,"fepet") OR sameas(entyFe,"fedie"))), vm_prodFe.l(ttot,regi,entySe,entyFe,te)) / (sum(se2fe(entySe,entyFe,te)$seAgg2se("all_seliq",entySe), vm_prodFe.l(ttot,regi,entySe,entyFe,te)) + 0.0000001);
 
-pm_Xport0(ttot,regi,tradePe)      = vm_Xport.l(ttot,regi,tradePe);
 *AJS* we need those in nash
 pm_capCum0(ttot,regi,teLearn)$( (ttot.val ge 2005) and  (pm_SolNonInfes(regi) eq 1)) = vm_capCum.l(ttot,regi,teLearn);
 pm_co2eq0(ttot,regi)$( (ttot.val ge 2005) and  (pm_SolNonInfes(regi) eq 1)) = vm_co2eq.l(ttot,regi);
diff --git a/core/sets.gms b/core/sets.gms
index 65c496f587eab7e66b5c7a65ce6c6da13896d796..a582bf12cf961eb051679046901299e4e8dd7124 100755
--- a/core/sets.gms
+++ b/core/sets.gms
@@ -452,148 +452,148 @@ all_exogEmi     " all exogenous emission types"
         GrasslandBurning "Exogenous emissions from Grassland Burning"
 /
 
-  all_in   "all inputs and outputs of the CES function"
-  /
-    inco    "macroeconomic output"  
-
-    lab     "labour input"
-    kap     "capital input"
-    en      "energy input"
-
-    ens     "stationary energy use"
-    ensh    "stationary heat energy use"
-    fesos   "stationary use of solid energy carriers"
-    fehos   "stationary use of liquid energy carriers"
-    fegas   "stationary use of gaseous energy carriers"
-    feh2s   "stationary use of hydrogen"
-    fehes   "stationary use of district heat"
-    feels   "stationary use of electricity"
-
-    enb     "buildings energy use"
-    enhb    "buildings heat energy use"
-    fesob   "buildings use of solid energy carriers"
-    fehob   "buildings use of liquid energy carriers"
-    fegab   "buildings use of gaseous energy carriers"
-    feh2b   "buildings use of hydrogen"
-    feheb   "buildings use of district heat"
-    feelb   "buildings use of electricity"
-
-    eni     "industry energy use"
-    enhi    "industry heat energy use"
-    fesoi   "industry use of solid energy carriers"
-    fehoi   "industry use of liquid energy carriers"
-    fegai   "industry use of gaseous energy carriers"
-    feh2i   "industry use of hydrogen"
-    fehei   "industry use of district heat"
-    feeli   "industry use of electricity"
-
-    fehcsob  "buildings heating and cooking solids final energy"
-    fehcelb  "buildings heating and cooking electricity final energy" 
-    fehcheb  "buildings heating and cooking district heat final energy"
-    fehcgab  "buildings heating and cooking gas final energy"
-    fehchob  "buildings heating and cooking liquids final energy"
-    fealelb  "buildings appliances and light electricity final energy"
-    fecwsob  "buildings cooking and water heating solids final energy"
-    fecwelb  "buildings cooking and water heating electricity final energy" 
-    fecwhpb  "buildings cooking and water heating electricity heat pump final energy" 
-    fecwheb  "buildings cooking and water heating district heat final energy"
-    fecwgab  "buildings cooking and water heating gas final energy"
-    fecwhob  "buildings cooking and water heating liquids final energy"
-    fescelb  "buildings space cooling electricity final energy"
-    feshsob  "buildings space heating solids final energy"
-    feshelb  "buildings space heating electricity final energy" 
-    feshheb  "buildings space heating district heat final energy"
-    feshgab  "buildings space heating gas final energy"
-    feshhob  "buildings space heating liquids final energy"
-    feshhpb  "buildings space heating electricity heat pump final energy"
+all_in   "all inputs and outputs of the CES function"
+/
+  inco                    "macroeconomic output"  
+
+  lab                     "labour input"
+  kap                     "capital input"
+  en                      "energy input"
+
+  ens                     "stationary energy use"
+  ensh                    "stationary heat energy use"
+  fesos                   "stationary use of solid energy carriers"
+  fehos                   "stationary use of liquid energy carriers"
+  fegas                   "stationary use of gaseous energy carriers"
+  feh2s                   "stationary use of hydrogen"
+  fehes                   "stationary use of district heat"
+  feels                   "stationary use of electricity"
+
+  enb                     "buildings energy use"
+  enhb                    "buildings heat energy use"
+  fesob                   "buildings use of solid energy carriers"
+  fehob                   "buildings use of liquid energy carriers"
+  fegab                   "buildings use of gaseous energy carriers"
+  feh2b                   "buildings use of hydrogen"
+  feheb                   "buildings use of district heat"
+  feelb                   "buildings use of electricity"
+
+  eni                     "industry energy use"
+  enhi                    "industry heat energy use"
+  fesoi                   "industry use of solid energy carriers"
+  fehoi                   "industry use of liquid energy carriers"
+  fegai                   "industry use of gaseous energy carriers"
+  feh2i                   "industry use of hydrogen"
+  fehei                   "industry use of district heat"
+  feeli                   "industry use of electricity"
+
+  fehcsob                 "buildings heating and cooking solids final energy"
+  fehcelb                 "buildings heating and cooking electricity final energy" 
+  fehcheb                 "buildings heating and cooking district heat final energy"
+  fehcgab                 "buildings heating and cooking gas final energy"
+  fehchob                 "buildings heating and cooking liquids final energy"
+  fealelb                 "buildings appliances and light electricity final energy"
+  fecwsob                 "buildings cooking and water heating solids final energy"
+  fecwelb                 "buildings cooking and water heating electricity final energy" 
+  fecwhpb                 "buildings cooking and water heating electricity heat pump final energy" 
+  fecwheb                 "buildings cooking and water heating district heat final energy"
+  fecwgab                 "buildings cooking and water heating gas final energy"
+  fecwhob                 "buildings cooking and water heating liquids final energy"
+  fescelb                 "buildings space cooling electricity final energy"
+  feshsob                 "buildings space heating solids final energy"
+  feshelb                 "buildings space heating electricity final energy" 
+  feshheb                 "buildings space heating district heat final energy"
+  feshgab                 "buildings space heating gas final energy"
+  feshhob                 "buildings space heating liquids final energy"
+  feshhpb                 "buildings space heating electricity heat pump final energy"
     
-    esswb   "buildings weatherization energy service"
-    uehcb    "buildings heating and cooking useful energy"
-    uecwb    "buildings cooking and water heating useful energy"
-    uescb    "buildings space cooling useful energy"
-    ueshb    "buildings space heating useful energy"
-    uealb  "buildings appliances and light, useful energy"
-    ueswb   "buildings weatherization"
-    feshh2b  "buildings space heating hydrogen"
-    fecwb    "buildings cooking and water heating FE"
-    fecwh2b  "buildings cooking and water heating hydrogen"
+  esswb                   "buildings weatherization energy service"
+  uehcb                   "buildings heating and cooking useful energy"
+  uecwb                   "buildings cooking and water heating useful energy"
+  uescb                   "buildings space cooling useful energy"
+  ueshb                   "buildings space heating useful energy"
+  uealb                   "buildings appliances and light, useful energy"
+  ueswb                   "buildings weatherization"
+  feshh2b                 "buildings space heating hydrogen"
+  fecwb                   "buildings cooking and water heating FE"
+  fecwh2b                 "buildings cooking and water heating hydrogen"
 *** FIXME this should be reworked with Robert when revising the transport module
-    entrp   "transport energy use"
-    fetf    "transport fuel use"
-    ueLDVt   "transport useful energy light duty vehicles"
-    ueHDVt   "transport useful energy heavy duty vehicles"
-    feh2t   "transport hydrogen use"
-    ueelTt    "transport useful energy for electric trains"
-
-    entrp_pass    "passenger transport"
-    entrp_frgt    "freight transport"
-    entrp_pass_sm    "short-to-medium distance passenger transport"
-    entrp_pass_lo    "long distance passenger transport"
-    entrp_frgt_sm    "short-to-medium distance freight transport"
-    entrp_frgt_lo    "long distance freight transport"
-    fepet_pass_sm    "short-to-medium distance passenger transport, petrol"
-    fedie_pass_sm    "short-to-medium distance passenger transport, diesel"
-    feelt_pass_sm    "short-to-medium distance passenger transport, electricity"
-    fedie_pass_lo    "long distance passenger transport, diesel"
-    fedie_frgt_sm    "short-to-medium distance freight transport, diesel"
-    feelt_frgt_sm    "short-to-medium distance freight transport, electricity"
-    fedie_frgt_lo    "long distance freight transport, diesel"
-
-    kaphc     "buildings capital stock insulation"
-    kapsc     "buildings capital stock space cooling"
-    kapal     "buildings capital stock appliances and light"
+  entrp                   "transport energy use"
+  fetf                    "transport fuel use"
+  ueLDVt                  "transport useful energy light duty vehicles"
+  ueHDVt                  "transport useful energy heavy duty vehicles"
+  feh2t                   "transport hydrogen use"
+  ueelTt                  "transport useful energy for electric trains"
+
+  entrp_pass              "passenger transport"
+  entrp_frgt              "freight transport"
+  entrp_pass_sm           "short-to-medium distance passenger transport"
+  entrp_pass_lo           "long distance passenger transport"
+  entrp_frgt_sm           "short-to-medium distance freight transport"
+  entrp_frgt_lo           "long distance freight transport"
+  fepet_pass_sm           "short-to-medium distance passenger transport, petrol"
+  fedie_pass_sm           "short-to-medium distance passenger transport, diesel"
+  feelt_pass_sm           "short-to-medium distance passenger transport, electricity"
+  fedie_pass_lo           "long distance passenger transport, diesel"
+  fedie_frgt_sm           "short-to-medium distance freight transport, diesel"
+  feelt_frgt_sm           "short-to-medium distance freight transport, electricity"
+  fedie_frgt_lo           "long distance freight transport, diesel"
+
+  kaphc                   "buildings capital stock insulation"
+  kapsc                   "buildings capital stock space cooling"
+  kapal                   "buildings capital stock appliances and light"
     
-    !! production factors of industry with subsectors
-    ue_industry   "useful energy of industry sector"
-
-    ue_cement                "useful energy of cement production"
-    en_cement                "energy use of cement production"
-    kap_cement               "energy efficiency capital of cement production"
-    en_cement_non_electric   "non-electric energy use of cement production"
-    feso_cement              "solids energy use of cement production"
-    feli_cement              "liquids energy use of cement production"
-    fega_cement              "gases energy use of cement production"
-    feh2_cement              "hydrogen energy use of cement production"
-    feel_cement              "electricity energy use of cement production"
+  !! production factors of industry with subsectors
+  ue_industry             "useful energy of industry sector"
+
+  ue_cement               "useful energy of cement production"
+  en_cement               "energy use of cement production"
+  kap_cement              "energy efficiency capital of cement production"
+  en_cement_non_electric  "non-electric energy use of cement production"
+  feso_cement             "solids energy use of cement production"
+  feli_cement             "liquids energy use of cement production"
+  fega_cement             "gases energy use of cement production"
+  feh2_cement             "hydrogen energy use of cement production"
+  feel_cement             "electricity energy use of cement production"
  
 
-    ue_chemicals         "useful energy of chemicals production"
-    en_chemicals         "energy use of chemicals production"
-    kap_chemicals        "energy efficiency capital of chemicals production"
-    en_chemicals_fhth    "feedstock and high temperature heat enery use of chemicals production"
-    feso_chemicals       "solids energy use of cement production"
-    feli_chemicals       "liquids energy use of chemicals production"
-    fega_chemicals       "gases energy use of chemicals production"
-    feh2_chemicals       "hydrogen energy use of chemicals production"
-    feelhth_chemicals    "high temperature heat electricity energy use of chemicals production"
-    feelwlth_chemicals   "work and low temperature heat electricity energy use of chemicals production"
-
-    ue_steel               "useful energy of steel production"
-    ue_steel_primary       "useful energy of primary steel production"
-    ue_steel_secondary     "useful energy of secondary steel production"
-    en_steel_primary       "energy use of primary steel production"
-    kap_steel_primary      "energy efficiency capital of primary steel production"
-    kap_steel_secondary    "energy efficiency capital of secondary steel production"
-    en_steel_furnace       "non-electric energy use of primary steel production"
-    feso_steel             "solids energy use of primary steel production"
-    feli_steel             "liquids energy use of primary steel production"
-    fega_steel             "gases energy use of primary steel production"
-    feh2_steel             "hydrogen energy use of primary steel production"
-    feel_steel_primary     "electricity energy use pf primary steel production"
-    feel_steel_secondary   "electricity energy use of secondary steel production"
-
-    ue_otherInd         "useful energy of other industry production"
-    en_otherInd         "energy use of other industry production"
-    kap_otherInd        "energy efficiency capital of other industry production"
-    en_otherInd_hth     "non-electric energy use of other industry production"
-    feso_otherInd       "solids energy use of other industry production"
-    feli_otherInd       "liquids energy use of other industry production"
-    fega_otherInd       "gases energy use of other industry production"
-    feh2_otherInd       "hydrogen energy use of other industry production"
-    fehe_otherInd       "heat energy use of other industry production"
-    feelhth_otherInd    "high temperature heat electricity energy use of other industry production"
-    feelwlth_otherInd   "work and low temperature heat electricity energy use of other industry production"
-  /
+  ue_chemicals            "useful energy of chemicals production"
+  en_chemicals            "energy use of chemicals production"
+  kap_chemicals           "energy efficiency capital of chemicals production"
+  en_chemicals_fhth       "feedstock and high temperature heat enery use of chemicals production"
+  feso_chemicals          "solids energy use of cement production"
+  feli_chemicals          "liquids energy use of chemicals production"
+  fega_chemicals          "gases energy use of chemicals production"
+  feh2_chemicals          "hydrogen energy use of chemicals production"
+  feelhth_chemicals       "high temperature heat electricity energy use of chemicals production"
+  feelwlth_chemicals      "work and low temperature heat electricity energy use of chemicals production"
+
+  ue_steel                "useful energy of steel production"
+  ue_steel_primary        "useful energy of primary steel production"
+  ue_steel_secondary      "useful energy of secondary steel production"
+  en_steel_primary        "energy use of primary steel production"
+  kap_steel_primary       "energy efficiency capital of primary steel production"
+  kap_steel_secondary     "energy efficiency capital of secondary steel production"
+  en_steel_furnace        "non-electric energy use of primary steel production"
+  feso_steel              "solids energy use of primary steel production"
+  feli_steel              "liquids energy use of primary steel production"
+  fega_steel              "gases energy use of primary steel production"
+  feh2_steel              "hydrogen energy use of primary steel production"
+  feel_steel_primary      "electricity energy use pf primary steel production"
+  feel_steel_secondary    "electricity energy use of secondary steel production"
+
+  ue_otherInd             "useful energy of other industry production"
+  en_otherInd             "energy use of other industry production"
+  kap_otherInd            "energy efficiency capital of other industry production"
+  en_otherInd_hth         "non-electric energy use of other industry production"
+  feso_otherInd           "solids energy use of other industry production"
+  feli_otherInd           "liquids energy use of other industry production"
+  fega_otherInd           "gases energy use of other industry production"
+  feh2_otherInd           "hydrogen energy use of other industry production"
+  fehe_otherInd           "heat energy use of other industry production"
+  feelhth_otherInd        "high temperature heat electricity energy use of other industry production"
+  feelwlth_otherInd       "work and low temperature heat electricity energy use of other industry production"
+/
 
 all_teEs                 "energy service technologies"
 /
@@ -788,6 +788,7 @@ sets
 
        modules "all the available modules"
        /
+       macro
        welfare
        PE_FE_parameters
        initialCap
@@ -798,6 +799,7 @@ sets
        tax
        subsidizeLearning
        capitalMarket
+       trade
        agCosts
        CES_parameters
        biomass
@@ -822,6 +824,7 @@ sets
        /
 
 module2realisation(modules,*) "mapping of modules and active realisations" /
+       macro . %macro%
        welfare . %welfare%
        PE_FE_parameters . %PE_FE_parameters%
        initialCap . %initialCap%
@@ -832,6 +835,7 @@ module2realisation(modules,*) "mapping of modules and active realisations" /
        tax . %tax%
        subsidizeLearning . %subsidizeLearning%
        capitalMarket . %capitalMarket%
+       trade . %trade%
        agCosts . %agCosts%
        CES_parameters . %CES_parameters%
        biomass . %biomass%
@@ -1876,29 +1880,7 @@ s_statusTe   "technology status: how close a technology is to market readiness.
 ***-----------------------------------------------------------------------------
 
 Sets
-  in(all_in)        "all inputs and outputs of the CES function"
-  /
-    inco    "macroeconomic output"  
-    lab     "labour input"
-    kap     "capital input"
-    en      "energy input"
-  /
 
-  ppf(all_in)                "all primary production factors"
-  ipf(all_in)                "all intermediate production factors"
-  ppfKap(all_in)              "primary production factors capital"   / kap /
-  ppfEn(all_in)              "primary production factors energy" /  /
-  in_putty(all_in)               "production factors subject to putty-clay dynamics"
-  ppf_putty(all_in)           "all putty-clay primary production factors"
-  ipf_putty(all_in)           "all putty-clay intermediate production factors"
-  ppfIO_putty(all_in)         "factors treated in the normal CES as ppf and in putty-clay as output"
-  nests_putty(all_in,all_in)  "defines factors which are in the same putty subnest. The first all_in gives the higher factors of the subnest"
-  in_complements(all_in)           "factors which are perfect complements" 
-  //
-  in_enerSerAdj(all_in)                "energy services factors which should be constrained by adjustment costs"
-  //
-  complements_ref(all_in,all_in)    "correspondence between complementary factors. Necessary to have a reference factor for the constraints equations"
- 
   fe_tax_sub_sbi(all_in,all_in) "correspondence between tax and subsidy input data resolution and model sectoral resolution. For FE which takes the pathway I to the CES "
   //
   fe_tax_subEs(all_in,all_esty) "correspondence between tax and subsidy input data resolution and model sectoral resolution. For FE which takes the pathway III to the CES "
@@ -1915,18 +1897,6 @@ Sets
     compl_coef    "coefficients for the perfectly complementary factors"
   /
 
-  trade(all_enty)             "all traded commodities"
-  //
-  tradeMacro(all_enty)      "traded macro-economic commodities"
-  /good, perm/
-  tradePe(all_enty)         "traded primary energy commodities"
-  /
-  peoil, pecoal, pegas, peur, pebiolc
-  /
-  tradeSe(all_enty)         "traded secondary energy commodities"
-  /
-  null
-  /
 
 ***-------------------------------------------------------------------------------
 ***                 SETS for fragmented policy regimes
@@ -1996,10 +1966,7 @@ alias(teEs,teEs2);
 alias(esty,esty2);
 alias(rlf,rlf2);
 alias(regi,regi2);
-alias(in,out);
 alias(steps,steps2);
-alias(in,in2,in3);
-alias(ipf,ipf2);
 
 ***-----------------------------------------------------------------------------
 ***-----------------------------------------------------------------------------
@@ -2540,10 +2507,7 @@ emiRCP2unitsMagicc(emiRCP,unitsMagicc) "match units to emission types"
     (CF4,C2F6,C6F14,HFC23,HFC32,HFC43-10,HFC125,HFC134a,HFC143a,HFC227ea,HFC245fa,SF6) . kt
 /
 
-cesOut2cesIn(all_in,all_in)              "CES tree structure"
-/
-    inco  . (lab, kap, en)
-/
+
 
 ue2ppfen(all_enty,all_in)      "matching UE in ESM to ppfEn in MACRO"
 //
@@ -2551,24 +2515,14 @@ ue2ppfen(all_enty,all_in)      "matching UE in ESM to ppfEn in MACRO"
 es2ppfen(all_esty,all_in)      "matching ES in ESM to ppfEn in MACRO"
 //
 
-cesLevel2cesIO(counter,all_in)   "CES tree structure by level"
-cesRev2cesIO(counter,all_in)   "CES tree structure by level - descending order"
-cesOut2cesIn_below(all_in,all_in) "all elements of the CES below located below the first item given"
-in_below_putty(all_in)            "all elements of the CES below ppf_putty, excluding ppf_putty. Only meaningful in case putty structures are not intertwined"
 ;
 
-in_putty(all_in)    = NO;   
-ppf_putty(all_in)   = NO; 
-ipf_putty(all_in)   = NO; 
-ppfIO_putty(all_in) = NO;  
-
 ***-----------------------------------------------------------------------------
 ***-----------------------------------------------------------------------------
 ***                             Helpful constructs: alias
 ***-----------------------------------------------------------------------------
 ***-----------------------------------------------------------------------------
 
-alias(cesOut2cesIn,cesOut2cesIn2);
 alias(ccs2te,ccs2te2);
 alias(pe2se,pe2se2);
 
diff --git a/main.gms b/main.gms
index 3b1b8b23dd99d908c3895967837d59dee34e7ecc..c125509a3903ded2f27493d8625b3d9c5e323c5b 100644
--- a/main.gms
+++ b/main.gms
@@ -72,9 +72,9 @@
 * 
 * Regionscode: 690d3718e151be1b450b394c1064b1c5
 * 
-* Input data revision: 5.936
+* Input data revision: 5.937
 * 
-* Last modification (input data): Mon Jan 13 09:10:28 2020
+* Last modification (input data): Thu Jan 16 14:11:39 2020
 * 
 *###################### R SECTION END (VERSION INFO) ###########################
 
@@ -126,6 +126,8 @@ $setGlobal c_expname  default
 ***                           MODULES
 ***------------------------------------------------------------------------------
 
+***---------------------    01_macro    -----------------------------------------
+$setGlobal macro  singleSectorGr  !! def = singleSectorGr
 ***---------------------    02_welfare    ---------------------------------------
 $setGlobal welfare  utilitarian  !! def = utilitarian
 ***---------------------    04_PE_FE_parameters    ------------------------------
@@ -146,6 +148,8 @@ $setGlobal tax  on                    !! def = on
 $setGlobal subsidizeLearning  off     !! def = off
 ***---------------------    23_capitalMarket    -----------------------------
 $setGlobal capitalMarket  perfect     !! def = perfect
+***---------------------    24_trade    -----------------------------------------
+$setGlobal trade  standard     !! def = standard
 ***---------------------    26_agCosts ------------------------------------------
 $setGlobal agCosts  costs               !! def = costs
 ***---------------------    29_CES_parameters    --------------------------------
@@ -159,7 +163,7 @@ $setGlobal power  IntC               !! def = IntC
 ***---------------------    33_cdr       ----------------------------------------
 $setGlobal CDR  DAC                   !! def = DAC
 ***---------------------    35_transport    -------------------------------------
-$setGlobal transport  edge_esm         !! def = complex
+$setGlobal transport  complex         !! def = complex
 ***---------------------    36_buildings    -------------------------------------
 $setglobal buildings  simple          !! def = simple
 ***---------------------    37_industry    --------------------------------------
@@ -214,8 +218,8 @@ cm_CCS_steel         "CCS for steel sub-sector"
 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"
-c_tradecost_bio       "choose financal tradecosts for biomass (purpose grown pebiolc)"
-c_1stgen_phaseout    "choose if 1st generation biofuels should phase out after 2030 (vm_deltaCap=0)"
+cm_tradecost_bio       "choose financal tradecosts for biomass (purpose grown pebiolc)"
+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"
@@ -254,7 +258,7 @@ c_abtrdy              "first year in which advanced bio-energy technology are re
 c_abtcst              "scaling of the cost of advanced bio-energy technologies (no unit, 50% increase means 1.5)"
 c_budgetCO2        "carbon budget for all CO2 emissions (in GtCO2)"
 
-c_trdcst              "parameter to scale trade export cost for gas"
+cm_trdcst              "parameter to scale trade export cost for gas"
 cm_trdadj              "parameter scale the adjustment cost parameter for increasing gas trade export"
 
 c_refcapbnd           "switch for fixing refinery capacities to the SSP2 levels in 2010 (if equal zero then no fixing)"
@@ -306,9 +310,9 @@ cm_CCS_steel           = 1;        !! def = 1
 
 cm_bioenergy_tax    = 1.5;       !! def = 1.5
 cm_bioenergymaxscen = 0;         !! def = 0
-c_tradecost_bio     = 2;         !! def = 2
+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
@@ -324,8 +328,8 @@ cm_fetaxscen        = 3;         !! def = 3
 cm_multigasscen     = 2;         !! def = 2
 cm_permittradescen  = 1;         !! def = 1
 cm_limit_peur_scen  = 1;         !! def = 1
-$setGlobal cm_oil_scen  medOil         !! def = medOil
-$setGlobal cm_gas_scen  medGas         !! def = medGas
+$setGlobal cm_oil_scen   medOil         !! def = medOil
+$setGlobal cm_gas_scen   medGas         !! def = medGas
 $setGlobal cm_coal_scen  medCoal        !! def = medCoal
 cm_rentdiscoil      = 0.2;       !! def 0.2
 cm_rentdiscoil2     = 0.9;       !! def 0.9
@@ -340,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
@@ -364,7 +368,7 @@ cm_taxCO2inc_after_peakBudgYr = 2;      !! def = 2
 cm_CO2priceRegConvEndYr       = 2050;   !! def = 2050
 
 cm_trdadj            = 2;    !! def = 2.0
-c_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
@@ -375,12 +379,11 @@ 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
 
 $setGlobal c_regi_nucscen  all !! def = all
 $setGlobal c_regi_capturescen  all !! def = all
@@ -390,15 +393,15 @@ $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_OILRETIRE  off        !! def = off
-$setglobal cm_INCONV_PENALTY  on         !! def = on
-$setGlobal cm_so2_out_of_opt  on         !! def = on
-$setGlobal c_skip_output  off        !! def = off
-$setGlobal cm_MOFEX  off        !! def = off
-$setGlobal cm_conoptv  conopt3    !! def = conopt3
-$setGlobal cm_ccsfosall  off        !! def = off
+$setGlobal cm_nash_mode        debug      !! 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
+$setGlobal c_skip_output       off        !! def = off
+$setGlobal cm_MOFEX            off        !! def = off
+$setGlobal cm_conoptv          conopt3    !! def = conopt3
+$setGlobal cm_ccsfosall        off        !! def = off
 
 $setGlobal cm_APscen  SSP2          !! def = SSP2
 $setGlobal cm_magicc_calibrateTemperature2000  uncalibrated  !! def=uncalibrated
@@ -407,9 +410,7 @@ $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 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
 $setglobal c_CES_calibration_iterations  10    !! def = 10
diff --git a/modules/01_macro/module.gms b/modules/01_macro/module.gms
new file mode 100644
index 0000000000000000000000000000000000000000..b19af80b9c9a55961238bbfa3169b4438805c2fe
--- /dev/null
+++ b/modules/01_macro/module.gms
@@ -0,0 +1,15 @@
+*** |  (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/01_macro/module.gms
+*' @title Macro-Economic Growth Model
+*'
+*' @description The macro module allows for the implementation of different 
+*' macro-economic modules. 
+*###################### R SECTION START (MODULETYPES) ##########################
+$Ifi "%macro%" == "singleSectorGr" $include "./modules/01_macro/singleSectorGr/realization.gms"
+*###################### R SECTION END (MODULETYPES) ############################
+*** EOF ./modules/01_macro/module.gms
diff --git a/modules/01_macro/singleSectorGr/bounds.gms b/modules/01_macro/singleSectorGr/bounds.gms
new file mode 100644
index 0000000000000000000000000000000000000000..1b3fc457c96aacd5daff4958be38534cfb4f1799
--- /dev/null
+++ b/modules/01_macro/singleSectorGr/bounds.gms
@@ -0,0 +1,25 @@
+*** |  (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/01_macro/singleSectorGr/bounds.gms
+
+*nb* lower bounds on CES values
+vm_cons.lo(t,regi)     = 1e-3;
+vm_cesIO.lo(t,regi,in) = 1e-6;
+vm_cesIOdelta.lo(t,regi,in_putty) = 1e-6;
+
+*nb fix energy inputs to CES structure in t0 to the parameter values
+vm_cesIO.fx(t0(tall),regi,in)$(ppfEn(in) OR ppfIO_putty(in)) = pm_cesdata(tall,regi,in,"quantity");
+vm_cesIOdelta.fx(t0(tall),regi,in)$(ppfEn(in) OR in_putty(in)) = pm_cesdata_putty(tall,regi,in,"quantity");
+
+
+*** set macro investments to bound in 2005
+vm_invMacro.fx("2005",regi,"kap") = p01_boundInvMacro(regi);
+*cb 2012-05-23 lower bound for capital investment to avoid "zero investment" problem for the conopt solver
+vm_invMacro.lo(t,regi,"kap")$(t.val gt 2005) = 0.01 * vm_invMacro.lo("2005",regi,"kap");
+
+v01_invMacroAdj.fx("2005",regi,ppfKap(in)) = 0;
+*** EOF ./modules/01_macro/singleSectorGr/bounds.gms
\ No newline at end of file
diff --git a/modules/01_macro/singleSectorGr/datainput.gms b/modules/01_macro/singleSectorGr/datainput.gms
new file mode 100644
index 0000000000000000000000000000000000000000..19be4aa1590349c8f4cee2b98cfd04036f4101a2
--- /dev/null
+++ b/modules/01_macro/singleSectorGr/datainput.gms
@@ -0,0 +1,21 @@
+*** |  (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/01_macro/singleSectorGr/datainput.gms
+
+*** depreciation rate of capital
+pm_delta_kap(regi,"kap") = 0.05;
+
+*** load data for macro investments in 2005, used as bound
+parameter p01_boundInvMacro(all_regi)        "macro investments in 2005" 
+/
+$ondelim
+$include "./modules/01_macro/singleSectorGr/input/p01_boundInvMacro.cs4r"
+$offdelim
+/
+;
+p01_boundInvMacro(all_regi) = p01_boundInvMacro(all_regi) * pm_shPPPMER(all_regi);
+*** EOF ./modules/01_macro/singleSectorGr/datainput.gms
\ No newline at end of file
diff --git a/modules/01_macro/singleSectorGr/declarations.gms b/modules/01_macro/singleSectorGr/declarations.gms
new file mode 100644
index 0000000000000000000000000000000000000000..89604543066b40f0032e857e926940b6c572ecca
--- /dev/null
+++ b/modules/01_macro/singleSectorGr/declarations.gms
@@ -0,0 +1,54 @@
+*** |  (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/01_macro/singleSectorGr/declarations.gms
+***-------------------------------------------------------------------------------
+***                                   PARAMETERS
+***-------------------------------------------------------------------------------
+parameters
+pm_delta_kap(all_regi,all_in)                                   "Depreciation rate of capital."
+pm_cumDeprecFactor_old(ttot,all_regi,all_in)                    "Investment depreciation within a period, applied to the investment of t -1."
+pm_cumDeprecFactor_new(ttot,all_regi,all_in)                    "Investment depreciation within a period, applied to the investment of t."
+pm_ppfen_ratios(all_in,all_in)                                  "Limit ratio of two primary production factors of energy (ppfEn)."
+pm_ppfen_shares(all_in,all_in)                                  "Limit the share of one ppfEn in total CES nest inputs."
+pm_consPC(tall,all_regi)                                        "Consumption per capita"
+;   
+***------------------------------------------------------------ -------------------
+***                                   VARIABLES 
+***------------------------------------------------------------ -------------------
+positive variables  
+vm_cons(ttot,all_regi)                                          "Consumption"  
+vm_cesIO(tall,all_regi,all_in)                                  "Production factor" 
+vm_invMacro(ttot,all_regi,all_in)                               "Investment for capital for ttot"
+v01_invMacroAdj(ttot,all_regi,all_in)                           "Adjustment costs of macro economic investments"
+vm_invRD(ttot,all_regi,all_in)                                  "R&D investments"
+vm_invInno(ttot,all_regi,all_in)                                "Investment into innovation"
+vm_invImi(ttot, all_regi,all_in)                                "Investment into imitation"     
+
+*** putty-clay variables   
+vm_cesIOdelta(tall,all_regi,all_in)                             "Putty-clay production factor"  
+;   
+***------------------------------------------------------------ -------------------
+***                                   EQUATIONS 
+***------------------------------------------------------------ -------------------
+equations   
+qm_budget(ttot,all_regi)                                        "Budget balance"
+q01_balLab(ttot,all_regi)                                       "Labour balance"
+q01_cesIO(ttot,all_regi,all_in)                                 "Production function"
+q01_prodCompl(ttot,all_regi,all_in,all_in)                      "Constraints for perfect complements in the CES tree"
+q01_kapMo(ttot,all_regi,all_in)                                 "Capital motion equation"
+q01_kapMo0(t0,all_regi,all_in)                                  "Initial condition for capital"
+q01_invMacroAdj(ttot,all_regi,all_in)                           "Adjustment costs for macro economic investments"
+q01_limitShPpfen(ttot,all_regi,all_in,all_in)                   "Limit the share of one ppfEn in total CES nest inputs"
+q01_limtRatioPpfen(ttot,all_regi,all_in,all_in)                 "Limit the ratio of two ppfEn"
+
+*** putty-clay equations    
+q01_cesIO_puttyclay(ttot,all_regi,all_in)                       "Putty-clay production function"
+q01_puttyclay(ttot,all_regi,all_in)                             "Putty-clay Correspondance between variations in input and past stocks of input"
+q01_prodCompl_putty(ttot,all_regi,all_in,all_in)                "Putty-Clay constraints for perfect complements in the CES tree"
+q01_kapMo_putty(ttot,all_regi,all_in)                           "Putty-clay capital motion equation"
+;
+*** EOF ./modules/01_macro/singleSectorGr/declarations.gms
\ No newline at end of file
diff --git a/modules/01_macro/singleSectorGr/equations.gms b/modules/01_macro/singleSectorGr/equations.gms
new file mode 100644
index 0000000000000000000000000000000000000000..2dc2b63f5027839cee9ece45fb0da71ea3d1c784
--- /dev/null
+++ b/modules/01_macro/singleSectorGr/equations.gms
@@ -0,0 +1,225 @@
+*** |  (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/01_macro/singleSectorGr/equations.gms
+
+
+***---------------------------------------------------------------------------
+*' Usable macroeconomic output - net of climate change damages - is calculated from the macroeconomic output, 
+*' taking into account export and import of the final good, taking specific trade costs into account, 
+*' which are assigned to the importer. The resulting output is used for consumption, 
+*' for investments into the capital stock, and for the energy system cost components investments,
+*' fuel costs and operation & maintenance. 
+*' Other additional costs like non-energy related greenhouse gas abatement costs and
+*' agricultural costs, which are delivered by the land use model MAgPIE, are deduced from disposable output. 
+*' Net tax revenues and adjustment costs converge to zero in the optimal solution (equilibrium point).
+***---------------------------------------------------------------------------
+qm_budget(ttot,regi)$( ttot.val ge cm_startyear ) .. 
+    vm_cesIO(ttot,regi,"inco") * vm_damageFactor(ttot,regi) 
+  - vm_Xport(ttot,regi,"good") 
+  + vm_Mport(ttot,regi,"good") * (1 - pm_tradecostgood(regi) - pm_risk_premium(regi))
+  =g=
+    vm_cons(ttot,regi)
+  + sum(ppfKap(in), vm_invMacro(ttot,regi,in))
+  + sum(ppfKap(in), v01_invMacroAdj(ttot,regi,in))  
+  + sum(in, vm_invRD(ttot,regi,in))
+  + sum(in, vm_invInno(ttot,regi,in))
+  + sum(in, vm_invImi(ttot,regi,in))
+  + sum(tradePe(enty), pm_costsTradePeFinancial(regi,"Mport",enty) * vm_Mport(ttot,regi,enty))
+  + sum(tradePe(enty),
+      (pm_costsTradePeFinancial(regi,"Xport",enty) * vm_Xport(ttot,regi,enty))
+    * ( 1 
+      + ( pm_costsTradePeFinancial(regi,"XportElasticity",enty)
+        / sqr(pm_ttot_val(ttot)-pm_ttot_val(ttot-1))
+        * ( vm_Xport(ttot,regi,enty) 
+          / ( vm_Xport(ttot-1,regi,enty) + pm_costsTradePeFinancial(regi, "tradeFloor",enty) ) 
+          - 1
+          )
+        )$( ttot.val ge max(2010, cm_startyear) )
+      )
+    )
+  + vm_taxrev(ttot,regi)$(ttot.val ge 2010)
+  + vm_costAdjNash(ttot,regi)
+  + sum(in_enerSerAdj(in), vm_enerSerAdj(ttot,regi,in))
+  + sum(teEs, vm_esCapInv(ttot,regi,teEs))
+  + vm_costpollution(ttot,regi)
+  + pm_totLUcosts(ttot,regi)
+*** agricultural MACs are part of pm_totLUcosts (see module 26_agCosts)
+  + sum(enty$(emiMacSector(enty) AND (NOT emiMacMagpie(enty))), pm_macCost(ttot,regi,enty))  
+  + vm_costEnergySys(ttot,regi)
+;
+
+
+
+***---------------------------------------------------------------------------
+*' The labor available in every time step and every region comes from exogenous data. 
+*' It is the population corrected by the population age structure,
+*' which results in the labour force of people agged 15 to 65. 
+*' The labor participation rate is not factored into the labour supply (as it would only imply a
+*' rescaling of parameters without consequences for the model's dynamic). 
+*' The labour market balance equation reads as follows:
+***---------------------------------------------------------------------------
+q01_balLab(t,regi)..
+    vm_cesIO(t,regi,"lab") 
+  =e= 
+    pm_lab(t,regi)
+;
+
+***---------------------------------------------------------------------------
+*' The production function is a nested CES (constant elasticity of substitution) production function. 
+*' The macroeconomic output is generated by the inputs capital, labor, and total final energy (as a macro-ecoomic
+*' aggregate in $US units). The generation of total final energy is described
+*' by a CES production function as well, whose input factors are CES function outputs again. 
+*' Hence, the outputs of CES nests are intermediates measured in $US units. 
+*' According to the Euler-equation the value of the intermediate equals the sum of expenditures for the inputs. 
+*' Sector-specific final energy types represent the bottom end of the `CES-tree'. These 'CES leaves' are
+*' measured in physical units and have a price in $US per physical unit. 
+*' The top of the tree is the total economic output measured in $US.
+*' The following equation is the generic form of the production function. 
+*' It treats the various CES nests separately and the nests are inter-connetected via mappings. 
+*' This equation calculates the amount of intermediate output in a time-step and region 
+*' from the associated factor input amounts according to:
+*** Keep in mind to adjust the calculation of derivatives and shares 
+*** in ./core/reswrite.inc if you change the structure of this function.
+***---------------------------------------------------------------------------
+q01_cesIO(t,regi,ipf(out))$ ( NOT ipf_putty(out)) ..
+    vm_cesIO(t,regi,out)
+  =e=
+    sum(cesOut2cesIn(out,in),
+      pm_cesdata(t,regi,in,"xi")
+    * ( 
+        pm_cesdata(t,regi,in,"eff")
+      * vm_effGr(t,regi,in)
+      * vm_cesIO(t,regi,in)
+      )
+   ** pm_cesdata(t,regi,out,"rho")
+    )
+  ** (1 / pm_cesdata(t,regi,out,"rho"))
+;
+
+***---------------------------------------------------------------------------
+*' Constraints for perfect complements in the CES tree
+***---------------------------------------------------------------------------
+q01_prodCompl(t,regi,in,in2) $ (complements_ref(in,in2) AND (( NOT in_putty(in2)) OR ppfIO_putty(in2))) ..
+    vm_cesIO(t,regi,in) 
+  =e= 
+    pm_cesdata(t,regi,in2,"compl_coef")
+  * vm_cesIO(t,regi,in2)
+;
+
+
+
+***---------------------------------------------------------------------------    
+*' The capital stock is claculated recursively. Its amount in the previous time
+*' step is devaluated by an annual depreciation factor and enlarged by investments. 
+*' Both depreciation and investments are expressed as annual values,
+*' so the time step length is taken into account.
+***---------------------------------------------------------------------------
+q01_kapMo(ttot,regi,ppfKap(in))$( ( NOT in_putty(in)) AND (ord(ttot) lt card(ttot)) AND (pm_ttot_val(ttot+1) ge max(2010, cm_startyear)) AND (pm_cesdata("2005",regi,in,"quantity") gt 0))..
+    vm_cesIO(ttot+1,regi,in)
+  =e=
+    (1- pm_delta_kap(regi,in))**(pm_ttot_val(ttot+1)-pm_ttot_val(ttot)) * vm_cesIO(ttot,regi,in)
+$ifthen setGlobal END2110
+*gl* short time horizon requires investments to materialize in the same time step
+  + pm_ts(ttot)*vm_invMacro(ttot,regi,in)*0.94**5 - (0.5*pm_ts(ttot)*vm_invMacro(ttot,regi,in)*0.94**5)$(ord(ttot) eq card(ttot));
+$else
+  + pm_cumDeprecFactor_old(ttot+1,regi,in) * vm_invMacro(ttot,regi,in)
+  + pm_cumDeprecFactor_new(ttot+1,regi,in) * vm_invMacro(ttot+1,regi,in) ;
+$endif
+;
+
+***---------------------------------------------------------------------------
+*' Adjustment costs of macro economic investments:
+***---------------------------------------------------------------------------
+q01_invMacroAdj(ttot,regi,ppfKap(in))$( ttot.val ge max(2010, cm_startyear))..
+    v01_invMacroAdj(ttot,regi,in)
+  =e= 
+    sqr( (vm_invMacro(ttot,regi,in)-vm_invMacro(ttot-1,regi,in)) 
+      / (pm_ttot_val(ttot)-pm_ttot_val(ttot-1)) 
+      / (vm_invMacro(ttot,regi,in)+0.0001)
+    )
+  * vm_cesIO(ttot,regi,in) / 11
+*ML/RP* use "kap/11"  instead of "vm_invMacro" for the scaling to remove the "invest=0"-trap that sometimes appeared in delay scenarios; kap/11 corresponds to the global average ratio of investments to capital in 2005.
+*** In some regions the ratio kap:invest is higher, in some it is lower.
+;
+
+***---------------------------------------------------------------------------
+*' Initial conditions for capital:
+***---------------------------------------------------------------------------
+q01_kapMo0(t0(t),regi,ppfKap(in))$(pm_cesdata(t,regi,in,"quantity") gt 0)..
+    vm_cesIO(t,regi,in) 
+  =e= 
+    pm_cesdata(t,regi,in,"quantity");
+
+*' Limit the share of one ppfEn in total CES nest inputs:
+q01_limitShPpfen(t,regi,out,in)$( pm_ppfen_shares(out,in) ) ..
+    vm_cesIO(t,regi,in)
+  =l=
+    pm_ppfen_shares(out,in)
+  * sum(cesOut2cesIn(out,in2), vm_cesIO(t,regi,in2))
+;
+
+*' Limit the ratio of two ppfEn:
+q01_limtRatioPpfen(t,regi,in,in2)$( pm_ppfen_ratios(in,in2) ) ..
+    vm_cesIO(t,regi,in)
+  =l=
+    pm_ppfen_ratios(in,in2)
+  * vm_cesIO(t,regi,in2)
+;
+
+
+***---------------------------------------------------------------------------                                
+*** Start of Putty-Clay equations 
+*' Putty-Clay production function:
+***---------------------------------------------------------------------------
+q01_cesIO_puttyclay(t,regi,ipf_putty(out)) ..
+  vm_cesIOdelta(t,regi,out)
+  =e=
+    sum(cesOut2cesIn(out,in),
+      pm_cesdata(t,regi,in,"xi")
+    * ( 
+        pm_cesdata(t,regi,in,"eff")
+      * vm_effGr(t,regi,in)
+      * vm_cesIOdelta(t,regi,in)
+      )
+   ** pm_cesdata(t,regi,out,"rho")
+    )
+ ** (1 / pm_cesdata(t,regi,out,"rho"))
+;
+
+*' Putty-Clay constraints for perfect complements in the CES tree:
+q01_prodCompl_putty(t,regi,in,in2) $ (complements_ref(in,in2)
+                                 AND ( in_putty(in2) AND  ( NOT ppfIO_putty(in2)))) ..
+      vm_cesIOdelta(t,regi,in) =e=
+                                pm_cesdata(t,regi,in2,"compl_coef")
+                                * vm_cesIOdelta(t,regi,in2);
+
+*' Correspondance between vm_cesIO and vm_cesIOdelta:
+q01_puttyclay(ttot,regi,in_putty(in))$(ord(ttot) lt card(ttot)  AND (pm_ttot_val(ttot+1) ge max(2010, cm_startyear)))..
+  vm_cesIO(ttot+1,regi,in)
+  =e=
+  vm_cesIO(ttot,regi,in)*(1- pm_delta_kap(regi,in))**(pm_ttot_val(ttot+1)-pm_ttot_val(ttot))
+           +  pm_cumDeprecFactor_old(ttot+1,regi,in)* vm_cesIOdelta(ttot,regi,in)
+           +  pm_cumDeprecFactor_new(ttot+1,regi,in)* vm_cesIOdelta(ttot+1,regi,in)
+;
+
+*' Capital motion equation for putty clay capital:
+q01_kapMo_putty(ttot,regi,in_putty(in))$(ppfKap(in) AND (ord(ttot) le card(ttot)) AND (pm_ttot_val(ttot) ge max(2005, cm_startyear)) AND (pm_cesdata("2005",regi,in,"quantity") gt 0))..
+    vm_cesIOdelta(ttot,regi,in)
+    =e=
+             0
+$ifthen setGlobal END2110
+*gl* short time horizon requires investments to materialize in the same time step
+                  + pm_ts(ttot)*vm_invMacro(ttot,regi,in)*0.94**5 - (0.5*pm_ts(ttot)*vm_invMacro(ttot,regi,in)*0.94**5)$(ord(ttot) eq card(ttot));
+$else
+                  + vm_invMacro(ttot,regi,in)
+                   ;
+$endif
+;
+***---------------------------------------------------------------------------
+*** End of Putty-Clay equations
+***---------------------------------------------------------------------------
+*** EOF ./modules/01_macro/singleSectorGr/equations.gms
\ No newline at end of file
diff --git a/modules/01_macro/singleSectorGr/input/files b/modules/01_macro/singleSectorGr/input/files
new file mode 100644
index 0000000000000000000000000000000000000000..d0d00263f496d9af2cf3f6aac80a80d8003196d1
--- /dev/null
+++ b/modules/01_macro/singleSectorGr/input/files
@@ -0,0 +1 @@
+p01_boundInvMacro.cs4r
diff --git a/modules/01_macro/singleSectorGr/postsolve.gms b/modules/01_macro/singleSectorGr/postsolve.gms
new file mode 100644
index 0000000000000000000000000000000000000000..ae9976d3dbd9d8ee35ad6848d4aedf3665216b11
--- /dev/null
+++ b/modules/01_macro/singleSectorGr/postsolve.gms
@@ -0,0 +1,21 @@
+*** |  (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/01_macro/singleSectorGr/postsolve.gms
+*** Consumption per capita
+pm_consPC(ttot,regi)$(ttot.val gt 2005 and ttot.val le 2150 and (pm_SolNonInfes(regi) eq 1) ) =
+    vm_cons.l(ttot,regi)/pm_pop(ttot,regi)
+;
+
+*** Interpolate years
+loop(ttot$(ttot.val ge 2005),
+	loop(tall$(pm_tall_2_ttot(tall, ttot)),
+		pm_consPC(tall,regi) =
+		    (1- pm_interpolWeight_ttot_tall(tall)) * pm_consPC(ttot,regi)
+		    + pm_interpolWeight_ttot_tall(tall) * pm_consPC(ttot + 1,regi);
+));
+pm_consPC(tall,regi)$(tall.val gt 2150) = pm_consPC("2150",regi);
+*** EOF ./modules/01_macro/singleSectorGr/postsolve.gms
\ No newline at end of file
diff --git a/modules/01_macro/singleSectorGr/preloop.gms b/modules/01_macro/singleSectorGr/preloop.gms
new file mode 100644
index 0000000000000000000000000000000000000000..fa850b04d74fc1555a240a7f07767d7fa4c6736f
--- /dev/null
+++ b/modules/01_macro/singleSectorGr/preloop.gms
@@ -0,0 +1,46 @@
+*** |  (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/01_macro/singleSectorGr/preloop.gms
+
+*** Calculate cummulative depreciation factors
+loop ((t,counter),
+if ( pm_dt(t) eq 2 * counter.val,
+pm_cumDeprecFactor_old(t,regi,in)$(ppfKap(in) OR in_putty(in)) 
+=   ((1 - pm_delta_kap(regi,in)) ** (pm_dt(t)/2 )
+      - (1 - pm_delta_kap(regi,in)) ** (pm_dt(t) ))
+     /  pm_delta_kap(regi,in)
+    ;
+
+pm_cumDeprecFactor_new(t,regi,in)$(ppfKap(in) OR in_putty(in)) 
+=   ( 1 
+     - (1 - pm_delta_kap(regi,in)) ** (pm_dt(t)/2)
+      )
+     /  pm_delta_kap(regi,in)
+    ;
+
+);
+if ( pm_dt(t) eq (2 * counter.val -1),
+pm_cumDeprecFactor_old(t,regi,in)$(ppfKap(in) OR in_putty(in)) 
+=   ((1 - pm_delta_kap(regi,in)) ** (pm_dt(t)/2 - 0.5)
+      - (1 - pm_delta_kap(regi,in)) ** (pm_dt(t)))
+     /  pm_delta_kap(regi,in)
+    - 1/2 * (1 - pm_delta_kap(regi,in)) ** (pm_dt(t)/2 - 0.5 ) 
+    ;
+
+pm_cumDeprecFactor_new(t,regi,in)$(ppfKap(in) OR in_putty(in)) 
+=   ( 1 
+     - (1 - pm_delta_kap(regi,in)) ** (pm_dt(t)/2 - 0.5 + 1)
+      )
+     /  pm_delta_kap(regi,in)
+    - 1/2 * (1 - pm_delta_kap(regi,in)) ** (pm_dt(t)/2 - 0.5) 
+    ;
+    
+);
+); 
+display "test Deprec", pm_cumDeprecFactor_new,pm_cumDeprecFactor_old;
+
+*** EOF ./modules/01_macro/singleSectorGr/preloop.gms
diff --git a/modules/01_macro/singleSectorGr/realization.gms b/modules/01_macro/singleSectorGr/realization.gms
new file mode 100644
index 0000000000000000000000000000000000000000..bdbf7f8b83ad173a2cc6e3dbf6a353bd26f98ad6
--- /dev/null
+++ b/modules/01_macro/singleSectorGr/realization.gms
@@ -0,0 +1,21 @@
+*** |  (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/01_macro/singleSectorGr.gms
+
+*' @description The singleSectorGr realization corresponds to a neo-classical, single 
+*' sector growth model.
+
+*####################### R SECTION START (PHASES) ##############################
+$Ifi "%phase%" == "sets" $include "./modules/01_macro/singleSectorGr/sets.gms"
+$Ifi "%phase%" == "declarations" $include "./modules/01_macro/singleSectorGr/declarations.gms"
+$Ifi "%phase%" == "datainput" $include "./modules/01_macro/singleSectorGr/datainput.gms"
+$Ifi "%phase%" == "equations" $include "./modules/01_macro/singleSectorGr/equations.gms"
+$Ifi "%phase%" == "preloop" $include "./modules/01_macro/singleSectorGr/preloop.gms"
+$Ifi "%phase%" == "bounds" $include "./modules/01_macro/singleSectorGr/bounds.gms"
+$Ifi "%phase%" == "postsolve" $include "./modules/01_macro/singleSectorGr/postsolve.gms"
+*######################## R SECTION END (PHASES) ###############################
+*** EOF ./modules/01_macro/singleSectorGr.gms
diff --git a/modules/01_macro/singleSectorGr/sets.gms b/modules/01_macro/singleSectorGr/sets.gms
new file mode 100644
index 0000000000000000000000000000000000000000..9d6c1159bfbad2cda52b02c61dc850f450cfc17e
--- /dev/null
+++ b/modules/01_macro/singleSectorGr/sets.gms
@@ -0,0 +1,54 @@
+*** |  (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/01_macro/singleSectorGr/sets.gms
+
+Sets
+
+cesOut2cesIn(all_in,all_in)           "CES tree structure"
+/
+  inco  . (lab, kap, en)
+/
+
+cesLevel2cesIO(counter,all_in)        "CES tree structure by level"
+cesRev2cesIO(counter,all_in)          "CES tree structure by level - descending order"
+cesOut2cesIn_below(all_in,all_in)     "All elements of the CES below located below the first item given"
+in_below_putty(all_in)                "All elements of the CES below ppf_putty, excluding ppf_putty. Only meaningful in case putty structures are not intertwined"
+
+
+in(all_in)                            "All inputs and outputs of the CES function"
+/
+  inco                                "Macroeconomic output"  
+  lab                                 "Labour input"
+  kap                                 "Capital input"
+  en                                  "Energy input"
+/
+ppf(all_in)                           "All primary production factors"
+ipf(all_in)                           "All intermediate production factors"
+ppfKap(all_in)                        "Primary production factors capital"   / kap /
+ppfEn(all_in)                         "Primary production factors energy" 
+in_putty(all_in)                      "Production factors subject to putty-clay dynamics"
+ppf_putty(all_in)                     "All putty-clay primary production factors"
+ipf_putty(all_in)                     "All putty-clay intermediate production factors"
+ppfIO_putty(all_in)                   "Factors treated in the normal CES as ppf and in putty-clay as output"
+nests_putty(all_in,all_in)            "Defines factors which are in the same putty subnest. The first all_in gives the higher factors of the subnest"
+in_enerSerAdj(all_in)                 "Energy services factors which should be constrained by adjustment costs" //
+in_complements(all_in)                "Factors which are perfect complements"  //
+complements_ref(all_in,all_in)        "Correspondence between complementary factors. Necessary to have a reference factor for the constraints equations"
+;
+
+
+
+in_putty(all_in)    = NO;   
+ppf_putty(all_in)   = NO; 
+ipf_putty(all_in)   = NO; 
+ppfIO_putty(all_in) = NO;  
+
+alias(cesOut2cesIn,cesOut2cesIn2);
+alias(in,out);
+alias(in,in2,in3);
+alias(ipf,ipf2);
+*** EOF ./modules/01_macro/singleSectorGr/sets.gms
\ No newline at end of file
diff --git a/modules/02_welfare/utilitarian/declarations.gms b/modules/02_welfare/utilitarian/declarations.gms
index 49d34a3bc9578743a8e7532b929f133da9daab42..81d70500effb6918f9958b13a12c142f4e85ebc6 100644
--- a/modules/02_welfare/utilitarian/declarations.gms
+++ b/modules/02_welfare/utilitarian/declarations.gms
@@ -29,7 +29,6 @@ vm_welfareGlob                                    "Global welfare"
 $ifthen.inconv %cm_INCONV_PENALTY% == "on" 
 v02_inconvPen(ttot,all_regi)                      "Inconvenience penalty in the welfare function, e.g. for air pollution. Unit: ?Utils?"
 v02_inconvPenCoalSolids(ttot,all_regi)            "Inconvenience penalty in the welfare function, e.g. for air pollution. Unit: ?Utils?"
-v02_inconvPenCoalSolids(ttot,all_regi)            "Inconvenience penalty in the welfare function, e.g. for air pollution. Unit: ?Utils?"
 v02_sesoInconvPenSlack(ttot,all_regi)             "Slack to avoid negative inconvenience penalty for Coal Solids" 
 $endif.inconv
 ;
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/not_used.txt b/modules/20_growth/exogenous/not_used.txt
index 32376a1f99c45422b9cdd7db51caf8ef192e9590..5e3f56f027faa08a22fa53692a2f837305704a3e 100644
--- a/modules/20_growth/exogenous/not_used.txt
+++ b/modules/20_growth/exogenous/not_used.txt
@@ -11,3 +11,4 @@ pm_ttot_val, parameter, ???
 pm_ts, parameter, ???
 cm_startyear, switch, ???
 pm_cumEff, parameter, ???
+vm_invRD,input,questionnaire
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/24_trade/module.gms b/modules/24_trade/module.gms
new file mode 100644
index 0000000000000000000000000000000000000000..65525cc2f90414d3e283743a011a8c163ecf54cf
--- /dev/null
+++ b/modules/24_trade/module.gms
@@ -0,0 +1,14 @@
+*** |  (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/24_trade/module.gms
+*' @title Trade module
+*'
+*' @description This file loads the trade module realization.
+*###################### R SECTION START (MODULETYPES) ##########################
+$Ifi "%trade%" == "standard" $include "./modules/24_trade/standard/realization.gms"
+*###################### R SECTION END (MODULETYPES) ############################
+*** EOF ./modules/24_trade/module.gms
diff --git a/modules/24_trade/standard/bounds.gms b/modules/24_trade/standard/bounds.gms
new file mode 100644
index 0000000000000000000000000000000000000000..2f31953cac48ccd2a51712643253d33cd8048fa5
--- /dev/null
+++ b/modules/24_trade/standard/bounds.gms
@@ -0,0 +1,105 @@
+*** |  (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/24_trade/standard/bounds.gms
+
+*** set Mport and Xport positive
+vm_Mport.lo(ttot,regi,tradePe)$(ttot.val ge 2005) = 0;
+vm_Xport.lo(ttot,regi,tradePe)$(ttot.val ge 2005) = 0;
+
+
+
+*** -----------------------------------------------------------
+*** no permit trade allowed in BAU and tax scenarios:
+*** -----------------------------------------------------------
+if (cm_emiscen = 1 or cm_emiscen = 9,
+   vm_Xport.fx(t,regi,"perm") = 0;
+   vm_Mport.fx(t,regi,"perm") = 0;
+else
+   vm_Xport.fx("2005",regi,"perm") = 0;
+   vm_Mport.fx("2005",regi,"perm") = 0;
+   vm_Xport.fx("2010",regi,"perm") = 0;
+   vm_Mport.fx("2010",regi,"perm") = 0;
+);
+
+
+
+
+*NB*110625 fix 2005 trade values to historic values
+*RR*Added correction factor to match fossil supply and internal region energy demand in the initial year if necessary
+*SB*190514 Made the correction factor for insufficient imports conditional on the fossil module realization
+
+*** Mports fixing for fossils in the initial year 
+loop( regi,
+    loop (enty$peFos(enty),
+*** if imports minus exports is higher than initial year demand there is a surplus of pe in the region. Correction -> set imports to 80% of the region pe demand plus Xports in the initial year
+        if ( (pm_EN_demand_from_initialcap2(regi,enty) < (1-pm_costsPEtradeMp(regi,enty))*pm_IO_trade("2005",regi,enty,"Mport") -  pm_IO_trade("2005",regi,enty,"Xport")),     !!region has more available pe through trade than it needs
+            p24_Mport2005correct(regi,enty) = (pm_EN_demand_from_initialcap2(regi,enty) + pm_IO_trade("2005",regi,enty,"Xport")) - pm_IO_trade("2005",regi,enty,"Mport");
+        );
+*** if internal region production (plus trade) is not enough to provide the energy demand. Correction ->  set imports to the difference between region energy demand (pm_EN_demand_from_initialcap2) and the internal production (pm_ffPolyCumEx(regi,enty,"max")) plus the trade balance (Mports-Xports) 
+$iftheni.fossil_realization %cfg$gms$fossil% == "timeDepGrades"
+        if ( pm_prodIni(regi,enty) + (1-pm_costsPEtradeMp(regi,enty))*(pm_IO_trade("2005",regi,enty,"Mport")+ p24_Mport2005correct(regi,enty)) -  pm_IO_trade("2005",regi,enty,"Xport") < pm_EN_demand_from_initialcap2(regi,enty),     !!region has a unbalance
+            p24_Mport2005correct(regi,enty) = pm_EN_demand_from_initialcap2(regi,enty)  - ((1-pm_costsPEtradeMp(regi,enty))*pm_IO_trade("2005",regi,enty,"Mport") -  pm_IO_trade("2005",regi,enty,"Xport")) - pm_prodIni(regi,enty) ;  !! SB: use pm_prodIni as an analog for pm_ffPolyCumEx(regi,enty,"max"), which does not exist in timeDepGrades
+        );
+$elseifi.fossil_realization %cfg$gms$fossil% == "grades2poly"
+        if ( (pm_ffPolyCumEx(regi,enty,"max") / (5*4)) + (1-pm_costsPEtradeMp(regi,enty))*(pm_IO_trade("2005",regi,enty,"Mport")+ p24_Mport2005correct(regi,enty)) -  pm_IO_trade("2005",regi,enty,"Xport") < pm_EN_demand_from_initialcap2(regi,enty),     !!region has a unbalance
+            p24_Mport2005correct(regi,enty) = pm_EN_demand_from_initialcap2(regi,enty)  - ((1-pm_costsPEtradeMp(regi,enty))*pm_IO_trade("2005",regi,enty,"Mport") -  pm_IO_trade("2005",regi,enty,"Xport")) - pm_ffPolyCumEx(regi,enty,"max") / (5*4) ;  !!pm_ffPolyCumEx(regi,enty,"max") is a 5 years value, so we dived by 5 to get the annual value and additionally we assume that if all the extraction is made in the first years, this would take a t least 4 time steps to completely exhaust the resources 
+        );
+$endif.fossil_realization
+    );
+);
+vm_Mport.fx(t0(tall),regi,peFos(enty)) = pm_IO_trade(t0,regi,enty,"Mport") + p24_Mport2005correct(regi,enty);
+
+*** Xports fixing for fossils in the initial year (with added exports to compensate for the Mports corrections above)
+loop( regi,
+    loop (enty$peFos(enty),
+        if ( (p24_Mport2005correct(regi,enty) = 0),
+            vm_Xport.fx(t0(tall),regi,peFos(enty)) = pm_IO_trade(t0,regi,enty,"Xport") +
+                   ( pm_IO_trade(t0,regi,enty,"Xport") / sum((regi2)$(NOT (p24_Mport2005correct(regi,enty))),pm_IO_trade(t0,regi2,enty,"Xport")) ) !! share of region Xports between regions with no balance problems
+                   * sum((regi2),p24_Mport2005correct(regi2,enty)) !! total unbalance problem
+            ;
+        else
+            vm_Xport.fx(t0(tall),regi,peFos(enty)) = pm_IO_trade(t0,regi,enty,"Xport") ;
+        );
+    );
+); 
+
+*** if region has no internal resources, demand must be entirely provided by trade (Switzerland problem). Correction ->  set imports free, exports zero. Warning: if the region is big enough this could cause a trade unbalance. The first best solution would be to calculate the exact imports amount needed and add extra exports to other countries to compensate for this exact amount.
+loop( regi,
+    loop (enty$peFos(enty),
+$iftheni.timeDepGrades %cfg$gms$fossil% == "timeDepGrades"
+        if ( (pm_fuelex_cum("2005",regi,enty,1) = 0),
+            vm_Xport.fx(t0(tall),regi,peFos(enty)) = 0;
+            vm_Mport.up(t0(tall),regi,peFos(enty)) = 1e10;
+            vm_Mport.lo(t0(tall),regi,peFos(enty)) = 1e-6;
+        );
+$elseifi.timeDepGrades %cfg$gms$fossil% == "grades2poly"
+        if ( (pm_ffPolyCumEx(regi,enty,"max") = 0),
+            vm_Xport.fx(t0(tall),regi,peFos(enty)) = 0;
+            vm_Mport.up(t0(tall),regi,peFos(enty)) = 1e10;
+            vm_Mport.lo(t0(tall),regi,peFos(enty)) = 1e-6;
+        );
+$endif.timeDepGrades
+    );
+);
+
+*** bounds on oil exports in 2010 and 2015
+vm_Xport.lo("2010",regi,"peoil") = 0.95 * pm_IO_trade("2010",regi,"peoil","Xport");
+vm_Xport.up("2010",regi,"peoil") = 1.05 * pm_IO_trade("2010",regi,"peoil","Xport");
+vm_Xport.lo("2015",regi,"peoil") = 0.95 * pm_IO_trade("2015",regi,"peoil","Xport");
+vm_Xport.up("2015",regi,"peoil") = 1.05 * pm_IO_trade("2015",regi,"peoil","Xport");
+
+*** upper bounds ( 1% yearly growth rate) on all big oil exporters (more than 15EJ in 2010) in 2020, 2025 and 2030
+loop(regi,
+      if( (pm_IO_trade("2010",regi,"peoil","Xport") ge (15*sm_EJ_2_TWa)),
+        vm_Xport.up("2020",regi,"peoil") = ((1 + 0.02) **  10) * pm_IO_trade("2010",regi,"peoil","Xport");
+        vm_Xport.up("2025",regi,"peoil") = ((1 + 0.02) **  15) * pm_IO_trade("2010",regi,"peoil","Xport");
+        vm_Xport.up("2030",regi,"peoil") = ((1 + 0.02) **  20) * pm_IO_trade("2010",regi,"peoil","Xport");
+      );
+);
+
+
+*** EOF ./modules/24_trade/standard/bounds.gms
\ No newline at end of file
diff --git a/modules/24_trade/standard/datainput.gms b/modules/24_trade/standard/datainput.gms
new file mode 100644
index 0000000000000000000000000000000000000000..ede5a82b33a7ac1b49ac33c1280c71308bcbc082
--- /dev/null
+++ b/modules/24_trade/standard/datainput.gms
@@ -0,0 +1,42 @@
+*** |  (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/24_trade/standard/datainput.gms
+
+
+pm_Xport0("2005",regi,peFos) = 0;
+
+*ML* Reintroduction of trade cost for composite good (based on export/import value difference for non-energy goods in GTAP6)
+pm_tradecostgood(regi)        = 0.03;
+
+*** load data on transportation costs of imports
+parameter pm_costsPEtradeMp(all_regi,all_enty)                   "PE tradecosts (energy losses on import)"
+/
+$ondelim
+$include "./modules/24_trade/standard/input/pm_costsPEtradeMp.cs4r"
+$offdelim
+/
+;
+
+
+table pm_costsTradePeFinancial(all_regi,char,all_enty)          "PE tradecosts (financial costs on import, export and use)"
+$ondelim
+$include "./modules/24_trade/standard/input/pm_costsTradePeFinancial.cs3r"
+$offdelim
+;
+pm_costsTradePeFinancial(regi,"XportElasticity", tradePe(enty)) = 100;
+pm_costsTradePeFinancial(regi, "tradeFloor", tradePe(enty))     = 0.0125;
+
+*DK* Only for SSP cases other than SSP2: use default trade costs
+if(cm_tradecost_bio = 1,
+pm_costsTradePeFinancial(regi,"Xport", "pebiolc") = pm_costsTradePeFinancial(regi,"Xport", "pebiolc")/2;
+);
+
+pm_costsTradePeFinancial(regi,"Xport", "pegas") = cm_trdcst * pm_costsTradePeFinancial(regi,"Xport", "pegas") ;
+pm_costsTradePeFinancial(regi,"XportElasticity","pegas") = cm_trdadj *pm_costsTradePeFinancial(regi,"XportElasticity","pegas");
+
+
+*** EOF ./modules/24_trade/standard/datainput.gms
\ No newline at end of file
diff --git a/modules/24_trade/standard/declarations.gms b/modules/24_trade/standard/declarations.gms
new file mode 100644
index 0000000000000000000000000000000000000000..5be62a91c5c302d9f6519912c2c88de7cf9e14e4
--- /dev/null
+++ b/modules/24_trade/standard/declarations.gms
@@ -0,0 +1,24 @@
+*** |  (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/24_trade/standard/declarations.gms
+***-------------------------------------------------------------------------------
+***                                   PARAMETERS
+***-------------------------------------------------------------------------------
+parameters
+pm_tradecostgood(all_regi)                  "Trade costs (final good)."
+pm_Xport0(tall,all_regi,all_enty)           "Reference level value of export." 
+pm_IO_trade(tall,all_regi,all_enty,char)    "Energy trade bounds based on IEA data."
+p24_Mport2005correct(all_regi,all_enty)     "Correction factor to match fossil supply and internal region energy demand in the initial year"
+;
+***-------------------------------------------------------------------------------
+***                                   VARIABLES
+***-------------------------------------------------------------------------------
+positive VARIABLES
+vm_Xport(tall,all_regi,all_enty)            "Export of traded commodity."
+vm_Mport(tall,all_regi,all_enty)            "Import of traded commodity."
+;
+*** EOF ./modules/24_trade/standard/declarations.gms
\ No newline at end of file
diff --git a/modules/24_trade/standard/input/files b/modules/24_trade/standard/input/files
new file mode 100644
index 0000000000000000000000000000000000000000..a13305f84dbee860d7445ecc464a1f3e6af3e373
--- /dev/null
+++ b/modules/24_trade/standard/input/files
@@ -0,0 +1,2 @@
+pm_costsPEtradeMp.cs4r
+pm_costsTradePeFinancial.cs3r
diff --git a/modules/24_trade/standard/postsolve.gms b/modules/24_trade/standard/postsolve.gms
new file mode 100644
index 0000000000000000000000000000000000000000..633e1ab68cec709a82b02b36e3d621fc1326d07e
--- /dev/null
+++ b/modules/24_trade/standard/postsolve.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/24_trade/standard/postsolve.gms
+
+pm_Xport0(ttot,regi,tradePe) = vm_Xport.l(ttot,regi,tradePe);
+
+*** EOF ./modules/24_trade/standard/postsolve.gms
\ No newline at end of file
diff --git a/modules/24_trade/standard/presolve.gms b/modules/24_trade/standard/presolve.gms
new file mode 100644
index 0000000000000000000000000000000000000000..14642b68d6f11a250c9dbe0a1cc851c491693d5a
--- /dev/null
+++ b/modules/24_trade/standard/presolve.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/24_trade/standard/presolve.gms
+
+pm_Xport0(ttot,regi,tradePe) = vm_Xport.l(ttot,regi,tradePe);
+
+*** EOF ./modules/24_trade/standard/presolve.gms
\ No newline at end of file
diff --git a/modules/24_trade/standard/realization.gms b/modules/24_trade/standard/realization.gms
new file mode 100644
index 0000000000000000000000000000000000000000..9b7a712f6fd5c024e7f102661706b5785e4a6209
--- /dev/null
+++ b/modules/24_trade/standard/realization.gms
@@ -0,0 +1,17 @@
+*** |  (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/24_trade/realization.gms
+
+*####################### R SECTION START (PHASES) ##############################
+$Ifi "%phase%" == "sets" $include "./modules/24_trade/standard/sets.gms"
+$Ifi "%phase%" == "declarations" $include "./modules/24_trade/standard/declarations.gms"
+$Ifi "%phase%" == "datainput" $include "./modules/24_trade/standard/datainput.gms"
+$Ifi "%phase%" == "bounds" $include "./modules/24_trade/standard/bounds.gms"
+$Ifi "%phase%" == "presolve" $include "./modules/24_trade/standard/presolve.gms"
+$Ifi "%phase%" == "postsolve" $include "./modules/24_trade/standard/postsolve.gms"
+*######################## R SECTION END (PHASES) ###############################
+*** EOF ./modules/24_trade/realization.gms
diff --git a/modules/24_trade/standard/sets.gms b/modules/24_trade/standard/sets.gms
new file mode 100644
index 0000000000000000000000000000000000000000..e89929f255e3e789188ff5ff49d2190a3f3202a3
--- /dev/null
+++ b/modules/24_trade/standard/sets.gms
@@ -0,0 +1,35 @@
+*** |  (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/24_trade/standard/sets.gms
+
+sets
+trade(all_enty)             "All traded commodities"
+/
+/
+
+tradeMacro(all_enty)        "Traded macro-economic commodities"
+/
+    good, 
+    perm
+/
+
+tradePe(all_enty)           "Traded primary energy commodities"
+/
+    peoil, 
+    pecoal, 
+    pegas, 
+    peur, 
+    pebiolc
+/
+
+tradeSe(all_enty)           "Traded secondary energy commodities"
+/
+    null
+/
+;
+
+*** EOF ./modules/24_trade/standard/sets.gms
\ No newline at end of file
diff --git a/modules/29_CES_parameters/calibrate/realization.gms b/modules/29_CES_parameters/calibrate/realization.gms
index d29f587cff862b7dcb911084243697464b92c16b..b332924b223215af929daa715dd6bd69f61d5b51 100644
--- a/modules/29_CES_parameters/calibrate/realization.gms
+++ b/modules/29_CES_parameters/calibrate/realization.gms
@@ -197,7 +197,7 @@
 *'
 *'To implement perfectly complementary factors, you should include the factors in the set `in_complements`. In addition, the elasticity of substitution between these factors should be set to `INF` (which is counter-intuitive). Prices of complementary inputs are set to 1, so that the output is equal to the sum of inputs (reason why the substitution elasticity should be INF), which makes sense for energetic entities. It would however be possible to change this (by choosing another elasticity of substitution) without harming the calibration.
 *'
-*'In the model, the complementary factors are subject to a constraint (`q_prodCompl` or `q_prodCompl_putty`), so that each variable is computed by multiplying a key variable of the CES function by a given factor. The calibration computes this factor for each period.
+*'In the model, the complementary factors are subject to a constraint (`q01_prodCompl` or `q01_prodCompl_putty`), so that each variable is computed by multiplying a key variable of the CES function by a given factor. The calibration computes this factor for each period.
 *'
 *'#### Setup
 *'
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/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/nash/declarations.gms b/modules/80_optimization/nash/declarations.gms
index c8cf637184c995e48ea7ff41b26f25c779e26499..72ca65af7c8a74c51803b7b9e48c683108417f10 100644
--- a/modules/80_optimization/nash/declarations.gms
+++ b/modules/80_optimization/nash/declarations.gms
@@ -79,6 +79,10 @@ p80_SolNonOpt(all_regi)                    "solve status"
 pm_fuExtrForeign(ttot,all_regi,all_enty,rlf) "foreign fuel extraction"
 ;
 
+positive variable
+*AJS* Adjustment costs for Nash trade algorithm.  Only non-zero in the Nash_test realization of 80_optimization module.
+vm_costAdjNash(ttot,all_regi)               "Adjustment costs for deviation from the trade structure of the last iteration." 
+;
 
 equations
 q80_budg_intertemp(all_regi)               "interemporal trade balance (Nash mode only)"
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/declarations.gms b/modules/80_optimization/negishi/declarations.gms
index 1fe0b0dfd7539eaf4cce03df7712221c21d26332..34270569be7f74e8000323e607bceeddda3a558d 100644
--- a/modules/80_optimization/negishi/declarations.gms
+++ b/modules/80_optimization/negishi/declarations.gms
@@ -23,6 +23,11 @@ pm_cumEff(tall,all_regi,all_in)          "parameter for spillover externality (a
 pm_fuExtrForeign(ttot,all_regi,all_enty,rlf) "foreign fuel extraction"
 ;
 
+positive variable
+*AJS* Adjustment costs for Nash trade algorithm.  Only non-zero in the Nash_test realization of 80_optimization module.
+vm_costAdjNash(ttot,all_regi)               "Adjustment costs for deviation from the trade structure of the last iteration." 
+;
+
 equations
 q80_balTrade(ttot,all_enty)              "trade balance equation"
 q80_budget_helper(ttot,all_regi)         "Helper declaration for import from gdx"
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/declarations.gms b/modules/80_optimization/testOneRegi/declarations.gms
index 926068c18fa41e1875fd7c07caf22c0221e841a1..a50a35efdf79e00813509ed11bb10f5e06aa7430 100644
--- a/modules/80_optimization/testOneRegi/declarations.gms
+++ b/modules/80_optimization/testOneRegi/declarations.gms
@@ -16,6 +16,11 @@ pm_cumEff(tall,all_regi,all_in)                     "parameter for spillover ext
 pm_fuExtrForeign(ttot,all_regi,all_enty,rlf)        "foreign fuel extraction"
 ;
 
+positive variable
+*AJS* Adjustment costs for Nash trade algorithm.  Only non-zero in the Nash_test realization of 80_optimization module.
+vm_costAdjNash(ttot,all_regi)               "Adjustment costs for deviation from the trade structure of the last iteration." 
+;
+
 equations
 q80_budg_intertemp(all_regi)                        "interemporal trade balance (Nash mode only)"
 q80_costAdjNash(ttot,all_regi)                      "plays a dummy role for now, allowing fixing to Nash GDX files"
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/modules/include.gms b/modules/include.gms
index a8b8e01c987e76da5314bf6283f2dbf72105e5fb..36718534b4d0953b69654a6f5d783bab3459c3c9 100644
--- a/modules/include.gms
+++ b/modules/include.gms
@@ -9,6 +9,7 @@
 $setglobal phase %1
 
 *######################## R SECTION START (MODULES) ############################
+$include "./modules/01_macro/module.gms"
 $include "./modules/02_welfare/module.gms"
 $include "./modules/04_PE_FE_parameters/module.gms"
 $include "./modules/05_initialCap/module.gms"
@@ -19,6 +20,7 @@ $include "./modules/20_growth/module.gms"
 $include "./modules/21_tax/module.gms"
 $include "./modules/22_subsidizeLearning/module.gms"
 $include "./modules/23_capitalMarket/module.gms"
+$include "./modules/24_trade/module.gms"
 $include "./modules/26_agCosts/module.gms"
 $include "./modules/29_CES_parameters/module.gms"
 $include "./modules/30_biomass/module.gms"
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/utils/gdx_rename.sh b/scripts/utils/gdx_rename.sh
index 7f7f2411b48c434392ac49e849f3465cd0792c9a..728cf5a12c401c09becab5ea9ffcf19a5a9e15e1 100644
--- a/scripts/utils/gdx_rename.sh
+++ b/scripts/utils/gdx_rename.sh
@@ -85,7 +85,7 @@ if (length(args) == 1) {
     p_nw                   = 'p80_nw',
     c_nucscen              = 'cm_nucscen',
     q_co2eq                = 'q_co2eq',
-    pm_costsPEtradeMp      = 'p_costsPEtradeMp', 
+    pm_costsPEtradeMp      = 'pm_costsPEtradeMp', 
     vm_welfare             = 'v_welfare',
     pm_tau_fe_sub          = 'p21_tau_fe_sub', 
     pm_tau_fe_tax          = 'p21_tau_fe_tax',
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 0422399b3d6c91fb9a22bc2ac8c0fe061921ae9c..fa53981532169345adb0456965de2bfcfc45868c 100644
--- a/standalone/MOFEX/MOFEX.gms
+++ b/standalone/MOFEX/MOFEX.gms
@@ -131,8 +131,8 @@ cm_CCS_steel         "CCS for steel sub-sector"
 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"
-c_tradecost_bio       "choose financal tradecosts for biomass (purpose grown pebiolc)"
-c_1stgen_phaseout    "choose if 1st generation biofuels should phase out after 2030 (vm_deltaCap=0)"
+cm_tradecost_bio       "choose financal tradecosts for biomass (purpose grown pebiolc)"
+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"
@@ -170,7 +170,7 @@ c_abtrdy              "first year in which advanced bio-energy technology are re
 c_abtcst              "scaling of the cost of advanced bio-energy technologies (no unit, 50% increase means 1.5)"
 c_budgetCO2        "carbon budget for all CO2 emissions (in GtCO2)"
 
-c_trdcst              "parameter to scale trade export cost for gas"
+cm_trdcst              "parameter to scale trade export cost for gas"
 cm_trdadj              "parameter scale the adjustment cost parameter for increasing gas trade export"
 
 c_refcapbnd           "switch for fixing refinery capacities to the SSP2 levels in 2010 (if equal zero then no fixing)"
@@ -217,9 +217,9 @@ cm_CCS_steel           = 1;        !! def = 1
 
 cm_bioenergy_tax    = 1.5;       !! def = 1.5
 cm_bioenergymaxscen = 0;         !! def = 0
-c_tradecost_bio     = 2;         !! def = 2
+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
@@ -271,7 +271,7 @@ c_budgetCO2              = 0;   !! def = 1300
 $setGlobal cm_regiCO2target  off     !! def = off
 
 cm_trdadj            = 2;    !! def = 2.0
-c_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
@@ -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 598d8baf2ac589c84bf13ca48aad2ea4d7c09177..737ce60da022ee181081b4d18775813ab2aba74d 100644
--- a/standalone/template.gms
+++ b/standalone/template.gms
@@ -139,8 +139,8 @@ cm_CCS_steel         "CCS for steel sub-sector"
 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"
-c_tradecost_bio       "choose financal tradecosts for biomass (purpose grown pebiolc)"
-c_1stgen_phaseout    "choose if 1st generation biofuels should phase out after 2030 (vm_deltaCap=0)"
+cm_tradecost_bio       "choose financal tradecosts for biomass (purpose grown pebiolc)"
+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"
@@ -178,7 +178,7 @@ c_abtrdy              "first year in which advanced bio-energy technology are re
 c_abtcst              "scaling of the cost of advanced bio-energy technologies (no unit, 50% increase means 1.5)"
 c_budgetCO2        "carbon budget for all CO2 emissions (in GtCO2)"
 
-c_trdcst              "parameter to scale trade export cost for gas"
+cm_trdcst              "parameter to scale trade export cost for gas"
 cm_trdadj              "parameter scale the adjustment cost parameter for increasing gas trade export"
 
 c_refcapbnd           "switch for fixing refinery capacities to the SSP2 levels in 2010 (if equal zero then no fixing)"
@@ -225,9 +225,9 @@ cm_CCS_steel           = 1;        !! def = 1
 
 cm_bioenergy_tax    = 1.5;       !! def = 1.5
 cm_bioenergymaxscen = 0;         !! def = 0
-c_tradecost_bio     = 2;         !! def = 2
+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
@@ -279,7 +279,7 @@ c_budgetCO2              = 1350;   !! def = 1300
 $setGlobal cm_regiCO2target  off     !! def = off
 
 cm_trdadj            = 2;    !! def = 2.0
-c_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
@@ -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")
diff --git a/tutorials/2_RunningREMIND.md b/tutorials/2_RunningREMIND.md
index 7f0150565b9bdb5e6974ea767d9706a99901feb7..e5e251c6e179fc9256ef95b73c8e6532f1e8310f 100644
--- a/tutorials/2_RunningREMIND.md
+++ b/tutorials/2_RunningREMIND.md
@@ -16,7 +16,8 @@ Felix Schreyer (<felix.schreyeru@pik-potsdam.de>), Lavinia Baumstark (<baumstark
 
 1. Your first run
 ==================
-   	
+   
+
 This section will explain how you start your first run in REMIND.
 
 Default Configurations (config/default.cfg)
@@ -28,7 +29,7 @@ a. The first part, MODULES, contains the various modules used in REMIND and vari
 
 ``` bash
 cfg$gms$<module name
-``` 
+```
 
 b. The SWITCHES and FLAGS section are various settings to control, for e.g., how many iterations to run, which technologies to run, which SSP to use, start and end year of model run etc. See the fourth section, explanations of switches and flags, to know more. 
 
@@ -47,7 +48,7 @@ Your config file should look like this:
 <p class="caption">
 Example for a scenario_config of REMIND
 </p>
-	
+
 Save the config file as a csv file with `;` as delimiter. You can check that, for example, by opening the csv in a text editor. If the delimiter is not `;`, change it in Windows under ***Control Panel*** ->  ***Region***  -> ***Additional Settings*** -> ***List separator***. 
 
 To finally start REMIND with this config file, you need to run the R-script ***start_bundle.R*** on the cluster on this config file. For this:
@@ -67,7 +68,7 @@ For starting one single or a bundle of runs via scenario_config.csv you use the
 
 ``` r
 nohup Rscript start_bundle.R config/scenario_config.csv &
-```		
+```
 Now, keep your fingers crossed that everything works as it should.The process of your job submission is documented in the file nohup.out that you created with the nohup command. After a couple of minutes, you should see something like `Submitted Batch Job ...` in the nohup.out file. This means that your run has been started. To see how far your run is or whether it was stopped due to some problems, go to the `Output` folder and type 
 
 ``` bash
@@ -97,13 +98,14 @@ in the terminal.
 2. What happens during a REMIND run?
 =====================================
 	
+
 This section will give some technical introduction into what happens after you have started a run. It will not be a tutorial, but rather an explanation of the different parts in the modeling routine. The whole routine is illustrated in Figure 1. The core of the model is the optimization written in GAMS. However, there is some pre-processing of the input data and some post-processing of the output data using R scripts.
 
 <img src="figures/REMIND_flow.png" alt="REMIND modeling routine" width="100%" />
 <p class="caption">
 REMIND modeling routine
 </p>
-	
+​	
 
 3. What happens once you start REMIND on the Cluster? 
 =======================================================
@@ -117,8 +119,8 @@ The optimization in REMIND requires a lot of input data. For example, the model
 ``` bash
 /p/projects/rd3mod/inputdata/sources.
 ```
-		
-The data are mostly in csv files. During the input data preparation, these files are read and processed, using functions from the *moinput* library. Input data are available on country-level. Then, depending on the regionmapping file you chose in the config file of your run, the country-level data are aggregated into regions, e.g. to LAM (Latin America), EUR (Europe) and so on. Finally, the data are stored as .cs3r or .cs4r files in various input folders of your REMIND directory. These files are basically tables, too, that you can open with a text editor or Excel. For example, you find the input file `p_histCap.cs3r` in your REMIND directory under `core/input`. It provides the model with historically observed values of installed capacities of some technologies in the respective regions. 
+
+The data are mostly in csv files. During the input data preparation, these files are read and processed, using functions from the *moinput* package. Input data are available on country-level. Then, depending on the regionmapping file you chose in the config file of your run, the country-level data are aggregated into regions, e.g. to LAM (Latin America), EUR (Europe) and so on. Finally, the data are stored as .cs3r or .cs4r files in various input folders of your REMIND directory. These files are basically tables, too, that you can open with a text editor or Excel. For example, you find the input file `p_histCap.cs3r` in your REMIND directory under `core/input`. It provides the model with historically observed values of installed capacities of some technologies in the respective regions. 
 The regional resolution of the run is set in the config/default.cfg by 
 ``` bash
 cfg$regionmapping
@@ -135,7 +137,7 @@ The actual REMIND is written in GAMS, a programming software to numerically solv
 		 
 c) Output Processing
 ----------------------
-The output processing works with a number of R functions from the **remind** library (most of them start with `report... .R`). The wrapper function **convGDX2MIF.R** writes the most relevant output into the so-called **.mif** file. Again, it is a table that you can open in Excel for example. You find under `output` in the folder of your REMIND run as 
+The output processing works with a number of R functions from the **remind** package (most of them start with `report... .R`). The wrapper function **convGDX2MIF.R** writes the most relevant output into the so-called **.mif** file. Again, it is a table that you can open in Excel for example. You find under `output` in the folder of your REMIND run as 
 
 ``` bash
 REMIND_generic_YourRun.mif
diff --git a/tutorials/5_AnalysingModelOutputs.md b/tutorials/5_AnalysingModelOutputs.md
index 1940ce2a697e159e52d5980e7c42b93ae51fb649..4790c82a26f32af36523adad9844d995367289de 100755
--- a/tutorials/5_AnalysingModelOutputs.md
+++ b/tutorials/5_AnalysingModelOutputs.md
@@ -22,23 +22,23 @@ Felix Scheyer (<felix.schreyer@pik-potsdam.de>), Isabelle Weindl (<weindl@pik-po
 1. Introduction
 ===============
 
-After having successfully started and accomplished a simulation run, the next step is to evaluate the simulation results. 
+After having successfully started and completed a scenario run, the next step is to evaluate the results. 
 
 There are plentiful ways to look at and analyze REMIND results. This tutorial gives an overview on different tools and options that can be used.
 
-For each simulation, results are written to a folder that is created automatically as a combination of **model title** name and the **current date** inside the **output** folder of the model.
+For each scenario, results are written to a folder that is created automatically as a combination of **scenario title** name and the **current date** inside the **output** folder of the model.
 
 2. Model output files
 =====================
 
-As mentioned in section 2, the two main output files you will typically care about are the *fulldata.gdx* and the *REMIND_generic_NameofYourRun.mif* files in the *output* folder of your run. The *fulldata.gdx* is the actual technical output of the GAMS optimization and contains all the variables, parameters, sets etc. (the differences between these GAMS objects are explained in tutorial 2) of the REMIND model. However, this gdx-file ia mainly interesting once you actually work on the GAMS code and want to check specific the variables and their values. If you simply want to look at REMIND results of your run or use it for further data analysis and plotting, you would open the *REMIND_generic_NameofYourRun.mif* which is basically a csv-file in a certain standardized format used in the Integrated Assessment Modeling community. 
+As mentioned in tutorial 2, the two main output files you will typically care about are the *fulldata.gdx* and the *REMIND_generic_NameofYourRun.mif* files in the *output* folder of your run. The *fulldata.gdx* is the actual technical output of the GAMS optimization and contains all the variables, parameters, sets etc. (the differences between these GAMS objects are explained in tutorial 2) of the REMIND model. However, this gdx-file is mainly interesting once you actually work on the GAMS code and want to check specific the variables and their values. If you simply want to look at REMIND results of your run or use it for further data analysis and plotting, you would open the *REMIND_generic_NameofYourRun.mif* which is basically a csv-file in a certain standardized format used in the Integrated Assessment Modeling community. 
 
-Looking at the *REMIND_generic_NameofYourRun.mif*, the column **scenario** gives the name of the run (that you specified in the first column of your config file when starting the run). The column **region** provides an three-letter acronym of the region (e.g. EUR -> EU, SSA -> Sub-Saharan Africa). The column **variable** represents the variable you are looking at (To avoid confusion with the above: It does not necessarily represent a variable in the GAMS code of REMIND. The mif-file is a synthetized output generated from *fulldata.gdx* by post-processing Rscripts from the *remind* library). Scrolling through the **variable** column, you will get an impression of the myriad of outputs the REMIND model permits you to explore. 
+Looking at the *REMIND_generic_NameofYourRun.mif*, the column **scenario** gives the name of the run (that you specified in the first column of your config file when starting the run). The column **region** provides an three-letter acronym of the region (e.g. EUR -> EU, SSA -> Sub-Saharan Africa). The column **variable** represents the variable you are looking at (To avoid confusion with the above: It does not necessarily represent a variable in the GAMS code of REMIND. The mif-file is a synthetized output generated from *fulldata.gdx* by post-processing Rscripts from the *remind* package). Scrolling through the **variable** column, you will get an impression of the outputs the REMIND model permits you to explore. 
 
 3. Loading and analyzing model output in R
 ==============================
 
-### 3.1 Access Cluster
+### 3.1 Access the Cluster
 
 To analyze your model results, you can load the output of the mif-file into a local session in RStudio. To get the file from the cluster, you can download the mif-file, for example, via WinSCP. You can read more details on how to access the cluster here:
 
@@ -46,9 +46,9 @@ To analyze your model results, you can load the output of the mif-file into a lo
 https://redmine.pik-potsdam.de/projects/mo/wiki/Getting_ready_to_use_the_Cluster
 
 
-### 3.2 Load mif file as Magpie Object
+### 3.2 Load a mif file as a Magpie Object
 
-You can load the mif-file of your run into a magpie object from the **magclass** R library by
+You can load the mif-file of your run into a magpie object from the **magclass** R package by
 
 ``` r
 out <- read.report("Path/to/your/mif-file", as.list = F)
@@ -63,14 +63,14 @@ you see the dimension of the magpie object. Magpie objects are basically arrays,
 ``` r
 out["EUR", c("y2020","y2050"), "FE|Transport (EJ/yr)"]
 ```
-Instead of these objects from the R library **magclass**, you can also use dataframes from the R library **quitte**. Arrays are generally better for doing calculations, while dataframes are better for plotting. You will find out after a while which way works best for you. The **quitte** dataframes are probably better for output analysis because this is a lot about plotting. For reading in the *.mif* file as a dataframe, you have to load the library **quitte** and then run the command
+Instead of these objects from the R package **magclass**, you can also use data frames from the R package **quitte**. Arrays are generally better for doing calculations, while data frames are better for plotting. You will find out after a while which way works best for you. The **quitte** data frames are probably better for output analysis because this is a lot about plotting. For reading in the *.mif* file as a data frame, you have to load the package **quitte** and then run the command
 
-### 3.3 Load mif file as quitte Object	
+### 3.3 Load a mif file as a quitte Object	
 
 ``` r
-mifdata <- read.quitte(PathtoYourMifFile.mif)
+mifdata <- read.quitte('PathtoYourMifFile.mif')
 ```
-The data is now stored in the *quitte* object *mifdata*. In RStudio, selecting it and hitting F2 will show you its content. Usually, you will want to filter for some regions, variables, periods that you are interested in. For example, like this: 
+The data is now stored in the *quitte* object *mifdata*. In RStudio, selecting it (the text *mifdata* in the editor window) and hitting F2 will show you its content. Usually, you will want to filter for some regions, variables, periods that you are interested in. For example, like this: 
 	
 ``` r
 df <- filter(mifdata,
@@ -79,9 +79,9 @@ df <- filter(mifdata,
 			scenario %in% c('BAU'),
 			period %in% c(2005,2030,2050)) 
 ```
-### 3.4 Load gdx file as magpie object
+### 3.4 Load a gdx file as a Magpie Object
 
-Finally, you can also load the content of the **fulldata.gdx** via the function **readGDX** of the **gdx library** (<https://github.com/pik-piam/gdx>) into a magpie file to directly access the GAMS output. Here is an example of how **readGDX** is used:
+Finally, you can also load the content of the **fulldata.gdx** via the function **readGDX** of the **gdx** package  (<https://github.com/pik-piam/gdx>) into a magpie file to directly access the GAMS output. Here is an example of how **readGDX** is used:
 
 ``` r
 pe2se  <- readGDX(gdx,"pe2se")
@@ -105,7 +105,7 @@ The automated model analysis (summary and validation) is an important example of
 For a first overview and for not getting lost in the huge amount of variables you can look at the *REMIND_summary_[title].pdf*. This .pdf-file will give you an overview on the model results and guides you through the story. 
 
 ### 4.3 The Whole Range of Validation
-A standard validation PDF *REMIND_validation_[title].pdf* consists of hundreds of evaluation outputs. By evaluating the model outputs on such a broad level rather than focusing only on key outputs, it allows getting a more complete picture of the corresponding simulation. The table of contents of the validation pdf gives a good overview about the breadth of model outputs that can be simulated with a REMIND standard simulation, even though the validation pdf only shows a subset of possible model outputs.
+A standard validation PDF *REMIND_validation_[title].pdf* consists of hundreds of evaluation outputs. By evaluating the model outputs on such a broad level rather than focusing only on key outputs, it allows getting a more complete picture of the corresponding scenario. The table of contents of the validation pdf gives a good overview about the breadth of model outputs that can be generated with a REMIND standard scenario, even though the validation pdf only shows a subset of possible model outputs.
 
 
 5. Interactive scenario analysis
@@ -115,20 +115,21 @@ The automated model validation is a good tool for visually evaluating a broad ra
 
 ### 5.1. AppResults
 
-To overcome this issue, we developed the interactive scenario analysis and evaluation tools appResults and appResultsLocal as part of the library **shinyresults** (<https://github.com/pik-piam/shinyresults>), which show evaluation plots for multiple scenarios including historical data and other projections based on an interactive selection of regions and variables. You can use this tool by running the following R command, which will automatically collect all runs and visualize them:
+To overcome this issue, we developed the interactive scenario analysis and evaluation tools appResults and appResultsLocal as part of the package **shinyresults** (<https://github.com/pik-piam/shinyresults>), which show evaluation plots for multiple scenarios including historical data and other projections based on an interactive selection of regions and variables. You can use this tool by running the following R command, which will automatically collect all runs and visualize them:
 
 ``` r
 shinyresults::appResults()
 ```
 
-This command opens an interactive window, where you can select the simulations that you want to evaluate.
+This command opens an interactive window, where you can select the scenarios that you want to evaluate.
 
 <img src="figures/appResults_window.png" alt="Interactive Results app" width="70%" />
+
 <p class="caption">
 Interactive Results app
 </p>
 
-You can use filters to select a subset of all runs stored in the output folder of the model, for example by searching for runs that have been finished at a certain day or by searching for keywords in the title of the simulation runs:
+You can use filters to select a subset of all runs stored in the output folder of the model, for example by searching for runs that have been finished at a certain day or by searching for keywords in the title of the scenarios:
 
 <img src="figures/appResults_runselection.png" alt="Run selection by using a filter" width="70%" />
 <p class="caption">
@@ -139,7 +140,7 @@ If you run the following command in the output folder of your local computer you
 ``` r
 shinyresults::appResultsLocal()
 ```
-Another tool for analyzing model output on your local computer is the scneario tool from the mip library. You can open it from the R console by: 
+Another tool for analyzing model output on your local computer is the scenario tool from the mip package. You can open it from the R console by: 
 
 ``` r
 mip::scenTool()
@@ -158,7 +159,7 @@ cfg$output <- c("reporting","validation","rds_report","validationSummary","dashb
 
 ### 6.2. Execution of model-internal output scripts in the command window
 
-Output scripts that are included in the folders **scripts/output/single** and **scripts/output/comparison** can also be executed via command window. To do so, windows users can open a command line prompt in the REMIND model folder by using **shift** + **right click** and then selecting *open command window here* option.
+Output scripts that are included in the folders **scripts/output/single** and **scripts/output/comparison** can also be executed via a command window. To do so, windows users can open a command line prompt in the REMIND model folder by using **shift** + **right click** and then selecting *open command window here* option.
 
 In the command prompt, use the following command:
 
@@ -173,23 +174,23 @@ You are now asked to choose the output mode: 1: Output for single run 2: Compari
 Executing output scripts via command window
 </p>
 
-In both cases, you can choose from the list of available model simulations, for which runs you want to conduct the model output analysis.In the next step, you can interactively indicate which model-internal output scripts you want to execute.
+In both cases, you can choose from the list of available model scenarios, for which runs you want to conduct the model output analysis. In the next step, you can interactively indicate which model-internal output scripts you want to execute.
 
-Now, the selected scripts are executed. After completion, the results are written in the respective folder of the simulation run (combination of **model title** name and the **current date** inside the **output** folder of the model).
+Now, the selected scripts are executed. After completion, the results are written in the respective folder of the run (combination of **model title** name and the **current date** inside the **output** folder of the model).
 
 
-7. Analysis of outputs with the remind library
+7. Analysis of outputs with the remind package
 ===============================================
 
-If you want to go beyond visual output analysis and predefined output evaluation facilitated by scripts in the model folders **scripts/output/single** and **scripts/output/comparison**, you can use the functionality of the R package *remind*. This library contains a list of common functions for extracting outputs from the REMIND model which are also the basis for the generation of the automated validation pdf. For a quick overview on the functions which are included in the library, you can scan the folder **remind/R**. 
+If you want to go beyond visual output analysis and predefined output evaluation facilitated by scripts in the model folders **scripts/output/single** and **scripts/output/comparison**, you can use the functionality of the R package *remind*. This package contains a list of common functions for extracting outputs from the REMIND model which are also the basis for the generation of the automated validation pdf. For a quick overview on the functions which are included in the package, you can scan the folder **remind/R**. 
 
-For making yourself familiar with this library, you can open a R/RStudio session and set the REMIND model folder as working directory. This can be done by using the following command:
+For making yourself familiar with this package, you can open a R/RStudio session and set the REMIND model folder as working directory. This can be done by using the following command:
 
 ``` r
 setwd("/path/to/your/remind/model/folder")
 ```
 
-Then, load the library and call the help pages:
+Then, load the package and call the help pages:
 
 ``` r
 library(remind)
diff --git a/tutorials/6_Advanced_ChangeInputs.md b/tutorials/6_Advanced_ChangeInputs.md
index 9c40f9530c64292afa2ac3ef3b0f9c4e6def8d10..fa83939142e305ce1f503e7714cbfea1e165a2eb 100644
--- a/tutorials/6_Advanced_ChangeInputs.md
+++ b/tutorials/6_Advanced_ChangeInputs.md
@@ -36,11 +36,11 @@ ssh-keygen -p
 ```
 It is recommended to first copy the existing key (e.g. id_dsa into id_dsa-local) and remove the passphrase of this copy and copy it to your machine.
 
-If you plan to run REMIND not with the default regional resolution you have to take care that REMIND starts from a gdx with the correct regional resolution. Either you can use one from an older run with the corresponding regional resolution or you can construct a new gdx with the correct regional resolution from a gdx in a different regional resolution by using the function gdx_rename from the library(gdx) (e.g. gdx_rename("input.gdx",set_name="all_regi",c(REF="RUS",CAZ="ROW",...,MEA="MEA",USA="USA"))).
+If you plan to run REMIND not with the default regional resolution you have to take care that REMIND starts from a gdx with the correct regional resolution. Either you can use one from an older run with the corresponding regional resolution or you can construct a new gdx with the correct regional resolution from a gdx in a different regional resolution by using the function gdx_rename from the package (gdx) (e.g. gdx_rename("input.gdx",set_name="all_regi",c(REF="RUS",CAZ="ROW",...,MEA="MEA",USA="USA"))).
 
 
 Adding New Input Data
 ======================
 
-The input data for REMIND are generated by using the R-libraries *moinput* and *madrat* (https://github.com/pik-piam/madrat). While *moinput* contains all calculations tailored to REMIND-input-data, the library *madrat* provides the general wrapper functions and helpful tools. For further information read the vignettes part of the R-packages.
+The input data for REMIND are generated by using the R-libraries *moinput* and *madrat* (https://github.com/pik-piam/madrat). While *moinput* contains all calculations tailored to REMIND-input-data, the package *madrat* provides the general wrapper functions and helpful tools. For further information read the vignettes part of the R-packages.
 
diff --git a/tutorials/7_Advanced_ChangeCode.md b/tutorials/7_Advanced_ChangeCode.md
index fc5e52cabae448504358219f8bd38de1e0a4960e..295053c604f6d5cd19f9b26b84f7437c16be33c9 100644
--- a/tutorials/7_Advanced_ChangeCode.md
+++ b/tutorials/7_Advanced_ChangeCode.md
@@ -92,7 +92,7 @@ How to make a new module or realization in REMIND
 
 If you want to create a **new module** in REMIND first think about the interfaces between the core code and your new module. This helps you to design your module. 
 
-For creating a new module you can use the function **module_skeleton** from the R library "lucode". Start R and set the working directory to the folder of your REMIND version you want to make the changes (e.g. setwd(../../remind_20/trunk)). 
+For creating a new module you can use the function **module_skeleton** from the R package "lucode". Start R and set the working directory to the folder of your REMIND version you want to make the changes (e.g. setwd(../../remind_20/trunk)). 
 
 ``` r
 library(lucode)
@@ -101,7 +101,7 @@ module.skeleton(100,"bla",c("on","off"))
 
 It creates all folders and gams files for your new module "100_bla" with the realizations "on" and "off". More information about the function module_skeleton you can find at the help desk of R. 
 
-For creating a **new realization** of an existing module you can also use the function module_skeleton of the R library "lucode". Go into the folder "module" of your REMIND version and there in the folder of the module you want to make a new realization for (e.g. "module/100_bla", "module/10_climate"). Now you can start R and set the working directory to the head folder of your REMIND version you want to introduce the new realization. 
+For creating a **new realization** of an existing module you can also use the function module_skeleton of the R package "lucode". Go into the folder "module" of your REMIND version and there in the folder of the module you want to make a new realization for (e.g. "module/100_bla", "module/10_climate"). Now you can start R and set the working directory to the head folder of your REMIND version you want to introduce the new realization. 
 
 ``` r
 library(lucode)