Skip to content

Commit 80d8cc8

Browse files
James CraigJames Craig
authored andcommitted
v488 - UPSTREAM_OF update; minor bug fixes
-made :PopulateSBGroup UPSTREAM_OF inclusive of basin by default (BACKWARD COMPATIBILITY) (ParseHRUFile.cpp) bug fixes: -writing StreamTemperatures.nc seg fault (found by Arelia S. @pcic) (ConstituentModel.cpp) -simulations starting prior to 1900 without snowfall data unable to run (found by Jonathan R-C @uw) (TimeSeries.cpp)
1 parent 4a20396 commit 80d8cc8

File tree

4 files changed

+7
-20
lines changed

4 files changed

+7
-20
lines changed

src/ConstituentModel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1529,7 +1529,7 @@ void CConstituentModel::WriteNetCDFMinorOutput(const optStruct& Options,const ti
15291529

15301530
CEnthalpyModel *pEnthalpyModel=NULL; //Necessary evil to reduce code duplication rather than having an entirely separate WriteMinorOutput for Enthalpy
15311531
if (_type==ENTHALPY){
1532-
CEnthalpyModel *pEnthalpyModel=(CEnthalpyModel*)(this);
1532+
pEnthalpyModel=(CEnthalpyModel*)(this);
15331533
}
15341534

15351535
if((Options.suppressICs) && (tt.model_time==0.0)) { return; }

src/ControlStructures.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ bool COutflowRegime::AreConditionsMet(const time_struct& tt) const
283283
//////////////////////////////////////////////////////////////////
284284
/// \brief returns outflow from control structure for given stage, with prioritized constraints applied
285285
/// \param h [in] stage, in [m]
286-
/// \param Q_start [in] outflow at start of timestep [m3/s]
286+
/// \param Q_start [in] total outflow at start of timestep [m3/s]
287287
/// \returns outflow, in [m3/s]
288288
//
289289
double COutflowRegime::GetOutflow(const double &h, const double &h_start, const double &Q_start, const long &target_SBID, const double &drefelev) const
@@ -292,6 +292,7 @@ double COutflowRegime::GetOutflow(const double &h, const double &h_star
292292
double rivdepth = _pModel->GetSubBasinByID(target_SBID)->GetRiverDepth();
293293

294294
double Q = _pCurve->GetDischarge(h, h_start, Q_start, rivdepth, drefelev);
295+
295296
double dQdt = (Q-Q_start)/tstep;
296297

297298
//apply constraints here

src/ParseHRUFile.cpp

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -826,21 +826,7 @@ bool ParseHRUPropsFile(CModel *&pModel, const optStruct &Options, bool terrain_r
826826
}
827827
}
828828
}
829-
else if(!strcmp(s[4],"UPSTREAM_OF"))
830-
{
831-
int SBID=s_to_l(s[5]);
832-
int iter=0;
833-
for(int p=0;p<pModel->GetNumSubBasins();p++)
834-
{
835-
if(pModel->IsSubBasinUpstream(pModel->GetSubBasin(p)->GetID(),SBID)) {
836-
pSBGroup->AddSubbasin(pModel->GetSubBasin(p));
837-
advice=advice+to_string(pModel->GetSubBasin(p)->GetID())+" ";
838-
iter++;
839-
if(iter%40==0) { advice=advice+"\n "; }
840-
}
841-
}
842-
}
843-
else if(!strcmp(s[4],"UPSTREAM_OF_INCLUSIVE"))
829+
else if(!strcmp(s[4],"UPSTREAM_OF")) /*inclusive of basin*/
844830
{
845831
int SBID=s_to_l(s[5]);
846832
int iter=0;
@@ -855,7 +841,7 @@ bool ParseHRUPropsFile(CModel *&pModel, const optStruct &Options, bool terrain_r
855841
}
856842
}
857843
}
858-
else if(!strcmp(s[4],"DOWNSTREAM_OF"))
844+
else if(!strcmp(s[4],"DOWNSTREAM_OF"))/*not inclusive of basin*/
859845
{
860846
CSubBasin *pBasin=pModel->GetSubBasinByID(s_to_l(s[5]));
861847
if(pBasin==NULL) {

src/TimeSeries.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ void GetNetCDFStationArray(const int ncid, const string filename,int &stat_dimid
2020
CTimeSeries::CTimeSeries(string Name, long loc_ID, double one_value)
2121
:CTimeSeriesABC(TS_REGULAR,Name,loc_ID,"")
2222
{
23-
_start_day=0.0;
24-
_start_year=1900;
23+
_start_day =0.0;
24+
_start_year=0000;
2525
_nPulses =2;
2626
_interval =ALMOST_INF;
2727
_aVal =new double [_nPulses];

0 commit comments

Comments
 (0)