Skip to content

Commit

Permalink
misc changes for the mip work
Browse files Browse the repository at this point in the history
  • Loading branch information
kdorheim committed Jul 6, 2023
1 parent fd5ac34 commit a315ecd
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 39 deletions.
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ export(LL_WARNING)
export(LO_WARMING_RATIO)
export(LUC_EMISSIONS)
export(MLD_OCEAN_CARBON)
export(MLD_THERMAL)
export(N2O_CONSTRAIN)
export(NATURAL_CH4)
export(NAT_EMISSIONS_N2O)
Expand Down
8 changes: 1 addition & 7 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -1491,18 +1491,12 @@ HEAT_FLUX <- function() {
.Call('_hector_HEAT_FLUX', PACKAGE = 'hector')
}

#' @describeIn special Ocean carbon mixed layer depth
#' @describeIn ocean define the depth of the mixed layer in the ocean carbon cycle, default is 100m.
#' @export
MLD_OCEAN_CARBON <- function() {
.Call('_hector_MLD_OCEAN_CARBON', PACKAGE = 'hector')
}

#' @describeIn special Thermal ocean mixed layer depth
#' @export
MLD_THERMAL <- function() {
.Call('_hector_MLD_THERMAL', PACKAGE = 'hector')
}

newcore_impl <- function(inifile, loglevel, suppresslogging, name) {
.Call('_hector_newcore_impl', PACKAGE = 'hector', inifile, loglevel, suppresslogging, name)
}
Expand Down
1 change: 0 additions & 1 deletion inst/include/component_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@
#define D_FLUX_MIXED "flux_mixed"
#define D_FLUX_INTERIOR "flux_interior"
#define D_HEAT_FLUX "heatflux"
#define D_THERMAL_MLD "thermal_mld"


