Skip to content
Open
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
8 changes: 0 additions & 8 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,6 @@ RF_MISC <- function() {
.Call('_hector_RF_MISC', PACKAGE = 'hector')
}

RFADJ_PREFIX <- function() {
.Call('_hector_RFADJ_PREFIX', PACKAGE = 'hector')
}

RF_PREFIX <- function() {
.Call('_hector_RF_PREFIX', PACKAGE = 'hector')
}

#' @describeIn haloforcings Radiative forcing due to CF4
#' @export
RF_CF4 <- function() {
Expand Down
3 changes: 0 additions & 3 deletions R/messages.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ fetchvars <- function(core, dates, vars = NULL, scenario = NULL) {
sendmessage(core, GETDATA(), v, dates, NA, "")
})
)
## Fix the variable name for the adjusted halocarbon forcings so that they are
## consistent with other forcings.
rslt$variable <- sub(paste0("^", RFADJ_PREFIX()), RF_PREFIX(), rslt$variable)
cols <- names(rslt)
rslt$scenario <- scenario
## reorder the columns to put the scenario name first
Expand Down
2 changes: 1 addition & 1 deletion data-raw/lookup-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ lines <- readLines("./src/rcpp_constants.cpp")
# Specific functions to exclude
# TODO is there a way to make this not hard coded?
lines <- lines[!grepl(
pattern = "GETDATA|SETDATA|BIOME_SPLIT_CHAR|RFADJ_PREFIX|RF_PREFIX",
pattern = "GETDATA|SETDATA|BIOME_SPLIT_CHAR|RF_PREFIX",
x = lines
)]

Expand Down
61 changes: 31 additions & 30 deletions inst/include/component_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
#define D_VOLCANIC_SCALE "vol_scalar"

// halocarbon components
// These capabilities allow a caller to fetch the
// adjusted values from the forcing component.
#define D_RF_CF4 D_RF_PREFIX CF4_COMPONENT_BASE
#define D_RF_C2F6 D_RF_PREFIX C2F6_COMPONENT_BASE
#define D_RF_HFC23 D_RF_PREFIX HFC23_COMPONENT_BASE
Expand Down Expand Up @@ -96,37 +98,36 @@
#define D_RF_CH3Cl D_RF_PREFIX CH3Cl_COMPONENT_BASE
#define D_RF_CH3Br D_RF_PREFIX CH3Br_COMPONENT_BASE

// Adjusted (i.e., relative) halocarbon forcings
// Unadjusted halocarbon forcings
// Forcings are tracked relative to the base year forcings, but the
// halocarbon components don't know that. These capabilities allow
// a caller to fetch the adjusted values from the forcing component.
#define D_RFADJ_PREFIX "Fadj"
#define D_RFADJ_CF4 D_RFADJ_PREFIX CF4_COMPONENT_BASE
#define D_RFADJ_C2F6 D_RFADJ_PREFIX C2F6_COMPONENT_BASE
#define D_RFADJ_HFC23 D_RFADJ_PREFIX HFC23_COMPONENT_BASE
#define D_RFADJ_HFC32 D_RFADJ_PREFIX HFC32_COMPONENT_BASE
#define D_RFADJ_HFC4310 D_RFADJ_PREFIX HFC4310_COMPONENT_BASE
#define D_RFADJ_HFC125 D_RFADJ_PREFIX HFC125_COMPONENT_BASE
#define D_RFADJ_HFC134a D_RFADJ_PREFIX HFC134a_COMPONENT_BASE
#define D_RFADJ_HFC143a D_RFADJ_PREFIX HFC143a_COMPONENT_BASE
#define D_RFADJ_HFC227ea D_RFADJ_PREFIX HFC227ea_COMPONENT_BASE
#define D_RFADJ_HFC245fa D_RFADJ_PREFIX HFC245fa_COMPONENT_BASE
#define D_RFADJ_SF6 D_RFADJ_PREFIX SF6_COMPONENT_BASE
#define D_RFADJ_CFC11 D_RFADJ_PREFIX CFC11_COMPONENT_BASE
#define D_RFADJ_CFC12 D_RFADJ_PREFIX CFC12_COMPONENT_BASE
#define D_RFADJ_CFC113 D_RFADJ_PREFIX CFC113_COMPONENT_BASE
#define D_RFADJ_CFC114 D_RFADJ_PREFIX CFC114_COMPONENT_BASE
#define D_RFADJ_CFC115 D_RFADJ_PREFIX CFC115_COMPONENT_BASE
#define D_RFADJ_CCl4 D_RFADJ_PREFIX CCl4_COMPONENT_BASE
#define D_RFADJ_CH3CCl3 D_RFADJ_PREFIX CH3CCl3_COMPONENT_BASE
#define D_RFADJ_HCFC22 D_RFADJ_PREFIX HCFC22_COMPONENT_BASE
#define D_RFADJ_HCFC141b D_RFADJ_PREFIX HCFC141b_COMPONENT_BASE
#define D_RFADJ_HCFC142b D_RFADJ_PREFIX HCFC142b_COMPONENT_BASE
#define D_RFADJ_halon1211 D_RFADJ_PREFIX halon1211_COMPONENT_BASE
#define D_RFADJ_halon1301 D_RFADJ_PREFIX halon1301_COMPONENT_BASE
#define D_RFADJ_halon2402 D_RFADJ_PREFIX halon2402_COMPONENT_BASE
#define D_RFADJ_CH3Cl D_RFADJ_PREFIX CH3Cl_COMPONENT_BASE
#define D_RFADJ_CH3Br D_RFADJ_PREFIX CH3Br_COMPONENT_BASE
// halocarbon components don't know that.
#define D_RFUNADJ_PREFIX "RF_unadj"
#define D_RFUNADJ_CF4 D_RFUNADJ_PREFIX CF4_COMPONENT_BASE
#define D_RFUNADJ_C2F6 D_RFUNADJ_PREFIX C2F6_COMPONENT_BASE
#define D_RFUNADJ_HFC23 D_RFUNADJ_PREFIX HFC23_COMPONENT_BASE
#define D_RFUNADJ_HFC32 D_RFUNADJ_PREFIX HFC32_COMPONENT_BASE
#define D_RFUNADJ_HFC4310 D_RFUNADJ_PREFIX HFC4310_COMPONENT_BASE
#define D_RFUNADJ_HFC125 D_RFUNADJ_PREFIX HFC125_COMPONENT_BASE
#define D_RFUNADJ_HFC134a D_RFUNADJ_PREFIX HFC134a_COMPONENT_BASE
#define D_RFUNADJ_HFC143a D_RFUNADJ_PREFIX HFC143a_COMPONENT_BASE
#define D_RFUNADJ_HFC227ea D_RFUNADJ_PREFIX HFC227ea_COMPONENT_BASE
#define D_RFUNADJ_HFC245fa D_RFUNADJ_PREFIX HFC245fa_COMPONENT_BASE
#define D_RFUNADJ_SF6 D_RFUNADJ_PREFIX SF6_COMPONENT_BASE
#define D_RFUNADJ_CFC11 D_RFUNADJ_PREFIX CFC11_COMPONENT_BASE
#define D_RFUNADJ_CFC12 D_RFUNADJ_PREFIX CFC12_COMPONENT_BASE
#define D_RFUNADJ_CFC113 D_RFUNADJ_PREFIX CFC113_COMPONENT_BASE
#define D_RFUNADJ_CFC114 D_RFUNADJ_PREFIX CFC114_COMPONENT_BASE
#define D_RFUNADJ_CFC115 D_RFUNADJ_PREFIX CFC115_COMPONENT_BASE
#define D_RFUNADJ_CCl4 D_RFUNADJ_PREFIX CCl4_COMPONENT_BASE
#define D_RFUNADJ_CH3CCl3 D_RFUNADJ_PREFIX CH3CCl3_COMPONENT_BASE
#define D_RFUNADJ_HCFC22 D_RFUNADJ_PREFIX HCFC22_COMPONENT_BASE
#define D_RFUNADJ_HCFC141b D_RFUNADJ_PREFIX HCFC141b_COMPONENT_BASE
#define D_RFUNADJ_HCFC142b D_RFUNADJ_PREFIX HCFC142b_COMPONENT_BASE
#define D_RFUNADJ_halon1211 D_RFUNADJ_PREFIX halon1211_COMPONENT_BASE
#define D_RFUNADJ_halon1301 D_RFUNADJ_PREFIX halon1301_COMPONENT_BASE
#define D_RFUNADJ_halon2402 D_RFUNADJ_PREFIX halon2402_COMPONENT_BASE
#define D_RFUNADJ_CH3Cl D_RFUNADJ_PREFIX CH3Cl_COMPONENT_BASE
#define D_RFUNADJ_CH3Br D_RFUNADJ_PREFIX CH3Br_COMPONENT_BASE
#define N_HALO_FORCINGS 26

