diff --git a/src/Abstraction.cpp b/src/Abstraction.cpp index 61b32d7..2e132e0 100644 --- a/src/Abstraction.cpp +++ b/src/Abstraction.cpp @@ -50,7 +50,7 @@ CmvAbstraction::CmvAbstraction(abstraction_type absttype, CModelABC *pModel) //adjust minimum deficit iFrom[2]=pModel->GetStateVarIndex(MIN_DEP_DEFICIT); iTo [2]=pModel->GetStateVarIndex(MIN_DEP_DEFICIT); - } + } else if (_type == ABST_HGDM) { CHydroProcessABC::DynamicSpecifyConnections(4); //abstraction (ponded-->large or small depressions or outflow) @@ -170,34 +170,34 @@ void CmvAbstraction::GetParticipatingStateVarList(abstraction_type absttype, sv_ /// \param current_contrib_frac [in] current contributing fraction [0..1] /// \param threshold [in] delta threshold for triggering zero contributing area [mm] // -double HGDMcontrib_fraction(const double ¤t_storage, - const double &delta_storage, - const double &max_storage, - const double ¤t_contrib_frac, - const double &threshold = -0.01) -{ +double HGDMcontrib_fraction(const double ¤t_storage, + const double &delta_storage, + const double &max_storage, + const double ¤t_contrib_frac, + const double &threshold = -0.01) +{ double vf1 = current_storage / max_storage; //[0..1] - double cf1 = current_contrib_frac; //[0..1] + double cf1 = current_contrib_frac; //[0..1] double vf2,cf2; - if (delta_storage == 0.0) + if (delta_storage == 0.0) { return current_contrib_frac; - } - else + } + else { - if (delta_storage < threshold) + if (delta_storage < threshold) { //vf2 = (current_storage + delta_storage) / max_storage; //never used return 0.0; - } - else + } + else { vf2 = vf1 + (1.0 - cf1 ) * (delta_storage / max_storage); if (vf1 < 0.999) { cf2 = (((1.0 - cf1) * (vf2 - vf1)) / (1.0 - vf1)) + cf1; cf2 = min(max(min(cf2, vf2), 0.0), 1.0); - } + } else { cf2 = 1.0; } @@ -373,14 +373,14 @@ void CmvAbstraction::GetRatesOfChange( const double *state_vars, double Vs_max =pHRU->GetSurfaceProps()->dep_max; double Vl_max =pHRU->GetSurfaceProps()->dep_max_large; double f_s_to_l=pHRU->GetSurfaceProps()->small_to_large; //[0..1] fraction of depression landscape draining to large gatekeeper - double f_s_to_o=(1-f_s_to_l); //[0..1] fraction of depression landscape draining to outlet + double f_s_to_o=(1-f_s_to_l); //[0..1] fraction of depression landscape draining to outlet double fsu =pHRU->GetSurfaceProps()->HGDM_frac_sm_dep; //[0..1] fraction of HRU covered in small depressions + contrib areas of depressions double flu =pHRU->GetSurfaceProps()->HGDM_frac_lr_dep; //[0..1] fraction of HRU covered in large depression + contrib areas of depression double fl =pHRU->GetSurfaceProps()->HGDM_frac_lr_are; //[0..1] fraction of HRU covered by maximum area of large depression double p =pHRU->GetSurfaceProps()->HGDM_P; double p_large =pHRU->GetSurfaceProps()->HGDM_P_LARGE; - - //rules: + + //rules: // flu+fsu+fo=1.0 // fl < flu @@ -388,7 +388,7 @@ void CmvAbstraction::GetRatesOfChange( const double *state_vars, double Al_max=fl *Atot; //[km2] - maximum area of gatekeeper double Asu =fsu*Atot; //[km2] - total contributing area + surface area of small depressions double Alu =flu*Atot; //[km2] - total contributing area to large depression + surface area of large - double As; //[km2] - total water surface area of small and large depressions (As=A_w in Shook paper) + double As; //[km2] - total water surface area of small and large depressions (As=A_w in Shook paper) double Al; //[km2] - surface area of large gatekeeper depression (0) { @@ -419,21 +419,21 @@ void CmvAbstraction::GetRatesOfChange( const double *state_vars, to_large =(overflow+dVs*(fsc_last))*f_s_to_l; //total ponded->large to_outlet =(overflow+dVs*(fsc_last))*f_s_to_o; //total ponded->outflow } - + //Large depression----------------------------------------------- if (Vlarge <= 0.0 ){Al=0.0;} else if (Vlarge >= Vl_max){Al=Al_max;} else {Al=Al_max*pow((Vlarge / Vl_max),2.0/(p_large + 2.0));} - + //double dVl=ponded*Al/Atot+to_large+runoff*(Alu-Al)/Atot+to_large; double dVl=ponded*(Alu/Atot)+to_large; //any water in local contributing area, which includes Al_max (i.e., Alu>=Al_max, always) Vlarge+=dVl; excess=0.0; - if (Vlarge>Vl_max){ + if (Vlarge>Vl_max){ excess= (Vlarge-Vl_max); - to_outlet+=excess; + to_outlet+=excess; Vlarge=Vl_max; - } + } to_dep_l=dVl-excess; //No depression-------------------------------------------------- diff --git a/src/CustomOutput.cpp b/src/CustomOutput.cpp index b166f43..e2361eb 100644 --- a/src/CustomOutput.cpp +++ b/src/CustomOutput.cpp @@ -1229,4 +1229,4 @@ CCustomOutput *CCustomOutput::ParseCustomOutputCommand(char *s[MAXINPUTITEMS], c } return pCustom; -} \ No newline at end of file +} diff --git a/src/DemandExpressionHandling.cpp b/src/DemandExpressionHandling.cpp index 1c2108b..e3ada74 100644 --- a/src/DemandExpressionHandling.cpp +++ b/src/DemandExpressionHandling.cpp @@ -1129,7 +1129,7 @@ exp_condition* CDemandOptimizer::ParseCondition(const char** s, const int Len, c } if (is_exp) { pCond->pExp=this->ParseExpression((const char**)(s),Len,lineno,filename,Options); - if (pCond->pExp==NULL){return NULL;}//bad expression + if (pCond->pExp==NULL){return NULL;}//bad expression return pCond; } else diff --git a/src/HydroUnits.cpp b/src/HydroUnits.cpp index ebac0e9..cb57a71 100644 --- a/src/HydroUnits.cpp +++ b/src/HydroUnits.cpp @@ -555,27 +555,27 @@ double CHydroUnit::GetStateVarMax(const int i, double max_var=ALMOST_INF; switch (_pModel->GetStateVarType(i)) { - case(SOIL): + case(SOIL): { max_var=GetSoilCapacity(_pModel->GetStateVarLayer(i)); break; } - case(CANOPY): + case(CANOPY): { if(!ignorevar) { max_var=_VegVar.capacity; } break; } - case(CANOPY_SNOW): + case(CANOPY_SNOW): { if(!ignorevar) { max_var=_VegVar.snow_capacity;} break; } - case(GROUNDWATER): + case(GROUNDWATER): { if(Options.modeltype != MODELTYPE_SURFACE){} break; //GetAquiferHeadCapacity(0,HRUid);} //GWMIGRATE - HRUid k not accesible from here yet } - case(DEPRESSION): + case(DEPRESSION): { if (_pSurface->dep_max>=0){max_var=_pSurface->dep_max;} break; } - case(SNOW_COVER): + case(SNOW_COVER): { max_var=1.0; break; } diff --git a/src/LatConnect.cpp b/src/LatConnect.cpp index 8a03a85..392fb54 100644 --- a/src/LatConnect.cpp +++ b/src/LatConnect.cpp @@ -77,7 +77,7 @@ double CLatConnect::GetWeight() const /// \param tolerance [in] Acceptable deviation from 1.0 (default 0.05) /// \return true if all HRU connection weights sum to approximately 1.0 // -bool CLatConnect::CheckConnectionWeights(const CLatConnect* const connections[], +bool CLatConnect::CheckConnectionWeights(const CLatConnect* const connections[], const int nConnections, const CModel* pModel, const double tolerance) @@ -100,7 +100,7 @@ bool CLatConnect::CheckConnectionWeights(const CLatConnect* const connections[], } // Calculate the sum of weights for each source HRU - for (int i = 0; i < nConnections; i++) + for (int i = 0; i < nConnections; i++) { int sourceHRU = pModel->GetHRUByID(connections[i]->GetSourceHRUID())->GetGlobalIndex(); double weight = connections[i]->GetWeight(); @@ -127,4 +127,4 @@ bool CLatConnect::CheckConnectionWeights(const CLatConnect* const connections[], delete[] hasConnections; return allValid; -} \ No newline at end of file +} diff --git a/src/LatConnect.h b/src/LatConnect.h index 904b643..c96d069 100644 --- a/src/LatConnect.h +++ b/src/LatConnect.h @@ -38,11 +38,11 @@ class CLatConnect // Static methods to interact with the collection static int GetNumLatConnections(const CModel *pModel); static CLatConnect* GetLatConnection(const CModel *pModel, int index); - static bool CheckConnectionWeights (const CLatConnect* const connections[], + static bool CheckConnectionWeights (const CLatConnect* const connections[], const int nConnections, const CModel* pModel, const double tolerance = 0.05); }; -#endif // LATCONNECT_H \ No newline at end of file +#endif // LATCONNECT_H diff --git a/src/LatFlush.cpp b/src/LatFlush.cpp index 6abaf94..cf38cce 100644 --- a/src/LatFlush.cpp +++ b/src/LatFlush.cpp @@ -87,14 +87,14 @@ void CmvLatFlush::Initialize() if (toHRUGrp->IsInGroup(k2)) { if (k1!=k2) - { + { //dynamically allocate memory int *tmpT=new int [q+1]; for (int i=0;iGetSubBasin(p)->GetHRU(ks2)->GetArea(); kFrom [q]=k1; - kTo [q]=k2; + kTo [q]=k2; _aFrac[q]=area; Asum+=area;//sum of recipient areas nRecipients++; @@ -146,7 +146,7 @@ void CmvLatFlush::Initialize() int *tmpT=new int [q+1]; for (int i=0;iGetStateVarMax(i,_pHydroUnits[k]->GetStateVarArray(),Options,true),0.0); val=min(val,maxv); - _pHydroUnits[k]->SetStateVarValue(i,val); + _pHydroUnits[k]->SetStateVarValue(i,val); } } } diff --git a/src/ModelInitialize.cpp b/src/ModelInitialize.cpp index 6f27068..83bc8bc 100644 --- a/src/ModelInitialize.cpp +++ b/src/ModelInitialize.cpp @@ -175,11 +175,11 @@ void CModel::Initialize(const optStruct &Options) // Generate Gauge Weights from Interpolation (except if in BMI mode and no RVT file is specified) //-------------------------------------------------------------- - if ((!Options.in_bmi_mode) || (strcmp(Options.rvt_filename.c_str(), "") != 0)) + if ((!Options.in_bmi_mode) || (strcmp(Options.rvt_filename.c_str(), "") != 0)) { if (!Options.silent){cout <<" Generating Gauge Interpolation Weights..."< 0) + if (nLat > 0) { // Check if weights sum to 1.0 diff --git a/src/RavenInclude.h b/src/RavenInclude.h index 1194c29..784d087 100644 --- a/src/RavenInclude.h +++ b/src/RavenInclude.h @@ -596,7 +596,7 @@ enum HRU_type HRU_WATER, ///< Non-lake Waterbody HRU (streams) HRU_GLACIER, ///< Glacier HRU HRU_WETLAND, ///< Wetland HRU - HRU_MASKED_GLACIER, ///< masked glacier in coupled model + HRU_MASKED_GLACIER, ///< masked glacier in coupled model HRU_ROCK, ///< Open Rock or Pavement (impermeable) HRUs HRU_INVALID_TYPE ///< returned if type is invalid }; diff --git a/src/RavenProcessConnections.dat b/src/RavenProcessConnections.dat index 496149a..fa6d555 100644 --- a/src/RavenProcessConnections.dat +++ b/src/RavenProcessConnections.dat @@ -218,4 +218,4 @@ DFLOW_THRESHPOW DepressionOverflow DEPRESSION SURFACE_WATER DFLOW_LINEAR DepressionOverflow DEPRESSION SURFACE_WATER DFLOW_WEIR DepressionOverflow DEPRESSION SURFACE_WATER SEEP_LINEAR Seepage DEPRESSION SOIL -LAKEREL_LINEAR LakeRelease LAKE SURFACE_WATER \ No newline at end of file +LAKEREL_LINEAR LakeRelease LAKE SURFACE_WATER diff --git a/src/SnowRedistribute.cpp b/src/SnowRedistribute.cpp index dcf3b49..d5facd4 100644 --- a/src/SnowRedistribute.cpp +++ b/src/SnowRedistribute.cpp @@ -36,13 +36,13 @@ CmvLatRedistribute::CmvLatRedistribute(int sv_ind, ////////////////////////////////////////////////////////////////// /// \brief Implementation of the default destructor // -CmvLatRedistribute::~CmvLatRedistribute() +CmvLatRedistribute::~CmvLatRedistribute() { for(int n=0; n<_nLatConnect;n++) { delete _pLatConnect[n]; } delete[] _pLatConnect; } ////////////////////////////////////////////////////////////////// -/// \brief Copies connnection array - called during RVH file read +/// \brief Copies connnection array - called during RVH file read // void CmvLatRedistribute::AddConnectionArray(CLatConnect **pConnections, const int nConnections) { @@ -73,15 +73,15 @@ void CmvLatRedistribute::Initialize() _iToLat = new int[_nLatConnections]; // Initialize the arrays using the methods from CLatConnect - for (int q = 0; q < _nLatConnections; q++) + for (int q = 0; q < _nLatConnections; q++) { CLatConnect* connection = _pLatConnect[q]; _kFrom [q] = _pModel->GetHRUByID(_pLatConnect[q]->GetSourceHRUID() )->GetGlobalIndex(); _kTo [q] = _pModel->GetHRUByID(_pLatConnect[q]->GetRecipientHRUID())->GetGlobalIndex(); - _iFromLat[q] = _iRedistributeFrom; - _iToLat [q] = _iRedistributeTo; + _iFromLat[q] = _iRedistributeFrom; + _iToLat [q] = _iRedistributeTo; } } @@ -206,10 +206,10 @@ void CmvLatRedistribute::GetLateralExchange(const double *const *state_vars, // Debug info - uncomment when needed // Debug info with comprehensive output - //std::cout << "Connection " << q << ": fromHRU=" << fromHRU << " toHRU=" << toHRU + //std::cout << "Connection " << q << ": fromHRU=" << fromHRU << " toHRU=" << toHRU //<< " method=" << (_method == CONTINUOUS_REDIST ? "CONTINUOUS" : "THRESHOLD"); //std::cout << " snowMoved=" << snowMoved << " mm" // << " exchange_rate=" << exchange_rates[q] << " mm-kmē/d" << std::endl; } -} \ No newline at end of file +} diff --git a/src/Solvers.cpp b/src/Solvers.cpp index fb0dc60..baf1a0d 100644 --- a/src/Solvers.cpp +++ b/src/Solvers.cpp @@ -24,7 +24,7 @@ void MassEnergyBalance( CModel *pModel, int nConstituents; // int iSW, iAtm, iAET, iGW, iRO; //Surface water, atmospheric precip, used PET, runoff indices int iTotalSWE; //total SWE index - + int maxLatConns=0; int maxConns=0; int maxTotConns=0; @@ -53,7 +53,7 @@ void MassEnergyBalance( CModel *pModel, static double **rate_guess; //need to set first array to nProcesses static int *iFrom=NULL; //arrays used to pass values through GetRatesOfChange routines [size maxTotConns] - static int *iTo=NULL; + static int *iTo=NULL; static double *rates_of_change=NULL; static int *kFrom=NULL; @@ -119,7 +119,7 @@ void MassEnergyBalance( CModel *pModel, maxLatConns=max(nLatConn,maxLatConns); } maxTotConns=max(maxLatConns,maxConns); - + if(Options.sol_method==ITERATED_HEUN) { rate_guess = new double *[nProcesses]; //need to set first array to numProcesses @@ -132,7 +132,7 @@ void MassEnergyBalance( CModel *pModel, iTo =new int [maxTotConns]; kFrom =new int [maxLatConns]; kTo =new int [maxLatConns]; - lat_exchange_rates =new double[maxLatConns]; + lat_exchange_rates =new double[maxLatConns]; rates_of_change =new double[maxConns ]; }//end static memory if diff --git a/src/StandardOutput.cpp b/src/StandardOutput.cpp index bb756fb..34a4771 100644 --- a/src/StandardOutput.cpp +++ b/src/StandardOutput.cpp @@ -1767,7 +1767,7 @@ void CModel::RunDiagnostics(const optStruct &Options) if(DIAG2.fail()) { ExitGracefully(("CModel::WriteOutputFileHeaders: Unable to open output file "+tmpFilename+" for writing.").c_str(),FILE_OPEN_ERR); } - + DIAG2<<"time,date,hour,observed"+svname+",simulated"+svname<GetNumSampledValues();nn++) { diff --git a/src/SubBasin.cpp b/src/SubBasin.cpp index 7907a52..9c31191 100644 --- a/src/SubBasin.cpp +++ b/src/SubBasin.cpp @@ -350,7 +350,7 @@ int CSubBasin::GetNumHRUs () const{return _nHydroUnit const CHydroUnit*CSubBasin::GetHRU(const int ks) const { #ifdef _STRICTCHECK_ - ExitGracefullyIf((ks<0) && (ks>=_nHydroUnits),"CSubBasin:GetHRU::improper index",BAD_DATA); + ExitGracefullyIf((ks<0) || (ks>=_nHydroUnits),"CSubBasin:GetHRU::improper index",BAD_DATA); #endif return _pHydroUnits[ks]; } @@ -370,7 +370,7 @@ CReservoir *CSubBasin::GetReservoir () const double CSubBasin::GetAvgStateVar (const int i) const { #ifdef _STRICTCHECK_ - ExitGracefullyIf((i<0) && (i>=_pModel->GetNumStateVars()),"CSubBasin:GetAverageStateVar::improper index",BAD_DATA); + ExitGracefullyIf((i<0) || (i>=_pModel->GetNumStateVars()),"CSubBasin:GetAverageStateVar::improper index",BAD_DATA); #endif double sum=0.0; for (int k=0;k<_nHydroUnits;k++) @@ -391,7 +391,7 @@ double CSubBasin::GetAvgStateVar (const int i) const double CSubBasin::GetAvgConcentration(const int i) const { #ifdef _STRICTCHECK_ - ExitGracefullyIf((i<0) && (i>=_pModel->GetNumStateVars()),"CSubBasin:GetAvgConcentration::improper index",BAD_DATA); + ExitGracefullyIf((i<0) || (i>=_pModel->GetNumStateVars()),"CSubBasin:GetAvgConcentration::improper index",BAD_DATA); #endif double sum=0.0; for(int k=0;k<_nHydroUnits;k++) @@ -1893,7 +1893,7 @@ void CSubBasin::Initialize(const double &Qin_avg, //[m3/s] from upst //determine upstream subbasin group //------------------------------------------------------------------------ //int nUpstream; - //CModel::GetUpstreamSubbasins(_ID,nUpstream); + //CModel::GetUpstreamSubbasins(_ID,nUpstream); //QA/QC check of Muskingum parameters, if necessary //------------------------------------------------------------------------ diff --git a/src/TimeSeries.cpp b/src/TimeSeries.cpp index 591ef52..7e0b671 100644 --- a/src/TimeSeries.cpp +++ b/src/TimeSeries.cpp @@ -1034,7 +1034,7 @@ CTimeSeries *CTimeSeries::Parse(CParser *p, bool is_pulse, string name, long lon j++; //cout<<"READING IRREGULAR "<ImproperFormat(s); break; } bool eof=p->Tokenize(s,Len); @@ -1057,7 +1057,7 @@ CTimeSeries *CTimeSeries::Parse(CParser *p, bool is_pulse, string name, long lon int nVals=int(Options.duration)+1; aVal =new double[nVals]; - for(int n=0;n=days[i]) && (tt.model_time