Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the magicc version configurable #1274

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion config/default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ 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).
# 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
Expand Down
5 changes: 5 additions & 0 deletions core/magicc.gms
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,12 @@ 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' /;
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' /;
put 's| RF_SOLAR_SCALE =.*| RF_SOLAR_SCALE = 0,|g' /;
Expand Down
7 changes: 7 additions & 0 deletions core/magicc/MAGCFG_STORE/MAGCFG_USER_MAGICC7.CFG
Original file line number Diff line number Diff line change
@@ -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.
/
12 changes: 10 additions & 2 deletions main.gms
Original file line number Diff line number Diff line change
Expand Up @@ -1551,8 +1551,16 @@ $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
*** cfg$gms$cm_damage_Labor_exposure <- "low" # def = "low"; {low,high}
Expand Down
21 changes: 13 additions & 8 deletions scripts/output/single/reporting.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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,"; ",
Expand Down Expand Up @@ -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)
Expand Down