// halocarbon emissions
Expand Down
2 changes: 1 addition & 1 deletion inst/include/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class IModelComponent;
*/
class Core : public IVisitable {
public:
Core(Logger::LogLevel loglvl = Logger::DEBUG, bool echotoscreen = true,
Core(Logger::LogLevel loglvl = Logger::DEBUG, bool echotoscreen = true,
bool echotofile = true);
~Core();

Expand Down
4 changes: 2 additions & 2 deletions inst/include/forcing_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ class ForcingComponent : public IModelComponent {
Logger logger; //! Logger

static const char
*adjusted_halo_forcings[]; //! Capability strings for halocarbon forcings
*unadjusted_halo_forcings[]; //! Capability strings for unadjusted halocarbon forcings
static const char
*halo_forcing_names[]; //! Internal names of halocarbon forcings
*halo_forcing_names[]; //! Names of adjusted (relative) halocarbon forcings
static std::map<std::string, std::string> forcing_name_map;
};

Expand Down
11 changes: 6 additions & 5 deletions inst/include/halocarbon_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,16 @@ class HalocarbonComponent : public IModelComponent {
double tau; // lifetime in years
unitval rho; // radiative efficiencies W/m2/ppt
unitval delta; // tropospheric adjustments scalar unitless
unitval H0; // Preindustrial concentration, pptv
unitval molarMass; // hc molar mass, g/mol

//! Forcing [W/m^2]
tseries<unitval> hc_forcing;
tseries<unitval> emissions; //! Time series of emissions, pptv

// Time series
tseries<unitval> hc_forcing; //! The unadjusted halocarbon RFs
tseries<unitval> emissions; //! Time series of emissions, Gg
tseries<unitval> Ha_ts; //! Time series of (ambient) concentration, pptv
tseries<unitval> Ha_constrain; //! Concentration constraint, pptv
unitval H0; //! Preindustrial concentration, pptv

double molarMass;

//! logger
Logger logger;
Expand Down
5 changes: 3 additions & 2 deletions inst/include/unitval.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,13 @@ enum unit_types {
U_CM, // Length-related
U_CM_YR,

U_G,
U_TG, // Mass-related
U_G, // Mass-related
U_TG,
U_GG, // Giga-grams
U_MOL,
U_GMOL,
U_GT,
U_G_MOL, // molar mass

U_PGC, // Carbon pools and fluxes
U_PGC_YR,
Expand Down
Loading