Skip to content

Commit 6580f1b

Browse files
James CraigJames Craig
authored andcommitted
v483 - Custom constituent outputs / LW_INC bug fixes
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)
1 parent 37b761b commit 6580f1b

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/Radiation.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,12 @@ double CRadiation::EstimateLongwaveRadiation(const int iSnow,
108108
case(LW_INC_DATA):
109109
{
110110
LW_incoming=F->LW_incoming;
111+
break;
111112
}
112113
case(LW_INC_DEFAULT):
113114
{
114115
LW_incoming=0.0; //calculated below with LW_DEFAULT, or not at all for algorithms which can calculate net LW only
116+
break;
115117
}
116118
//--------------------------------------------------------
117119
case(LW_INC_SICART):
@@ -139,6 +141,7 @@ double CRadiation::EstimateLongwaveRadiation(const int iSnow,
139141
L_F = epsilon_s*STEFAN_BOLTZ*pow(Tair,4.0); // eqn 6 of Sicart et al (2005)
140142

141143
LW_incoming = svf*L_0 + (1.0-svf)*L_F;
144+
break;
142145
}
143146
//--------------------------------------------------------
144147
case (LW_INC_SKYVIEW):
@@ -162,6 +165,7 @@ double CRadiation::EstimateLongwaveRadiation(const int iSnow,
162165

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

188192
LW_incoming=STEFAN_BOLTZ*eps_at*pow(Tair,4);
193+
break;
189194
}
190195
}
191196

src/StateVariables.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,32 @@
1717
CStateVariable::CStateVariable()
1818
{
1919
this->Initialize();
20+
_pTransportModel=NULL;
2021
}
2122

2223
//////////////////////////////////////////////////////////////////
2324
/// \brief Initializes static arrays of CStateVariable class
2425
//
2526
void CStateVariable::Initialize()
2627
{
27-
this->_nAliases = 0;
28-
this->_aAliases = NULL;
29-
this->_aAliasReferences = NULL;
28+
_nAliases = 0;
29+
_aAliases = NULL;
30+
_aAliasReferences = NULL;
3031
}
3132

3233
//////////////////////////////////////////////////////////////////
3334
/// Destructor
3435
//
3536
CStateVariable::~CStateVariable()
3637
{
37-
this->Destroy();
38+
delete [] _aAliases;
39+
delete [] _aAliasReferences;
3840
}
3941

4042
//////////////////////////////////////////////////////////////////
4143
/// \brief Delete references to static alias arrays
4244
//
43-
void CStateVariable::Destroy()
44-
{
45-
delete [] _aAliases;
46-
delete [] _aAliasReferences;
47-
}
45+
void CStateVariable::Destroy(){}
4846

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

399397
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
400398
{
401-
layer_index = this->_pTransportModel->GetLayerIndexFromName2(tmp, layer_index);
399+
layer_index = _pTransportModel->GetLayerIndexFromName2(tmp, layer_index);
402400
if (layer_index==DOESNT_EXIST){typ=UNRECOGNIZED_SVTYPE;}
403401
}
404402

0 commit comments

Comments
 (0)