// ------------------- messages being passed between components -------------------------
Expand Down
16 changes: 8 additions & 8 deletions inst/include/forcing_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ class ForcingComponent : public IModelComponent {


// CO2 parameters
const double a1 = -2.4785e-7; // (W m–2 ppm–2) IPCC AR6 parameter for CH4 SARF Table 7.SM.1
const double b1 = 7.5906e-4; // (W m–2 ppm–1) IPCC AR6 parameter for CH4 SARF Table 7.SM.1
const double c1 = -2.1492e-3; // (W m–2 ppb–1/2) IPCC AR6 parameter for CH4 SARF Table 7.SM.1
const double d1 = 5.2488; // (W m–2) IPCC AR6 parameter for CH4 SARF Table 7.SM.1
const double a1 = -2.4785e-7; // (W m–2 ppm–2) IPCC AR6 parameter for CO2 SARF Table 7.SM.1
const double b1 = 7.5906e-4; // (W m–2 ppm–1) IPCC AR6 parameter for CO2 SARF Table 7.SM.1
const double c1 = -2.1492e-3; // (W m–2 ppb–1/2) IPCC AR6 parameter for CO2 SARF Table 7.SM.1
const double d1 = 5.2488; // (W m–2) IPCC AR6 parameter for CO2 SARF Table 7.SM.1
unitval delta_co2; // forcing tropospheric adjustment for CO2 see 7.3.2.1 of IPCC AR6

// N2O parameters
const double a2 = -3.4197e-4; // (W m–2 ppm–1) IPCC AR6 parameter for CH4 SARF Table 7.SM.1
const double b2 = 2.5455e-4; // (W m–2 ppb–1) IPCC AR6 parameter for CH4 SARF Table 7.SM.1
const double c2 = -2.4357e-4; // (W m–2 ppb–1) IPCC AR6 parameter for CH4 SARF Table 7.SM.1
const double d2 = 0.12173; // (W m-2 ppb–1/2) IPCC AR6 parameter for CH4 SARF Table 7.SM.1
const double a2 = -3.4197e-4; // (W m–2 ppm–1) IPCC AR6 parameter for N2O SARF Table 7.SM.1
const double b2 = 2.5455e-4; // (W m–2 ppb–1) IPCC AR6 parameter for N2O SARF Table 7.SM.1
const double c2 = -2.4357e-4; // (W m–2 ppb–1) IPCC AR6 parameter for N2O SARF Table 7.SM.1
const double d2 = 0.12173; // (W m-2 ppb–1/2) IPCC AR6 parameter for N2O SARF Table 7.SM.1
unitval delta_n2o; // forcing tropospheric adjustment for N2O see 7.3.2.3 of IPCC AR6

// CH4 parameters
Expand Down
6 changes: 4 additions & 2 deletions inst/include/ocean_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class OceanComponent : public CarbonCycleModel {
// The warm low-latitude surface box makes up the rest.
double part_high = 0.15;
double part_low = 1-part_high;

/*****************************************************************
* State variables for the component
* All of these will need to be recorded at the end of a timestep,
Expand Down Expand Up @@ -120,6 +120,8 @@ class OceanComponent : public CarbonCycleModel {
unitval tu; //!< m3/s high latitude overturning
unitval twi; //!< m3/s warm-intermediate exchange
unitval tid; //!< m3/s intermediate-deep exchange
unitval ocean_carbon_mld; //!< m3/s intermediate-deep exchange


/*****************************************************************
* Input data
Expand Down Expand Up @@ -174,7 +176,7 @@ class OceanComponent : public CarbonCycleModel {
tseries<unitval> temp_LL_ts;
tseries<unitval> co3_HL_ts;
tseries<unitval> co3_LL_ts;

// timestep control
tseries<double> max_timestep_ts;
tseries<int> reduced_timestep_timeout_ts;
Expand Down
5 changes: 5 additions & 0 deletions man/ocean.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2500,16 +2500,6 @@ BEGIN_RCPP
return rcpp_result_gen;
END_RCPP
}
// MLD_THERMAL
String MLD_THERMAL();
RcppExport SEXP _hector_MLD_THERMAL() {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = Rcpp::wrap(MLD_THERMAL());
return rcpp_result_gen;
END_RCPP
}
// newcore_impl
Environment newcore_impl(String inifile, int loglevel, bool suppresslogging, String name);
RcppExport SEXP _hector_newcore_impl(SEXP inifileSEXP, SEXP loglevelSEXP, SEXP suppressloggingSEXP, SEXP nameSEXP) {
Expand Down Expand Up @@ -2906,7 +2896,6 @@ static const R_CallMethodDef CallEntries[] = {
{"_hector_FLUX_INTERIOR", (DL_FUNC) &_hector_FLUX_INTERIOR, 0},
{"_hector_HEAT_FLUX", (DL_FUNC) &_hector_HEAT_FLUX, 0},
{"_hector_MLD_OCEAN_CARBON", (DL_FUNC) &_hector_MLD_OCEAN_CARBON, 0},
{"_hector_MLD_THERMAL", (DL_FUNC) &_hector_MLD_THERMAL, 0},
{"_hector_newcore_impl", (DL_FUNC) &_hector_newcore_impl, 4},
{"_hector_shutdown", (DL_FUNC) &_hector_shutdown, 1},
{"_hector_reset", (DL_FUNC) &_hector_reset, 2},
Expand Down
16 changes: 14 additions & 2 deletions src/ocean_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ void OceanComponent::init( Core* coreptr ) {
oceanflux_constrain.name = "atm_ocean_constrain";

SST.set( 0.0, U_DEGC );
ocean_carbon_mld.set( 100, U_UNITLESS);

lastflux_annualized.set( 0.0, U_PGC );

Expand Down Expand Up @@ -112,13 +113,16 @@ void OceanComponent::init( Core* coreptr ) {
core->registerCapability( D_CO3_HL, getComponentName() );
core->registerCapability( D_CO3_LL, getComponentName() );
core->registerCapability( D_CO3, getComponentName() );
core->registerCapability( D_OC_MLD, getComponentName() );


// Register the inputs we can receive from outside
core->registerInput(D_TT, getComponentName());
core->registerInput(D_TU, getComponentName());
core->registerInput(D_TWI, getComponentName());
core->registerInput(D_TID, getComponentName());
core->registerInput(D_OC_MLD, getComponentName());

}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -167,6 +171,9 @@ void OceanComponent::setData( const string& varName,
} else if( varName == D_CARBON_LL ) {
H_ASSERT( data.date == Core::undefinedIndex() , "date not allowed" );
surfaceLL.set_carbon( data.getUnitval( U_PGC ) );
} else if( varName == D_OC_MLD ) {
H_ASSERT( data.date == Core::undefinedIndex() , "date not allowed" );
ocean_carbon_mld = data.getUnitval(U_UNITLESS);
} else if( varName == D_CARBON_IO ) {
H_ASSERT( data.date == Core::undefinedIndex() , "date not allowed" );
inter.set_carbon( data.getUnitval( U_PGC ) );
Expand All @@ -190,6 +197,9 @@ void OceanComponent::setData( const string& varName,
spinup_chem = (data.getUnitval(U_UNDEFINED) > 0);
} else if( varName == D_ATM_OCEAN_CONSTRAIN ) {
H_ASSERT( data.date != Core::undefinedIndex(), "date required" );
} else if( varName == D_OC_MLD ) {
H_ASSERT( data.date == Core::undefinedIndex() , "date not allowed" );
ocean_carbon_mld = data.getUnitval(U_UNDEFINED);
} else {
H_THROW( "Unknown variable name while parsing " + getComponentName() + ": "
+ varName );
Expand All @@ -209,8 +219,8 @@ void OceanComponent::prepareToRun() {
double spy = 60 * 60 * 24 * 365.25; // seconds per year

// ocean depth
double thick_LL = 100; // (m) Thickness of surface ocean from Knox and McElroy (1984)
double thick_HL = 100; // (m) Thickness of surface ocean from Knox and McElroy (1984)
double thick_LL = ocean_carbon_mld; // (m) Thickness of surface ocean from Knox and McElroy (1984)
double thick_HL = ocean_carbon_mld; // (m) Thickness of surface ocean from Knox and McElroy (1984)
double thick_inter = 1000-thick_LL; // (m) Thickness of of intermediate ocean from Knox and McElroy (1984)
double thick_deep = 3777-thick_inter-thick_LL; // (m) Thickness of deep ocean from Knox and McElroy (1984)

Expand Down Expand Up @@ -429,6 +439,8 @@ unitval OceanComponent::getData( const std::string& varName,
returnval = tid;
} else if( varName == D_TWI ) {
returnval = twi;
} else if( varName == D_OC_MLD ) {
returnval = ocean_carbon_mld;
} else if( varName == D_OMEGACA_HL ) {
returnval = surfaceHL.mychemistry.OmegaCa;
} else if( varName == D_OMEGACA_LL ) {
Expand Down
8 changes: 1 addition & 7 deletions src/rcpp_constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1873,16 +1873,10 @@ return D_HEAT_FLUX;
}


//' @describeIn special Ocean carbon mixed layer depth
//' @describeIn ocean define the depth of the mixed layer in the ocean carbon cycle, default is 100m.
//' @export
// [[Rcpp::export]]
String MLD_OCEAN_CARBON() {
return D_OC_MLD;
}

//' @describeIn special Thermal ocean mixed layer depth
//' @export
// [[Rcpp::export]]
String MLD_THERMAL() {
return D_THERMAL_MLD;
}

0 comments on commit a315ecd

Please sign in to comment.