diff --git a/config/output_spec.csv b/config/output_spec.csv index 4a7c862d..5cd5a5e7 100644 --- a/config/output_spec.csv +++ b/config/output_spec.csv @@ -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, diff --git a/include/OutputHolder.h b/include/OutputHolder.h index 823ec9ab..894fcf4f 100644 --- a/include/OutputHolder.h +++ b/include/OutputHolder.h @@ -47,6 +47,8 @@ class OutputHolder{ std::vector qrunoff_for_output; std::vector reco_for_output; std::vector rhdwd_for_output; + std::vector socfrozen_for_output; + std::vector socunfrozen_for_output; std::vector shlwc_for_output; std::vector snowthick_for_output; std::vector swe_for_output; diff --git a/src/Runner.cpp b/src/Runner.cpp index f066fbe3..12c2d075 100644 --- a/src/Runner.cpp +++ b/src/Runner.cpp @@ -4842,6 +4842,93 @@ void Runner::output_netCDF(std::map &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()){