Skip to content

Commit fddfed5

Browse files
authored
Merge pull request #303 from JGCRI/krd_RF_H2O
Fix bugs in reporting for halocarbon forcings. Version 2.2.2
2 parents 40c512d + cd9b0f8 commit fddfed5

19 files changed

+345
-109
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: hector
22
Title: The Hector Simple Climate Model
3-
Version: 2.2.1
3+
Version: 2.2.2
44
Authors@R: c(person("Robert", "Link", email = "robert.link@pnnl.gov", role = c("aut", "cre")),
55
person("Corinne", "Hartin", email = "corinne.hartin@pnnl.gov", role = "aut"),
66
person("Ben", "Bond-Lamberty", email = "BondLamberty@pnnl.gov", role = "aut"),
@@ -14,7 +14,7 @@ License: GPL-3
1414
Encoding: UTF-8
1515
LazyData: true
1616
LinkingTo: Rcpp, BH
17-
Imports: Rcpp (>= 0.12), BH (>= 1.65)
17+
Imports: Rcpp (>= 0.12), BH (>= 1.69)
1818
Suggests:
1919
testthat,
2020
nleqslv,

R/RcppExports.R

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
33

44
#' @include aadoc.R
5-
#' @describeIn msgtype Message type for retrieving data from a component
5+
#' @describeIn msgtype Message type for retrieving data from a component
66
#' @export
77
#' @keywords internal
88
GETDATA <- function() {
@@ -40,7 +40,7 @@ LL_SEVERE <- function() {
4040
.Call('_hector_LL_SEVERE', PACKAGE = 'hector')
4141
}
4242

43-
#' @describeIn emissions Black carbon emissions (\code{"Tg"})
43+
#' @describeIn emissions Black carbon emissions (\code{"Tg"})
4444
#' @export
4545
EMISSIONS_BC <- function() {
4646
.Call('_hector_EMISSIONS_BC', PACKAGE = 'hector')
@@ -118,6 +118,14 @@ RF_VOL <- function() {
118118
.Call('_hector_RF_VOL', PACKAGE = 'hector')
119119
}
120120

121+
RFADJ_PREFIX <- function() {
122+
.Call('_hector_RFADJ_PREFIX', PACKAGE = 'hector')
123+
}
124+
125+
RF_PREFIX <- function() {
126+
.Call('_hector_RF_PREFIX', PACKAGE = 'hector')
127+
}
128+
121129
#' @describeIn haloforcings Radiative forcing due to CF4
122130
#' @export
123131
RF_CF4 <- function() {

R/aadoc.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ NULL
7676
#' These identifiers specify forcing values that can be provided by hector via
7777
#' one of the myriad halocarbon components. All of the values corresponding to
7878
#' these identifiers are read-only (\emph{i.e.}, they can only appear in
79-
#' \code{\link{GETDATA}} messages.)
79+
#' \code{\link{GETDATA}} messages.) The forcings returned are the
80+
#' \emph{relative} forcings, with the base year (typically 1750) values
81+
#' subtracted off.
8082
#'
8183
#' @inheritSection msgtype Note
8284
#'

R/messages.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ fetchvars <- function(core, dates, vars=NULL, scenario=NULL)
5353
lapply(vars, function(v) {
5454
sendmessage(core, GETDATA(), v, dates, NA, '')
5555
}))
56+
## Fix the variable name for the adjusted halocarbon forcings so that they are
57+
## consistent with other forcings.
58+
rslt$variable <- sub(paste0('^',RFADJ_PREFIX()), RF_PREFIX(), rslt$variable)
5659
cols <- names(rslt)
5760
rslt$scenario <- scenario
5861
## reorder the columns to put the scenario name first

changelog.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
Hector 2.2.2
2+
============
3+
* Fix bug that was causing requests for H2O forcing in the R interface
4+
to return N2O forcing instead (the model internals were
5+
unaffected).
6+
* Fix bug that was causing API requests for halocarbon forcing to
7+
return absolute forcing values, rather than values relative to the
8+
base year (which is what is done for all other forcings).
9+
* Add missing RF_VOL (volcanic forcing) dependency to forcing component. In practice the
10+
missing dependency had no effect because the forcing component
11+
already had a dependency on the SO2 component, which also provides
12+
the volcanic forcing, but in the event that we ever split them up,
13+
this will ensure that the dependency graph is still valid.
14+
15+
(All 2.2.2 changes merged in PR #303)
16+
117
Hector 2.2.1
218
============
319
* Report global averages for land temperature, ocean air

inst/include/component_data.hpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,41 @@
8282
#define D_RF_halon2402 D_RF_PREFIX halon2402_COMPONENT_BASE
8383
#define D_RF_CH3Cl D_RF_PREFIX CH3Cl_COMPONENT_BASE
8484
#define D_RF_CH3Br D_RF_PREFIX CH3Br_COMPONENT_BASE
85+
86+
// Adjusted (i.e., relative) halocarbon forcings
87+
// Forcings are tracked relative to the base year forcings, but the
88+
// halocarbon components don't know that. These capabilities allow
89+
// a caller to fetch the adjusted values from the forcing component.
90+
#define D_RFADJ_PREFIX "Fadj"
91+
#define D_RFADJ_CF4 D_RFADJ_PREFIX CF4_COMPONENT_BASE
92+
#define D_RFADJ_C2F6 D_RFADJ_PREFIX C2F6_COMPONENT_BASE
93+
#define D_RFADJ_HFC23 D_RFADJ_PREFIX HFC23_COMPONENT_BASE
94+
#define D_RFADJ_HFC32 D_RFADJ_PREFIX HFC32_COMPONENT_BASE
95+
#define D_RFADJ_HFC4310 D_RFADJ_PREFIX HFC4310_COMPONENT_BASE
96+
#define D_RFADJ_HFC125 D_RFADJ_PREFIX HFC125_COMPONENT_BASE
97+
#define D_RFADJ_HFC134a D_RFADJ_PREFIX HFC134a_COMPONENT_BASE
98+
#define D_RFADJ_HFC143a D_RFADJ_PREFIX HFC143a_COMPONENT_BASE
99+
#define D_RFADJ_HFC227ea D_RFADJ_PREFIX HFC227ea_COMPONENT_BASE
100+
#define D_RFADJ_HFC245fa D_RFADJ_PREFIX HFC245fa_COMPONENT_BASE
101+
#define D_RFADJ_SF6 D_RFADJ_PREFIX SF6_COMPONENT_BASE
102+
#define D_RFADJ_CFC11 D_RFADJ_PREFIX CFC11_COMPONENT_BASE
103+
#define D_RFADJ_CFC12 D_RFADJ_PREFIX CFC12_COMPONENT_BASE
104+
#define D_RFADJ_CFC113 D_RFADJ_PREFIX CFC113_COMPONENT_BASE
105+
#define D_RFADJ_CFC114 D_RFADJ_PREFIX CFC114_COMPONENT_BASE
106+
#define D_RFADJ_CFC115 D_RFADJ_PREFIX CFC115_COMPONENT_BASE
107+
#define D_RFADJ_CCl4 D_RFADJ_PREFIX CCl4_COMPONENT_BASE
108+
#define D_RFADJ_CH3CCl3 D_RFADJ_PREFIX CH3CCl3_COMPONENT_BASE
109+
#define D_RFADJ_HCF22 D_RFADJ_PREFIX HCF22_COMPONENT_BASE
110+
#define D_RFADJ_HCF141b D_RFADJ_PREFIX HCF141b_COMPONENT_BASE
111+
#define D_RFADJ_HCF142b D_RFADJ_PREFIX HCF142b_COMPONENT_BASE
112+
#define D_RFADJ_halon1211 D_RFADJ_PREFIX halon1211_COMPONENT_BASE
113+
#define D_RFADJ_halon1301 D_RFADJ_PREFIX halon1301_COMPONENT_BASE
114+
#define D_RFADJ_halon2402 D_RFADJ_PREFIX halon2402_COMPONENT_BASE
115+
#define D_RFADJ_CH3Cl D_RFADJ_PREFIX CH3Cl_COMPONENT_BASE
116+
#define D_RFADJ_CH3Br D_RFADJ_PREFIX CH3Br_COMPONENT_BASE
117+
#define N_HALO_FORCINGS 26
118+
119+
85120
// halocarbon emissions
86121
#define D_EMISSIONS_CF4 CF4_COMPONENT_BASE EMISSIONS_EXTENSION
87122
#define D_EMISSIONS_C2F6 C2F6_COMPONENT_BASE EMISSIONS_EXTENSION

inst/include/forcing_component.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ class ForcingComponent : public IModelComponent {
8989

9090
Core* core; //! Core
9191
Logger logger; //! Logger
92+
93+
static const char *adjusted_halo_forcings[]; //! Capability strings for halocarbon forcings
94+
static const char *halo_forcing_names[]; //! Internal names of halocarbon forcings
95+
static std::map<std::string, std::string> forcing_name_map;
9296
};
9397

9498
}

inst/include/h_util.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* \brief The model version number to be included in logs and outputs.
2727
* \note This must be updated manually when the model version changes.
2828
*/
29-
#define MODEL_VERSION "2.2.1"
29+
#define MODEL_VERSION "2.2.2"
3030

3131
#define OUTPUT_DIRECTORY "output/"
3232

man/haloforcings.Rd

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Makevars

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
PKG_CPPFLAGS = -I../inst/include -DUSE_RCPP
1+
CXX_STD = CXX11
2+
PKG_CPPFLAGS = -I../inst/include -DUSE_RCPP

0 commit comments

Comments
 (0)