From 01b0a3deb0e875818a82af6bc7a593154cc385af Mon Sep 17 00:00:00 2001 From: rchlumsk Date: Mon, 15 Dec 2025 14:49:22 -0500 Subject: [PATCH 1/2] updated profile parsing limit and added error --- src/ParsePropertyFile.cpp | 6 ++++++ src/RavenInclude.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ParsePropertyFile.cpp b/src/ParsePropertyFile.cpp index 9fc0485..7d4597f 100644 --- a/src/ParsePropertyFile.cpp +++ b/src/ParsePropertyFile.cpp @@ -845,8 +845,11 @@ bool ParseClassPropertiesFile(CModel *&pModel, { p->Tokenize(s,Len); done=false; + int j = 0; while (!done) { + j += 1; + ExitGracefullyIf(j>=MAX_SURVEY_PTS,"ParseClassPropertiesFile: Maximum number of channel points exceeded (max 500).",BAD_DATA); // check against MAX_SURVEY_PTS if (IsComment(s[0], Len)){}//comment line else if (Len==2) {x[countSP]=s_to_d(s[0]); y[countSP]=s_to_d(s[1]);countSP++;} else {p->ImproperFormat(s); break;} @@ -859,8 +862,11 @@ bool ParseClassPropertiesFile(CModel *&pModel, { p->Tokenize(s,Len); done=false; + int j = 0; while (!done) { + j += 1; + ExitGracefullyIf(j>=MAX_SURVEY_PTS,"ParseClassPropertiesFile: Maximum number of roughness points exceeded (max 500).",BAD_DATA); // check against MAX_SURVEY_PTS if (IsComment(s[0], Len)){}//comment line else if (Len==2 ){xz[countRS]=s_to_d(s[0]);n [countRS]=s_to_d(s[1]);countRS++;} else {p->ImproperFormat(s); break;} diff --git a/src/RavenInclude.h b/src/RavenInclude.h index 1e48844..b5124c3 100644 --- a/src/RavenInclude.h +++ b/src/RavenInclude.h @@ -338,7 +338,7 @@ const int MAX_SOIL_PROFILES =200; ///< Max number of soil profiles const int MAX_VEG_CLASSES =200; ///< Max number of vegetation classes const int MAX_LULT_CLASSES =200; ///< Max number of lult classes const int MAX_TERRAIN_CLASSES =50; ///< Max number of terrain classes -const int MAX_SURVEY_PTS =50; ///< Max number of survey points +const int MAX_SURVEY_PTS =500; ///< Max number of survey points const int MAX_CONSTITUENTS =10; ///< Max number of transported constituents const int MAX_RIVER_SEGS =50; ///< Max number of river segments const int MAX_FILENAME_LENGTH =256; ///< Max filename length From 2b58ef00d686818beedda2cbf9bce40771bce062 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 15 Dec 2025 19:51:02 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/Baseflow.cpp | 2 +- src/CapillaryRise.cpp | 4 ++-- src/HydroUnits.cpp | 4 ++-- src/Interflow.cpp | 4 ++-- src/ModelInitialize.cpp | 2 +- src/Percolation.cpp | 4 ++-- src/Recharge.cpp | 4 ++-- src/UpdateForcings.cpp | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Baseflow.cpp b/src/Baseflow.cpp index 1680849..ab552ed 100644 --- a/src/Baseflow.cpp +++ b/src/Baseflow.cpp @@ -155,7 +155,7 @@ void CmvBaseflow::GetRatesOfChange( const double *storage, const time_struct &tt, double *rates) const { - if ((pHRU->GetHRUType()==HRU_LAKE) || (pHRU->GetHRUType()==HRU_WATER) || + if ((pHRU->GetHRUType()==HRU_LAKE) || (pHRU->GetHRUType()==HRU_WATER) || (pHRU->GetHRUType()==HRU_ROCK)){return;}//Lake/Water/Rock const soil_struct *pSoil=NULL; diff --git a/src/CapillaryRise.cpp b/src/CapillaryRise.cpp index 0f71de1..2444f4d 100644 --- a/src/CapillaryRise.cpp +++ b/src/CapillaryRise.cpp @@ -106,7 +106,7 @@ void CmvCapillaryRise::GetRatesOfChange( const double *storage, const time_struct &tt, double *rates) const { - if ((pHRU->GetHRUType()==HRU_LAKE) || (pHRU->GetHRUType()==HRU_WATER) || + if ((pHRU->GetHRUType()==HRU_LAKE) || (pHRU->GetHRUType()==HRU_WATER) || (pHRU->GetHRUType()==HRU_ROCK)){return;}//Lake/Water/Rock const soil_struct *pSoil=NULL; @@ -163,7 +163,7 @@ void CmvCapillaryRise::ApplyConstraints( const double *storage, const time_struct &tt, double *rates) const { - if ((pHRU->GetHRUType()==HRU_LAKE) || (pHRU->GetHRUType()==HRU_WATER) || + if ((pHRU->GetHRUType()==HRU_LAKE) || (pHRU->GetHRUType()==HRU_WATER) || (pHRU->GetHRUType()==HRU_ROCK)){return;}//Lake/Water/Rock double min_stor=g_min_storage; diff --git a/src/HydroUnits.cpp b/src/HydroUnits.cpp index 1026f22..a26e2d3 100644 --- a/src/HydroUnits.cpp +++ b/src/HydroUnits.cpp @@ -491,11 +491,11 @@ void CHydroUnit::AdjustHRUForcing(const forcing_type Ftyp,force_struct &F, const else if (adj==ADJ_ADDITIVE ){F.temp_ave+=epsilon; } else if (adj==ADJ_REPLACE ){F.temp_ave =epsilon;} } - else if(Ftyp==F_TEMP_DAILY_MIN) + else if(Ftyp==F_TEMP_DAILY_MIN) { //handled in AdjustDailyHRUForcings } - else if(Ftyp==F_TEMP_DAILY_MAX) + else if(Ftyp==F_TEMP_DAILY_MAX) { //handled in AdjustDailyHRUForcings } diff --git a/src/Interflow.cpp b/src/Interflow.cpp index 005c6ab..14ecd4e 100644 --- a/src/Interflow.cpp +++ b/src/Interflow.cpp @@ -101,7 +101,7 @@ void CmvInterflow::GetRatesOfChange(const double *state_v const time_struct &tt, double *rates) const { - if ((pHRU->GetHRUType()==HRU_LAKE) || (pHRU->GetHRUType()==HRU_WATER) || + if ((pHRU->GetHRUType()==HRU_LAKE) || (pHRU->GetHRUType()==HRU_WATER) || (pHRU->GetHRUType()==HRU_ROCK)){return;}//Lake/Water/Rock double stor = state_vars[iFrom[0]]; @@ -139,7 +139,7 @@ void CmvInterflow::ApplyConstraints( const double *state_vars, const time_struct &tt, double *rates) const { - if ((pHRU->GetHRUType()==HRU_LAKE) || (pHRU->GetHRUType()==HRU_WATER) || + if ((pHRU->GetHRUType()==HRU_LAKE) || (pHRU->GetHRUType()==HRU_WATER) || (pHRU->GetHRUType()==HRU_ROCK)){return;}//Lake/Water/Rock //cant remove more than is there diff --git a/src/ModelInitialize.cpp b/src/ModelInitialize.cpp index cd4cf4a..79c5da5 100644 --- a/src/ModelInitialize.cpp +++ b/src/ModelInitialize.cpp @@ -615,7 +615,7 @@ void CModel::InitializeRoutingNetwork() if (need_upstream){ long long SBID; int nUp; - + for (int p=0;p<_nSubBasins;p++) { SBID=_pSubBasins[p]->GetID(); diff --git a/src/Percolation.cpp b/src/Percolation.cpp index 9be3a8b..83c762e 100644 --- a/src/Percolation.cpp +++ b/src/Percolation.cpp @@ -186,7 +186,7 @@ void CmvPercolation::GetRatesOfChange( const double *state_v const time_struct &tt, double *rates) const { - if ((pHRU->GetHRUType()==HRU_LAKE) || (pHRU->GetHRUType()==HRU_WATER) || + if ((pHRU->GetHRUType()==HRU_LAKE) || (pHRU->GetHRUType()==HRU_WATER) || (pHRU->GetHRUType()==HRU_ROCK)){return;}//Lake/Water/Rock double stor,max_stor; @@ -342,7 +342,7 @@ void CmvPercolation::ApplyConstraints(const double *state_vars, const time_struct &tt, double *rates) const { - if ((pHRU->GetHRUType()==HRU_LAKE) || (pHRU->GetHRUType()==HRU_WATER) || + if ((pHRU->GetHRUType()==HRU_LAKE) || (pHRU->GetHRUType()==HRU_WATER) || (pHRU->GetHRUType()==HRU_ROCK)){return;}//Lake/Water/Rock double min_stor=g_min_storage; diff --git a/src/Recharge.cpp b/src/Recharge.cpp index 95d3595..44c1efa 100644 --- a/src/Recharge.cpp +++ b/src/Recharge.cpp @@ -156,7 +156,7 @@ void CmvRecharge::GetRatesOfChange( const double *storage, const time_struct &tt, double *rates) const { - if ((pHRU->GetHRUType()==HRU_LAKE) || (pHRU->GetHRUType()==HRU_WATER) || + if ((pHRU->GetHRUType()==HRU_LAKE) || (pHRU->GetHRUType()==HRU_WATER) || (pHRU->GetHRUType()==HRU_ROCK) || (pHRU->GetHRUType()==HRU_MASKED_GLACIER)){return;}//Lake/Water/Rock if( _type==RECHARGE_FROMFILE){ @@ -195,7 +195,7 @@ void CmvRecharge::ApplyConstraints( const double *state_vars, const time_struct &tt, double *rates) const { - if ((pHRU->GetHRUType()==HRU_LAKE) || (pHRU->GetHRUType()==HRU_WATER) || + if ((pHRU->GetHRUType()==HRU_LAKE) || (pHRU->GetHRUType()==HRU_WATER) || (pHRU->GetHRUType()==HRU_ROCK) || (pHRU->GetHRUType()==HRU_MASKED_GLACIER)){return;}//Lake/Water/Rock if (_type==RECHARGE_FROMFILE) diff --git a/src/UpdateForcings.cpp b/src/UpdateForcings.cpp index 6e25a58..7e69e8a 100644 --- a/src/UpdateForcings.cpp +++ b/src/UpdateForcings.cpp @@ -561,7 +561,7 @@ void CModel::UpdateHRUForcingFunctions(const optStruct &Options, ApplyForcingPerturbation(F_SNOWFALL, F, k, Options, tt); if (_pHydroUnits[k]->GetHRUType()==HRU_MASKED_GLACIER){ // disable all precip from masked portion - F.precip=F.precip_daily_ave=F.precip_5day=0; + F.precip=F.precip_daily_ave=F.precip_5day=0; } //-------------------------------------------------------------------