Skip to content

Commit

Permalink
Add timestamp to csvoutputstream; documentation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kdorheim committed Feb 25, 2022
1 parent 8fad518 commit 9db72f8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
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
11 changes: 10 additions & 1 deletion src/csv_outputstream_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

#include <fstream>
#include <regex>

// some boost headers generate warnings under clang; not our problem, ignore
#pragma clang diagnostic push
Expand Down Expand Up @@ -42,6 +43,7 @@ namespace Hector {

using namespace std;


//------------------------------------------------------------------------------
/*! \brief Constructor
* \param outputStream The file to write the csv output to
Expand All @@ -51,8 +53,15 @@ CSVOutputStreamVisitor::CSVOutputStreamVisitor( ostream& outputStream, const boo
:csvFile( outputStream )
{
if( printHeader ) {

// Save the current time (real world not Hector current time) to write out in outputstream.
std::time_t result = std::time(nullptr);
const string real_time = std::ctime(&result);
std::regex newlines_re("\n+");
auto print_time = std::regex_replace(real_time, newlines_re, "");

// Print model version header
csvFile << "# Output from " << MODEL_NAME << " version " << MODEL_VERSION << endl;
csvFile << "# Output from " << MODEL_NAME << " version " << MODEL_VERSION << " on " << print_time << endl;

// Print table header
csvFile << "year" << DELIMITER << "run_name" << DELIMITER << "spinup" << DELIMITER
Expand Down
3 changes: 0 additions & 3 deletions src/ocean_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,16 +373,13 @@ void OceanComponent::run( const double runToDate ) {
surfaceLL.new_year( SST );
inter.new_year( SST );
deep.new_year( SST );
//double x = surfaceHL.get_Tbox();
H_LOG( logger, Logger::DEBUG ) << "----------------------------------------------------" << std::endl;
H_LOG( logger, Logger::DEBUG ) << "runToDate=" << runToDate << ", Ca=" << Ca << ", spinup=" << in_spinup << std::endl;

// If chemistry models weren't turned on during spinup, do so now
if( !spinup_chem && !in_spinup && !surfaceHL.active_chemistry ) {

H_LOG( logger, Logger::DEBUG ) << "*** Turning on chemistry models ***" << std::endl;
std::cout << "triggered when spinup_chem = 0";

surfaceHL.active_chemistry = true;
surfaceLL.active_chemistry = true;
surfaceHL.chem_equilibrate( Ca );
Expand Down
3 changes: 1 addition & 2 deletions src/temperature_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ void TemperatureComponent::setData( const string& varName,
H_ASSERT( data.date == Core::undefinedIndex(), "date not allowed" );
lo_warming_ratio = data.getUnitval(U_UNITLESS);
} else {
H_THROW( "Unknown variable name while parsing " + getComponentName() + ": "
+ varName );
H_THROW( "Unknown variable name while parsing " + getComponentName() + ": " + varName );
}
} catch( bad_lexical_cast& castException ) {
H_THROW( "Could not convert var: "+varName+", value: " + data.value_str + ", exception: "
Expand Down

1 comment on commit 9db72f8

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Differences in Hector outputs

Hello, this is leeyabot! 🤖

The current pull request's outputs do not differ from 3.0.0 (2dc164a).

CML watermark

Please sign in to comment.