Skip to content

Commit

Permalink
v483 - Custom constituent outputs / LW_INC bug fixes
Browse files Browse the repository at this point in the history
bug fixes (bugs found by Arelia S.):
-moved initialization of CStateVariable::SetTransportModel() so that custom transport outputs can be generated
-added breaks to ensure correct LW_INC routine is applied in EstimateLongwaveRadiation (Radiation.cpp)
  • Loading branch information
James Craig authored and James Craig committed Oct 22, 2024
1 parent 37b761b commit 6580f1b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
5 changes: 5 additions & 0 deletions src/Radiation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,12 @@ double CRadiation::EstimateLongwaveRadiation(const int iSnow,
case(LW_INC_DATA):
{
LW_incoming=F->LW_incoming;
break;
}
case(LW_INC_DEFAULT):
{
LW_incoming=0.0; //calculated below with LW_DEFAULT, or not at all for algorithms which can calculate net LW only
break;
}
//--------------------------------------------------------
case(LW_INC_SICART):
Expand Down Expand Up @@ -139,6 +141,7 @@ double CRadiation::EstimateLongwaveRadiation(const int iSnow,
L_F = epsilon_s*STEFAN_BOLTZ*pow(Tair,4.0); // eqn 6 of Sicart et al (2005)

LW_incoming = svf*L_0 + (1.0-svf)*L_F;
break;
}
//--------------------------------------------------------
case (LW_INC_SKYVIEW):
Expand All @@ -162,6 +165,7 @@ double CRadiation::EstimateLongwaveRadiation(const int iSnow,

LW_incoming = epsilon_s * (1 - svf) * STEFAN_BOLTZ * pow(Tair,4);
LW_incoming += epsilon_air * ( svf) * STEFAN_BOLTZ * pow(Tair,4);
break;
}
//--------------------------------------------------------
case (LW_INC_DINGMAN):
Expand All @@ -186,6 +190,7 @@ double CRadiation::EstimateLongwaveRadiation(const int iSnow,
eps_at=(1-forest_cover)*eps_at+(forest_cover)*1.0; //treats forest as blackbody - neglects sky view factor

LW_incoming=STEFAN_BOLTZ*eps_at*pow(Tair,4);
break;
}
}

Expand Down
18 changes: 8 additions & 10 deletions src/StateVariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,32 @@
CStateVariable::CStateVariable()
{
this->Initialize();
_pTransportModel=NULL;
}

//////////////////////////////////////////////////////////////////
/// \brief Initializes static arrays of CStateVariable class
//
void CStateVariable::Initialize()
{
this->_nAliases = 0;
this->_aAliases = NULL;
this->_aAliasReferences = NULL;
_nAliases = 0;
_aAliases = NULL;
_aAliasReferences = NULL;
}

//////////////////////////////////////////////////////////////////
/// Destructor
//
CStateVariable::~CStateVariable()
{
this->Destroy();
delete [] _aAliases;
delete [] _aAliasReferences;
}

//////////////////////////////////////////////////////////////////
/// \brief Delete references to static alias arrays
//
void CStateVariable::Destroy()
{
delete [] _aAliases;
delete [] _aAliasReferences;
}
void CStateVariable::Destroy(){}

//////////////////////////////////////////////////////////////////
/// \brief Dynamically adds additional string, s, onto dynamic array of strings, pArr. Increments size of array by one
Expand Down Expand Up @@ -398,7 +396,7 @@ sv_type CStateVariable::StringToSVType(const string s, int &layer_index,bool str

if ((typ==CONSTITUENT) && ((int)(tmp.find_first_of("|"))!=-1)) //only used if e.g., !Nitrogen|SOIL[1] (rather than CONSTITUENT[32] or !Nitrogen[32]) is used
{
layer_index = this->_pTransportModel->GetLayerIndexFromName2(tmp, layer_index);
layer_index = _pTransportModel->GetLayerIndexFromName2(tmp, layer_index);
if (layer_index==DOESNT_EXIST){typ=UNRECOGNIZED_SVTYPE;}
}

Expand Down

0 comments on commit 6580f1b

Please sign in to comment.