Skip to content

Commit

Permalink
final clang-format run
Browse files Browse the repository at this point in the history
  • Loading branch information
kdorheim committed Feb 6, 2023
1 parent 2d0f107 commit 09c7b93
Show file tree
Hide file tree
Showing 25 changed files with 434 additions and 375 deletions.
22 changes: 11 additions & 11 deletions inst/include/component_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@
#define D_VEGC "veg_c"
#define D_DETRITUSC "detritus_c"
#define D_SOILC "soil_c"
#define D_PERMAFROSTC "permafrost_c"
#define D_THAWEDPC "thawedp_c"
#define D_PERMAFROSTC "permafrost_c"
#define D_THAWEDPC "thawedp_c"
#define D_FFI_EMISSIONS "ffi_emissions"
#define D_DACCS_UPTAKE "daccs_uptake"
#define D_LUC_EMISSIONS "luc_emissions"
Expand All @@ -357,21 +357,21 @@
#define D_Q10_RH "q10_rh"
#define D_NPP "NPP"
#define D_RH "RH"
#define D_RH_DETRITUS "rh_det"
#define D_RH_SOIL "rh_soil"
#define D_RH_THAWEDP "rh_thawedp"
#define D_RH_DETRITUS "rh_det"
#define D_RH_SOIL "rh_soil"
#define D_RH_THAWEDP "rh_thawedp"
#define D_F_NPPV "f_nppv"
#define D_F_NPPD "f_nppd"
#define D_F_LITTERD "f_litterd"
#define D_NPP_FLUX0 "npp_flux0"
#define D_BETA "beta"
#define D_WARMINGFACTOR "warmingfactor"
#define D_F_FROZEN "f_frozen"
#define D_RH_CH4 "rh_ch4"
#define D_RH_CH4_FRAC "rh_ch4_frac"
#define D_PF_SIGMA "pf_sigma"
#define D_PF_MU "pf_mu"
#define D_FPF_STATIC "fpf_static"
#define D_F_FROZEN "f_frozen"
#define D_RH_CH4 "rh_ch4"
#define D_RH_CH4_FRAC "rh_ch4_frac"
#define D_PF_SIGMA "pf_sigma"
#define D_PF_MU "pf_mu"
#define D_FPF_STATIC "fpf_static"

