From 7051179512a82b86150ce1a24dedad2838e429b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=20Pfl=C3=BCger?= Date: Mon, 6 Feb 2023 10:05:18 +0100 Subject: [PATCH 1/6] Add switch for MAGICC version --- config/default.cfg | 2 +- main.gms | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/config/default.cfg b/config/default.cfg index bfde2322e..07b9d66a7 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -46,7 +46,7 @@ cfg$repositories <- getOption("remind_repos") cfg$runstatistics <- "/p/projects/rd3mod/models/statistics/remind" #### Folder containing magicc files that can not be published open source. These files are automatically -# copied into remind when starting a run and required to calcualte climate responses (e.g. temperature). +# copied into remind when starting a run and required to calculate climate responses (e.g. temperature). cfg$magicc_template <- "/p/projects/rd3mod/magicc/" #### Output folder of the modeltests generated by running config/scenario_config_AMT.csv diff --git a/main.gms b/main.gms index 3bc39d08a..11f5a040b 100755 --- a/main.gms +++ b/main.gms @@ -1553,6 +1553,10 @@ $setGlobal cm_magicc_temperatureImpulseResponse off !! def = off *' roughly comparable to TCRE value, or even more roughly, equivalent climate sensitivity *' choose from OLDDEFAULT (REMIND1.7 legacy file); or different percentiles of RCP26 or generic TCRE outcomes calibrated to CMIP5 (see Schultes et al. (2018) for details) $setGlobal cm_magicc_config OLDDEFAULT !! def = OLDDEFAULT ; {OLDDEFAULT, RCP26_[5,15,..,95], TCRE_[LOWEST,LOW,MEDIUM,HIGH,HIGHEST] } +*' MAGICC version +*' different MAGICC versions have slightly different parameter names +*' choose either 6005_REMIND, or 7.5.3 +$setGlobal cm_magicc_version 6005_REMIND !! def = 6005_REMIND *' climate damages (HowardNonCatastrophic, DICE2013R, DICE2016, HowardNonCatastrophic, HowardInclCatastrophic, KWcross, KWpanelPop} $setGlobal cm_damage_DiceLike_specification HowardNonCatastrophic !! def = HowardNonCatastrophic *** cfg$gms$cm_damage_Labor_exposure <- "low" # def = "low"; {low,high} From d15eada33b82cd7551bc305ba6df36fc5b466446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=20Pfl=C3=BCger?= Date: Mon, 6 Feb 2023 10:11:23 +0100 Subject: [PATCH 2/6] Write appropriate config for magicc 7.5.3 --- core/magicc.gms | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/magicc.gms b/core/magicc.gms index 6f5cf9d83..567760e76 100644 --- a/core/magicc.gms +++ b/core/magicc.gms @@ -183,7 +183,11 @@ putclose magicc_scenario *** write sed scripts to edit MAGICC configuration files put magicc_sed_script +$ifThen %cm_magicc_version% == 6005_REMIND put 's| FILE_EMISSIONSCENARIO.*| FILE_EMISSIONSCENARIO = "REMIND_%c_expname%",|g' /; +$elseIf %cm_magicc_version% == 7.5.3 +put 's| FILE_EMISSCEN.*| FILE_EMISSCEN = "REMIND_%c_expname%.SCEN",|g' /; +$endIf put 's| RUNNAME.*| RUNNAME = "%c_expname%",|g' /; put 's| RUNDATE.*| RUNDATE = "%system.date%",|g' /; put 's| RF_SOLAR_SCALE =.*| RF_SOLAR_SCALE = 0,|g' /; From 21df006c0461a8adcf81c4ff780d5280ec4df003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=20Pfl=C3=BCger?= Date: Mon, 6 Feb 2023 10:12:28 +0100 Subject: [PATCH 3/6] Add some documentation to cm_magicc_version --- main.gms | 1 + 1 file changed, 1 insertion(+) diff --git a/main.gms b/main.gms index 11f5a040b..5bc59e93a 100755 --- a/main.gms +++ b/main.gms @@ -1556,6 +1556,7 @@ $setGlobal cm_magicc_config OLDDEFAULT !! def = OLDDEFAULT ; {OLDDEFAULT, RC *' MAGICC version *' different MAGICC versions have slightly different parameter names *' choose either 6005_REMIND, or 7.5.3 +*' Note that the magicc version configured here has to correspond to the template given in cfg$magicc_template in default.cfg $setGlobal cm_magicc_version 6005_REMIND !! def = 6005_REMIND *' climate damages (HowardNonCatastrophic, DICE2013R, DICE2016, HowardNonCatastrophic, HowardInclCatastrophic, KWcross, KWpanelPop} $setGlobal cm_damage_DiceLike_specification HowardNonCatastrophic !! def = HowardNonCatastrophic From cfd472e3570c94fe574dfa08421fbabdfb79c456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=20Pfl=C3=BCger?= Date: Wed, 8 Feb 2023 14:46:51 +0100 Subject: [PATCH 4/6] use magicc from configuration in reporting --- scripts/output/single/reporting.R | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/scripts/output/single/reporting.R b/scripts/output/single/reporting.R index 13e8cc43b..72bf802d1 100644 --- a/scripts/output/single/reporting.R +++ b/scripts/output/single/reporting.R @@ -23,6 +23,10 @@ if(!exists("source_include")) { readArgs("outputdir", "gdx_name", "gdx_ref_name") } +configfile <- file.path(outputdir, "config.Rdata") +envir <- new.env() +load(configfile, envir = envir) +cfg <- envir$cfg gdx <- file.path(outputdir,gdx_name) gdx_ref <- file.path(outputdir,gdx_ref_name) if (!file.exists(gdx_ref)) { gdx_ref <- NULL } @@ -46,16 +50,20 @@ message("\n### start generation of mif files at ", Sys.time()) tmp <- try(convGDX2MIF(gdx,gdx_ref,file=remind_reporting_file,scenario=scenario)) # try to execute convGDX2MIF if(class(tmp)=="try-error") convGDX2MIF_REMIND2MAgPIE(gdx, file = remind_reporting_file, scenario = scenario) -# MAGICC code not working with REMIND-EU # generate MAGICC reporting and append to REMIND reporting -if (0 == nchar(Sys.getenv('MAGICC_BINARY'))) { - warning('Can\'t find magicc executable under environment variable MAGICC_BINARY') +if (cfg$gms$magicc_version == "6005_REMIND") { + magiccBinary <- file.path(cfg$magicc_template, "magicc6") +} else if (cfg$gms$magicc_version == "7.5.3") { + magiccBinary <- file.path(cfg$magicc_template, "magicc") +} +if (!file.exists(magiccBinary)) { + warning(paste('Can\'t find magicc executable at', magiccBinary)) } else { message("Generate ", basename(magicc_reporting_file)) system(paste("cd ",outputdir ,"/magicc; ", "pwd;", "sed -f modify_MAGCFG_USER_CFG.sed -i MAGCFG_USER.CFG; ", - Sys.getenv('MAGICC_BINARY'), '; ', + magiccBinary, '; ', "awk -f MAGICC_reporting.awk -v c_expname=\"", scenario, "\"", " < climate_reporting_template.txt ", " > ","../../../", magicc_reporting_file,"; ", @@ -91,10 +99,7 @@ if(file.exists(edgetOutputDir)) { message("end generation of EDGE-T reporting") } -configfile <- file.path(outputdir, "config.Rdata") -envir <- new.env() -load(configfile, envir = envir) -magpie_reporting_file <- envir$cfg$pathToMagpieReport +magpie_reporting_file <- cfg$pathToMagpieReport if (! is.null(magpie_reporting_file) && file.exists(magpie_reporting_file)) { message("add MAgPIE reporting from ", magpie_reporting_file) tmp_rem <- read.report(remind_reporting_file, as.list=FALSE) From 4927b0bf0edb2501556444ce4f3b99499c9cf92f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=20Pfl=C3=BCger?= Date: Thu, 3 Mar 2022 14:56:15 +0100 Subject: [PATCH 5/6] add MAGICC configuration to drive MAGICC7 --- core/magicc/MAGCFG_STORE/MAGCFG_USER_MAGICC7.CFG | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 core/magicc/MAGCFG_STORE/MAGCFG_USER_MAGICC7.CFG diff --git a/core/magicc/MAGCFG_STORE/MAGCFG_USER_MAGICC7.CFG b/core/magicc/MAGCFG_STORE/MAGCFG_USER_MAGICC7.CFG new file mode 100644 index 000000000..ddc4eee33 --- /dev/null +++ b/core/magicc/MAGCFG_STORE/MAGCFG_USER_MAGICC7.CFG @@ -0,0 +1,7 @@ +&NML_ALLCFGS + RUNNAME = "DEFAULT", ! is filled by REMIND + RUNDATE = "unset", ! is filled by REMIND + FILE_EMISSCEN = "RCP45.SCEN", ! is filled by REMIND + OUT_DYNAMIC_VARS = 'DAT_SURFACE_TEMP', 'DAT_TOTAL_ANTHRO_ERF', 'DAT_CO2_CONC', 'DAT_CH4_CONC', 'DAT_N2O_CONC', 'DAT_KYOTOGHG_ERF', 'DAT_MHALOSUM_ERF', 'DAT_CO2_ERF', 'DAT_CH4_ERF', 'DAT_N2O_ERF', 'DAT_FGASSUM_ERF', 'DAT_TOTAER_DIR_ERF', 'DAT_CLOUD_ALBEDO_ERF', 'DAT_BCSNOW_ERF', 'DAT_SOXI_ERF', 'DAT_BCI_ERF', 'DAT_OCI_ERF', 'DAT_TROPOZ_ERF', 'DAT_LANDUSE_ERF', 'DAT_MINERALDUST_ERF', + PATHNAME_OUTFILES = "./", ! Define path, where all .OUT, .BINOUT, or .BULKBINOUT files shall be saved. + / From 15c3bd42a23fa8023a89642634b04d9568f70563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=20Pfl=C3=BCger?= Date: Thu, 30 Mar 2023 13:59:35 +0200 Subject: [PATCH 6/6] Better documentation for magicc switches. --- config/default.cfg | 4 ++++ core/magicc.gms | 1 + main.gms | 7 +++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 07b9d66a7..c13e22f89 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -47,6 +47,10 @@ cfg$runstatistics <- "/p/projects/rd3mod/models/statistics/remind" #### Folder containing magicc files that can not be published open source. These files are automatically # copied into remind when starting a run and required to calculate climate responses (e.g. temperature). +# The version of magicc configured here has to fit with the settings cm_magicc_version and +# cm_magicc_config +# To use magicc6 on the cluster, use /p/projects/rd3mod/magicc/ +# To use magicc7 on the cluster, use /p/projects/rd3mod/magicc7/magicc/ cfg$magicc_template <- "/p/projects/rd3mod/magicc/" #### Output folder of the modeltests generated by running config/scenario_config_AMT.csv diff --git a/core/magicc.gms b/core/magicc.gms index 567760e76..2096965e9 100644 --- a/core/magicc.gms +++ b/core/magicc.gms @@ -187,6 +187,7 @@ $ifThen %cm_magicc_version% == 6005_REMIND put 's| FILE_EMISSIONSCENARIO.*| FILE_EMISSIONSCENARIO = "REMIND_%c_expname%",|g' /; $elseIf %cm_magicc_version% == 7.5.3 put 's| FILE_EMISSCEN.*| FILE_EMISSCEN = "REMIND_%c_expname%.SCEN",|g' /; +put 's| FILE_EMISSIONSCENARIO.*| FILE_EMISSCEN = "REMIND_%c_expname%.SCEN",|g' /; $endIf put 's| RUNNAME.*| RUNNAME = "%c_expname%",|g' /; put 's| RUNDATE.*| RUNDATE = "%system.date%",|g' /; diff --git a/main.gms b/main.gms index 5bc59e93a..6abb48116 100755 --- a/main.gms +++ b/main.gms @@ -1551,12 +1551,15 @@ $setGlobal cm_magicc_calibrateTemperature2000 uncalibrated !! def = uncalibrat $setGlobal cm_magicc_temperatureImpulseResponse off !! def = off *' MAGICC configuration *' roughly comparable to TCRE value, or even more roughly, equivalent climate sensitivity -*' choose from OLDDEFAULT (REMIND1.7 legacy file); or different percentiles of RCP26 or generic TCRE outcomes calibrated to CMIP5 (see Schultes et al. (2018) for details) -$setGlobal cm_magicc_config OLDDEFAULT !! def = OLDDEFAULT ; {OLDDEFAULT, RCP26_[5,15,..,95], TCRE_[LOWEST,LOW,MEDIUM,HIGH,HIGHEST] } +*' for cm_magicc_version = 6005_REMIND, choose from OLDDEFAULT (REMIND1.7 legacy file); or different percentiles of RCP26 or generic +*' TCRE outcomes calibrated to CMIP5 (see Schultes et al. (2018) for details) +*' for cm_magicc_version = 7.5.3, use MAGICC7 +$setGlobal cm_magicc_config OLDDEFAULT !! def = OLDDEFAULT ; {OLDDEFAULT, RCP26_[5,15,..,95], TCRE_[LOWEST,LOW,MEDIUM,HIGH,HIGHEST], MAGICC7 } *' MAGICC version *' different MAGICC versions have slightly different parameter names *' choose either 6005_REMIND, or 7.5.3 *' Note that the magicc version configured here has to correspond to the template given in cfg$magicc_template in default.cfg +*' and to the cm_magicc_config configured above $setGlobal cm_magicc_version 6005_REMIND !! def = 6005_REMIND *' climate damages (HowardNonCatastrophic, DICE2013R, DICE2016, HowardNonCatastrophic, HowardInclCatastrophic, KWcross, KWpanelPop} $setGlobal cm_damage_DiceLike_specification HowardNonCatastrophic !! def = HowardNonCatastrophic