diff --git a/R/RcppExports.R b/R/RcppExports.R index a982c0802..9df6810f7 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -1,6 +1,9 @@ # Generated by using Rcpp::compileAttributes() -> do not edit by hand # Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 +#' @rdname carboncycle +NULL + #' @describeIn msgtype Message type for retrieving data from a component #' @keywords internal GETDATA <- function() { @@ -1292,6 +1295,10 @@ RH <- function() { .Call('_hector_RH', PACKAGE = 'hector') } +RH_DETRITU <- function() { + .Call('_hector_RH_DETRITU', PACKAGE = 'hector') +} + #' @describeIn parameters Preindustrial CO2 concentration (\code{"ppmv CO2"}) #' @export PREINDUSTRIAL_CO2 <- function() { diff --git a/inst/include/simpleNbox.hpp b/inst/include/simpleNbox.hpp index 91780800d..8d8595174 100644 --- a/inst/include/simpleNbox.hpp +++ b/inst/include/simpleNbox.hpp @@ -140,6 +140,8 @@ class SimpleNbox : public CarbonCycleModel { final_npp; //!< final NPP after any NBP constraint accounted for, Pg C/yr fluxpool_stringmap final_rh; //!< final RH after any NBP constraint accounted for, Pg C/yr + fluxpool_stringmap + final_rh_detritus; //!< final RH detritus after any NBP constraint accounted for, Pg C/yr // Other state variables unitval Ca_residual; //!< residual (when constraining [CO2]), Pg C @@ -175,7 +177,10 @@ class SimpleNbox : public CarbonCycleModel { final_npp_tv; //!< Time series of biome-specific final NPP tvector final_rh_tv; //!< Time series of biome-specific final RH - +tvector + final_rh_detritus_tv; //!< Time series of biome-specific final detritus RH + + tseries Ca_residual_ts; //!< Time series of residual flux values tvector tempfertd_tv, diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index 295eb78ef..6adbc7042 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -2170,6 +2170,16 @@ BEGIN_RCPP return rcpp_result_gen; END_RCPP } +// RH_DETRITU +String RH_DETRITU(); +RcppExport SEXP _hector_RH_DETRITU() { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::RNGScope rcpp_rngScope_gen; + rcpp_result_gen = Rcpp::wrap(RH_DETRITU()); + return rcpp_result_gen; +END_RCPP +} // PREINDUSTRIAL_CO2 String PREINDUSTRIAL_CO2(); RcppExport SEXP _hector_PREINDUSTRIAL_CO2() { @@ -2971,6 +2981,7 @@ static const R_CallMethodDef CallEntries[] = { {"_hector_CONCENTRATIONS_CO2", (DL_FUNC) &_hector_CONCENTRATIONS_CO2, 0}, {"_hector_NPP", (DL_FUNC) &_hector_NPP, 0}, {"_hector_RH", (DL_FUNC) &_hector_RH, 0}, + {"_hector_RH_DETRITU", (DL_FUNC) &_hector_RH_DETRITU, 0}, {"_hector_PREINDUSTRIAL_CO2", (DL_FUNC) &_hector_PREINDUSTRIAL_CO2, 0}, {"_hector_ATMOSPHERIC_CO2", (DL_FUNC) &_hector_ATMOSPHERIC_CO2, 0}, {"_hector_FFI_EMISSIONS", (DL_FUNC) &_hector_FFI_EMISSIONS, 0}, diff --git a/src/csv_outputstream_visitor.cpp b/src/csv_outputstream_visitor.cpp index b6eeecbdc..4929e9ed8 100644 --- a/src/csv_outputstream_visitor.cpp +++ b/src/csv_outputstream_visitor.cpp @@ -174,6 +174,7 @@ void CSVOutputStreamVisitor::visit(SimpleNbox *c) { STREAM_UNITVAL(csvFile, c, D_NPP, c->final_npp[SNBOX_DEFAULT_BIOME]); STREAM_UNITVAL(csvFile, c, D_RH, c->final_rh[SNBOX_DEFAULT_BIOME]); STREAM_UNITVAL(csvFile, c, D_RH_CH4, c->final_rh[SNBOX_DEFAULT_BIOME]); + STREAM_UNITVAL(csvFile, c, D_RH_DETRITUS, c->final_rh_detritus[SNBOX_DEFAULT_BIOME]); STREAM_MESSAGE_DATE(csvFile, c, D_CO2_CONC, current_date); STREAM_MESSAGE(csvFile, c, D_ATMOSPHERIC_CO2); STREAM_MESSAGE(csvFile, c, D_ATMOSPHERIC_C_RESIDUAL); diff --git a/src/rcpp_constants.cpp b/src/rcpp_constants.cpp index 5b5626cae..42aaf8b99 100644 --- a/src/rcpp_constants.cpp +++ b/src/rcpp_constants.cpp @@ -1128,6 +1128,11 @@ String NPP() { return D_NPP; } // [[Rcpp::export]] String RH() { return D_RH; } +//' @rdname carboncycle + //' @export + // [[Rcpp::export]] + String RH_DETRITU() { return D_RH_DETRITUS; } + //' @describeIn parameters Preindustrial CO2 concentration (\code{"ppmv CO2"}) //' @export // [[Rcpp::export]] diff --git a/src/simpleNbox-runtime.cpp b/src/simpleNbox-runtime.cpp index 2952c9ce8..918f24870 100644 --- a/src/simpleNbox-runtime.cpp +++ b/src/simpleNbox-runtime.cpp @@ -478,6 +478,9 @@ void SimpleNbox::stashCValues(double t, const double c[]) { // issue, we track it and adjust in the mass balance check below cumulative_pf_ch4 += rh_fpa_ch4_flux.value(U_PGC); + final_rh_detritus[biome] = rh_fda_flux; + + // Permafrost thaw and refreeze if (!in_spinup) { // We pass in the annual fluxes here, because want annual thaw and diff --git a/src/simpleNbox.cpp b/src/simpleNbox.cpp index 42e983f6f..eb601b8be 100644 --- a/src/simpleNbox.cpp +++ b/src/simpleNbox.cpp @@ -685,6 +685,9 @@ unitval SimpleNbox::getData(const std::string &varName, const double date) { } else if (varNameParsed == D_RH) { returnval = sum_fluxpool_biome_ts(varName, date, biome, final_rh, final_rh_tv); + } else if (varNameParsed == D_RH_DETRITUS) { + returnval = + sum_fluxpool_biome_ts(varName, date, biome, final_rh_detritus, final_rh_detritus_tv); } else if (varNameParsed == D_RH_CH4) { returnval = sum_fluxpool_biome_ts(varName, date, biome, RH_ch4, RH_ch4_tv); } else { @@ -709,6 +712,7 @@ void SimpleNbox::reset(double time) { thawed_permafrost_c = thawed_permafrost_c_tv.get(time); final_npp = final_npp_tv.get(time); final_rh = final_rh_tv.get(time); + final_rh_detritus = final_rh_detritus_tv.get(time); RH_thawed_permafrost = RH_thawed_permafrost_tv.get(time); RH_ch4 = RH_ch4_tv.get(time);