Skip to content

Commit

Permalink
Adds SOCFROZEN and SOCUNFROZEN outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
rarutter committed Oct 17, 2024
1 parent 40ec081 commit bca8a23
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config/output_spec.csv
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ SNOWLAYERTEMP,Snow temperature by layer,degree_C,,,invalid,invalid,invalid,force
SNOWSTART,DOY of first snow fall,DOY,,invalid,invalid,invalid,invalid,invalid,int,
SNOWTHICK,Snow pack thickness,m,,,,invalid,invalid,invalid,double,
SOC,Soil organic C total,g/m2,,,invalid,invalid,invalid,,double,
SOCFROZEN,Soil organic C frozen,g/m2,,,invalid,invalid,invalid,invalid,double,
SOCUNFROZEN,Soil organic C unfrozen,g/m2,,,invalid,invalid,invalid,invalid,double,
SOMA,Soil organic C active,g/m2,,,invalid,invalid,invalid,,double,
SOMCR,Soil organic C chemically resistant,g/m2,,,invalid,invalid,invalid,,double,
SOMPR,Soil organic C physically resistant,g/m2,,,invalid,invalid,invalid,,double,
Expand Down
2 changes: 2 additions & 0 deletions include/OutputHolder.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class OutputHolder{
std::vector<double> qrunoff_for_output;
std::vector<double> reco_for_output;
std::vector<double> rhdwd_for_output;
std::vector<double> socfrozen_for_output;
std::vector<double> socunfrozen_for_output;
std::vector<double> shlwc_for_output;
std::vector<double> snowthick_for_output;
std::vector<double> swe_for_output;
Expand Down
87 changes: 87 additions & 0 deletions src/Runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4842,6 +4842,93 @@ void Runner::output_netCDF(std::map<std::string, OutputSpec> &netcdf_outputs, in
map_itr = netcdf_outputs.end();


//SOCFROZEN
map_itr = netcdf_outputs.find("SOCFROZEN");
if (map_itr != netcdf_outputs.end()) {
BOOST_LOG_SEV(glg, debug) << "NetCDF output: SOCFROZEN";
curr_spec = map_itr->second;

#pragma omp critical(outputSOCFROZEN)
{
double frozenC = 0.0;

Layer* currl = this->cohort.ground.fstsoill;
while(currl != NULL && currl != cohort.ground.lstsoill){

double layerC = currl->rawc + currl->soma
+ currl->sompr + currl->somcr;

double temp_frozenC = currl->frozenfrac * layerC;

frozenC += currl->frozenfrac * layerC;

currl = currl->nextl;
}

outhold.socfrozen_for_output.push_back(frozenC);

//Monthly
if(curr_spec.monthly){
if(output_this_timestep){
output_nc_3dim(&curr_spec, file_stage_suffix, &outhold.socfrozen_for_output[0], 1, month_start_idx, months_to_output);
outhold.socfrozen_for_output.clear();
}
}
//Yearly
else if(curr_spec.yearly){
if(output_this_timestep){
output_nc_3dim(&curr_spec, file_stage_suffix, &outhold.socfrozen_for_output[0], 1, year_start_idx, years_to_output);
outhold.socfrozen_for_output.clear();
}
}
} //end critical(outputSOCFROZEN)
} //end SOCFROZEN
map_itr = netcdf_outputs.end();


//SOCUNFROZEN
map_itr = netcdf_outputs.find("SOCUNFROZEN");
if (map_itr != netcdf_outputs.end()) {
BOOST_LOG_SEV(glg, debug) << "NetCDF output: SOCUNFROZEN";
curr_spec = map_itr->second;

#pragma omp critical(outputSOCUNFROZEN)
{
double unfrozenC = 0.0;

Layer* currl = this->cohort.ground.fstsoill;
while(currl != NULL && currl != cohort.ground.lstsoill){

double layerC = currl->rawc + currl->soma
+ currl->sompr + currl->somcr;

unfrozenC += (1 - currl->frozenfrac) * layerC;

currl = currl->nextl;
}

outhold.socunfrozen_for_output.push_back(unfrozenC);

//Monthly
if(curr_spec.monthly){
if(output_this_timestep){
output_nc_3dim(&curr_spec, file_stage_suffix, &outhold.socunfrozen_for_output[0], 1, month_start_idx, months_to_output);
outhold.socunfrozen_for_output.clear();
}
}
//Yearly
else if(curr_spec.yearly){

if(output_this_timestep){
output_nc_3dim(&curr_spec, file_stage_suffix, &outhold.socunfrozen_for_output[0], 1, year_start_idx, years_to_output);
outhold.socunfrozen_for_output.clear();
}
}
} //end critical(outputSOCUNFROZEN)
} //end SOCUNFROZEN
map_itr = netcdf_outputs.end();


//SOMA - soil organic matter, active
map_itr = netcdf_outputs.find("SOMA");
if(map_itr != netcdf_outputs.end()){
Expand Down

0 comments on commit bca8a23

Please sign in to comment.