// Constraints
#define D_CO2_CONSTRAIN "CO2_constrain"
Expand Down
4 changes: 2 additions & 2 deletions inst/include/fluxpool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ inline fluxpool::fluxpool(unitval v, unordered_map<string, double> pool_map,
ctmap = pool_map;
name = pool_name;

if(v < 0) {
if (v < 0) {
H_ASSERT(v >= 0, "Flux and pool values may not be negative in " + name);
}

Expand All @@ -118,7 +118,7 @@ inline fluxpool::fluxpool(unitval v, unordered_map<string, double> pool_map,
inline void fluxpool::set(double v, unit_types u, bool track = false,
string pool_name = "?") {
name = pool_name;
if(v < 0) {
if (v < 0) {
H_ASSERT(v >= 0, "Flux and pool values may not be negative in " + name);
}
tracking = track;
Expand Down
5 changes: 3 additions & 2 deletions inst/include/ocean_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ class OceanComponent : public CarbonCycleModel {
*****************************************************************/
// Ocean initial state
unitval preind_C_surface; //!< Carbon in the preindustrial surface pool
unitval preind_C_ID; //!< Carbon in the preindustrial intermediate and deep pool

unitval
preind_C_ID; //!< Carbon in the preindustrial intermediate and deep pool

// Ocean boxes over time
tvector<oceanbox> surfaceHL_tv;
tvector<oceanbox> surfaceLL_tv;
Expand Down
6 changes: 3 additions & 3 deletions inst/include/oceanbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

// Mean absolute global tos temperature, preindustrial (deg C), this is used by
// the ocean component which, requires absolute temperature to calculate ocean
// chemistry, the CMIP6 multi model mean from 1850 - 1860. See Leeya Pressburger,
// & Kalyn R. Dorheim. (2022). JGCRI/hector_cmip6data: v1.0 (v1.0). Zenodo.
// https://doi.org/10.5281/zenodo.7304553
// chemistry, the CMIP6 multi model mean from 1850 - 1860. See Leeya
// Pressburger, & Kalyn R. Dorheim. (2022). JGCRI/hector_cmip6data: v1.0 (v1.0).
// Zenodo. https://doi.org/10.5281/zenodo.7304553
#define MEAN_TOS_TEMP 18

namespace Hector {
Expand Down
10 changes: 6 additions & 4 deletions inst/include/simpleNbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ class SimpleNbox : public CarbonCycleModel {
double_stringmap pf_mu; //!< Mean for permafrost-temp model fit
double_stringmap fpf_static; //!< Permafrost C non-labile fraction
typedef std::map<std::string, boost::math::lognormal> lognormal_stringmap;
lognormal_stringmap pf_s;//!< Permafrost lognormal distribution
lognormal_stringmap pf_s; //!< Permafrost lognormal distribution

/*****************************************************************
* Functions computing sub-elements of the carbon cycle
*****************************************************************/
Expand All @@ -293,8 +293,10 @@ class SimpleNbox : public CarbonCycleModel {
double time = Core::undefinedIndex()) const; //!< calculates RH for a biome
fluxpool sum_rh(double time = Core::undefinedIndex())
const; //!< calculates RH, global total
tuple<double, double, double> compute_pf_thaw_refreeze(string biome, fluxpool rh_co2, fluxpool rh_ch4) const;

tuple<double, double, double> compute_pf_thaw_refreeze(string biome,
fluxpool rh_co2,
fluxpool rh_ch4) const;

/*****************************************************************
* Private helper functions
*****************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion inst/include/unitval.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ inline void unitval::set(double v, unit_types u, double err = 0.0) {
* Get value. Caller has to provide assumed units, as a check.
*/
inline double unitval::value(unit_types u) const {
if(u != valUnits) {
if (u != valUnits) {
H_ASSERT(u == valUnits, "variable is not of this type. Expected: " +
unitsName(valUnits) + "; got: " + unitsName(u));
}
Expand Down
2 changes: 1 addition & 1 deletion src/carbon-cycle-solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ unitval CarbonCycleSolver::sendMessage(const std::string &message,

} else if (message == M_SETDATA) { //! Caller is requesting to set data
// TODO: call setData below

} else { //! We don't handle any other messages
H_THROW("Caller sent unknown message: " + message);
}
Expand Down
21 changes: 12 additions & 9 deletions src/ch4_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,12 @@ void CH4Component::setData(const string &varName, const message_data &data) {
try {
if (varName == D_PREINDUSTRIAL_CH4) {
H_ASSERT(data.date == Core::undefinedIndex(), "date not allowed");
if (data.getUnitval(U_PPBV_CH4).value(U_PPBV_CH4) != 731.41) {
H_LOG(logger, Logger::WARNING) << "Changing " << varName <<
" from default value; this is not recomended and may cause" <<
" issues with RF CH4 calucation" << std::endl;
}
if (data.getUnitval(U_PPBV_CH4).value(U_PPBV_CH4) != 731.41) {
H_LOG(logger, Logger::WARNING)
<< "Changing " << varName
<< " from default value; this is not recomended and may cause"
<< " issues with RF CH4 calucation" << std::endl;
}
M0 = data.getUnitval(U_PPBV_CH4);
} else if (varName == D_EMISSIONS_CH4) {
H_ASSERT(data.date != Core::undefinedIndex(), "date required");
Expand Down Expand Up @@ -163,13 +164,15 @@ void CH4Component::run(const double runToDate) {
<< "Year " << runToDate << " current_toh = " << current_toh
<< std::endl;

// Permafrost thaw produces CH4 emissions
#define PG_C_TO_TG_CH4 (1000.0 * 16.04 / 12.01)
const double rh_ch4 = core->sendMessage(M_GETDATA, D_RH_CH4).value(U_PGC_YR) * PG_C_TO_TG_CH4;
// Permafrost thaw produces CH4 emissions
#define PG_C_TO_TG_CH4 (1000.0 * 16.04 / 12.01)
const double rh_ch4 =
core->sendMessage(M_GETDATA, D_RH_CH4).value(U_PGC_YR) * PG_C_TO_TG_CH4;

// Additional, background CH4 natural emissions
const double ch4n = CH4N.value(U_TG_CH4);
const double emisTocon = (current_ch4em + rh_ch4 + ch4n) / UC_CH4.value(U_TG_PPBV);
const double emisTocon =
(current_ch4em + rh_ch4 + ch4n) / UC_CH4.value(U_TG_PPBV);
const double previous_ch4 = CH4.get(oldDate);

H_LOG(logger, Logger::DEBUG)
Expand Down
2 changes: 1 addition & 1 deletion src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ void Core::reset(double resetdate) {
if (rerun_spinup) {
prepareToRun();
lastDate = getStartDate();
} else {
} else {
lastDate = resetdate;
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/csv_outputstream_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,16 @@ void CSVOutputStreamVisitor::visit(SimpleNbox *c) {
c->final_rh[biome]);
STREAM_UNITVAL(csvFile, c, biome + SNBOX_PARSECHAR + D_RH_CH4,
c->RH_ch4[biome]);
STREAM_UNITVAL(csvFile, c, biome + SNBOX_PARSECHAR + D_VEGC,
STREAM_UNITVAL(csvFile, c, biome + SNBOX_PARSECHAR + D_VEGC,
c->veg_c[biome]);
STREAM_UNITVAL(csvFile, c, biome + SNBOX_PARSECHAR + D_DETRITUSC,
c->detritus_c[biome]);
STREAM_UNITVAL(csvFile, c, biome + SNBOX_PARSECHAR + D_SOILC,
c->soil_c[biome]);
STREAM_UNITVAL( csvFile, c, biome + SNBOX_PARSECHAR + D_PERMAFROSTC, c->permafrost_c[ biome ] );
STREAM_UNITVAL( csvFile, c, biome + SNBOX_PARSECHAR + D_THAWEDPC, c->thawed_permafrost_c[ biome ] );
STREAM_UNITVAL(csvFile, c, biome + SNBOX_PARSECHAR + D_PERMAFROSTC,
c->permafrost_c[biome]);
STREAM_UNITVAL(csvFile, c, biome + SNBOX_PARSECHAR + D_THAWEDPC,
c->thawed_permafrost_c[biome]);
STREAM_UNITVAL(csvFile, c, biome + SNBOX_PARSECHAR + D_F_FROZEN,
unitval(c->f_frozen[biome], U_UNITLESS));
STREAM_UNITVAL(csvFile, c, biome + SNBOX_PARSECHAR + D_TEMPFERTD,
Expand Down
4 changes: 2 additions & 2 deletions src/csv_tracking_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ void CSVFluxPoolVisitor::visit(SimpleNbox *c) {
print_pool(c->veg_c[biome], cname);
print_pool(c->detritus_c[biome], cname);
print_pool(c->soil_c[biome], cname);
print_pool( c->permafrost_c[ biome ], cname );
print_pool( c->thawed_permafrost_c[ biome ], cname );
print_pool(c->permafrost_c[biome], cname);
print_pool(c->thawed_permafrost_c[biome], cname);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/dependency_finder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

//#include <cassert>
// #include <cassert>
#include <algorithm>
#include <limits>

Expand Down
2 changes: 1 addition & 1 deletion src/dummy_model_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ unitval DummyModelComponent::sendMessage(const std::string &message,

} else if (message == M_SETDATA) { //! Caller is requesting to set data
// TODO: call setData below

} else { //! We don't handle any other messages
H_THROW("Caller sent unknown message: " + message);
}
Expand Down
10 changes: 5 additions & 5 deletions src/h_interpolator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ h_interpolator::~h_interpolator() { release_data(); }
* Release memory used by internal vars.
*/
void h_interpolator::release_data() {
delete[](xdata); // free old memory, if necessary
delete[](ydata);
delete[](b_coef);
delete[](c_coef);
delete[](d_coef);
delete[] (xdata); // free old memory, if necessary
delete[] (ydata);
delete[] (b_coef);
delete[] (c_coef);
delete[] (d_coef);
}

//-----------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 09c7b93

Please sign in to comment.