diff --git a/.Rprofile b/.Rprofile index ccfe3ebf9b..e8d4f1facc 100644 --- a/.Rprofile +++ b/.Rprofile @@ -8,6 +8,15 @@ Sys.setenv(RENV_PATHS_LIBRARY = "renv/library") source("renv/activate.R") +renvVersion <- "0.16.0" +if (packageVersion("renv") != renvVersion) { + renvLockExisted <- file.exists(renv::paths$lockfile()) + renv::upgrade(version = renvVersion, reload = TRUE, prompt = FALSE) + if (!renvLockExisted) { + unlink(renv::paths$lockfile()) + } +} + if (!"https://rse.pik-potsdam.de/r/packages" %in% getOption("repos")) { options(repos = c(getOption("repos"), pik = "https://rse.pik-potsdam.de/r/packages")) } diff --git a/.snapshot.Rprofile b/.snapshot.Rprofile deleted file mode 100644 index cb4dc70c79..0000000000 --- a/.snapshot.Rprofile +++ /dev/null @@ -1,23 +0,0 @@ -# source global .Rprofile (very important to load user specific settings) -# DO NOT EDIT THIS LINE! -if(file.exists("~/.Rprofile")) source("~/.Rprofile") - - -# This profile can be used to link the model to a specified library snapshot -# (e.g. if your model version is from an older date and does not work with the -# newest libraries anymore). -# By default it is not active. Just uncomment the following lines and set the -# snapshot path to a path of your choice. -# Please make also sure that in your config file this .Rprofile file is copied -# to the model output folder. Otherwise, the run itself will again use the -# default library set! - -# PLEASE NOTE: snapshots ending with '_R4' require R 4.1 (piam/1.24 and newer), -# other snapshots require R 3.6 (piam/1.20) -# snapshot <- "/p/projects/rd3mod/R/libraries/snapshots/2022_10_28_R4" -# if(file.exists(snapshot)) { -# cat("Setting libPaths to",snapshot,"\n") -# .libPaths(snapshot, include.site = FALSE) -# } else { -# cat("Could not find",snapshot,"\n") -# } diff --git a/.zenodo.json b/.zenodo.json index d33ef2c3d7..5e69eaa32a 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -1,6 +1,6 @@ { "title": "MAgPIE - An Open Source land-use modeling framework", - "version": "4.6.7", + "version": "4.6.8", "creators": [ { "name": "Dietrich, Jan Philipp", @@ -109,5 +109,5 @@ "license": { "id": "AGPL-3.0-or-later" }, - "publication_date": "2023-05-10" + "publication_date": "2023-07-17" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 4777e041ab..6840e5850a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,34 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [4.6.8] - 2023-07-17 + +### changed +- **41_area_equipped_for_irrigation** new AEI data (Mehta2022) replacing old Siebert data +- **80_optimization** printing of solprint when solver status is 7 re-activated +- **scripts** start_functions.R can now handle clusters per region flexibly +- **scripts** the REMIND-MAgPIE coupling now uses renv + +### added +- **31_past** added `cc`, `nocc` and `nocc_hist` options for `c31_past_suit_scen` and `c31_grassl_yld_scenario` +- **32_carbon** added `nocc` and `nocc_hist` option for `c52_land_carbon_sink_rcp` +- **71_disagg_lvst** added new realisation `foragebased_jul23` which solves GAMS issues at higher spatial resolutions +- **config** added `cfg$results_folder_highres` which allows to modify the output folder used in the `highres.R` output script +- **config** new area equipped for irrigation (AEI) data in preprocessing (4.87) +- **scenario_config.csv** added a scenario for the NGFS project +- **scripts** New output script for reporting disaggregated land use patterns to the SEALS (Spatial Economic Allocation Landscape Simulator) downscaling model + +### removed +- **config** `s80_num_nonopt_allowed` +- **scripts** removed .snapshot.Rprofile and the Rprofile.R script, renv now fully supersedes snapshots + +### fixed +- **30_crop** corrected q30_cropland in module realization rotation_apr22, where fallow land was on the wrong side of the equation +- **71_disagg_lvst** reworked `foragebased_aug18` (including removal of linear version and correction of balance flow calculation) +- **80_optimization** resolve was not working in nlp_par realization due to `s80_num_nonopt_allowed` +- **config** corrected wrong names of parameters for peatland costs +- **config** updated scenario configs to newest preprocessing (4.87) + ## [4.6.7] - 2023-05-10 ### changed @@ -701,7 +729,8 @@ This release version is focussed on consistency between the MAgPIE setup and the First open source release of the framework. See [MAgPIE 4.0 paper](https://doi.org/10.5194/gmd-12-1299-2019) for more information. -[Unreleased]: https://github.com/magpiemodel/magpie/compare/v4.6.7...develop +[Unreleased]: https://github.com/magpiemodel/magpie/compare/v4.6.8...develop +[4.6.8]: https://github.com/magpiemodel/magpie/compare/v4.6.7...v4.6.8 [4.6.7]: https://github.com/magpiemodel/magpie/compare/v4.6.6...v4.6.7 [4.6.6]: https://github.com/magpiemodel/magpie/compare/v4.6.5...v4.6.6 [4.6.5]: https://github.com/magpiemodel/magpie/compare/v4.6.4...v4.6.5 diff --git a/CITATION.cff b/CITATION.cff index d298f0f5df..6ebb15977b 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -125,8 +125,8 @@ authors: email: popp@pik-potsdam.de title: MAgPIE - An Open Source land-use modeling framework -version: 4.6.7 -date-released: 2023-05-10 +version: 4.6.8 +date-released: 2023-07-17 repository-code: https://github.com/magpiemodel/magpie keywords: - landuse diff --git a/README.md b/README.md index 72cb867ea6..5f15852147 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,8 @@ https://www.pik-potsdam.de/research/projects/activities/land-use-modelling/magpi A framework description paper has been published in Geoscientific Model Development (GMD): https://doi.org/10.5194/gmd-12-1299-2019 -The model documentation for version 4.6.7 can be found at -https://rse.pik-potsdam.de/doc/magpie/4.6.7/ +The model documentation for version 4.6.8 can be found at +https://rse.pik-potsdam.de/doc/magpie/4.6.8/ A most recent version of the documentation can also be extracted from the model source code via the R package goxygen @@ -188,7 +188,7 @@ magpie@pik-potsdam.de Please contact magpie@pik-potsdam.de ## CITATION -See file CITATION.cff or the [How-to-Cite section](https://rse.pik-potsdam.de/doc/magpie/4.6.7/#how-to-cite) in the model documentation for information how to cite the model. +See file CITATION.cff or the [How-to-Cite section](https://rse.pik-potsdam.de/doc/magpie/4.6.8/#how-to-cite) in the model documentation for information how to cite the model. ## AUTHORS See list of authors in CITATION.cff diff --git a/config/default.cfg b/config/default.cfg index 75052a6582..821203f355 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -22,11 +22,11 @@ cfg$model <- "main.gms" #def = "main.gms" #### input settings #### # which input data sets should be used? -cfg$input <- c(regional = "rev4.85_h12_magpie.tgz", - cellular = "rev4.85_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", - validation = "rev4.85_h12_validation.tgz", +cfg$input <- c(regional = "rev4.87_h12_magpie.tgz", + cellular = "rev4.87_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "rev4.87_h12_validation.tgz", additional = "additional_data_rev4.43.tgz", - calibration = "calibration_H12_per_ton_fao_may22_glo_23Mar23.tgz") + calibration = "calibration_H12_per_ton_fao_may22_glo_08Jul23.tgz") # NOTE: It is recommended to recalibrate the model when changing cellular input data # as well as for any other setting that would affect initial values in the model, @@ -173,7 +173,7 @@ oecd90andEU <- "ALB,AUS,AUT,BEL,BIH,BGR,CAN,CYP,CZE,DNK,EST,FIN,FRA, cfg$gms$drivers <- "aug17" # def = aug17 cfg$gms$c09_pop_scenario <- "SSP2" # def = SSP2 cfg$gms$c09_gdp_scenario <- "SSP2" # def = SSP2 -# * options: SSP: "SSP1", "SSP2", "SSP2EU", "SSP3", "SSP4", "SSP5" +# * options: SSP: "SSP1", "SSP2", "SSP2EU", "SSP3", "SSP4", "SSP5" # * SDP: "SDP", "SDP_EI", "SDP_MC", "SDP_RC" # * Note: SSP2EU a European Commission population/income scenario for # * Ariadne project. SDP is same as SSP1 income, while SDP_EI, SDP_RC, SDP_MC @@ -181,7 +181,7 @@ cfg$gms$c09_gdp_scenario <- "SSP2" # def = SSP2 # * Physical activity level scenario: cfg$gms$c09_pal_scenario <- "SSP2" # def = SSP2 -# * options: SSP: "SSP1", "SSP2", "SSP2EU", "SSP3", "SSP4", "SSP5" +# * options: SSP: "SSP1", "SSP2", "SSP2EU", "SSP3", "SSP4", "SSP5" # * SDP: "SDP", "SDP_EI", "SDP_MC", "SDP_RC" # Year until which all parameters are fixed to SSP2 values @@ -694,8 +694,17 @@ cfg$gms$s31_fac_req_past <- 1 # def = 1 # * reflecting that not all pasture area is grazed. cfg$gms$s31_unequal <- 1 # def = 1 +# * Scenario for grassland and pasture yields (only take effect for realization grasslands_apr22) +# * options: cc (climate change) +# * nocc (no climate change) +# * nocc_hist (no climate change after year defined by sm_fix_cc) +cfg$gms$c31_grassl_yld_scenario <- "cc" # def = "cc" + + # * SSP scenario switch for pasture suitability areas (only take effect for realization grasslands_apr22) # * options: ssp126, ssp245, ssp370, ssp460, ssp585 +# * nocc (fixed to values from 1995), +# * nocc_hist (ssp245 until year defined in sm_fix_cc, fixed thereafter) cfg$gms$c31_past_suit_scen <- "ssp370" # def = "ssp370" # * Switch that allows selecting how yield calibration factors will be calculated. @@ -1017,12 +1026,12 @@ cfg$gms$s40_pasture_transport_costs <- 0 # def = 0 # ***--------------------- 41_area_equipped_for_irrigation --------------- # * (static): no expansion # * (endo_apr13): endogenous, cost driven expansion -cfg$gms$area_equipped_for_irrigation <- "endo_apr13" # def = endo_apr13 +cfg$gms$area_equipped_for_irrigation <- "endo_apr13" # def = endo_apr13 # * switch for initialization area -# * (LUH2v2): area equipped for irrigation based on LUH2v2 -# * (Siebert): area equipped for irrigation from Siebert et al. -cfg$gms$c41_initial_irrigation_area <- "LUH2v2" # def = LUH2v2 +# * (LUH2v2): area equipped for irrigation based on LUH2v2 irrigated areas +# * (Mehta2022): area equipped for irrigation from Mehta et al. (2022) +cfg$gms$c41_initial_irrigation_area <- "LUH2v2" # def = LUH2v2 # * Sets the rate of depreciation of irrigation infrastructure in every timestep. # * Only applicable when (endo_apr13) realization is selected @@ -1272,7 +1281,9 @@ cfg$gms$nitrogen <- "rescaled_jan21" # def = rescaled_jan21 cfg$gms$carbon <- "normal_dec17" # def = normal_dec17 # * RCP scenario of land carbon sink adjustment factor, from Grassi et al 2021 -# * options: RCP19, RCP26, RCP34, RCP45, RCP60, RCPBU +# * options: RCP19, RCP26, RCP34, RCP45, RCP60, RCPBU, +# * nocc (fixed to values from 1995), +# * nocc_hist (RCPBU until year defined in sm_fix_cc, fixed thereafter) cfg$gms$c52_land_carbon_sink_rcp <- "RCPBU" @@ -1514,8 +1525,8 @@ cfg$gms$peatland <- "on" # def = on cfg$gms$s58_rewetting_switch <- Inf # def = Inf # * One-time and recurring costs for peatland rewetting (USD05MER per ha) -cfg$gms$s58_rewet_cost_onetime <- 7000 # def = 7000 -cfg$gms$s58_rewet_cost_recur <- 200 # def = 200 +cfg$gms$s58_cost_rewet_onetime <- 7000 # def = 7000 +cfg$gms$s58_cost_rewet_recur <- 200 # def = 200 # * One-time and recurring costs for peatland degradation (USD05MER per ha) # * Can be used to test area-based incentives for peatland protection and restoration, @@ -1524,8 +1535,8 @@ cfg$gms$s58_rewet_cost_recur <- 200 # def = 200 # * Therefore, one-time costs can used to incentivize the protection of intact peatlands. # * Recurring costs apply on the level of degraded peatland. Therefore, recurring costs, # * in combination with one-time costs, can be used to incentivize peatland restoration. -cfg$gms$s58_degrad_cost_onetime <- 0 # def = 0 -cfg$gms$s58_degrad_cost_recur <- 0 # def = 0 +cfg$gms$s58_cost_degrad_onetime <- 0 # def = 0 +cfg$gms$s58_cost_degrad_recur <- 0 # def = 0 # * Artificial cost for balance variables (USD05MER per ha) # * The balance variables in the peatland module avoid infeasibilities due to @@ -1719,7 +1730,10 @@ cfg$gms$c70_fac_req_regr <- "glo" # def = glo # * (off): default # * (foragebased_aug18): Disaggregation of livestock to cells # * with high pasture and fodder availability -cfg$gms$disagg_lvst <- "foragebased_aug18" # def = foragebased_aug18 +# * (foragebased_jul23): Disaggregation of livestock to cells +# * with high pasture and fodder availability +# * (improved and flexibitized) +cfg$gms$disagg_lvst <- "foragebased_jul23" # def = foragebased_jul23 # ***--------------------- 73_timber ----------------------------------- @@ -1807,11 +1821,6 @@ cfg$gms$s80_maxiter <- 30 # * (conopt4+conopt3): conopt4 followed by conopt3 cfg$gms$c80_nlp_solver <- "conopt4" # def = conopt4 -# number of allowed non-optimal variables -# Should be set to 0 for GAMS version 25.x.x or earlier -# Should be set to Inf for GAMS version 26.x.x or later -cfg$gms$s80_num_nonopt_allowed <- Inf - # * 1: using optfile for specified solver settings # * 0: default settings (optfile will be ignored) cfg$gms$s80_optfile <- 1 @@ -1865,6 +1874,12 @@ cfg$output <- c("output_check", "extra/disaggregation", "rds_report") # :title: is a placeholder for the current run title (cfg$title) cfg$results_folder <- "output/:title::date:" +# Results folder used by the "highres.R" output script +# If NULL, the default set in "highres.R" is used (currently a subfolder in "output") +# To place highres runs directly in the "output" folder, change to "output" +# To place highres runs in a specific subfolder change to "output/HR" +cfg$results_folder_highres <- NULL + # Which files should be copied into the output folder? cfg$files2export <- list() # Files that should be copied before MAgPIE is started @@ -1895,6 +1910,10 @@ cfg$files2export$start <- c("input/info.txt", # Files that should be copied after the MAgPIE run is finished cfg$files2export$end <- NULL +# Expert use only, should not be set manually. Path to a renv.lock file +# defining the package environment for newly started runs. +cfg$renv_lock <- NULL + # Folder run statistics should be submitted to cfg$runstatistics <- "/p/projects/rd3mod/models/statistics/magpie" diff --git a/config/scenario_config.csv b/config/scenario_config.csv index 5d45847bd7..c1a5b1695b 100644 --- a/config/scenario_config.csv +++ b/config/scenario_config.csv @@ -1,85 +1,86 @@ -;cc;nocc;nocc_hist;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SDP;SDP-EI;SDP-RC;SDP-MC;BASE;NPI;NDC;coupling;emulator;input;Tland;eat_lancet_diet;LAMA_Inequal;LAMA_Inequal-SustDemand;LAMA_Inequal-EnvirProt;LAMA_Inequal-GHGPrice;LAMA_Sustainability;NAVIGATE_AllOff;NAVIGATE_LandSup;NAVIGATE_LandDem;NAVIGATE_AllOn;ForestryEndo;ForestryExo;ForestryOff;frst_shock_none;frst_shock_002lin2030;frst_shock_004lin2030;frst_shock_008lin2030;frst_shock_016lin2030;rcp1p9;rcp2p6;rcp4p5;rcp6p0;rcp7p0;rcp8p5 -gms$c09_pop_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SSP1;SSP1;SSP1;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;; -gms$c09_gdp_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SDP_EI;SDP_RC;SDP_MC;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;; -gms$c09_pal_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SSP2;SSP1;SSP1;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;; -gms$c15_food_scenario;;;;SSP1;SSP2;SSP2;SSP3;SSP4;SSP5;SSP1;SSP2;SSP1;SSP1;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;; -gms$c15_food_scenario_noselect;;;;;;;;;;;;;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;; -gms$s15_elastic_demand;;;;0;0;0;0;0;0;0;0;0;0;;;;;;;0;0;0;0;0;0;0;;;;;;;;;;;;;;;;;; -gms$c15_rumdairy_scp_scen;;;;constant;constant;constant;constant;constant;constant;constant;sigmoid_50pc_20_50;constant;constant;;;;;;;constant;;;;;;;;;;;;;;;;;;;;;;;; -gms$kfo_rd;;;;;;;;;;;livst_rum;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -gms$c15_exo_foodscen;;;;;;;;;;lin_zero_20_50;lin_zero_20_50;lin_zero_20_50;lin_zero_20_70;;;;;;;lin_zero_20_50;lin_zero_20_50;;lin_zero_20_50;;;lin_zero_20_50;;;;;;;;;;;;;;;;;; -gms$s15_exo_waste;;;;0;0;0;0;0;0;1;1;1;1;;;;;;;1;0;0;1;0;0;1;0;0;1;1;;;;;;;;;;;;;; -gms$s15_waste_scen;;;;;;;;;;1.2;1.3;1.2;1.25;;;;;;;1.2;1.2;;1.2;;;1.2;;;;;;;;;;;;;;;;;; -gms$s15_exo_diet;;;;0;0;0;0;0;0;1;1;1;1;;;;;;;1;1;0;1;0;0;1;0;0;1;1;;;;;;;;;;;;;; -gms$c15_kcal_scen;;;;;;;;;;healthy_BMI;no_underweight;healthy_BMI;healthy_BMI;;;;;;;healthy_BMI;healthy_BMI;;healthy_BMI;;;healthy_BMI;;;;;;;;;;;;;;;;;; -gms$c15_EAT_scen;;;;;;;;;;FLX;;FLX;FLX;;;;;;;FLX;FLX;;FLX;;;FLX;;;;;;;;;;;;;;;;;; -gms$s15_exo_monogastric;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;; -gms$s15_exo_ruminant;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;; -gms$s15_exo_fish;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;; -gms$s15_exo_fruitvegnut;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;; -gms$s15_exo_pulses;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;; -gms$s15_exo_sugar;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;; -gms$s15_exo_oils;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;; -gms$s15_exo_brans;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;; -gms$s15_exo_scp;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;; -gms$s15_exo_alcohol;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;; -gms$c21_trade_liberalization;;;;l908080r807070;l909090r808080;l909090r808080;l909595r809090;l908080r807070;l908080r807070;l908080r807070;l908080r807070;l909595r809090;l908080r807070;;;;;;;;;l908080r807070;l908080r807070;l908080r807070;l908080r807070;l908080r807070;;;;;;;;;;;;;;;;;; -gms$c22_protect_scenario;;;;none;none;none;none;none;none;BH;none;BH_IFL;BH;;;;;;;BH;;BH_IFL;BH_IFL;BH_IFL;BH_IFL;BH_IFL;;;;;;;;;;;;;;;;;; -gms$c22_protect_scenario_noselect;;;;;;;;;;;;;;;;;;;;;;none;none;BH_IFL;none;BH_IFL;;;;;;;;;;;;;;;;;; -gms$c30_bioen_water;;;;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;all;rainfed;rainfed;;;;;;;rainfed;;;;;;;;;;;;;;;;;;;;;;;; -gms$s30_snv_shr;;;;0;0;0;0;0;0;0;0;0;0.2;;;;;;;0;;0.2;0.2;0.2;0.2;0.2;;;;;;;;;;;;;;;;;; -gms$s30_snv_shr_noselect;;;;;;;;;;;;;;;;;;;;;;0;0;0.2;0;0.2;;;;;;;;;;;;;;;;;; -gms$s30_snv_scenario_target;;;;;;;;;;;;;2030;;;;;;;;;2030;2030;2030;2030;2030;;;;;;;;;;;;;;;;;; -gms$c31_past_suit_scen;;;;ssp126;ssp245;ssp245;ssp370;ssp460;ssp585;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ssp126;ssp126;ssp245;ssp460;ssp370;ssp585 -gms$s32_aff_plantation;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;; -gms$s32_aff_bii_coeff;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;; -gms$s32_max_aff_area;;;;Inf;Inf;Inf;Inf;Inf;Inf;500;350;0;700;;;;;;;500;;Inf;Inf;Inf;500;500;;;;;;;;;;;;;;;;;; -gms$c32_aff_mask;;;;noboreal;noboreal;noboreal;noboreal;noboreal;noboreal;onlytropical;onlytropical;onlytropical;onlytropical;;;;;;;onlytropical;;noboreal;noboreal;noboreal;noboreal;noboreal;;;;;;;;;;;;;;;;;; -gms$c34_urban_scenario;;;;SSP1;SSP2;SSP2;SSP3;SSP4;SSP5;SSP1;SSP1;SSP2;SSP1;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;; -gms$c32_aff_policy;;;;;;;;;;;;;;none;npi;ndc;;;;;;ndc;ndc;ndc;ndc;ndc;;;;;;;;;;;;;;;;;; -gms$s32_planing_horizon;;;;50;50;50;50;50;50;50;30;50;50;;;;;;;50;;;;;;;;;;;;;;;;;;;;;;;; -gms$c35_ad_policy;;;;;;;;;;;;;;none;npi;ndc;;;;;;ndc;ndc;ndc;ndc;ndc;;;;;;;;;;;;;;;;;; -gms$c35_aolc_policy;;;;;;;;;;;;;;none;npi;ndc;;;;;;ndc;ndc;ndc;ndc;ndc;;;;;;;;;;;;;;;;;; -gms$s35_forest_damage_end;;;;2030;2050;2050;2050;2050;2030;2030;2030;2030;2030;;;;;;;2030;;2030;2030;2030;2030;2030;;;;;;;;;;;;;;;;;; -gms$s42_watdem_nonagr_scenario;;;;1;2;2;3;2;1;1;1;3;1;;;;;;;;;2;1;2;2;1;;;;;;;;;;;;;;;;;; -gms$s42_irrig_eff_scenario;;;;2;2;2;2;2;2;3;3;3;3;;;;;;;3;;3;3;3;3;3;;;;;;;;;;;;;;;;;; -gms$c42_env_flow_policy;;;;on;off;off;off;mixed;on;on;on;on;on;;;;;;;on;;on;on;on;on;on;;;;;;;;;;;;;;;;;; -gms$s42_efp_targetyear;;;;2040;2040;2040;2040;2040;2040;2040;2050;2070;2050;;;;;;;2040;;2040;2040;2040;2040;2040;;;;;;;;;;;;;;;;;; -gms$s44_target_price;;;;0;0;0;0;0;0;0;0;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;; -gms$c50_scen_neff;;;;baseeff_add3_add10_add20_max75;baseeff_add3_add5_add10_max65;baseeff_add3_add5_add10_max65;baseeff_add3_add0_add0_max55;baseeff_add3_add10_add15_max75;baseeff_add3_add5_add15_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max65;baseeff_add3_add15_add25_max75;;;;;;;baseeff_add3_add15_add25_max75;;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;;;;;;;;;;;;;;;;;; -gms$c50_scen_neff_noselect;;;;baseeff_add3_add10_add20_max75;baseeff_add3_add5_add10_max65;baseeff_add3_add5_add10_max65;baseeff_add3_add0_add0_max55;baseeff_add3_add10_add15_max75;baseeff_add3_add5_add15_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max65;baseeff_add3_add15_add25_max75;;;;;;;baseeff_add3_add15_add25_max75;;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;;;;;;;;;;;;;;;;;; -gms$c55_scen_conf;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp1;ssp1;ssp1;;;;;;;ssp1;;ssp1;ssp1;ssp1;ssp1;ssp1;;;;;;;;;;;;;;;;;; -gms$c55_scen_conf_noselect;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp1;ssp1;ssp1;;;;;;;ssp1;;ssp4;ssp4;ssp1;ssp4;ssp1;;;;;;;;;;;;;;;;;; -gms$c56_pollutant_prices;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;; -gms$c56_pollutant_prices_noselect;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-NPi;R21M42-SDP-NPi;R21M42-SDP-NPi;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;; -gms$s56_c_price_exp_aff;;;;50;50;50;50;50;50;50;30;50;50;;;;;;;50;;;;;;;;;;;;;;;;;;;;;;;; -gms$s56_buffer_aff;;;;0.2;0.2;0.2;0.2;0.2;0.2;0.2;0.5;0.2;0.3;;;;;;;0.2;;;;;;;;;;;;;;;;;;;;;;;; -gms$c56_emis_policy;;;;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+_nosoil;all_nosoil;;;;;;;redd+natveg_nosoil;;;;;;;;;;;;;;;;;;;;;;;; -gms$s56_minimum_cprice;;;;;;;;;;;;;;0;0;18;;;;;;;;;;;;;;;;;;;;;;;;;;;; -gms$maccs;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -gms$c60_2ndgen_biodem;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;; -gms$c60_2ndgen_biodem_noselect;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;; -gms$c60_1stgen_biodem;;;;phaseout2020;const2020;const2020;const2030;const2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;;;;;;;phaseout2020;;phaseout2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;;;;;;;;;;;;;;;;;; -gms$c60_biodem_level;;;;;;;;;;;;;;;;;1;0;;;;1;1;1;1;1;;;;;;;;;;;;;;;;;; -gms$c60_bioenergy_subsidy;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -gms$c60_res_2ndgenBE_dem;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;sdp;ssp2;sdp;sdp;;;;;;;sdp;;ssp4;sdp;ssp4;ssp4;sdp;;;;;;;;;;;;;;;;;; -gms$c70_feed_scen;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp5;ssp1;ssp1;;;;;;;ssp1;;ssp4;ssp1;ssp4;ssp4;ssp1;;;;;;;;;;;;;;;;;; -gms$c_timesteps;;;;;;;;;;;;;;;;;less_TS;less_TS;;;;5year;5year;5year;5year;5year;;;;;;;;;;;;;;;;;; -gms$c14_yields_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;; -gms$c42_watdem_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;; -gms$c43_watavail_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;; -gms$c52_carbon_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;; -gms$c59_som_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;cc;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;; -gms$s32_initial_distribution;;;;;;;;;;;;;;;;;;;;;;4;4;4;4;4;;;;;4;4;0;;;;;;;;;;; -gms$s32_hvarea;;;;;;;;;;;;;;;;;;;;;;2;2;2;2;2;;;;;2;1;0;;;;;;;;;;; -gms$s35_secdf_distribution;;;;;;;;;;;;;;;;;;;;;;2;2;2;2;2;;;;;2;2;0;;;;;;;;;;; -gms$s35_hvarea;;;;;;;;;;;;;;;;;;;;;;2;2;2;2;2;;;;;2;2;0;;;;;;;;;;; -gms$s73_timber_demand_switch;;;;;;;;;;;;;;;;;;;;;;1;1;1;1;1;;;;;1;1;0;;;;;;;;;;; -gms$s35_forest_damage;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4;4;4;4;4;;;;;; -gms$c32_shock_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;none;002lin2030;004lin2030;008lin2030;016lin2030;;;;;; -gms$c35_shock_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;none;002lin2030;004lin2030;008lin2030;016lin2030;;;;;; -input['cellular'];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.85_h12_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.85_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;rev4.85_h12_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.85_h12_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.85_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.85_h12_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz -gms$c52_land_carbon_sink_rcp;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;RCP19;RCP26;RCP45;RCP60;RCPBU;RCPBU -gms$c57_macc_version;;;;;;;;;;;;;;;;;;;;;;;;;;;PBL_2022;PBL_2022;PBL_2022;PBL_2022;;;;;;;;;;;;;; -gms$c57_macc_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;Default;Optimistic;Default;Optimistic;;;;;;;;;;;;;; -gms$s58_rewetting_switch;;;;;;;;;;;;;;;;;;;;;;;;;;;0;1;0;1;;;;;;;;;;;;;; +;cc;nocc;nocc_hist;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SDP;SDP-EI;SDP-RC;SDP-MC;BASE;NPI;NDC;coupling;emulator;input;Tland;eat_lancet_diet;LAMA_Inequal;LAMA_Inequal-SustDemand;LAMA_Inequal-EnvirProt;LAMA_Inequal-GHGPrice;LAMA_Sustainability;NAVIGATE_AllOff;NAVIGATE_LandSup;NAVIGATE_LandDem;NAVIGATE_AllOn;ForestryEndo;ForestryExo;ForestryOff;frst_shock_none;frst_shock_002lin2030;frst_shock_004lin2030;frst_shock_008lin2030;frst_shock_016lin2030;rcp1p9;rcp2p6;rcp4p5;rcp6p0;rcp7p0;rcp8p5;NGFS_o_lowdem +gms$c09_pop_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SSP1;SSP1;SSP1;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; +gms$c09_gdp_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SDP_EI;SDP_RC;SDP_MC;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; +gms$c09_pal_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SSP2;SSP1;SSP1;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; +gms$c15_food_scenario;;;;SSP1;SSP2;SSP2;SSP3;SSP4;SSP5;SSP1;SSP2;SSP1;SSP1;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;;SSP2 +gms$c15_food_scenario_noselect;;;;;;;;;;;;;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;;SSP2 +gms$s15_elastic_demand;;;;0;0;0;0;0;0;0;0;0;0;;;;;;;0;0;0;0;0;0;0;;;;;;;;;;;;;;;;;;; +gms$c15_rumdairy_scp_scen;;;;constant;constant;constant;constant;constant;constant;constant;sigmoid_50pc_20_50;constant;constant;;;;;;;constant;;;;;;;;;;;;;;;;;;;;;;;;; +gms$kfo_rd;;;;;;;;;;;livst_rum;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c15_exo_foodscen;;;;;;;;;;lin_zero_20_50;lin_zero_20_50;lin_zero_20_50;lin_zero_20_70;;;;;;;lin_zero_20_50;lin_zero_20_50;;lin_zero_20_50;;;lin_zero_20_50;;;;;;;;;;;;;;;;;;;lin_zero_20_50 +gms$s15_exo_waste;;;;0;0;0;0;0;0;1;1;1;1;;;;;;;1;0;0;1;0;0;1;0;0;1;1;;;;;;;;;;;;;;;1 +gms$s15_waste_scen;;;;;;;;;;1.2;1.3;1.2;1.25;;;;;;;1.2;1.2;;1.2;;;1.2;;;;;;;;;;;;;;;;;;;1.2 +gms$s15_exo_diet;;;;0;0;0;0;0;0;1;1;1;1;;;;;;;1;1;0;1;0;0;1;0;0;1;1;;;;;;;;;;;;;;;1 +gms$c15_kcal_scen;;;;;;;;;;healthy_BMI;no_underweight;healthy_BMI;healthy_BMI;;;;;;;healthy_BMI;healthy_BMI;;healthy_BMI;;;healthy_BMI;;;;;;;;;;;;;;;;;;;healthy_BMI +gms$c15_EAT_scen;;;;;;;;;;FLX;;FLX;FLX;;;;;;;FLX;FLX;;FLX;;;FLX;;;;;;;;;;;;;;;;;;; +gms$s15_exo_monogastric;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_ruminant;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_fish;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_fruitvegnut;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_pulses;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_sugar;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_oils;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_brans;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_scp;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_alcohol;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$c21_trade_liberalization;;;;l908080r807070;l909090r808080;l909090r808080;l909595r809090;l908080r807070;l908080r807070;l908080r807070;l908080r807070;l909595r809090;l908080r807070;;;;;;;;;l908080r807070;l908080r807070;l908080r807070;l908080r807070;l908080r807070;;;;;;;;;;;;;;;;;;; +gms$c22_protect_scenario;;;;none;none;none;none;none;none;BH;none;BH_IFL;BH;;;;;;;BH;;BH_IFL;BH_IFL;BH_IFL;BH_IFL;BH_IFL;;;;;;;;;;;;;;;;;;; +gms$c22_protect_scenario_noselect;;;;;;;;;;;;;;;;;;;;;;none;none;BH_IFL;none;BH_IFL;;;;;;;;;;;;;;;;;;; +gms$c30_bioen_water;;;;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;all;rainfed;rainfed;;;;;;;rainfed;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s30_snv_shr;;;;0;0;0;0;0;0;0;0;0;0.2;;;;;;;0;;0.2;0.2;0.2;0.2;0.2;;;;;;;;;;;;;;;;;;; +gms$s30_snv_shr_noselect;;;;;;;;;;;;;;;;;;;;;;0;0;0.2;0;0.2;;;;;;;;;;;;;;;;;;; +gms$s30_snv_scenario_target;;;;;;;;;;;;;2030;;;;;;;;;2030;2030;2030;2030;2030;;;;;;;;;;;;;;;;;;; +gms$c31_past_suit_scen;;nocc;nocc_hist;ssp126;ssp245;ssp245;ssp370;ssp460;ssp585;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ssp126;ssp126;ssp245;ssp460;ssp370;ssp585; +gms$c31_grassl_yld_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s32_aff_plantation;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s32_aff_bii_coeff;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s32_max_aff_area;;;;Inf;Inf;Inf;Inf;Inf;Inf;500;350;0;700;;;;;;;500;;Inf;Inf;Inf;500;500;;;;;;;;;;;;;;;;;;; +gms$c32_aff_mask;;;;noboreal;noboreal;noboreal;noboreal;noboreal;noboreal;onlytropical;onlytropical;onlytropical;onlytropical;;;;;;;onlytropical;;noboreal;noboreal;noboreal;noboreal;noboreal;;;;;;;;;;;;;;;;;;; +gms$c34_urban_scenario;;;;SSP1;SSP2;SSP2;SSP3;SSP4;SSP5;SSP1;SSP1;SSP2;SSP1;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; +gms$c32_aff_policy;;;;;;;;;;;;;;none;npi;ndc;;;;;;ndc;ndc;ndc;ndc;ndc;;;;;;;;;;;;;;;;;;; +gms$s32_planing_horizon;;;;50;50;50;50;50;50;50;30;50;50;;;;;;;50;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c35_ad_policy;;;;;;;;;;;;;;none;npi;ndc;;;;;;ndc;ndc;ndc;ndc;ndc;;;;;;;;;;;;;;;;;;; +gms$c35_aolc_policy;;;;;;;;;;;;;;none;npi;ndc;;;;;;ndc;ndc;ndc;ndc;ndc;;;;;;;;;;;;;;;;;;; +gms$s35_forest_damage_end;;;;2030;2050;2050;2050;2050;2030;2030;2030;2030;2030;;;;;;;2030;;2030;2030;2030;2030;2030;;;;;;;;;;;;;;;;;;; +gms$s42_watdem_nonagr_scenario;;;;1;2;2;3;2;1;1;1;3;1;;;;;;;;;2;1;2;2;1;;;;;;;;;;;;;;;;;;; +gms$s42_irrig_eff_scenario;;;;2;2;2;2;2;2;3;3;3;3;;;;;;;3;;3;3;3;3;3;;;;;;;;;;;;;;;;;;; +gms$c42_env_flow_policy;;;;on;off;off;off;mixed;on;on;on;on;on;;;;;;;on;;on;on;on;on;on;;;;;;;;;;;;;;;;;;; +gms$s42_efp_targetyear;;;;2040;2040;2040;2040;2040;2040;2040;2050;2070;2050;;;;;;;2040;;2040;2040;2040;2040;2040;;;;;;;;;;;;;;;;;;; +gms$s44_target_price;;;;0;0;0;0;0;0;0;0;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c50_scen_neff;;;;baseeff_add3_add10_add20_max75;baseeff_add3_add5_add10_max65;baseeff_add3_add5_add10_max65;baseeff_add3_add0_add0_max55;baseeff_add3_add10_add15_max75;baseeff_add3_add5_add15_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max65;baseeff_add3_add15_add25_max75;;;;;;;baseeff_add3_add15_add25_max75;;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;;;;;;;;;;;;;;;;;;; +gms$c50_scen_neff_noselect;;;;baseeff_add3_add10_add20_max75;baseeff_add3_add5_add10_max65;baseeff_add3_add5_add10_max65;baseeff_add3_add0_add0_max55;baseeff_add3_add10_add15_max75;baseeff_add3_add5_add15_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max65;baseeff_add3_add15_add25_max75;;;;;;;baseeff_add3_add15_add25_max75;;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;;;;;;;;;;;;;;;;;;; +gms$c55_scen_conf;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp1;ssp1;ssp1;;;;;;;ssp1;;ssp1;ssp1;ssp1;ssp1;ssp1;;;;;;;;;;;;;;;;;;; +gms$c55_scen_conf_noselect;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp1;ssp1;ssp1;;;;;;;ssp1;;ssp4;ssp4;ssp1;ssp4;ssp1;;;;;;;;;;;;;;;;;;; +gms$c56_pollutant_prices;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; +gms$c56_pollutant_prices_noselect;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-NPi;R21M42-SDP-NPi;R21M42-SDP-NPi;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; +gms$s56_c_price_exp_aff;;;;50;50;50;50;50;50;50;30;50;50;;;;;;;50;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s56_buffer_aff;;;;0.2;0.2;0.2;0.2;0.2;0.2;0.2;0.5;0.2;0.3;;;;;;;0.2;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c56_emis_policy;;;;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+_nosoil;all_nosoil;;;;;;;redd+natveg_nosoil;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s56_minimum_cprice;;;;;;;;;;;;;;0;0;18;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$maccs;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c60_2ndgen_biodem;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; +gms$c60_2ndgen_biodem_noselect;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; +gms$c60_1stgen_biodem;;;;phaseout2020;const2020;const2020;const2030;const2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;;;;;;;phaseout2020;;phaseout2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;;;;;;;;;;;;;;;;;;; +gms$c60_biodem_level;;;;;;;;;;;;;;;;;1;0;;;;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$c60_bioenergy_subsidy;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c60_res_2ndgenBE_dem;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;sdp;ssp2;sdp;sdp;;;;;;;sdp;;ssp4;sdp;ssp4;ssp4;sdp;;;;;;;;;;;;;;;;;;; +gms$c70_feed_scen;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp5;ssp1;ssp1;;;;;;;ssp1;;ssp4;ssp1;ssp4;ssp4;ssp1;;;;;;;;;;;;;;;;;;; +gms$c_timesteps;;;;;;;;;;;;;;;;;less_TS;less_TS;;;;5year;5year;5year;5year;5year;;;;;;;;;;;;;;;;;;; +gms$c14_yields_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; +gms$c42_watdem_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; +gms$c43_watavail_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; +gms$c52_carbon_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; +gms$c59_som_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;cc;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; +gms$s32_initial_distribution;;;;;;;;;;;;;;;;;;;;;;4;4;4;4;4;;;;;4;4;0;;;;;;;;;;;; +gms$s32_hvarea;;;;;;;;;;;;;;;;;;;;;;2;2;2;2;2;;;;;2;1;0;;;;;;;;;;;; +gms$s35_secdf_distribution;;;;;;;;;;;;;;;;;;;;;;2;2;2;2;2;;;;;2;2;0;;;;;;;;;;;; +gms$s35_hvarea;;;;;;;;;;;;;;;;;;;;;;2;2;2;2;2;;;;;2;2;0;;;;;;;;;;;; +gms$s73_timber_demand_switch;;;;;;;;;;;;;;;;;;;;;;1;1;1;1;1;;;;;1;1;0;;;;;;;;;;;; +gms$s35_forest_damage;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4;4;4;4;4;;;;;;; +gms$c32_shock_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;none;002lin2030;004lin2030;008lin2030;016lin2030;;;;;;; +gms$c35_shock_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;none;002lin2030;004lin2030;008lin2030;016lin2030;;;;;;; +input['cellular'];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.87_h12_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.87_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;rev4.87_h12_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.87_h12_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.87_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.87_h12_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; +gms$c52_land_carbon_sink_rcp;;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;RCP19;RCP26;RCP45;RCP60;RCPBU;RCPBU; +gms$c57_macc_version;;;;;;;;;;;;;;;;;;;;;;;;;;;PBL_2022;PBL_2022;PBL_2022;PBL_2022;;;;;;;;;;;;;;; +gms$c57_macc_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;Default;Optimistic;Default;Optimistic;;;;;;;;;;;;;;; +gms$s58_rewetting_switch;;;;;;;;;;;;;;;;;;;;;;;;;;;0;1;0;1;;;;;;;;;;;;;;; diff --git a/config/scenario_fsec.csv b/config/scenario_fsec.csv index bacf5d1ae8..5210788d95 100644 --- a/config/scenario_fsec.csv +++ b/config/scenario_fsec.csv @@ -65,9 +65,9 @@ gms$s62_max_dem_bioplastic;0;;;;400;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c70_fac_req_regr;reg;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c70_feed_scen;;;;;;;;;;;;;;;;;;ssp1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c73_build_demand;;;;;;;;;;;;;;;;;;;;;;;;50pc;;;;;;;;;;;;;;;;;;;;;;;;; -input['cellular'];rev4.84_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.84_FSEC_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.84_FSEC_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;;rev4.84_FSEC_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.84_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.84_FSEC_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.84_FSEC_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; -input['regional'];rev4.84_FSEC_magpie.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -input['validation'];rev4.86_FSEC_validation.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -input['additional'];additional_data_rev4.37.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +input['cellular'];rev4.87_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.87_FSEC_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.87_FSEC_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;;rev4.87_FSEC_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.87_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.87_FSEC_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.87_FSEC_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; +input['regional'];rev4.87_FSEC_magpie.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +input['validation'];rev4.87_FSEC_validation.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +input['additional'];additional_data_rev4.43.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; input['calibration'];calibration_FSEC_24Mar23.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; magicc_emis_scen;bjoernAR6_C_SSP2-NDC.mif;;;bjoernAR6_C_SSP2-PkBudg900.mif;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;bjoernAR6_C_SSP1-NDC.mif;;;;;;;;;;;;bjoernAR6_C_SSP1-PkBudg900.mif diff --git a/core/sets.gms b/core/sets.gms index 13be12ee50..844ea9e52f 100644 --- a/core/sets.gms +++ b/core/sets.gms @@ -59,7 +59,7 @@ sets CHA_7*CHA_23, EUR_24*EUR_32, IND_33*IND_40, - JPN_41, + JPN_41*JPN_41, LAM_42*LAM_85, MEA_86*MEA_111, NEU_112*NEU_118, @@ -73,7 +73,7 @@ sets CHA . (CHA_7*CHA_23) EUR . (EUR_24*EUR_32) IND . (IND_33*IND_40) - JPN . (JPN_41) + JPN . (JPN_41*JPN_41) LAM . (LAM_42*LAM_85) MEA . (MEA_86*MEA_111) NEU . (NEU_112*NEU_118) diff --git a/main.gms b/main.gms index d64f7ecb03..3595e9c073 100644 --- a/main.gms +++ b/main.gms @@ -148,26 +148,26 @@ $title magpie *##################### R SECTION START (VERSION INFO) ########################## * -* Used data set: rev4.85_h12_magpie.tgz -* md5sum: NA -* Repository: scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output +* Used data set: rev4.87_h12_magpie.tgz +* md5sum: 658398f1dcbef89198bd85d61b1db9ad +* Repository: /p/projects/rd3mod/inputdata/output * -* Used data set: rev4.85_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz -* md5sum: NA -* Repository: scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output +* Used data set: rev4.87_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz +* md5sum: 8a1d668acfe66a700eb5da2143b31cb2 +* Repository: /p/projects/rd3mod/inputdata/output * -* Used data set: rev4.85_h12_validation.tgz -* md5sum: NA -* Repository: scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output +* Used data set: rev4.87_h12_validation.tgz +* md5sum: d02217d791b58400e6e3be7186527ed5 +* Repository: /p/projects/rd3mod/inputdata/output * * Used data set: additional_data_rev4.43.tgz * md5sum: NA -* Repository: scp://cluster.pik-potsdam.de/p/projects/landuse/data/input/archive -* -* Used data set: calibration_H12_per_ton_fao_may22_glo_23Mar23.tgz -* md5sum: NA * Repository: https://rse.pik-potsdam.de/data/magpie/public * +* Used data set: calibration_H12_per_ton_fao_may22_glo_08Jul23.tgz +* md5sum: 7315d0f268d6225805a4c1f1c3c05b13 +* Repository: /p/projects/landuse/data/input/calibration +* * Low resolution: c200 * High resolution: 0.5 * @@ -179,11 +179,11 @@ $title magpie * * Regionscode: 62eff8f7 * -* Regions data revision: 4.85 +* Regions data revision: 4.87 * * lpj2magpie settings: * * LPJmL data: MRI-ESM2-0:ssp370 -* * Revision: 4.85 +* * Revision: 4.87 * * aggregation settings: * * Input resolution: 0.5 @@ -195,7 +195,7 @@ $title magpie * * Call: withCallingHandlers(expr, message = messageHandler, warning = warningHandler, error = errorHandler) * * -* Last modification (input data): Fri Apr 28 16:30:54 2023 +* Last modification (input data): Thu Jul 13 10:36:10 2023 * *###################### R SECTION END (VERSION INFO) ########################### @@ -219,9 +219,9 @@ $offlisting **************************MODEL SPECIFIC SCALARS******************************** * Key parameters during model runs -$setglobal c_timesteps calib +$setglobal c_timesteps coup2100 $setglobal c_past till_2010 -$setglobal c_title BilatPRFade_ON_Nofadeout +$setglobal c_title default scalars s_use_gdx use of gdx files / 0 / @@ -249,7 +249,7 @@ $setglobal land_conservation area_based_apr22 $setglobal ageclass feb21 -$setglobal crop penalty_apr22 +$setglobal crop endo_apr21 $setglobal past endo_jun13 $setglobal forestry dynamic_feb21 @@ -259,7 +259,7 @@ $setglobal natveg dynamic_feb21 $setglobal employment exo_may22 $setglobal labor_prod off -$setglobal factor_costs sticky_feb18 +$setglobal factor_costs per_ton_fao_may22 $setglobal landconversion calib $setglobal transport gtap_nov12 diff --git a/modules/30_crop/penalty_apr22/equations.gms b/modules/30_crop/penalty_apr22/equations.gms index 7937ab12bb..bb649fa47f 100644 --- a/modules/30_crop/penalty_apr22/equations.gms +++ b/modules/30_crop/penalty_apr22/equations.gms @@ -9,12 +9,11 @@ *' The total land requirements for cropland are calculated as *' the sum of crop and water supply type specific land requirements. *' Fallow is no explicit landuse type, but the difference between -*' land and harvested vm_area +*' the land area for crops vm_land and the croparea vm_area q30_cropland(j2) .. sum((kcr,w), vm_area(j2,kcr,w)) + vm_fallow(j2) =e= vm_land(j2,"crop"); - *' We assume that crop production can only take place on suitable cropland area. *' We use a suitability index (SI) map from @zabel_global_2014 to exclude areas *' from cropland production that have a low suitability, e.g. due to steep slopes, diff --git a/modules/30_crop/rotation_apr22/equations.gms b/modules/30_crop/rotation_apr22/equations.gms index dd7270bcb4..d3db06641a 100644 --- a/modules/30_crop/rotation_apr22/equations.gms +++ b/modules/30_crop/rotation_apr22/equations.gms @@ -8,9 +8,11 @@ *' @equations *' The total land requirements for cropland are calculated as *' the sum of crop and water supply type specific land requirements: +*' Fallow is no explicit landuse type, but the difference between +*' the land area for crops vm_land and the croparea vm_area q30_cropland(j2) .. - sum((kcr,w), vm_area(j2,kcr,w)) =e= vm_land(j2,"crop") + vm_fallow(j2); + sum((kcr,w), vm_area(j2,kcr,w)) + vm_fallow(j2) =e= vm_land(j2,"crop"); *' We assume that crop production can only take place on suitable cropland area. *' We use a suitability index (SI) map from @zabel_global_2014 to exclude areas diff --git a/modules/31_past/endo_jun13/not_used.txt b/modules/31_past/endo_jun13/not_used.txt index 18bfcce33c..e695835bae 100644 --- a/modules/31_past/endo_jun13/not_used.txt +++ b/modules/31_past/endo_jun13/not_used.txt @@ -3,3 +3,4 @@ pcm_land, input, not needed vm_tau,input,questionnaire fm_pastr_tau_hist,input,questionnaire sm_fix_SSP2, input, not needed +sm_fix_cc, input, not needed diff --git a/modules/31_past/grasslands_apr22/input.gms b/modules/31_past/grasslands_apr22/input.gms index 03a32fcd1c..0896afc475 100644 --- a/modules/31_past/grasslands_apr22/input.gms +++ b/modules/31_past/grasslands_apr22/input.gms @@ -16,7 +16,6 @@ $setglobal c31_past_suit_scen ssp370 table f31_pastr_suitability(t_all,j,ssp_past) Areas suitable for pasture management (mio. ha) $ondelim $include "./modules/31_past/input/f31_pastr_suitability.cs3" - $offdelim ; @@ -28,11 +27,20 @@ $offdelim scalar s31_limit_calib Relative managament calibration switch (1=limited 0=pure relative) / 1 /; +$setglobal c31_grassl_yld_scenario cc +* options: cc (climate change) +* nocc (no climate change) +* nocc_hist (no climate change after year defined by sm_fix_cc) + table f31_grassl_yld(t_all,j,grassland,w) LPJmL potential yields per cell (rainfed only) (tDM per ha) $ondelim $include "./modules/31_past/input/f31_grassl_yld.cs3" $offdelim ; +* set values to 1995 if nocc scenario is used, or to sm_fix_cc after sm_fix_cc if nocc_hist is used +$if "%c31_grassl_yld_scenario%" == "nocc" f31_grassl_yld(t_all,j,grassland,w) = f31_grassl_yld("y1995",j,grassland,w); +$if "%c31_grassl_yld_scenario%" == "nocc_hist" f31_grassl_yld(t_all,j,grassland,w)$(m_year(t_all) > sm_fix_cc) = f31_grassl_yld(t_all,j,grassland,w)$(m_year(t_all) = sm_fix_cc); + table f31_grass_bio(t_all,i, grassland) Estimated regional grass biomass consumption in the past (tDM) $ondelim diff --git a/modules/31_past/grasslands_apr22/preloop.gms b/modules/31_past/grasslands_apr22/preloop.gms index 3b480a8f1b..5b48e2cfc5 100644 --- a/modules/31_past/grasslands_apr22/preloop.gms +++ b/modules/31_past/grasslands_apr22/preloop.gms @@ -5,8 +5,16 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -i31_manpast_suit(t_all,j) = f31_pastr_suitability(t_all,j,"%c31_past_suit_scen%"); -i31_manpast_suit(t_all,j)$(m_year(t_all) <= sm_fix_SSP2) = f31_pastr_suitability(t_all,j,"ssp245"); +$ifthen "%c31_past_suit_scen%" == "nocc" + i31_manpast_suit(t_all,j) = f31_pastr_suitability("y1995",j,"ssp245"); +$elseif "%c31_past_suit_scen%" == "nocc_hist" + i31_manpast_suit(t_all,j) = f31_pastr_suitability(t_all,j,"ssp245"); + i31_manpast_suit(t_all,j)$(m_year(t_all) > sm_fix_cc) = f31_pastr_suitability(t_all,j,"ssp245")$(m_year(t_all) = sm_fix_cc); +$else + i31_manpast_suit(t_all,j) = f31_pastr_suitability(t_all,j,"%c31_past_suit_scen%"); + i31_manpast_suit(t_all,j)$(m_year(t_all) <= sm_fix_SSP2) = f31_pastr_suitability(t_all,j,"ssp245"); +$endif + pc31_grass(j,grassland) = f31_LUH2v2("y1995",j,grassland); diff --git a/modules/31_past/static/not_used.txt b/modules/31_past/static/not_used.txt index 637a12d740..57f7b20c03 100644 --- a/modules/31_past/static/not_used.txt +++ b/modules/31_past/static/not_used.txt @@ -5,3 +5,4 @@ pm_land_conservation,input,questionnaire vm_tau,input,questionnaire fm_pastr_tau_hist,input,questionnaire sm_fix_SSP2, input, not needed +sm_fix_cc, input, not needed diff --git a/modules/41_area_equipped_for_irrigation/endo_apr13/declarations.gms b/modules/41_area_equipped_for_irrigation/endo_apr13/declarations.gms index 42d1d51c11..b61b9f5166 100644 --- a/modules/41_area_equipped_for_irrigation/endo_apr13/declarations.gms +++ b/modules/41_area_equipped_for_irrigation/endo_apr13/declarations.gms @@ -16,7 +16,7 @@ variables ; positive variables - vm_AEI(j) Area equipped for irrigation in each grid cell (mio. ha) + vm_AEI(j) Area equipped for irrigation in each grid cell (mio. ha) ; equations diff --git a/modules/41_area_equipped_for_irrigation/endo_apr13/input.gms b/modules/41_area_equipped_for_irrigation/endo_apr13/input.gms index 24beccec4b..ec5094b9c2 100644 --- a/modules/41_area_equipped_for_irrigation/endo_apr13/input.gms +++ b/modules/41_area_equipped_for_irrigation/endo_apr13/input.gms @@ -11,27 +11,15 @@ scalars s41_AEI_depreciation Depreciation rate in capital value of irrigation infrastructure (USD05PPP per USD05PPP) / 0 / ; - table f41_c_irrig(t_all,i) Irrigation investment costs (USD04MER per ha) $ondelim $include "./modules/41_area_equipped_for_irrigation/endo_apr13/input/f41_c_irrig.csv" $offdelim ; -parameters -f41_irrig(j) Available area equipped for irrigation according to Siebert [AVL] (mio. ha) -/ -$ondelim -$include "./modules/41_area_equipped_for_irrigation/input/avl_irrig.cs2" -$offdelim -/ -; - -parameters -f41_irrig_luh(t_ini41,j) Available area equipped for irrigation according to LUH [AVL] (mio. ha) -/ +table +f41_irrig(t_ini41,j,aei41) Available area equipped for irrigation [AVL] (mio. ha) $ondelim -$include "./modules/41_area_equipped_for_irrigation/input/avl_irrig_luh_t.cs2" +$include "./modules/41_area_equipped_for_irrigation/input/avl_irrig.cs3" $offdelim -/ ; diff --git a/modules/41_area_equipped_for_irrigation/endo_apr13/postsolve.gms b/modules/41_area_equipped_for_irrigation/endo_apr13/postsolve.gms index 7bf8c056d4..a71cb0733f 100644 --- a/modules/41_area_equipped_for_irrigation/endo_apr13/postsolve.gms +++ b/modules/41_area_equipped_for_irrigation/endo_apr13/postsolve.gms @@ -5,11 +5,8 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de - - pc41_AEI_start(j)=vm_AEI.l(j) ; - *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### ov_cost_AEI(t,i,"marginal") = vm_cost_AEI.m(i); ov_AEI(t,j,"marginal") = vm_AEI.m(j); diff --git a/modules/41_area_equipped_for_irrigation/endo_apr13/preloop.gms b/modules/41_area_equipped_for_irrigation/endo_apr13/preloop.gms index 5ffaf199fa..dfec267f1e 100644 --- a/modules/41_area_equipped_for_irrigation/endo_apr13/preloop.gms +++ b/modules/41_area_equipped_for_irrigation/endo_apr13/preloop.gms @@ -5,6 +5,5 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -$ifthen "%c41_initial_irrigation_area%" == "Siebert" pc41_AEI_start(j) = f41_irrig(j); -$elseif "%c41_initial_irrigation_area%" == "LUH2v2" pc41_AEI_start(j) = f41_irrig_luh("y1995",j); -$endif +*' Area equipped for irrigation in initialization year +pc41_AEI_start(j) = f41_irrig("y1995",j,"%c41_initial_irrigation_area%"); diff --git a/modules/41_area_equipped_for_irrigation/endo_apr13/presolve.gms b/modules/41_area_equipped_for_irrigation/endo_apr13/presolve.gms index c2f630a0da..02bfed4c8f 100644 --- a/modules/41_area_equipped_for_irrigation/endo_apr13/presolve.gms +++ b/modules/41_area_equipped_for_irrigation/endo_apr13/presolve.gms @@ -8,7 +8,7 @@ p41_AEI_start(t,j) = pc41_AEI_start(j); *' Updating existing capital stocks to account for depreciation -vm_AEI.lo(j) = pc41_AEI_start(j)/((1- s41_AEI_depreciation)**(m_timestep_length)); - +vm_AEI.lo(j) = pc41_AEI_start(j) / ((1 - s41_AEI_depreciation)**(m_timestep_length)); +*' Unit costs for irrigation expansion pc41_unitcost_AEI(i) = f41_c_irrig(t,i); diff --git a/modules/41_area_equipped_for_irrigation/endo_apr13/sets.gms b/modules/41_area_equipped_for_irrigation/endo_apr13/sets.gms index 92dee76fbe..0eb6194be7 100644 --- a/modules/41_area_equipped_for_irrigation/endo_apr13/sets.gms +++ b/modules/41_area_equipped_for_irrigation/endo_apr13/sets.gms @@ -8,4 +8,7 @@ sets t_ini41 Time periods with area equipped for irrigation initialization data / y1995, y2000, y2005, y2010, y2015 / + + aei41 Data source for area equipped for irrigation + / LUH2v2, Mehta2022 / ; diff --git a/modules/41_area_equipped_for_irrigation/input/files b/modules/41_area_equipped_for_irrigation/input/files index 17d076cde1..94f0346458 100644 --- a/modules/41_area_equipped_for_irrigation/input/files +++ b/modules/41_area_equipped_for_irrigation/input/files @@ -1,3 +1,2 @@ * list of files that are required here -avl_irrig.cs2 -avl_irrig_luh_t.cs2 +avl_irrig.cs3 diff --git a/modules/41_area_equipped_for_irrigation/static/declarations.gms b/modules/41_area_equipped_for_irrigation/static/declarations.gms index dd88de4a3d..fa4ffdbb5a 100644 --- a/modules/41_area_equipped_for_irrigation/static/declarations.gms +++ b/modules/41_area_equipped_for_irrigation/static/declarations.gms @@ -10,7 +10,7 @@ variables ; positive variables - vm_AEI(j) Area equipped for irrigation in each grid cell (mio. ha) + vm_AEI(j) Area equipped for irrigation in each grid cell (mio. ha) ; equations diff --git a/modules/41_area_equipped_for_irrigation/static/input.gms b/modules/41_area_equipped_for_irrigation/static/input.gms index d5519ef955..09202692df 100644 --- a/modules/41_area_equipped_for_irrigation/static/input.gms +++ b/modules/41_area_equipped_for_irrigation/static/input.gms @@ -7,20 +7,9 @@ $setglobal c41_initial_irrigation_area LUH2v2 -parameters -f41_irrig(j) Available area equipped for irrigation according to Siebert [AVL] (mio. ha) -/ +table +f41_irrig(t_ini41,j,aei41) Available area equipped for irrigation [AVL] (mio. ha) $ondelim -$include "./modules/41_area_equipped_for_irrigation/input/avl_irrig.cs2" +$include "./modules/41_area_equipped_for_irrigation/input/avl_irrig.cs3" $offdelim -/ -; - -parameters -f41_irrig_luh(t_ini41,j) Available area equipped for irrigation according to LUH [AVL] (mio. ha) -/ -$ondelim -$include "./modules/41_area_equipped_for_irrigation/input/avl_irrig_luh_t.cs2" -$offdelim -/ ; diff --git a/modules/41_area_equipped_for_irrigation/static/presolve.gms b/modules/41_area_equipped_for_irrigation/static/presolve.gms index 708110003e..3428e65569 100644 --- a/modules/41_area_equipped_for_irrigation/static/presolve.gms +++ b/modules/41_area_equipped_for_irrigation/static/presolve.gms @@ -5,8 +5,7 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -$ifthen "%c41_initial_irrigation_area%" == "Siebert" vm_AEI.fx(j) = f41_irrig(j); -$elseif "%c41_initial_irrigation_area%" == "LUH2v2" vm_AEI.fx(j) = f41_irrig_luh("y1995",j); -$endif +*' Area equipped for irrigation in initialization year +vm_AEI.fx(j) = f41_irrig("y1995",j,"%c41_initial_irrigation_area%"); vm_cost_AEI.fx(i) = 0; diff --git a/modules/41_area_equipped_for_irrigation/static/sets.gms b/modules/41_area_equipped_for_irrigation/static/sets.gms index 92dee76fbe..0eb6194be7 100644 --- a/modules/41_area_equipped_for_irrigation/static/sets.gms +++ b/modules/41_area_equipped_for_irrigation/static/sets.gms @@ -8,4 +8,7 @@ sets t_ini41 Time periods with area equipped for irrigation initialization data / y1995, y2000, y2005, y2010, y2015 / + + aei41 Data source for area equipped for irrigation + / LUH2v2, Mehta2022 / ; diff --git a/modules/51_nitrogen/module.gms b/modules/51_nitrogen/module.gms index 4b530725d6..e28a27bf21 100644 --- a/modules/51_nitrogen/module.gms +++ b/modules/51_nitrogen/module.gms @@ -14,7 +14,6 @@ *' @authors Benjamin Leon Bodirsky *###################### R SECTION START (MODULETYPES) ########################## -$Ifi "%nitrogen%" == "ipcc2006_sep16" $include "./modules/51_nitrogen/ipcc2006_sep16/realization.gms" $Ifi "%nitrogen%" == "off" $include "./modules/51_nitrogen/off/realization.gms" $Ifi "%nitrogen%" == "rescaled_jan21" $include "./modules/51_nitrogen/rescaled_jan21/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/52_carbon/normal_dec17/input.gms b/modules/52_carbon/normal_dec17/input.gms index 93016aeee8..f9e9d2f35d 100644 --- a/modules/52_carbon/normal_dec17/input.gms +++ b/modules/52_carbon/normal_dec17/input.gms @@ -48,4 +48,11 @@ $offdelim ; $offEmpty -i52_land_carbon_sink(t_all,i) = f52_land_carbon_sink(t_all,i,"%c52_land_carbon_sink_rcp%"); +$ifthen "%c52_land_carbon_sink_rcp%" == "nocc" + i52_land_carbon_sink(t_all,i) = f52_land_carbon_sink("y1995",i,"RCPBU"); +$elseif "%c52_land_carbon_sink_rcp%" == "nocc_hist" + i52_land_carbon_sink(t_all,i) = f52_land_carbon_sink(t_all,i,"RCPBU"); + i52_land_carbon_sink(t_all,i)$(m_year(t_all) > sm_fix_cc) = f52_land_carbon_sink(t_all,i,"RCPBU")$(m_year(t_all) = sm_fix_cc); +$else + i52_land_carbon_sink(t_all,i) = f52_land_carbon_sink(t_all,i,"%c52_land_carbon_sink_rcp%"); +$endif diff --git a/modules/71_disagg_lvst/foragebased_aug18/declarations.gms b/modules/71_disagg_lvst/foragebased_aug18/declarations.gms index d68611a046..f3a74d5b78 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/declarations.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/declarations.gms @@ -7,21 +7,20 @@ positive variables v71_prod_rum(j,kli_rum,kforage) Production of forage fed ruminants within a cell (mio. tDM per yr) - v71_additional_mon(j, kli_mon) Additional punished production of monogastric livestock (mio. tDM per yr) - vm_costs_additional_mon(i) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) + v71_additional_mon(j, kli_mon) Additional punished production of monogastric livestock (mio. tDM per yr) + vm_costs_additional_mon(i) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) ; variables - v71_feed_balanceflow(j,kli_rum,kforage) Cellular feed balanceflow for forage feed for ruminant livestock (mio. tDM per yr) + v71_feed_balanceflow_share(j,kli_rum,kforage) Cellular feed balanceflow multiplier for forage feed for ruminant livestock (1) ; equations q71_feed_rum_liv(j,kforage) Production constraint for ruminant livestock products (mio. tDM per yr) - q71_balanceflow_constraint_nlp(j,kli_rum,kforage) Nonlinear balanceflow constraint for cellular forage feed products (mio. tDM per yr) - q71_balanceflow_constraint_lp(i,kli_rum,kforage) Linear balanceflow constraint for cellular forage feed product (mio. tDM per yr) + q71_balanceflow_constraint(j,kli_rum,kforage) Nonlinear balanceflow constraint for cellular forage feed products (mio. tDM per yr) q71_sum_rum_liv(j,kli_rum) Total production of forage fed ruminants (mio. tDM per yr) q71_prod_mon_liv(j,kli_mon) Production constraint for monogastric livestock products (mio. tDM per yr) - q71_punishment_mon(i) Punishment for additional monogastrics (mio. USD05MER per yr) + q71_punishment_mon(i) Punishment for additional monogastrics (mio. USD05MER per yr) ; parameters @@ -29,22 +28,20 @@ parameters ; scalars - s71_lp_fix Switch to fix equations to linear relation (Logical) s71_scale_mon Scalar for flexible distribution of monogastrics (1) s71_punish_additional_mon Scaling factor for transport punishment (USD05MER per tDM) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - ov71_prod_rum(t,j,kli_rum,kforage,type) Production of forage fed ruminants within a cell (mio. tDM per yr) - ov71_additional_mon(t,j,kli_mon,type) Additional punished production of monogastric livestock (mio. tDM per yr) - ov_costs_additional_mon(t,i,type) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) - ov71_feed_balanceflow(t,j,kli_rum,kforage,type) Cellular feed balanceflow for forage feed for ruminant livestock (mio. tDM per yr) - oq71_feed_rum_liv(t,j,kforage,type) Production constraint for ruminant livestock products (mio. tDM per yr) - oq71_balanceflow_constraint_nlp(t,j,kli_rum,kforage,type) Nonlinear balanceflow constraint for cellular forage feed products (mio. tDM per yr) - oq71_balanceflow_constraint_lp(t,i,kli_rum,kforage,type) Linear balanceflow constraint for cellular forage feed product (mio. tDM per yr) - oq71_sum_rum_liv(t,j,kli_rum,type) Total production of forage fed ruminants (mio. tDM per yr) - oq71_prod_mon_liv(t,j,kli_mon,type) Production constraint for monogastric livestock products (mio. tDM per yr) - oq71_punishment_mon(t,i,type) Punishment for additional monogastrics (mio. USD05MER per yr) + ov71_prod_rum(t,j,kli_rum,kforage,type) Production of forage fed ruminants within a cell (mio. tDM per yr) + ov71_additional_mon(t,j,kli_mon,type) Additional punished production of monogastric livestock (mio. tDM per yr) + ov_costs_additional_mon(t,i,type) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) + ov71_feed_balanceflow_share(t,j,kli_rum,kforage,type) Cellular feed balanceflow multiplier for forage feed for ruminant livestock (1) + oq71_feed_rum_liv(t,j,kforage,type) Production constraint for ruminant livestock products (mio. tDM per yr) + oq71_balanceflow_constraint(t,j,kli_rum,kforage,type) Nonlinear balanceflow constraint for cellular forage feed products (mio. tDM per yr) + oq71_sum_rum_liv(t,j,kli_rum,type) Total production of forage fed ruminants (mio. tDM per yr) + oq71_prod_mon_liv(t,j,kli_mon,type) Production constraint for monogastric livestock products (mio. tDM per yr) + oq71_punishment_mon(t,i,type) Punishment for additional monogastrics (mio. USD05MER per yr) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/71_disagg_lvst/foragebased_aug18/equations.gms b/modules/71_disagg_lvst/foragebased_aug18/equations.gms index 575ba6c47b..be1490c045 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/equations.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/equations.gms @@ -11,48 +11,28 @@ *' feed items grazed pasture and fodder. These must be larger than the ruminant feed requirements *' that are given by the product of ruminant production and the respective feed baskets: -q71_feed_rum_liv(j2,kforage) .. - vm_prod(j2,kforage) =g= - sum(kli_rum, v71_prod_rum(j2,kli_rum,kforage) - * sum((ct,cell(i2,j2),kforage2),im_feed_baskets(ct,i2,kli_rum,kforage2)) - * (1 + v71_feed_balanceflow(j2,kli_rum,kforage)$(s71_lp_fix=0)) - + v71_feed_balanceflow(j2,kli_rum,kforage)$(s71_lp_fix=1)) - ; - +q71_feed_rum_liv(j2, kforage) .. + vm_prod(j2, kforage) =g= + sum(kli_rum, v71_prod_rum(j2, kli_rum, kforage) + * sum((ct, cell(i2,j2), kforage2), im_feed_baskets(ct, i2, kli_rum,kforage2)) * + v71_feed_balanceflow_share(j2, kli_rum, kforage)) + ; *' The above equation contains a split of pasture and fodder fed ruminants, since we assume that depending *' on the intensity level of the livestock production, ruminants will graze on pastures (extensive systems) *' or will be fed via harvested fodder crops (intensive systems). -*' Please note that `s71_lp_fix` is set to zero (for more information please look into the source code). - -*' The balance flow for pasture and fodder (summarized with forage) production, accounts as in -*' [70_livestock] `q70_feed(i2,kap,kall)` for inconsistencies with the FAO inventory of national feed use. -*' @stop - -* If module is fixed to linear behaviour the balance flow is allowed to be used in any cell -* containing pasture or cropland area in the previous time step ensured by the restrictions -* in the nl_fix statement. The balance flow within a region is then determined by - -q71_balanceflow_constraint_lp(i2,kli_rum,kforage)$(s71_lp_fix=1) .. - sum(ct, fm_feed_balanceflow(ct,i2,kli_rum,kforage)) =e= - sum(cell(i2,j2), v71_feed_balanceflow(j2,kli_rum,kforage)) - ; +*' A regional balance flow accounts in [70_livestock] `q70_feed(i2,kap,kall)` for inconsistencies with +*' the FAO inventory of national feed use. On cellular level we distribute the regional balance flow as +*' a multiplicative correction term (introduced in `q71_feed_rum_liv`) that is given by -* Note that for fixation to linear behaviour `q71_balanceflow_constraint_lp` replaces `q71_balanceflow_constraint_nlp`. - -*' @equations - -*' In each cluster the balance flow is constrained by its share of livestock production regarding the regional level by - -q71_balanceflow_constraint_nlp(j2,kli_rum,kforage)$(s71_lp_fix=0) .. - v71_feed_balanceflow(j2,kli_rum,kforage) =e= - sum((ct,cell(i2,j2)),fm_feed_balanceflow(ct,i2,kli_rum,kforage) - /(im_feed_baskets(ct,i2,kli_rum,kforage)*vm_prod_reg(i2,kli_rum) + 10**(-6))) - ; +q71_balanceflow_constraint(j2, kli_rum, kforage) .. + v71_feed_balanceflow_share(j2, kli_rum, kforage) =e= + 1 + sum((ct, cell(i2,j2)), fm_feed_balanceflow(ct, i2, kli_rum, kforage) / + (im_feed_baskets(ct, i2, kli_rum, kforage) * vm_prod_reg(i2, kli_rum) + 10**(-10))) + ; -*' Note that $10^{-6}$ is required to avoid division by zero. -*' The regional ruminant production is then given by +*' The total cellular ruminant production is then given by q71_sum_rum_liv(j2,kli_rum) .. vm_prod(j2,kli_rum) =e= sum(kforage,v71_prod_rum(j2,kli_rum,kforage)) diff --git a/modules/71_disagg_lvst/foragebased_aug18/nl_fix.gms b/modules/71_disagg_lvst/foragebased_aug18/nl_fix.gms deleted file mode 100644 index 3e88e2581d..0000000000 --- a/modules/71_disagg_lvst/foragebased_aug18/nl_fix.gms +++ /dev/null @@ -1,16 +0,0 @@ -*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) -*** | authors, and contributors see CITATION.cff file. This file is part -*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -*** | AGPL-3.0, you are granted additional permissions described in the -*** | MAgPIE License Exception, version 1.0 (see LICENSE file). -*** | Contact: magpie@pik-potsdam.de - -* ### nl_fix ### - -v71_feed_balanceflow.lo(j,kli_rum,kforage)$(sum(cell(i,j),fm_feed_balanceflow(t,i,kli_rum,kforage)) > 0) = 0; -v71_feed_balanceflow.up(j,kli_rum,kforage)$(sum(cell(i,j),fm_feed_balanceflow(t,i,kli_rum,kforage)) < 0) = 0; -v71_feed_balanceflow.fx(j,kli_rum,kforage)$(sum(cell(i,j),fm_feed_balanceflow(t,i,kli_rum,kforage)) = 0) = 0; -v71_feed_balanceflow.fx(j,kli_rum,"pasture")$(pcm_land(j,"past")=0) = 0; -v71_feed_balanceflow.fx(j,kli_rum,"foddr")$(pcm_land(j,"crop")=0) = 0; - -s71_lp_fix=1; diff --git a/modules/71_disagg_lvst/foragebased_aug18/not_used.txt b/modules/71_disagg_lvst/foragebased_aug18/not_used.txt new file mode 100644 index 0000000000..2feaafe196 --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_aug18/not_used.txt @@ -0,0 +1,2 @@ +name,type,reason +pcm_land,input,questionnaire diff --git a/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms b/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms index 9c2b6507f3..ca1e1eacf6 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms @@ -6,44 +6,40 @@ *** | Contact: magpie@pik-potsdam.de *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov71_prod_rum(t,j,kli_rum,kforage,"marginal") = v71_prod_rum.m(j,kli_rum,kforage); - ov71_additional_mon(t,j,kli_mon,"marginal") = v71_additional_mon.m(j,kli_mon); - ov_costs_additional_mon(t,i,"marginal") = vm_costs_additional_mon.m(i); - ov71_feed_balanceflow(t,j,kli_rum,kforage,"marginal") = v71_feed_balanceflow.m(j,kli_rum,kforage); - oq71_feed_rum_liv(t,j,kforage,"marginal") = q71_feed_rum_liv.m(j,kforage); - oq71_balanceflow_constraint_nlp(t,j,kli_rum,kforage,"marginal") = q71_balanceflow_constraint_nlp.m(j,kli_rum,kforage); - oq71_balanceflow_constraint_lp(t,i,kli_rum,kforage,"marginal") = q71_balanceflow_constraint_lp.m(i,kli_rum,kforage); - oq71_sum_rum_liv(t,j,kli_rum,"marginal") = q71_sum_rum_liv.m(j,kli_rum); - oq71_prod_mon_liv(t,j,kli_mon,"marginal") = q71_prod_mon_liv.m(j,kli_mon); - oq71_punishment_mon(t,i,"marginal") = q71_punishment_mon.m(i); - ov71_prod_rum(t,j,kli_rum,kforage,"level") = v71_prod_rum.l(j,kli_rum,kforage); - ov71_additional_mon(t,j,kli_mon,"level") = v71_additional_mon.l(j,kli_mon); - ov_costs_additional_mon(t,i,"level") = vm_costs_additional_mon.l(i); - ov71_feed_balanceflow(t,j,kli_rum,kforage,"level") = v71_feed_balanceflow.l(j,kli_rum,kforage); - oq71_feed_rum_liv(t,j,kforage,"level") = q71_feed_rum_liv.l(j,kforage); - oq71_balanceflow_constraint_nlp(t,j,kli_rum,kforage,"level") = q71_balanceflow_constraint_nlp.l(j,kli_rum,kforage); - oq71_balanceflow_constraint_lp(t,i,kli_rum,kforage,"level") = q71_balanceflow_constraint_lp.l(i,kli_rum,kforage); - oq71_sum_rum_liv(t,j,kli_rum,"level") = q71_sum_rum_liv.l(j,kli_rum); - oq71_prod_mon_liv(t,j,kli_mon,"level") = q71_prod_mon_liv.l(j,kli_mon); - oq71_punishment_mon(t,i,"level") = q71_punishment_mon.l(i); - ov71_prod_rum(t,j,kli_rum,kforage,"upper") = v71_prod_rum.up(j,kli_rum,kforage); - ov71_additional_mon(t,j,kli_mon,"upper") = v71_additional_mon.up(j,kli_mon); - ov_costs_additional_mon(t,i,"upper") = vm_costs_additional_mon.up(i); - ov71_feed_balanceflow(t,j,kli_rum,kforage,"upper") = v71_feed_balanceflow.up(j,kli_rum,kforage); - oq71_feed_rum_liv(t,j,kforage,"upper") = q71_feed_rum_liv.up(j,kforage); - oq71_balanceflow_constraint_nlp(t,j,kli_rum,kforage,"upper") = q71_balanceflow_constraint_nlp.up(j,kli_rum,kforage); - oq71_balanceflow_constraint_lp(t,i,kli_rum,kforage,"upper") = q71_balanceflow_constraint_lp.up(i,kli_rum,kforage); - oq71_sum_rum_liv(t,j,kli_rum,"upper") = q71_sum_rum_liv.up(j,kli_rum); - oq71_prod_mon_liv(t,j,kli_mon,"upper") = q71_prod_mon_liv.up(j,kli_mon); - oq71_punishment_mon(t,i,"upper") = q71_punishment_mon.up(i); - ov71_prod_rum(t,j,kli_rum,kforage,"lower") = v71_prod_rum.lo(j,kli_rum,kforage); - ov71_additional_mon(t,j,kli_mon,"lower") = v71_additional_mon.lo(j,kli_mon); - ov_costs_additional_mon(t,i,"lower") = vm_costs_additional_mon.lo(i); - ov71_feed_balanceflow(t,j,kli_rum,kforage,"lower") = v71_feed_balanceflow.lo(j,kli_rum,kforage); - oq71_feed_rum_liv(t,j,kforage,"lower") = q71_feed_rum_liv.lo(j,kforage); - oq71_balanceflow_constraint_nlp(t,j,kli_rum,kforage,"lower") = q71_balanceflow_constraint_nlp.lo(j,kli_rum,kforage); - oq71_balanceflow_constraint_lp(t,i,kli_rum,kforage,"lower") = q71_balanceflow_constraint_lp.lo(i,kli_rum,kforage); - oq71_sum_rum_liv(t,j,kli_rum,"lower") = q71_sum_rum_liv.lo(j,kli_rum); - oq71_prod_mon_liv(t,j,kli_mon,"lower") = q71_prod_mon_liv.lo(j,kli_mon); - oq71_punishment_mon(t,i,"lower") = q71_punishment_mon.lo(i); + ov71_prod_rum(t,j,kli_rum,kforage,"marginal") = v71_prod_rum.m(j,kli_rum,kforage); + ov71_additional_mon(t,j,kli_mon,"marginal") = v71_additional_mon.m(j,kli_mon); + ov_costs_additional_mon(t,i,"marginal") = vm_costs_additional_mon.m(i); + ov71_feed_balanceflow_share(t,j,kli_rum,kforage,"marginal") = v71_feed_balanceflow_share.m(j,kli_rum,kforage); + oq71_feed_rum_liv(t,j,kforage,"marginal") = q71_feed_rum_liv.m(j,kforage); + oq71_balanceflow_constraint(t,j,kli_rum,kforage,"marginal") = q71_balanceflow_constraint.m(j,kli_rum,kforage); + oq71_sum_rum_liv(t,j,kli_rum,"marginal") = q71_sum_rum_liv.m(j,kli_rum); + oq71_prod_mon_liv(t,j,kli_mon,"marginal") = q71_prod_mon_liv.m(j,kli_mon); + oq71_punishment_mon(t,i,"marginal") = q71_punishment_mon.m(i); + ov71_prod_rum(t,j,kli_rum,kforage,"level") = v71_prod_rum.l(j,kli_rum,kforage); + ov71_additional_mon(t,j,kli_mon,"level") = v71_additional_mon.l(j,kli_mon); + ov_costs_additional_mon(t,i,"level") = vm_costs_additional_mon.l(i); + ov71_feed_balanceflow_share(t,j,kli_rum,kforage,"level") = v71_feed_balanceflow_share.l(j,kli_rum,kforage); + oq71_feed_rum_liv(t,j,kforage,"level") = q71_feed_rum_liv.l(j,kforage); + oq71_balanceflow_constraint(t,j,kli_rum,kforage,"level") = q71_balanceflow_constraint.l(j,kli_rum,kforage); + oq71_sum_rum_liv(t,j,kli_rum,"level") = q71_sum_rum_liv.l(j,kli_rum); + oq71_prod_mon_liv(t,j,kli_mon,"level") = q71_prod_mon_liv.l(j,kli_mon); + oq71_punishment_mon(t,i,"level") = q71_punishment_mon.l(i); + ov71_prod_rum(t,j,kli_rum,kforage,"upper") = v71_prod_rum.up(j,kli_rum,kforage); + ov71_additional_mon(t,j,kli_mon,"upper") = v71_additional_mon.up(j,kli_mon); + ov_costs_additional_mon(t,i,"upper") = vm_costs_additional_mon.up(i); + ov71_feed_balanceflow_share(t,j,kli_rum,kforage,"upper") = v71_feed_balanceflow_share.up(j,kli_rum,kforage); + oq71_feed_rum_liv(t,j,kforage,"upper") = q71_feed_rum_liv.up(j,kforage); + oq71_balanceflow_constraint(t,j,kli_rum,kforage,"upper") = q71_balanceflow_constraint.up(j,kli_rum,kforage); + oq71_sum_rum_liv(t,j,kli_rum,"upper") = q71_sum_rum_liv.up(j,kli_rum); + oq71_prod_mon_liv(t,j,kli_mon,"upper") = q71_prod_mon_liv.up(j,kli_mon); + oq71_punishment_mon(t,i,"upper") = q71_punishment_mon.up(i); + ov71_prod_rum(t,j,kli_rum,kforage,"lower") = v71_prod_rum.lo(j,kli_rum,kforage); + ov71_additional_mon(t,j,kli_mon,"lower") = v71_additional_mon.lo(j,kli_mon); + ov_costs_additional_mon(t,i,"lower") = vm_costs_additional_mon.lo(i); + ov71_feed_balanceflow_share(t,j,kli_rum,kforage,"lower") = v71_feed_balanceflow_share.lo(j,kli_rum,kforage); + oq71_feed_rum_liv(t,j,kforage,"lower") = q71_feed_rum_liv.lo(j,kforage); + oq71_balanceflow_constraint(t,j,kli_rum,kforage,"lower") = q71_balanceflow_constraint.lo(j,kli_rum,kforage); + oq71_sum_rum_liv(t,j,kli_rum,"lower") = q71_sum_rum_liv.lo(j,kli_rum); + oq71_prod_mon_liv(t,j,kli_mon,"lower") = q71_prod_mon_liv.lo(j,kli_mon); + oq71_punishment_mon(t,i,"lower") = q71_punishment_mon.lo(i); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/71_disagg_lvst/foragebased_aug18/preloop.gms b/modules/71_disagg_lvst/foragebased_aug18/preloop.gms index e7235b9da5..c28ebc62d7 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/preloop.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/preloop.gms @@ -9,6 +9,9 @@ i71_urban_area_share(j) = pm_land_start(j,"urban")/sum(cell(i,j),sum(cell2(i,j3),pm_land_start(j3,"urban"))) ; -s71_lp_fix = 0; s71_scale_mon = 1.10; s71_punish_additional_mon = 15000; + +* Minimal regional production of `kli_rum` to avoid division by zero in `q71_feed_balanceflow`. +vm_prod_reg.lo(i,kli_rum) = 10**(-6); + diff --git a/modules/71_disagg_lvst/foragebased_aug18/realization.gms b/modules/71_disagg_lvst/foragebased_aug18/realization.gms index dfea6fd299..11effc8e81 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/realization.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/realization.gms @@ -8,12 +8,17 @@ *' @description The foragebased_aug18 realization constrains the cellular ruminant livestock production by *' the feed availability for grazed pasture and fodder crops. This accounts for the fact that pasture and fodder *' (summarized with forage) feed stuff is usually not transported over long distances and at the same time -*' is very essential in livestock diets. The monogastric livestock is distributed following the idea -*' that these animals are held close to densely populated areas. For more detailed information on cellular livestock -*' distribution see @robinson_mapping_2014, which inspired this realization. +*' is very essential in livestock diets. Internally it distinguishs between extensively and intensively fed ruminants. +*' The monogastric livestock is distributed following the idea that these animals are held close to densely populated +*' areas. For more detailed information on cellular livestock distribution see @robinson_mapping_2014, which inspired +*' this realization. -*' @limitations Distribution of monogastrics do not account for feed availability within a cell. Crop residue feed stuff -*' for ruminant production is also not considered to restrict livestock production. +*' This realization includes a minimal lower bound for ruminant production to avoid avoid GAMS corner solutions at +*' higher spatial resolutions. + +*' @limitations Distribution of monogastrics do not account for feed availability within a cell. +*' Crop residue feed stuff for ruminant production is also not considered to restrict livestock +*' production. Forage feed stuff is consider not to be transported, but is in reality. *####################### R SECTION START (PHASES) ############################## $Ifi "%phase%" == "sets" $include "./modules/71_disagg_lvst/foragebased_aug18/sets.gms" @@ -22,6 +27,4 @@ $Ifi "%phase%" == "equations" $include "./modules/71_disagg_lvst/foragebased_aug $Ifi "%phase%" == "scaling" $include "./modules/71_disagg_lvst/foragebased_aug18/scaling.gms" $Ifi "%phase%" == "preloop" $include "./modules/71_disagg_lvst/foragebased_aug18/preloop.gms" $Ifi "%phase%" == "postsolve" $include "./modules/71_disagg_lvst/foragebased_aug18/postsolve.gms" -$Ifi "%phase%" == "nl_fix" $include "./modules/71_disagg_lvst/foragebased_aug18/nl_fix.gms" -$Ifi "%phase%" == "nl_release" $include "./modules/71_disagg_lvst/foragebased_aug18/nl_release.gms" *######################## R SECTION END (PHASES) ############################### diff --git a/modules/71_disagg_lvst/foragebased_jul23/declarations.gms b/modules/71_disagg_lvst/foragebased_jul23/declarations.gms new file mode 100644 index 0000000000..b663054aa8 --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_jul23/declarations.gms @@ -0,0 +1,50 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + +positive variables + v71_feed_forage(j, kforage) Production of forage within a cell (mio. tDM per yr) + v71_additional_mon(j, kli_mon) Additional punished production of monogastric livestock (mio. tDM per yr) + vm_costs_additional_mon(i) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) +; + +variables + v71_feed_balanceflow(j, kforage) Cellular feed balanceflow for forage feed for ruminant livestock (mio. tDM per yr) +; + +equations + q71_feed_rum_liv(j, kforage) Production constraint for ruminant livestock products (mio. tDM per yr) + q71_feed_forage(j) Forage feed constraint (mio. tDM per yr) + q71_feed_balanceflow_nlp(j) Non-linear balanceflow constraint for forage feed products (mio. tDM per yr) + q71_feed_balanceflow_lp(i) Linear balanceflow constraint for forage feed products (mio. tDM per yr) + q71_prod_mon_liv(j,kli_mon) Production constraint for monogastric livestock products (mio. tDM per yr) + q71_punishment_mon(i) Punishment for additional monogastrics (mio. USD05MER per yr) +; + +parameters + i71_urban_area_share(j) Share of urban area within a region (1) +; + +scalars + s71_lp_fix Switch to fix equations to linear relation (Logical) + s71_scale_mon Scalar for flexible distribution of monogastrics (1) + s71_punish_additional_mon Scaling factor for transport punishment (USD05MER per tDM) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov71_feed_forage(t,j,kforage,type) Production of forage within a cell (mio. tDM per yr) + ov71_additional_mon(t,j,kli_mon,type) Additional punished production of monogastric livestock (mio. tDM per yr) + ov_costs_additional_mon(t,i,type) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) + ov71_feed_balanceflow(t,j,kforage,type) Cellular feed balanceflow for forage feed for ruminant livestock (mio. tDM per yr) + oq71_feed_rum_liv(t,j,kforage,type) Production constraint for ruminant livestock products (mio. tDM per yr) + oq71_feed_forage(t,j,type) Forage feed constraint (mio. tDM per yr) + oq71_feed_balanceflow_nlp(t,j,type) Non-linear balanceflow constraint for forage feed products (mio. tDM per yr) + oq71_feed_balanceflow_lp(t,i,type) Linear balanceflow constraint for forage feed products (mio. tDM per yr) + oq71_prod_mon_liv(t,j,kli_mon,type) Production constraint for monogastric livestock products (mio. tDM per yr) + oq71_punishment_mon(t,i,type) Punishment for additional monogastrics (mio. USD05MER per yr) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/71_disagg_lvst/foragebased_jul23/equations.gms b/modules/71_disagg_lvst/foragebased_jul23/equations.gms new file mode 100644 index 0000000000..8c18f57f44 --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_jul23/equations.gms @@ -0,0 +1,72 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + +*' @equations + +*' Ruminant livestock production within a cell is determined by the production of the non-transportable +*' feed items grazed pasture and fodder (`kforage`). Forage production must be larger than the ruminant feed requirements +*' (`v71_feed_forage`) adjusted by a balance flow (`v71_feed_forage`). + +q71_feed_rum_liv(j2,kforage) .. + vm_prod(j2,kforage) =g= + v71_feed_forage(j2,kforage) + + v71_feed_balanceflow(j2,kforage); + +*' Ruminant feed requirements are given by the product of ruminant production and the respective feed baskets. + +q71_feed_forage(j2) .. + sum(kforage, v71_feed_forage(j2,kforage)) =e= + sum((kli_rum,kforage), vm_prod(j2,kli_rum) + * sum((ct,cell(i2,j2)),im_feed_baskets(ct,i2,kli_rum,kforage))); + +*' The above equation contains a split of pasture and fodder fed ruminant feed requirements, since we assume +*' that depending on the intensity level of the livestock production, ruminants will graze on pastures (extensive systems) +*' or will be fed via harvested fodder crops (intensive systems). + +*' The balance flow for pasture and fodder production (`kforage`) accounts as in [70_livestock] `q70_feed(i2,kap,kall)` +*' for inconsistencies with the FAO inventory of national feed use. In each cluster the balance flow is constrained by +*' its share of livestock production regarding the regional level by + +q71_feed_balanceflow_nlp(j2)$(s71_lp_fix=0) .. + sum(kforage, v71_feed_balanceflow(j2,kforage)) =e= + sum((ct,cell(i2,j2),kli_rum,kforage), fm_feed_balanceflow(ct,i2,kli_rum,kforage) + * (vm_prod(j2,kli_rum) / (vm_prod_reg(i2,kli_rum)))); + +*' @stop + +* If fixed to linear behaviour (`s71_lp_fix=1`) the balance flow for pasture and fodder production (`kforage`) +* can be freely distributed among all cells beloning to a region. + +q71_feed_balanceflow_lp(i2)$(s71_lp_fix=1) .. + sum((cell(i2,j2),kforage), v71_feed_balanceflow(j2,kforage)) =e= + sum((ct,kli_rum,kforage), fm_feed_balanceflow(ct,i2,kli_rum,kforage)); + +* Note that for fixation to linear behaviour `q71_feed_balanceflow_lp` replaces `q71_feed_balanceflow_nlp`. + +*' @equations + +*' To account for the above mentioned fact that monogastric livestock are held close to the population, it is +*' distributed based on urban area by the formula + +q71_prod_mon_liv(j2,kli_mon) .. + vm_prod(j2,kli_mon) =l= + i71_urban_area_share(j2) * s71_scale_mon * sum(cell(i2,j2),vm_prod_reg(i2,kli_mon)) + + v71_additional_mon(j2,kli_mon) + ; + +*' Note that s71_scale_mon relaxes the constraint (per default by 10%) and v71_additional_mon ensures +*' feasability by punishing additonal monogastric production within a cluster. + +*' The punishmment of additional monogastric livestock production are calculated via + +q71_punishment_mon(i2) .. + vm_costs_additional_mon(i2) =e= + sum((cell(i2,j2),kli_mon), v71_additional_mon(j2,kli_mon)) * s71_punish_additional_mon + ; + +*' Note that the punishment costs are based on transport costs and scaled up by one order of magnitude +*' of the average transport costs to account for additional transport between clusters. diff --git a/modules/71_disagg_lvst/foragebased_jul23/nl_fix.gms b/modules/71_disagg_lvst/foragebased_jul23/nl_fix.gms new file mode 100644 index 0000000000..c583b2e187 --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_jul23/nl_fix.gms @@ -0,0 +1,14 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + +* ### nl_fix ### + +v71_feed_balanceflow.lo(j,kforage)$(sum((cell(i,j),kli_rum),fm_feed_balanceflow(t,i,kli_rum,kforage)) > 0) = 0; +v71_feed_balanceflow.up(j,kforage)$(sum((cell(i,j),kli_rum),fm_feed_balanceflow(t,i,kli_rum,kforage)) < 0) = 0; +v71_feed_balanceflow.fx(j,kforage)$(sum((cell(i,j),kli_rum),fm_feed_balanceflow(t,i,kli_rum,kforage)) = 0) = 0; +v71_feed_balanceflow.fx(j,"pasture")$(pcm_land(j,"past")=0) = 0; +v71_feed_balanceflow.fx(j,"foddr")$(pcm_land(j,"crop")=0) = 0; diff --git a/modules/71_disagg_lvst/foragebased_aug18/nl_release.gms b/modules/71_disagg_lvst/foragebased_jul23/nl_release.gms similarity index 78% rename from modules/71_disagg_lvst/foragebased_aug18/nl_release.gms rename to modules/71_disagg_lvst/foragebased_jul23/nl_release.gms index cbad58b03d..7b216fd4c5 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/nl_release.gms +++ b/modules/71_disagg_lvst/foragebased_jul23/nl_release.gms @@ -7,7 +7,5 @@ * ### nl_release ### -v71_feed_balanceflow.lo(j,kli_rum,kforage)= -Inf; -v71_feed_balanceflow.up(j,kli_rum,kforage)= Inf; - -s71_lp_fix=0; +v71_feed_balanceflow.lo(j,kforage)= -Inf; +v71_feed_balanceflow.up(j,kforage)= Inf; diff --git a/modules/71_disagg_lvst/foragebased_jul23/postsolve.gms b/modules/71_disagg_lvst/foragebased_jul23/postsolve.gms new file mode 100644 index 0000000000..959882e6e9 --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_jul23/postsolve.gms @@ -0,0 +1,49 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov71_feed_forage(t,j,kforage,"marginal") = v71_feed_forage.m(j,kforage); + ov71_additional_mon(t,j,kli_mon,"marginal") = v71_additional_mon.m(j,kli_mon); + ov_costs_additional_mon(t,i,"marginal") = vm_costs_additional_mon.m(i); + ov71_feed_balanceflow(t,j,kforage,"marginal") = v71_feed_balanceflow.m(j,kforage); + oq71_feed_rum_liv(t,j,kforage,"marginal") = q71_feed_rum_liv.m(j,kforage); + oq71_feed_forage(t,j,"marginal") = q71_feed_forage.m(j); + oq71_feed_balanceflow_nlp(t,j,"marginal") = q71_feed_balanceflow_nlp.m(j); + oq71_feed_balanceflow_lp(t,i,"marginal") = q71_feed_balanceflow_lp.m(i); + oq71_prod_mon_liv(t,j,kli_mon,"marginal") = q71_prod_mon_liv.m(j,kli_mon); + oq71_punishment_mon(t,i,"marginal") = q71_punishment_mon.m(i); + ov71_feed_forage(t,j,kforage,"level") = v71_feed_forage.l(j,kforage); + ov71_additional_mon(t,j,kli_mon,"level") = v71_additional_mon.l(j,kli_mon); + ov_costs_additional_mon(t,i,"level") = vm_costs_additional_mon.l(i); + ov71_feed_balanceflow(t,j,kforage,"level") = v71_feed_balanceflow.l(j,kforage); + oq71_feed_rum_liv(t,j,kforage,"level") = q71_feed_rum_liv.l(j,kforage); + oq71_feed_forage(t,j,"level") = q71_feed_forage.l(j); + oq71_feed_balanceflow_nlp(t,j,"level") = q71_feed_balanceflow_nlp.l(j); + oq71_feed_balanceflow_lp(t,i,"level") = q71_feed_balanceflow_lp.l(i); + oq71_prod_mon_liv(t,j,kli_mon,"level") = q71_prod_mon_liv.l(j,kli_mon); + oq71_punishment_mon(t,i,"level") = q71_punishment_mon.l(i); + ov71_feed_forage(t,j,kforage,"upper") = v71_feed_forage.up(j,kforage); + ov71_additional_mon(t,j,kli_mon,"upper") = v71_additional_mon.up(j,kli_mon); + ov_costs_additional_mon(t,i,"upper") = vm_costs_additional_mon.up(i); + ov71_feed_balanceflow(t,j,kforage,"upper") = v71_feed_balanceflow.up(j,kforage); + oq71_feed_rum_liv(t,j,kforage,"upper") = q71_feed_rum_liv.up(j,kforage); + oq71_feed_forage(t,j,"upper") = q71_feed_forage.up(j); + oq71_feed_balanceflow_nlp(t,j,"upper") = q71_feed_balanceflow_nlp.up(j); + oq71_feed_balanceflow_lp(t,i,"upper") = q71_feed_balanceflow_lp.up(i); + oq71_prod_mon_liv(t,j,kli_mon,"upper") = q71_prod_mon_liv.up(j,kli_mon); + oq71_punishment_mon(t,i,"upper") = q71_punishment_mon.up(i); + ov71_feed_forage(t,j,kforage,"lower") = v71_feed_forage.lo(j,kforage); + ov71_additional_mon(t,j,kli_mon,"lower") = v71_additional_mon.lo(j,kli_mon); + ov_costs_additional_mon(t,i,"lower") = vm_costs_additional_mon.lo(i); + ov71_feed_balanceflow(t,j,kforage,"lower") = v71_feed_balanceflow.lo(j,kforage); + oq71_feed_rum_liv(t,j,kforage,"lower") = q71_feed_rum_liv.lo(j,kforage); + oq71_feed_forage(t,j,"lower") = q71_feed_forage.lo(j); + oq71_feed_balanceflow_nlp(t,j,"lower") = q71_feed_balanceflow_nlp.lo(j); + oq71_feed_balanceflow_lp(t,i,"lower") = q71_feed_balanceflow_lp.lo(i); + oq71_prod_mon_liv(t,j,kli_mon,"lower") = q71_prod_mon_liv.lo(j,kli_mon); + oq71_punishment_mon(t,i,"lower") = q71_punishment_mon.lo(i); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/71_disagg_lvst/foragebased_jul23/preloop.gms b/modules/71_disagg_lvst/foragebased_jul23/preloop.gms new file mode 100644 index 0000000000..b4a0510e06 --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_jul23/preloop.gms @@ -0,0 +1,17 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + +i71_urban_area_share(j) = + pm_land_start(j,"urban")/sum(cell(i,j),sum(cell2(i,j3),pm_land_start(j3,"urban"))) + ; + +s71_lp_fix = 0; +s71_scale_mon = 1.10; +s71_punish_additional_mon = 15000; + +* Minimal regional production of `kli_rum` to avoid division by zero in `q71_feed_balanceflow_nlp`. +vm_prod_reg.lo(i,kli_rum)$(s71_lp_fix=0) = 10**(-6); diff --git a/modules/71_disagg_lvst/foragebased_jul23/realization.gms b/modules/71_disagg_lvst/foragebased_jul23/realization.gms new file mode 100644 index 0000000000..cb46c66113 --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_jul23/realization.gms @@ -0,0 +1,32 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + +*' @description The foragebased_jul23 realization constrains the cellular ruminant livestock production by +*' the feed availability for grazed pasture and fodder crops. This accounts for the fact that pasture and fodder +*' (summarized with forage) feed stuff is usually not transported over long distances and at the same time +*' is very essential in livestock diets. The monogastric livestock is distributed following the idea +*' that these animals are held close to densely populated areas. For more detailed information on cellular livestock +*' distribution see @robinson_mapping_2014, which inspired this realization. + +*' This realization includes a minimal lower bound for ruminant production to avoid avoid GAMS corner solutions at +*' higher spatial resolutions. It also has a linearized version, which can be switch on via `s71_lp_fix`. + +*' @limitations Distribution of monogastrics do not account for feed availability within a cell. +*' Crop residue feed stuff for ruminant production is also not considered to restrict livestock +*' production. Forage feed stuff is consider not to be transported, but is in reality. + + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/71_disagg_lvst/foragebased_jul23/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/71_disagg_lvst/foragebased_jul23/declarations.gms" +$Ifi "%phase%" == "equations" $include "./modules/71_disagg_lvst/foragebased_jul23/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/71_disagg_lvst/foragebased_jul23/scaling.gms" +$Ifi "%phase%" == "preloop" $include "./modules/71_disagg_lvst/foragebased_jul23/preloop.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/71_disagg_lvst/foragebased_jul23/postsolve.gms" +$Ifi "%phase%" == "nl_fix" $include "./modules/71_disagg_lvst/foragebased_jul23/nl_fix.gms" +$Ifi "%phase%" == "nl_release" $include "./modules/71_disagg_lvst/foragebased_jul23/nl_release.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/71_disagg_lvst/foragebased_jul23/scaling.gms b/modules/71_disagg_lvst/foragebased_jul23/scaling.gms new file mode 100644 index 0000000000..f6d1479d6c --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_jul23/scaling.gms @@ -0,0 +1,10 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + +vm_costs_additional_mon.scale(i) = 10e4; +*Don't scale this variable. Model is very sensitive to scaling this variable and might become infeasible or very slow. +*v71_feed_balanceflow.scale(j,kforage) = 10e3; diff --git a/modules/71_disagg_lvst/foragebased_jul23/sets.gms b/modules/71_disagg_lvst/foragebased_jul23/sets.gms new file mode 100644 index 0000000000..60573b6015 --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_jul23/sets.gms @@ -0,0 +1,27 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + +sets + kli_rum(kli) Ruminant livestock + / + livst_rum, livst_milk + / + + kli_mon(kli) Monogastric livestock + / + livst_pig, livst_chick, livst_egg + / + + kforage(k) Forage feed categories + / + pasture, foddr + / +; + +alias(j,j3); +alias(cell,cell2); +alias(kforage,kforage2); diff --git a/modules/71_disagg_lvst/module.gms b/modules/71_disagg_lvst/module.gms index 388e97797d..68b66dcf67 100644 --- a/modules/71_disagg_lvst/module.gms +++ b/modules/71_disagg_lvst/module.gms @@ -16,5 +16,6 @@ *###################### R SECTION START (MODULETYPES) ########################## $Ifi "%disagg_lvst%" == "foragebased_aug18" $include "./modules/71_disagg_lvst/foragebased_aug18/realization.gms" +$Ifi "%disagg_lvst%" == "foragebased_jul23" $include "./modules/71_disagg_lvst/foragebased_jul23/realization.gms" $Ifi "%disagg_lvst%" == "off" $include "./modules/71_disagg_lvst/off/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/80_optimization/lp_nlp_apr17/input.gms b/modules/80_optimization/lp_nlp_apr17/input.gms index cd8b1abe23..5b7f1d4edd 100644 --- a/modules/80_optimization/lp_nlp_apr17/input.gms +++ b/modules/80_optimization/lp_nlp_apr17/input.gms @@ -6,11 +6,10 @@ *** | Contact: magpie@pik-potsdam.de scalars - s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / + s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / s80_optfile switch to use specfied solver settings (1) / 1 / s80_add_cplex add cplex optimization after conopt4 (1) / 0 / - s80_add_conopt3 add conopt3 optimization after conopt4 (1) / 0 / - s80_num_nonopt_allowed number of allowed non-optimal variables (1) / Inf / + s80_add_conopt3 add conopt3 optimization after conopt4 (1) / 0 / ; diff --git a/modules/80_optimization/lp_nlp_apr17/solve.gms b/modules/80_optimization/lp_nlp_apr17/solve.gms index e01c6323d2..672c4bfa31 100644 --- a/modules/80_optimization/lp_nlp_apr17/solve.gms +++ b/modules/80_optimization/lp_nlp_apr17/solve.gms @@ -72,7 +72,7 @@ $batinclude "./modules/include.gms" nl_fix *' of the previous optimization as upper bound and minimizing the land *' differences. - if((magpie.modelstat=1 or magpie.modelstat = 7), + if ((magpie.modelstat=1 or magpie.modelstat = 7), vm_cost_glo.up = vm_cost_glo.l; solve magpie USING nlp MINIMIZING vm_landdiff; vm_cost_glo.up = Inf; @@ -148,7 +148,7 @@ $batinclude "./modules/include.gms" nl_relax ); * if solve stopped with an error, try it again with conopt3 - if((magpie.modelstat = 13), + if ((magpie.modelstat = 13), display "WARNING: Modelstat 13 | retry with CONOPT3!"; option nlp = conopt; solve magpie USING nlp MINIMIZING vm_cost_glo; @@ -165,13 +165,13 @@ $batinclude "./modules/include.gms" nl_relax * write extended run information in list file in the case that the final solution is infeasible - if((s80_counter >= s80_maxiter and p80_modelstat(t) > 2 and p80_modelstat(t) ne 7), + if ((s80_counter >= s80_maxiter and p80_modelstat(t) > 2), magpie.solprint = 1 ); display s80_counter; - until ((p80_modelstat(t) <= 2 and p80_num_nonopt(t) <= s80_num_nonopt_allowed) or s80_counter >= s80_maxiter) + until (p80_modelstat(t) <= 2 or s80_counter >= s80_maxiter) ); * if s80_add_cplex is 1 add additional solve statement for cplex diff --git a/modules/80_optimization/nlp_apr17/input.gms b/modules/80_optimization/nlp_apr17/input.gms index 491db45626..f2e369af2a 100644 --- a/modules/80_optimization/nlp_apr17/input.gms +++ b/modules/80_optimization/nlp_apr17/input.gms @@ -6,9 +6,8 @@ *** | Contact: magpie@pik-potsdam.de scalars - s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / + s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / s80_optfile switch to use specfied solver settings (1) / 1 / - s80_num_nonopt_allowed number of allowed non-optimal variables (1) / Inf / ; $setglobal c80_nlp_solver conopt4 diff --git a/modules/80_optimization/nlp_apr17/solve.gms b/modules/80_optimization/nlp_apr17/solve.gms index 6e28d017f8..7c971b1493 100644 --- a/modules/80_optimization/nlp_apr17/solve.gms +++ b/modules/80_optimization/nlp_apr17/solve.gms @@ -45,11 +45,11 @@ display vm_cost_glo.l; display magpie.modelstat; * in case of problems try different solvers and optfile settings -if(magpie.modelstat > 2 OR magpie.numNOpt > s80_num_nonopt_allowed, +if (magpie.modelstat > 2, repeat( s80_counter = s80_counter + 1 ; - if(magpie.modelstat ne s80_modelstat_previter, + if (magpie.modelstat ne s80_modelstat_previter, display "Modelstat > 2 | Retry solve with CONOPT4 default setting"; solve magpie USING nlp MINIMIZING vm_cost_glo ; elseif magpie.modelstat = s80_modelstat_previter, @@ -73,14 +73,14 @@ if(magpie.modelstat > 2 OR magpie.numNOpt > s80_num_nonopt_allowed, display vm_cost_glo.l; * write extended run information in list file in the case that the final solution is infeasible - if((s80_counter >= (s80_maxiter-1) and magpie.modelstat > 2 and magpie.modelstat ne 7), + if ((s80_counter >= (s80_maxiter-1) and magpie.modelstat > 2), magpie.solprint = 1 ); display s80_counter; display magpie.modelstat; - until ((magpie.modelstat <= 2 and magpie.numNOpt <= s80_num_nonopt_allowed) or s80_counter >= s80_maxiter) + until (magpie.modelstat <= 2 or s80_counter >= s80_maxiter) ); ); diff --git a/modules/80_optimization/nlp_par/input.gms b/modules/80_optimization/nlp_par/input.gms index d51ef89aa7..00370ae459 100644 --- a/modules/80_optimization/nlp_par/input.gms +++ b/modules/80_optimization/nlp_par/input.gms @@ -8,5 +8,4 @@ scalars s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / s80_optfile switch to use specfied solver settings (1) / 1 / - s80_num_nonopt_allowed number of allowed non-optimal variables (1) / Inf / ; diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 3f1facbac1..0b8fe4e232 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -69,7 +69,7 @@ repeat display s80_counter; display magpie.modelStat; - if((p80_counter(h) >= s80_maxiter AND p80_modelstat(t,h) > 2 AND p80_modelstat(t,h) ne 7), + if ((p80_counter(h) >= s80_maxiter AND p80_modelstat(t,h) > 2), display "No feasible solution found. Writing LST file."; option AsyncSolLst=1; display$handlecollect(p80_handle(h)) 're-collect'; @@ -79,15 +79,15 @@ repeat display$handledelete(p80_handle(h)) 'trouble deleting handles' ; - if(p80_modelstat(t,h) <= 2 AND magpie.numNOpt <= s80_num_nonopt_allowed, + if (p80_modelstat(t,h) <= 2, display "Model status <= 2. Handle cleared."; s80_resolve = 0; p80_handle(h) = 0; ); - if(s80_resolve = 1, + if (s80_resolve = 1, display "Resolve" - if(p80_modelstat(t,h) ne s80_modelstat_previter, + if (p80_modelstat(t,h) ne s80_modelstat_previter, display "Modelstat > 2 | Retry solve with CONOPT4 default setting"; solve magpie USING nlp MINIMIZING vm_cost_glo ; elseif p80_modelstat(t,h) = s80_modelstat_previter, diff --git a/output.R b/output.R index 32c737b2db..a3c9395412 100644 --- a/output.R +++ b/output.R @@ -197,8 +197,8 @@ runOutputs <- function(comp=NULL, output=NULL, outputdir=NULL, submit=NULL) { freshLockfile <- withr::local_tempfile() message("Generating lockfile... ", appendLF = FALSE) - utils::capture.output({ - errorMessage <- utils::capture.output({ + errorMessage1 <- utils::capture.output({ + errorMessage2 <- utils::capture.output({ snapshotSuccess <- tryCatch({ renv::snapshot(lockfile = freshLockfile, prompt = FALSE) TRUE @@ -206,7 +206,7 @@ runOutputs <- function(comp=NULL, output=NULL, outputdir=NULL, submit=NULL) { }, type = "message") }) if (!snapshotSuccess) { - stop(paste(errorMessage, collapse = "\n")) + stop(paste(errorMessage1, collapse = "\n"), paste(errorMessage2, collapse = "\n")) } message("done.") diff --git a/renv/settings.json b/renv/settings.json new file mode 100644 index 0000000000..3331ef2535 --- /dev/null +++ b/renv/settings.json @@ -0,0 +1,17 @@ +{ + "bioconductor.version": [], + "external.libraries": [], + "ignored.packages": [], + "package.dependency.fields": [ + "Imports", + "Depends", + "LinkingTo" + ], + "r.version": [], + "snapshot.type": "implicit", + "use.cache": true, + "vcs.ignore.cellar": true, + "vcs.ignore.library": true, + "vcs.ignore.local": true, + "vcs.manage.ignores": true +} diff --git a/scripts/output/extra/highres.R b/scripts/output/extra/highres.R index e1707e82e2..60083fafff 100644 --- a/scripts/output/extra/highres.R +++ b/scripts/output/extra/highres.R @@ -74,9 +74,9 @@ highres <- function(cfg) { #list files with sftp command path <- paste0(sub("scp://","sftp://",repo),"/") h <- try(curl::new_handle(verbose = debug, .list = repositories[[repo]], ftp_use_epsv = TRUE, dirlistonly = TRUE), silent = TRUE) - con <- curl::curl(url = path, "r", handle = h) + con <- try(curl::curl(url = path, "r", handle = h), silent = TRUE) dat <- try(readLines(con), silent = TRUE) - close(con) + try(close(con), silent = TRUE) found <- c(found,grep(glob2rx(file),dat,value = T)) } else if (dir.exists(repo)) { dat <- list.files(repo) @@ -120,7 +120,11 @@ highres <- function(cfg) { tmp[1] <- paste0(tmp[1], paste0("HR", res)) cfg$title <- paste(tmp, collapse = "_") - cfg$results_folder <- paste0("output/HR", res, "/:title:") + if(!is.null(cfg$results_folder_highres)) { + cfg$results_folder <- file.path(cfg$results_folder_highres,":title:") + } else { + cfg$results_folder <- paste0("output/HR", res, "/:title:") + } cfg$force_replace <- TRUE cfg$recalc_npi_ndc <- TRUE diff --git a/scripts/output/extra/land_cluster_shapefile.R b/scripts/output/extra/land_cluster.R similarity index 55% rename from scripts/output/extra/land_cluster_shapefile.R rename to scripts/output/extra/land_cluster.R index ec89d56ebb..796b9ac083 100644 --- a/scripts/output/extra/land_cluster_shapefile.R +++ b/scripts/output/extra/land_cluster.R @@ -6,22 +6,27 @@ # | Contact: magpie@pik-potsdam.de # -------------------------------------------------------------- -# description: Write land use information on cluster level to a shapefile +# description: Write land use information on cluster level to land_cluster.gpkg (GeoPackage) # comparison script: FALSE # --------------------------------------------------------------- if (packageVersion("magpie4") < "1.180.0") { - stop("land_cluster_shapefile.R requires magpie4 >= 1.180.0, please update magpie4") + stop("land_cluster.R requires magpie4 >= 1.180.0, please update magpie4") } if (!exists("source_include")) { - outputdir <- Sys.glob("output/*")[[1]] + outputdir <- utils::tail(Sys.glob("output/default_*"), 1) lucode2::readArgs("outputdir") } -landUse <- magpie4::land(file.path(outputdir, "fulldata.gdx"), - dir = outputdir, - level = "cell") +landUse <- magpie4::land(file.path(outputdir, "fulldata.gdx"), level = "cell") +cropArea <- magpie4::croparea(file.path(outputdir, "fulldata.gdx"), level = "cell", product_aggr = FALSE) +x <- magclass::mbind(landUse, cropArea) +if (!isTRUE(all.equal(x[, , "crop"], + magclass::dimSums(x[, , dimnames(cropArea)[[3]]]), + check.attributes = FALSE))) { + stop("Summing up crop area for all crops from magpie4::croparea != crop area from magpie4::land") +} clustermap <- Sys.glob(file.path(outputdir, "clustermap_*.rds")) if (length(clustermap) == 0) { @@ -32,8 +37,8 @@ if (length(clustermap) == 0) { } clustermap <- readRDS(clustermap) -clusterPolygons <- magpie4::clusterOutputToTerraVector(landUse, clustermap) +clusterPolygons <- magpie4::clusterOutputToTerraVector(x, clustermap) -outfile <- file.path(outputdir, "cluster_resolution.shp") +outfile <- file.path(outputdir, "land_cluster.gpkg") message("Writing ", outfile) terra::writeVector(clusterPolygons, outfile, overwrite = TRUE) diff --git a/scripts/output/extra/reportMAgPIE2SEALS.R b/scripts/output/extra/reportMAgPIE2SEALS.R new file mode 100644 index 0000000000..eb4ea1dacc --- /dev/null +++ b/scripts/output/extra/reportMAgPIE2SEALS.R @@ -0,0 +1,40 @@ +# | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +# | authors, and contributors see CITATION.cff file. This file is part +# | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +# | AGPL-3.0, you are granted additional permissions described in the +# | MAgPIE License Exception, version 1.0 (see LICENSE file). +# | Contact: magpie@pik-potsdam.de + +# -------------------------------------------------------------- +# description: Modifies gridded MAgPIE land use patterns so that they can be read in by the Spatial Economic Allocation Landscape Simulator (SEALS) +# comparison script: FALSE +# --------------------------------------------------------------- + +# Version 1.00 - Patrick v. Jeetze +# 1.00: first working version + +library(gms) +library(magpie4) + +message("Starting to report gridded MAgPIE land use for SEALS") + +############################# BASIC CONFIGURATION ####################################### +if (!exists("source_include")) { + title <- NULL + outputdir <- NULL + + # Define arguments that can be read from command line + readArgs("outputdir", "title") +} +######################################################################################### + +message("Script started for output directory: ", outputdir) +cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) +title <- cfg$title + +# Restructure data to conform to SEALS +reportLandUseForSEALS( + magCellLand = "cell.land_0.5_share.nc", + outFile = paste0("cell.land_0.5_SEALS_", title, ".nc"), + dir = outputdir, selectyears = c(2015, 2050) +) diff --git a/scripts/postRelease.R b/scripts/postRelease.R index 6c5f3195bf..5330da3fca 100644 --- a/scripts/postRelease.R +++ b/scripts/postRelease.R @@ -2,7 +2,8 @@ postRelease <- function() { gert::git_fetch("upstream") gert::git_merge("upstream/master") - pattern <- "and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)." + pattern <- "The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)." + stopifnot(any(grepl(pattern, readLines("CHANGELOG.md"), fixed = TRUE))) textToAdd <- paste("", "", "", diff --git a/scripts/start/Rprofile.R b/scripts/start/Rprofile.R deleted file mode 100644 index 46001513cf..0000000000 --- a/scripts/start/Rprofile.R +++ /dev/null @@ -1,53 +0,0 @@ -# | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) -# | authors, and contributors see CITATION.cff file. This file is part -# | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -# | AGPL-3.0, you are granted additional permissions described in the -# | MAgPIE License Exception, version 1.0 (see LICENSE file). -# | Contact: magpie@pik-potsdam.de - -# ------------------------------------------------- -# description: Add R snapshot to ".Rprofile" -# position: 4 -# ------------------------------------------------- - -setSnapshot <- function(snapshotdir=NULL) { - choose_snapshot <- function(title="Please choose a R snapshot") { - if(dir.exists("/p/projects/rd3mod/R/libraries/snapshots/")) { - dirs <- base::list.dirs("/p/projects/rd3mod/R/libraries/snapshots/",recursive=F,full.names=F) - dirs <- sort(dirs) - cat("\n",title,":\n", sep="") - cat("0: No snapshot\n") - cat(paste(1:length(dirs), dirs, sep=": " ),sep="\n") - cat("Number: ") - identifier <- as.numeric(gms::getLine()) - if(identifier > 0 & identifier <= length(dirs)) { - return(paste0("/p/projects/rd3mod/R/libraries/snapshots/",dirs[identifier])) - } else return(invisible(NULL)) - } else stop("R snapshot folder is only available on PIK cluster") - } - - if(is.null(snapshotdir)) snapshotdir <- choose_snapshot("Please choose a R snapshot") - - if(is.null(snapshotdir)) { - fc <- file(".Rprofile") - withr::defer(close(fc)) - writeLines(c('if(file.exists("~/.Rprofile")) source("~/.Rprofile")'), - fc) - } else { - fc <- file(".Rprofile") - withr::defer(close(fc)) - writeLines(c('if(file.exists("~/.Rprofile")) source("~/.Rprofile")', - paste0('.libPaths(',deparse(snapshotdir),')'), - paste0('print("Setting libPaths to ',snapshotdir,'")')), - fc) - } - message(".Rprofile written") -} -if(!exists("source_include")) { - snapshotdir <- NULL - lucode2::readArgs("snapshotdir", .silent=TRUE) -} - -setSnapshot(snapshotdir = snapshotdir) - - diff --git a/scripts/start/test_runs.R b/scripts/start/test_runs.R index b7bf326f92..7815102f9a 100644 --- a/scripts/start/test_runs.R +++ b/scripts/start/test_runs.R @@ -77,9 +77,11 @@ codeCheck <- FALSE ### Business-as-usual cfg <- fsecScenario(scenario = "c_BAU") +cfg$results_folder_highres <- "output" start_run(cfg = cfg, codeCheck = codeCheck) ### FSDP Scenario cfg <- fsecScenario(scenario = "e_FSDP") +cfg$results_folder_highres <- "output" start_run(cfg = cfg, codeCheck = codeCheck) diff --git a/scripts/start_functions.R b/scripts/start_functions.R index 3e9cf03c01..25de9122b7 100644 --- a/scripts/start_functions.R +++ b/scripts/start_functions.R @@ -9,7 +9,24 @@ # Define internal functions ################################################################################ -.update_sets_core <- function(cpr,map) { +.calcClusterCells <- function(x) { + cells <- noCells <- NULL + for (i in magclass::getItems(x, dim = 1.1)) { + max <- max(as.numeric(magclass::getItems(x[i, , ], dim = 1.2))) + min <- min(as.numeric(magclass::getItems(x[i, , ], dim = 1.2))) + count <- length(magclass::getItems(x[i, , ], dim = 1.2)) + + tmp <- paste0(paste(i, min, sep = "_"), "*" , paste(i, max, sep = "_")) + cells <- c(cells, tmp) + noCells <- c(noCells, count) + } + out <- data.frame(i = magclass::getItems(x, dim = 1.1), + j = cells, + n = noCells) + return(out) +} + +.update_sets_core <- function(x, map) { require(gms) if (!("region" %in% names(map))) map$region <- map$RegionCode @@ -17,25 +34,14 @@ if (!("superregion" %in% names(map))) map$superregion <- map$region reg1 <- unique(as.character(map$region)) - reg2 <- names(cpr) - if(!all(union(reg1,reg2) %in% intersect(reg1,reg2))) { + reg2 <- magclass::getItems(x, dim = 1.1) + if (!all(union(reg1,reg2) %in% intersect(reg1, reg2))) { stop("Inconsistent region information!", - "\n cpr info: ",paste(reg2,collapse=", "), - "\n spatial header info: ", paste(reg1,collapse=", ")) + "\n cpr info: ", paste(reg2, collapse = ", "), + "\n spatial header info: ", paste(reg1, collapse = ", ")) } - - j <- 0; cells <- NULL - for (i in 1:length(cpr)) { - if (cpr[i] == 1) { - cells <- c(cells, paste0(names(cpr)[i], "_", j + 1)) - } else { - cells <- c(cells, paste0(names(cpr)[i], "_", j + 1, "*", - names(cpr)[i], "_", j + cpr[i])) - } - j <- j + cpr[i] - } - ij <- data.frame(i = names(cpr), j = cells) + ij <- .calcClusterCells(x = x)[c("i", "j")] hi <- unique(map[c("superregion", "region")]) hi <- hi[order(hi$superregion),] @@ -45,7 +51,7 @@ items = sort(unique(as.character(map$superregion)))), list(name = "i", desc = "all economic regions", - items = names(cpr)), + items = ij[["i"]]), list(name = "supreg(h,i)", desc = "mapping of superregions to its regions", items = hi), @@ -54,7 +60,7 @@ items = as.character(map$country)), list(name = "j", desc = "number of LPJ cells", - items = cells), + items = ij[["j"]]), list(name = "cell(i,j)", desc = "number of LPJ cells per region i", items = ij), @@ -96,36 +102,39 @@ } # Function to extract information from info.txt -.get_info <- function(file, grep_expression, sep, pattern="", replacement="") { +.get_info <- function(file, grep_expression, sep, pattern = "", replacement = "") { if(!file.exists(file)) return("#MISSING#") file <- readLines(file, warn=FALSE) tmp <- grep(grep_expression, file, value=TRUE) tmp <- strsplit(tmp, sep) tmp <- sapply(tmp, "[[", 2) - tmp <- gsub(pattern, replacement ,tmp) + tmp <- gsub(pattern, replacement, tmp) if(all(!is.na(as.logical(tmp)))) return(as.vector(sapply(tmp, as.logical))) - if (all(!(regexpr("[a-zA-Z]",tmp) > 0))) { + if (all(!(regexpr("[a-zA-Z]", tmp) > 0))) { tmp <- as.numeric(tmp) } return(tmp) } -#Define routine to update info file in input folder and info in main.gms -.update_info <- function(datasets, cpr, regionscode, reg_revision, warnings=NULL) { +# Define routine to update info file in input folder and info in main.gms +.update_info <- function(datasets, x, regionscode, reg_revision, warnings = NULL) { + + # extract cluster information from file: + ijn <- .calcClusterCells(x = x) - low_res <- .get_info("input/info.txt","^\\* Output ?resolution:",": ") - high_res <- .get_info("input/info.txt","^\\* Input ?resolution:",": ") + low_res <- .get_info("input/info.txt", "^\\* Output ?resolution:", ": ") + high_res <- .get_info("input/info.txt", "^\\* Input ?resolution:", ": ") - info <- readLines('input/info.txt') + info <- readLines('input/info.txt') subject <- 'VERSION INFO' useddata <- NULL for(dataset in rownames(datasets)) { useddata <- c(useddata, '', - paste('Used data set:',dataset), - paste('md5sum:',datasets[dataset,"md5"]), - paste('Repository:',datasets[dataset,"repo"])) + paste('Used data set:', dataset), + paste('md5sum:', datasets[dataset, "md5"]), + paste('Repository:', datasets[dataset, "repo"])) } warnings <- attr(datasets,"warnings") @@ -135,18 +144,18 @@ content <- c(useddata, '', - paste('Low resolution:',low_res), - paste('High resolution:',high_res), + paste('Low resolution:', low_res), + paste('High resolution:', high_res), '', - paste('Total number of cells:',sum(cpr)), + paste('Total number of cells:', sum(ijn["n"])), '', 'Number of cells per region:', - paste(format(names(cpr),width=5,justify="right"),collapse=""), - paste(format(cpr,width=5),collapse=""), + paste(format(ijn[["i"]], width = 5, justify = "right"), collapse = ""), + paste(format(ijn[["n"]], width = 5), collapse = ""), '', - paste('Regionscode:',regionscode), + paste('Regionscode:', regionscode), '', - paste('Regions data revision:',reg_revision), + paste('Regions data revision:', reg_revision), '', info, '', @@ -166,10 +175,10 @@ sp <- luscale::read.spam(spamfile) a <- apply(sp, 2, function(x) return(which(x == 1))) out <- data.frame(cell = cells_tmp, region = sub("\\..*$","",spatial_header), - country = sub("\\..*$","",cells_tmp), global = "GLO") - out$cluster <- paste0(out$region,".",a) - out <- out[,c("cell", "cluster","region","country","global")] - saveRDS(out, paste0("input/",outfile), version = 2) + country = sub("\\..*$", "", cells_tmp), global = "GLO") + out$cluster <- paste0(out$region,".", a) + out <- out[,c("cell", "cluster", "region", "country", "global")] + saveRDS(out, paste0("input/", outfile), version = 2) } @@ -197,15 +206,14 @@ download_and_update <- function(cfg) { # and .update_sets, which is updating the resolution- and region-depending # sets in core/sets.gms tmp <- magclass::read.magpie("modules/10_land/input/avl_land_t.cs3") - cpr <- magclass::getCPR(tmp) tmp2 <- magclass::read.magpie("modules/10_land/input/avl_land_t_0.5.mz") - cel <- magclass::getItems(tmp2,1) + cel <- magclass::getItems(tmp2, dim = 1) # read spatial_header, map, reg_revision and regionscode load("input/spatial_header.rda") - rds <- any(grepl(pattern = "clustermap_rev.*.rds", x=list.files("input"))) - if(!rds) .spam2rds(spatial_header, cel, "clustermap_rev0_dummy.rds") - .update_info(filemap,cpr,regionscode,reg_revision, warnings) - .update_sets_core(cpr,map) + rds <- any(grepl(pattern = "clustermap_rev.*.rds", x = list.files("input"))) + if (!rds) .spam2rds(spatial_header, cel, "clustermap_rev0_dummy.rds") + .update_info(filemap, x = tmp, regionscode, reg_revision, warnings) + .update_sets_core(x = tmp, map = map) .update_sets_modules() } @@ -225,12 +233,12 @@ start_run <- function(cfg, scenario = NULL, codeCheck = TRUE, lock_model = TRUE) checkNamespace("gms", "lucode2", "magclass") - Sys.setlocale(locale="C") + Sys.setlocale(locale = "C") maindir <- getwd() withr::defer(setwd(maindir)) if(lock_model) { - lock_id <- gms::model_lock(timeout1=1) + lock_id <- gms::model_lock(timeout1 = 1) withr::defer(gms::model_unlock(lock_id)) } @@ -264,12 +272,16 @@ start_run <- function(cfg, scenario = NULL, codeCheck = TRUE, lock_model = TRUE) if (is.null(renv::project())) { message("No active renv project found, not using renv.") } else { - # this script always runs in repo root, so we can check whether the main renv is loaded with: - if (normalizePath(renv::project()) == normalizePath(".")) { + if (!is.null(cfg$renv_lock)) { + message("Copying cfg$renv_lock (= '", normalizePath(cfg$renv_lock, mustWork = TRUE), "') into '", + cfg$results_folder, "'") + file.copy(cfg$renv_lock, file.path(cfg$results_folder, "_renv.lock")) + } else if (normalizePath(renv::project()) == normalizePath(".")) { + # the main renv is loaded message("Generating lockfile in '", cfg$results_folder, "'... ", appendLF = FALSE) # suppress output of renv::snapshot - utils::capture.output({ - errorMessage <- utils::capture.output({ + errorMessage1 <- utils::capture.output({ + errorMessage2 <- utils::capture.output({ snapshotSuccess <- tryCatch({ # snapshot current main renv into run folder renv::snapshot(lockfile = file.path(cfg$results_folder, "_renv.lock"), prompt = FALSE) @@ -278,11 +290,11 @@ start_run <- function(cfg, scenario = NULL, codeCheck = TRUE, lock_model = TRUE) }, type = "message") }) if (!snapshotSuccess) { - stop(paste(errorMessage, collapse = "\n")) + stop(paste(errorMessage1, collapse = "\n"), paste(errorMessage2, collapse = "\n")) } message("done.") } else { - # a run renv is loaded, we are presumably starting a HR follow up run + # a run renv is loaded message("Copying lockfile into '", cfg$results_folder, "'") file.copy(renv::paths$lockfile(), file.path(cfg$results_folder, "_renv.lock")) } @@ -403,9 +415,9 @@ start_run <- function(cfg, scenario = NULL, codeCheck = TRUE, lock_model = TRUE) user = Sys.info()[["user"]], date = rundate, version_management = "git", - revision = try(system("git rev-parse HEAD", intern=TRUE), silent=TRUE), - revision_date = try(as.POSIXct(system("git show -s --format=%ci", intern=TRUE), silent=TRUE)), - status = try(system("git status", intern=TRUE), silent=TRUE)) + revision = try(system("git rev-parse HEAD", intern = TRUE), silent=TRUE), + revision_date = try(as.POSIXct(system("git show -s --format=%ci", intern = TRUE), silent = TRUE)), + status = try(system("git status", intern = TRUE), silent = TRUE)) ############################################################################## @@ -475,12 +487,12 @@ start_run <- function(cfg, scenario = NULL, codeCheck = TRUE, lock_model = TRUE) # copy important files into output_folder (before MAgPIE execution) for(file in cfg$files2export$start) { - try(file.copy(Sys.glob(file), cfg$results_folder, overwrite=TRUE)) + try(file.copy(Sys.glob(file), cfg$results_folder, overwrite = TRUE)) } cfg$magpie_folder <- getwd() # only store repository paths, not their credentials - cfg$repositories <- sapply(names(cfg$repositories),function(x) NULL) + cfg$repositories <- sapply(names(cfg$repositories), function(x) NULL) # store config in human and machine readable form gms::saveConfig(cfg, file.path(cfg$results_folder, "config.yml")) @@ -504,7 +516,7 @@ start_run <- function(cfg, scenario = NULL, codeCheck = TRUE, lock_model = TRUE) if(is.na(cfg$sequential)) cfg$sequential <- !slurm - if(slurm & !cfg$sequential) { + if(slurm && !cfg$sequential) { if(is.null(cfg$qos)) { # try to select best QOS based on available resources # and available information diff --git a/start.R b/start.R index 9ca78a4cae..121986e4e7 100644 --- a/start.R +++ b/start.R @@ -129,6 +129,7 @@ runOutputs <- function(runscripts=NULL, submit=NULL) { system("git config core.hooksPath .githooks") -runscripts <- submit <- NULL +submit <- NULL +runscripts <- NULL lucode2::readArgs("runscripts","submit", .silent=TRUE) runOutputs(runscripts=runscripts, submit=submit)