diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c7aaaa9..f18161f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,7 +26,7 @@ repos: # - id: include-what-you-use - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.2 hooks: - id: check-github-workflows - repo: meta diff --git a/src/Assimilate.cpp b/src/Assimilate.cpp index 20821bf..5aaa412 100644 --- a/src/Assimilate.cpp +++ b/src/Assimilate.cpp @@ -59,7 +59,7 @@ void CModel::InitializeDataAssimilation(const optStruct &Options) } ///////////////////////////////////////////////////////////////// -/// \brief Overrides flows with observations at gauges and propagates adjustments upstream of gauges +/// \brief Overrides flows with observations at gauges and propagates adjustments upstream of gauges /// \param p [in] global subbasin index /// \param Options [in] current model options structure /// \param tt [in] current model time structure @@ -102,7 +102,7 @@ void CModel::AssimilationOverride(const int p,const optStruct& Options,const tim } } - // + // if(mass_added>0.0){_CumulInput +=mass_added/(_WatershedArea*M2_PER_KM2)*MM_PER_METER;} else {_CumulOutput-=mass_added/(_WatershedArea*M2_PER_KM2)*MM_PER_METER;} @@ -151,7 +151,7 @@ void CModel::PrepareAssimilation(const optStruct &Options,const time_struct &tt) break; //avoids duplicate observations } } - } + } pdown=GetDownstreamBasin(p); @@ -184,7 +184,7 @@ void CModel::PrepareAssimilation(const optStruct &Options,const time_struct &tt) _aDAscale [p]= _aDAscale [pdown]; _aDAlength [p]+=_pSubBasins [pdown]->GetReachLength(); _aDAtimesince [p]= _aDAtimesince[pdown]; - _aDAoverride [p]=false; + _aDAoverride [p]=false; } else{ //Nothing downstream or reservoir present in this basin, no assimilation _aDAscale [p]=1.0; @@ -194,7 +194,7 @@ void CModel::PrepareAssimilation(const optStruct &Options,const time_struct &tt) } } }// end downstream to upstream - + //Calculate _aDADrainSum, sum of assimilated drainage areas upstream of a subbasin outlet // and _aDADownSum, drainage of nearest assimilated flow observation // dynamic because data can disappear mid simulation @@ -221,7 +221,7 @@ void CModel::PrepareAssimilation(const optStruct &Options,const time_struct &tt) _aDADrainSum[pdown]+=_aDADrainSum[p]; } } - for(int pp=_nSubBasins-1;pp>=0; pp--)// downstream to upstream + for(int pp=_nSubBasins-1;pp>=0; pp--)// downstream to upstream { p=GetOrderedSubBasinIndex(pp); pdown=GetDownstreamBasin(p); @@ -266,7 +266,7 @@ void CModel::AssimilationBackPropagate(const optStruct &Options,const time_struc if (_pSubBasins[p]->GetDownstreamID()!=DOESNT_EXIST){ pdown = GetSubBasinByID(_pSubBasins[p]->GetDownstreamID())->GetGlobalIndex(); } - + // no observations in this basin, get scaling from downstream //---------------------------------------------------------------- pdown=GetDownstreamBasin(p); @@ -302,7 +302,7 @@ void CModel::AssimilationBackPropagate(const optStruct &Options,const time_struc } } - // Actually update flows + // Actually update flows //---------------------------------------------------------------- for(p=0; p<_nSubBasins; p++) { diff --git a/src/CommonFunctions.cpp b/src/CommonFunctions.cpp index d8dbae3..1107d00 100644 --- a/src/CommonFunctions.cpp +++ b/src/CommonFunctions.cpp @@ -935,7 +935,7 @@ double GetSaturatedVaporPressure(const double &T)//[C] const double A3=237.3; const double A4=21.87456; const double A5=265.5; - + //0.61115*exp(22.452*T/(T+ZERO_CELSIUS)); //MESH //0.611*exp(17.27*Ta/(Ta+237.3)); //Common simplification of Dingman for T>0 @@ -1749,11 +1749,11 @@ double ADRCumDist(const double &t, const double &L, const double &v, const doubl /// \param &L reach length [m] /// \param &v celerity [m/d] /// \param &D diffusivity [m2/d] -/// \return Returns integral +/// \return Returns integral // //int_0^time L/2/t^(1/2)/sqrt(pi*D)*exp(-(v*t-L)^2/(4*D*t)) dt // extreme case (D->0): =1 for v*tpTerms[j][k]->mult) * term; } - + } } diff --git a/src/DemandOptimization.cpp b/src/DemandOptimization.cpp index 365f863..a465c4e 100644 --- a/src/DemandOptimization.cpp +++ b/src/DemandOptimization.cpp @@ -572,7 +572,7 @@ void CDemandOptimizer::Initialize(CModel* pModel, const optStruct& Options) } } } - // add reservoir delta stage DVs + // add reservoir delta stage DVs res_count=0; for (int pp=0;ppGetNumSubBasins();pp++) { @@ -1325,7 +1325,7 @@ void CDemandOptimizer::IncrementAndSetRowName(lp_lib::lprec *pLinProg,int &rowco // int CDemandOptimizer::GetDVColumnInd(const dv_type typ, const int counter) const { - int N=5; + int N=5; if (typ==DV_QOUT ){return counter+1;} else if (typ==DV_QOUTRES ){return _nEnabledSubBasins+counter+1;} @@ -1474,7 +1474,7 @@ void CDemandOptimizer::SolveManagementProblem(CModel *pModel, const optStruct &O r++; } } - + // Set lower bounds of stages to min stage -2m // ---------------------------------------------------------------- int res_count=0; @@ -1710,7 +1710,7 @@ void CDemandOptimizer::SolveManagementProblem(CModel *pModel, const optStruct &O // Mass balance equation at reach outlet: // Q_p = (Qin +Qin2 )*U0 + sum(Ui*Qn-i) + Runoff - Div_out(Q) + Div_in - Delivered + Qadded + U_0*Qadded2 +Qreturn // Q_p-U_0*Qin-U_0*Qin2... +Delivered -Qreturn= sum(Ui*Qn-i) + Runoff - Div_out(Q) + Div_in + Qadded + U_0*Qadded2 - // + // // or, if assimilating flows, use direct insertion: // Q_p = Q*_p //------------------------------------------------------------------------ @@ -1721,7 +1721,7 @@ void CDemandOptimizer::SolveManagementProblem(CModel *pModel, const optStruct &O i=0; Qobs=_pModel->GetObservedFlow(p,nn); - assimilating = ((Options.assimilate_flow) && (pSB->UseInFlowAssimilation()) && (Qobs!=RAV_BLANK_DATA) && (pSB->GetReservoir()==NULL)); + assimilating = ((Options.assimilate_flow) && (pSB->UseInFlowAssimilation()) && (Qobs!=RAV_BLANK_DATA) && (pSB->GetReservoir()==NULL)); // outflow term ============================= col_ind[i]=GetDVColumnInd(DV_QOUT,_aSBIndices[p]); @@ -1811,7 +1811,7 @@ void CDemandOptimizer::SolveManagementProblem(CModel *pModel, const optStruct &O double Adt,ET,precip,seepage(0); double h_old,dQdh,Qout_last,Qin_last,h_obs,h_dry; bool assim_stage(false); - + for (int pp = 0; ppGetNumSubBasins(); pp++) { p =pModel->GetOrderedSubBasinIndex(pp); @@ -1822,7 +1822,7 @@ void CDemandOptimizer::SolveManagementProblem(CModel *pModel, const optStruct &O { Qobs=_pModel->GetObservedFlow(p,nn); assimilating = ((Options.assimilate_flow) && (pSB->UseInFlowAssimilation()) && (Qobs!=RAV_BLANK_DATA)); - + h_obs = pRes->GetObsStage(nn); assim_stage = ((Options.assimilate_stage) && (pRes->UseInStageAssimilation()) && (h_obs!=RAV_BLANK_DATA)); @@ -1867,11 +1867,11 @@ void CDemandOptimizer::SolveManagementProblem(CModel *pModel, const optStruct &O row_val[i]=+0.5; i++; - col_ind[i]=GetDVColumnInd(DV_DSTAGE ,_aResIndices[p]); + col_ind[i]=GetDVColumnInd(DV_DSTAGE ,_aResIndices[p]); row_val[i]=Adt; i++; - - col_ind[i]=GetDVColumnInd(DV_DSTAGE2 ,_aResIndices[p]); + + col_ind[i]=GetDVColumnInd(DV_DSTAGE2 ,_aResIndices[p]); row_val[i]=-Adt; i++; @@ -1882,7 +1882,7 @@ void CDemandOptimizer::SolveManagementProblem(CModel *pModel, const optStruct &O row_val[i]=+1.0; i++; } - + RHS=(precip-ET)-seepage-0.5*Qout_last+0.5*Qin_last; retval = lp_lib::add_constraintex(pLinProg,i,row_val,col_ind,ROWTYPE_EQ,RHS); @@ -1894,8 +1894,8 @@ void CDemandOptimizer::SolveManagementProblem(CModel *pModel, const optStruct &O else //(assim_stage==true) { // lake assimilation equation - solves for dh - // dh+-dh- = h_obs-h_old - + // dh+-dh- = h_obs-h_old + col_ind[0]=GetDVColumnInd(DV_DSTAGE ,_aResIndices[p]); row_val[0]=1.0; col_ind[1]=GetDVColumnInd(DV_DSTAGE2 ,_aResIndices[p]); row_val[1]=-1.0; RHS=h_obs-h_old; @@ -1905,7 +1905,7 @@ void CDemandOptimizer::SolveManagementProblem(CModel *pModel, const optStruct &O IncrementAndSetRowName(pLinProg,rowcount,"reser_MB_"+to_string(pSB->GetID())); } - // Equation: Definition of delta h + // Equation: Definition of delta h //------------------------------------------------------- col_ind[0]=GetDVColumnInd(DV_STAGE,_aResIndices[p]); row_val[0]= 1.0; col_ind[1]=GetDVColumnInd(DV_DSTAGE,_aResIndices[p]); row_val[1]=-1.0; @@ -1948,10 +1948,10 @@ void CDemandOptimizer::SolveManagementProblem(CModel *pModel, const optStruct &O lprow[p]=lp_lib::get_Nrows(pLinProg); } - else if (assimilating) + else if (assimilating) { //------------------------------------------------------------------------ - // Assimilating + // Assimilating // Q^n+1 == Qobs //------------------------------------------------------------------------ @@ -2107,7 +2107,7 @@ void CDemandOptimizer::SolveManagementProblem(CModel *pModel, const optStruct &O //lp_lib::set_epslevel(pLinProg, EPS_MEDIUM); retval = lp_lib::solve(pLinProg); - + if (retval!=OPTIMAL) { if (_do_debug_level>0){ cout<<"LP instability found."<h " << SBID << ": "; for (int i = 0; i <= iter; i++) { cout << setprecision(10)<B " << SBID << ": "; for (int i = 0; i <= iter; i++) { cout << aBinHist[p][i] << " "; }cout << endl; cout << " >Sill ht "<< SBID<<": "<< sill_ht<< " diff: "<< h_iter[p]-sill_ht< VERY CLOSE TO SILL: PROBLEM LAKE IS "<GetOrderedSubBasinIndex(pp); pSB =pModel->GetSubBasin(p); - + long long SBID=pSB->GetID(); if ((pSB->IsEnabled()) && (pSB->GetReservoir() != NULL)) { @@ -2427,7 +2427,7 @@ void CDemandOptimizer::SolveManagementProblem(CModel *pModel, const optStruct &O else if (typ == DV_QOUTRES) { if (_aDisableSDCurve[p]){ // no need to report if this is handled properly by Raven default solver - pModel->GetSubBasin(p)->GetReservoir()->SetOptimizedOutflow(value); + pModel->GetSubBasin(p)->GetReservoir()->SetOptimizedOutflow(value); } } else if (typ == DV_DELIVERY) diff --git a/src/EnergyTransport.cpp b/src/EnergyTransport.cpp index 9994e8f..d273eaf 100644 --- a/src/EnergyTransport.cpp +++ b/src/EnergyTransport.cpp @@ -546,7 +546,7 @@ void CEnthalpyModel::Initialize(const optStruct& Options) for(int p=0;p<_pModel->GetNumSubBasins();p++) { pBasin=_pModel->GetSubBasin(p); - + for(int i=0; iGetNumSegments(); i++) { _aMout[p][i]=pBasin->GetOutflowArray()[_pModel->GetSubBasin(p)->GetNumSegments()-1] * SEC_PER_DAY * hv; //not really - requires outflow rate from all segments in general case. Don't have access to this. assumes nSegs=1 diff --git a/src/ForcingGrid.cpp b/src/ForcingGrid.cpp index 9dd3b57..2c57750 100644 --- a/src/ForcingGrid.cpp +++ b/src/ForcingGrid.cpp @@ -1003,7 +1003,7 @@ bool CForcingGrid::ReadData(const optStruct &Options, } } } - // Deaccumulate + // Deaccumulate // ------------------------------- Deaccumulate(); diff --git a/src/ForcingGrid.h b/src/ForcingGrid.h index 202390a..6f6b9c5 100644 --- a/src/ForcingGrid.h +++ b/src/ForcingGrid.h @@ -189,7 +189,7 @@ class CForcingGrid //: public CForcingGridABC void SetAsPeriodEnding (); ///< set _period_ending void SetIs3D( const bool is3D); ///< set _is3D of class void SetIdxNonZeroGridCells( const int nHydroUnits, - const int nGridCells, + const int nGridCells, const bool *disabledHRUs, const optStruct &Options); ///< set _IdxNonZeroGridCells of class diff --git a/src/IsotopeTransport.cpp b/src/IsotopeTransport.cpp index 0821b6d..4f45046 100644 --- a/src/IsotopeTransport.cpp +++ b/src/IsotopeTransport.cpp @@ -55,7 +55,7 @@ void CIsotopeModel::UpdateInitialConditions(const optStruct& Options) pBasin=_pModel->GetSubBasin(p); int nSegments=pBasin->GetNumSegments(); - + for(int i=0; iGetNumSegments(); i++) { _aMout[p][i]=pBasin->GetOutflowArray()[nSegments-1] * SEC_PER_DAY * Cinit; // assumes nSegs=1 @@ -63,7 +63,7 @@ void CIsotopeModel::UpdateInitialConditions(const optStruct& Options) _aMout_last[p]=_aMout[p][0]; const double *aQin=_pModel->GetSubBasin(p)->GetInflowHistory(); - for(int i=0; i<_nMinHist[p]; i++) { + for(int i=0; i<_nMinHist[p]; i++) { _aMinHist [p][i]=aQin[i]*SEC_PER_DAY*Cinit; } const double *aQlat=_pModel->GetSubBasin(p)->GetLatHistory(); @@ -73,7 +73,7 @@ void CIsotopeModel::UpdateInitialConditions(const optStruct& Options) _aMlat_last[p]=_aMlatHist[p][0]; _aMlocal [p]=_aMlat_last[p]; _aMlocLast [p]=_aMlat_last[p]; - + //_channel_storage[p]=0.0; //_rivulet_storage[p]=0.0; @@ -93,7 +93,7 @@ void CIsotopeModel::UpdateInitialConditions(const optStruct& Options) ////////////////////////////////////////////////////////////////// /// \brief set initial surface water concentration // -void CIsotopeModel::SetSurfaceWaterConc(const double& delta) +void CIsotopeModel::SetSurfaceWaterConc(const double& delta) { _initSWconc=delta; } @@ -137,7 +137,7 @@ double CIsotopeModel::ConvertConcentration(const double &delta) const /// \param iToWater [in] index of "to" water storage state variable /// \param mass [in] source mass prior to advection [mg] /// \param vol [in] source volume prior to advection [mm] or [mm-m2] -/// \param Q [in] flow between source and recipient [mm/d] or [mm-m2] +/// \param Q [in] flow between source and recipient [mm/d] or [mm-m2] /// double CIsotopeModel::GetAdvectionCorrection(const CHydroUnit* pHRU,const int iFromWater,const int iToWater,const double& mass, const double &vol, const double &Q) const { @@ -186,7 +186,7 @@ double CIsotopeModel::GetAdvectionCorrection(const CHydroUnit* pHRU,const int iF CK0=25.0/TO_PER_MILLE; } ep_star =alpha_star-1.0; //[-] - + if (fromType==DEPRESSION ) {eta=0.6;} else if (fromType==SOIL ) {eta=1.0;} else if (fromType==SURFACE_WATER) {eta=0.5;} @@ -200,7 +200,7 @@ double CIsotopeModel::GetAdvectionCorrection(const CHydroUnit* pHRU,const int iF dStar=(h*dA/TO_PER_MILLE+ekin+ep_star/alpha_star)/(h - ekin - ep_star/alpha_star)*TO_PER_MILLE; //[o/oo] dE =((dL/TO_PER_MILLE-ep_star)/alpha_star - h*dA/TO_PER_MILLE - ekin) / (1.0-h+ekin)*TO_PER_MILLE; //[o/oo] - + if (dE>dL){dE=dL;} double C_E =CompositionToConc(dE); @@ -225,7 +225,7 @@ double CIsotopeModel::GetAdvectionCorrection(const CHydroUnit* pHRU,const int iF } else if ( ((fromType==SNOW_LIQ) || (toType==SNOW)) ) //refreeze - dilutes snow { - // \todo[funct] + // \todo[funct] } return 1.0; diff --git a/src/LatFlush.cpp b/src/LatFlush.cpp index 281589d..7518fa3 100644 --- a/src/LatFlush.cpp +++ b/src/LatFlush.cpp @@ -100,7 +100,7 @@ void CmvLatFlush::Initialize() double Asum,area; for(int p=0;p<_pModel->GetNumSubBasins();p++) { - + for(int ks=0; ks<_pModel->GetSubBasin(p)->GetNumHRUs(); ks++) //sources { k1=_pModel->GetSubBasin(p)->GetHRU(ks)->GetGlobalIndex(); diff --git a/src/Model.cpp b/src/Model.cpp index 7727ec9..cf09162 100644 --- a/src/Model.cpp +++ b/src/Model.cpp @@ -324,7 +324,7 @@ int CModel::GetNumObservedTS() const { return _nObservedTS; } /// \param i [in] index of observation time series /// \return pointer to observation time series i // -const CTimeSeriesABC *CModel::GetObservedTS(const int i) const +const CTimeSeriesABC *CModel::GetObservedTS(const int i) const { return _pObservedTS[i]; } @@ -335,9 +335,9 @@ const CTimeSeriesABC *CModel::GetObservedTS(const int i) const /// \return observed flow in basin p at time step n, or RAV_BLANK_DATA if no observation available /// \todo[optimize] - this call could be slow with lots of observations // -double CModel::GetObservedFlow(const int p, const int n) const +double CModel::GetObservedFlow(const int p, const int n) const { - long long SBID=_pSubBasins[p]->GetID(); + long long SBID=_pSubBasins[p]->GetID(); for(int i=0; i<_nObservedTS; i++) { if(IsContinuousFlowObs(_pObservedTS[i], SBID)) { return _pObservedTS[i]->GetSampledValue(n); @@ -2813,7 +2813,7 @@ void CModel::UpdateDiagnostics(const optStruct &Options, } } - if (invalid_data) + if (invalid_data) { value=RAV_BLANK_DATA; } @@ -2884,7 +2884,7 @@ void CModel::UpdateDiagnostics(const optStruct &Options, } value=0; } - + _pModeledTS[i]->SetValue(n,value); _pModeledTS[i]->SetSampledValue(n,value); //Handles blank value issue in final time step diff --git a/src/ModelForcingGrids.cpp b/src/ModelForcingGrids.cpp index 70dff36..d020600 100644 --- a/src/ModelForcingGrids.cpp +++ b/src/ModelForcingGrids.cpp @@ -451,5 +451,3 @@ void CModel::GenerateZeroSnow(const optStruct &Options) AddForcingGrid(pSnow,F_SNOWFALL); } - - diff --git a/src/NetCDFReading.cpp b/src/NetCDFReading.cpp index bd848a9..7f9f4a0 100644 --- a/src/NetCDFReading.cpp +++ b/src/NetCDFReading.cpp @@ -95,7 +95,7 @@ Copyright (c) 2008-2021 the Raven Development Team else { ExitGracefully("GetTimeInfoFromNetCDF: this unit in time is not implemented yet (only days, hours, minutes, seconds)",BAD_DATA); } - string warn="GetTimeInfoFromNetCDF: Time interval in netCDF file "+filename+" is negative or zero!"; + string warn="GetTimeInfoFromNetCDF: Time interval in netCDF file "+filename+" is negative or zero!"; ExitGracefullyIf(tstep<=0,warn.c_str(), BAD_DATA); //Get julian date/year of time[0] diff --git a/src/ParseInitialConditionFile.cpp b/src/ParseInitialConditionFile.cpp index f12a5a7..94818c4 100644 --- a/src/ParseInitialConditionFile.cpp +++ b/src/ParseInitialConditionFile.cpp @@ -933,7 +933,7 @@ bool ParseInitialConditionsFile(CModel *&pModel, const optStruct &Options) } //end while !end_of_file IC.close(); - // update initial conditions for transport models + // update initial conditions for transport models //====================================================================== for (int c = 0; c < pModel->GetTransportModel()->GetNumConstituents(); c++) { pModel->GetTransportModel()->GetConstituentModel(c)->UpdateInitialConditions(Options); diff --git a/src/ParseManagementFile.cpp b/src/ParseManagementFile.cpp index 004cfb6..febd37c 100644 --- a/src/ParseManagementFile.cpp +++ b/src/ParseManagementFile.cpp @@ -844,7 +844,7 @@ bool ParseManagementFile(CModel *&pModel,const optStruct &Options) ExitGracefullyIf(pSB==NULL,"ParseManagementFile: subbasin ID in :OverrideStageDischargeCurve is invalid",BAD_DATA_WARN); break; } - + if (pSB->GetReservoir()==NULL){ string advice="ParseManagementFile:The reservoir in subbasin "+to_string(pSB->GetID()) + " doesnt exist and stage discharge curve cannot be overridden."; ExitGracefully(advice.c_str(), BAD_DATA_WARN); diff --git a/src/Reservoir.cpp b/src/Reservoir.cpp index 7f90229..c9ed9ba 100644 --- a/src/Reservoir.cpp +++ b/src/Reservoir.cpp @@ -446,7 +446,7 @@ double CReservoir::GetDryStage () const { return _min_stage;} // double CReservoir::GetSillElevation(const int nn) const { - + double weir_adj=0.0; if (_pWeirHeightTS!=NULL){ weir_adj=_pWeirHeightTS->GetSampledValue(nn); @@ -460,7 +460,7 @@ double CReservoir::GetSillElevation(const int nn) const ////////////////////////////////////////////////////////////////// /// \returns observed stage [m] // -double CReservoir::GetObsStage(const int nn) const +double CReservoir::GetObsStage(const int nn) const { if (_pObsStage!=NULL){ return _pObsStage->GetSampledValue(nn); @@ -473,7 +473,7 @@ double CReservoir::GetObsStage(const int nn) const ////////////////////////////////////////////////////////////////// /// \returns true if this reservoir/lake is used in assimilation // -bool CReservoir::UseInStageAssimilation() const +bool CReservoir::UseInStageAssimilation() const { return _assimilate_stage; } @@ -1188,7 +1188,7 @@ double CReservoir::GetDZTROutflow(const double &V, const double &Qin, const time double tstep=Options.timestep*SEC_PER_DAY; if (VIsGauged()) && (_pSubBasins[p]->IsEnabled())){ - ASSIM<<","<<_pSubBasins[p]->GetID()<<" "; + ASSIM<<","<<_pSubBasins[p]->GetID()<<" "; } } ASSIM<IsGauged()) && (_pSubBasins[p]->IsEnabled())){ - ASSIM<<", "; + ASSIM<<", "; } } ASSIM<GetID(); BAS<<","<<_pSubBasins[pp]->GetReferenceFlow(); @@ -1973,7 +1973,7 @@ void CModel::WriteNetcdfStandardHeaders(const optStruct &Options) int dimids1[ndims1]; // array which will contain all dimension ids for a variable int ncid, varid_pre; // When we create netCDF variables and dimensions, we get back an ID for each one. int time_dimid, varid_time; // dimension ID (holds number of time steps) and variable ID (holds time values) for time - int nSim, nbasins_dimid, varid_bsim,varid_bsim2; + int nSim, nbasins_dimid, varid_bsim,varid_bsim2; // // # of sub-basins with simulated outflow, dimension ID, and // // variable to write basin IDs for simulated outflows int varid_qsim; // variable ID for simulated outflows @@ -2055,7 +2055,7 @@ void CModel::WriteNetcdfStandardHeaders(const optStruct &Options) retval = nc_put_att_text(_HYDRO_ncid, varid_bsim, "long_name", tmp.length(), tmp.c_str()); HandleNetCDFErrors(retval); retval = nc_put_att_text(_HYDRO_ncid, varid_bsim, "cf_role" , tmp2.length(),tmp2.c_str()); HandleNetCDFErrors(retval); retval = nc_put_att_text(_HYDRO_ncid, varid_bsim, "units" , tmp3.length(),tmp3.c_str()); HandleNetCDFErrors(retval); - + // (d) create variable and set attributes for"basin_fullname" dimids1[0] = nbasins_dimid; retval = nc_def_var(_HYDRO_ncid, "basin_fullname", NC_STRING, ndims1, dimids1, &varid_bsim2); HandleNetCDFErrors(retval); @@ -3097,8 +3097,8 @@ void WriteNetCDFBasinList(const int ncid,const int varid,const int varid_name,co if(pModel->GetSubBasin(p)->IsGauged() && (pModel->GetSubBasin(p)->IsEnabled())) { if (!( (is_res) && (pModel->GetSubBasin(p)->GetReservoir()==NULL))){ string bID,bname; - bID = to_string(pModel->GetSubBasin(p)->GetID()); - bname = pModel->GetSubBasin(p)->GetName(); + bID = to_string(pModel->GetSubBasin(p)->GetID()); + bname = pModel->GetSubBasin(p)->GetName(); start[0] = ibasin; count[0] = 1; strcpy(current_basin_name[0],bID.c_str()); diff --git a/src/SubBasin.cpp b/src/SubBasin.cpp index e27b8c2..fecac64 100644 --- a/src/SubBasin.cpp +++ b/src/SubBasin.cpp @@ -1205,7 +1205,7 @@ double CSubBasin::GetBasinProperties(const string label) const else if (!label_n.compare("RIVERBED_CONDUCTIVITY")){ return _bed_conductivity; } else if (!label_n.compare("RIVERBED_THICKNESS" )){ return _bed_thickness; } else if (!label_n.compare("LAKEBED_CONDUCTIVITY" )){ - if (_pReservoir != NULL) { return _pReservoir->GetLakebedConductivity(); } + if (_pReservoir != NULL) { return _pReservoir->GetLakebedConductivity(); } else { return 0.0;} } else if (!label_n.compare("LAKEBED_THICKNESS" )){ @@ -1457,7 +1457,7 @@ double CSubBasin::AdjustAllFlows(const double &adjust, const bool overriding, co if(!overriding) { for(int n=0;n<_nQinHist; n++) { - _aQinHist[n]+=adjust*(_drainage_area-_basin_area)/_drainage_area; + _aQinHist[n]+=adjust*(_drainage_area-_basin_area)/_drainage_area; upperswap(_aQinHist[n],0.0); va+=adjust*tstep*SEC_PER_DAY; } @@ -1614,15 +1614,15 @@ double CSubBasin::CalculateTOC(const toc_method method) double C=0.3; //TMP DEBUG - cant have a single rational coeff for entire basin return 3.26*(1.1-C)*sqrt(_basin_length*M_PER_KM)*pow(slope_pct,-0.33)/MIN_PER_DAY; } - else if (method == TOC_BRANSBY_WILLIAMS) //MTO Drainage Manual 1997 + else if (method == TOC_BRANSBY_WILLIAMS) //MTO Drainage Manual 1997 { return 0.057*(_basin_length*M_PER_KM)*pow(slope_pct,-0.2)*pow(A*HECTARE_PER_KM2,-0.1); } - else if (method == TOC_WILLIAMS_1922) + else if (method == TOC_WILLIAMS_1922) { return 0.2426*_reach_length*pow(A,-0.1)*pow(slope_pct/100,-0.2)/HR_PER_DAY; } - else if (method == TOC_TEMEZ) + else if (method == TOC_TEMEZ) { return 0.3*pow(_reach_length,0.76)*pow(slope_pct/100,-0.19)/HR_PER_DAY; } @@ -1683,7 +1683,7 @@ void CSubBasin::Initialize(const double &Qin_avg, //[m3/s] from upst if(_pChannel!=NULL) { _pChannel->CheckReferenceFlow(_Q_ref,_slope,_mannings_n,_ID); } - + //Calculate mean slope from HRUs //------------------------------------------------------------------------ double area; @@ -1691,7 +1691,7 @@ void CSubBasin::Initialize(const double &Qin_avg, //[m3/s] from upst area=_pHydroUnits[k]->GetArea(); _mean_slope = (_pHydroUnits[k]->GetSlope()) * area / _basin_area; //[radians] } - + //Estimate basin length from area if not provided //------------------------------------------------------------------------ if (_basin_length == AUTO_COMPUTE) { diff --git a/src/SubBasin.h b/src/SubBasin.h index 169201a..724ba70 100644 --- a/src/SubBasin.h +++ b/src/SubBasin.h @@ -60,8 +60,8 @@ class CSubBasin bool _assimilate; ///< true if observed data in this basin should be assimilated. const CSubBasin *_pDownSB; ///< pointer to downstream subbasin instance - double _mean_slope; ///< mean slope of basin [rad] - double _basin_length; ///< watershed length (travel distance to reach) [km] + double _mean_slope; ///< mean slope of basin [rad] + double _basin_length; ///< watershed length (travel distance to reach) [km] //catchment routing properties double _t_conc; ///< basin time of concentration [d] diff --git a/src/TimeSeries.cpp b/src/TimeSeries.cpp index 0f24879..85f3aa4 100644 --- a/src/TimeSeries.cpp +++ b/src/TimeSeries.cpp @@ -821,7 +821,7 @@ CTimeSeries *CTimeSeries::Parse(CParser *p, bool is_pulse, string name, long lon time_struct tt; double aMonVal[12]; for(int i=0;i<12;i++){ aMonVal[i]=s_to_d(s[i+1]); } - + monthly_interp interp_method=Options.month_interp; if (!strcmp(s[0],":AnnualCycleStep")){interp_method=MONTHINT_UNIFORM;} diff --git a/src/Transport.cpp b/src/Transport.cpp index acdc28c..2fe2670 100644 --- a/src/Transport.cpp +++ b/src/Transport.cpp @@ -454,9 +454,9 @@ double CTransportModel::GetConcentration(const int k,const int sv_index) const /// \brief returns concentration (or temperature, or isotopic composition) in HRU k in storage variable of type typ and layer=layer /// \param k - global HRU index of interest /// \param c - constituent index -/// \param typ - state variable +/// \param typ - state variable // -double CTransportModel::GetConcentration(const int k, const int c, const sv_type typ, const int layer) const +double CTransportModel::GetConcentration(const int k, const int c, const sv_type typ, const int layer) const { int i_stor=pModel->GetStateVarIndex(typ,layer); int m =GetLayerIndex(c,i_stor); @@ -468,11 +468,11 @@ double CTransportModel::GetConcentration(const int k, const int c, const sv_type /// \brief returns correction factor for adjusting advected mass transport /// \param c [in] - constituent index /// \param pHRU [in] - HRU -/// \param iFromWater [in] - state variable index of source +/// \param iFromWater [in] - state variable index of source /// \param iToWater [in] - state variable index of recipient /// \param mass [in] - source mass prior to advection [mg] /// \param vol [in] - source volume prior to advection [mm] or [mm-m2] -/// \param Q [in] - flow between source and recipient [mm/d] or [mm-m2] +/// \param Q [in] - flow between source and recipient [mm/d] or [mm-m2] // double CTransportModel::GetAdvectionCorrection(const int c,const CHydroUnit* pHRU,const int iFromWater,const int iToWater,const double& mass, const double &vol, const double &Q) const { diff --git a/src/UnitTesting.cpp b/src/UnitTesting.cpp index 2ec89fe..51bf8e8 100644 --- a/src/UnitTesting.cpp +++ b/src/UnitTesting.cpp @@ -614,4 +614,4 @@ void IncGammaLimit() { cout<0.5){return 1.0-(0.4/1.5)*(Ta-0.5); } else {return 1.0;} } - else if (method == RAINSNOW_CLASS) + else if (method == RAINSNOW_CLASS) { //from ECCC's CLASSI code IPCP==3 double Ta=F->temp_ave;