diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..c9a4399 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,19 @@ +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: github-actions + directory: /.github/workflows + schedule: + interval: "semiannually" + groups: + actions: + patterns: + - "*" + update-types: + - patch + - minor + - major + cooldown: + default-days: 7 diff --git a/.github/workflows/auto-approve-dependabot.yml b/.github/workflows/auto-approve-dependabot.yml new file mode 100644 index 0000000..ebdb017 --- /dev/null +++ b/.github/workflows/auto-approve-dependabot.yml @@ -0,0 +1,72 @@ +name: Dependabot CI Updates + +on: + pull_request: + branches: + - main + types: + - opened + - synchronize + +permissions: + contents: read + +jobs: + dependabot-auto-approve: + name: Auto-approve and auto-merge safe Dependabot updates + runs-on: ubuntu-latest + if: > + github.event.pull_request.user.login == 'dependabot[bot]' && + contains(github.event.pull_request.labels.*.name, 'dependencies') + permissions: + contents: write + pull-requests: write + steps: + - name: Harden Runner + uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 + with: + disable-sudo: true + egress-policy: audit + + - name: Fetch Dependabot metadata + id: dependabot-metadata + uses: dependabot/fetch-metadata@21025c705c08248db411dc16f3619e6b5f9ea21a # v2.5.0 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Stop workflow if not minor update or patch update + id: skip-condition + if: > + steps.dependabot-metadata.outputs.update-type != 'version-update:semver-minor' && + steps.dependabot-metadata.outputs.update-type != 'version-update:semver-patch' + run: | + echo "Not a minor or patch update; skipping auto-approval." + echo "skip=true" >> $GITHUB_OUTPUT + + - name: Checkout Repository + if: steps.skip-condition.outputs.skip != 'true' + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + persist-credentials: false + + - name: Approve Changes + if: steps.skip-condition.outputs.skip != 'true' + run: | + decision="$(gh pr status --json reviewDecision -q .currentBranch.reviewDecision)" + if [ "$decision" != "APPROVED" ]; then + gh pr review --approve "$PR_URL" + else + echo "PR already approved: skipping approval." + fi + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_URL: ${{ github.event.pull_request.html_url }} + + - name: Enable auto-merge on Pull Request + if: steps.skip-condition.outputs.skip != 'true' + run: | + gh pr merge --auto --merge "$PR_URL" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_URL: ${{ github.event.pull_request.html_url }} diff --git a/src/FirnEvolution.cpp b/src/FirnEvolution.cpp index b9238f2..545db42 100644 --- a/src/FirnEvolution.cpp +++ b/src/FirnEvolution.cpp @@ -13,7 +13,7 @@ /// \param melt_type [in] Model of firn evolution selected // CmvFirnEvolution::CmvFirnEvolution(firn_evolution_type fe_type, - CModel *pModel): + CModel *pModel): CHydroProcessABC(FIRN_EVOLUTION, pModel) { type =fe_type; @@ -106,7 +106,7 @@ void CmvFirnEvolution::GetRatesOfChange( const double *state_var, double snow_to_firn=0.0; //[mm/d] double firn_to_glacier=0.0; //[mm/d] double firn_grav_change=0.0;//[1/d] - + double firnPct=1.0; //percentage of snow remaining in summer converted to firn \todo[funct] - make this a parameter const double PACKED_GRAVITY=0.5; //500 kg/m3 - density of snow converted to firn const double THRESH_GRAVITY=0.83; //830 kg/m3 - density at which firn converts to ice (pore close off density) @@ -136,7 +136,7 @@ double firn_old=firn; } firn+=snow_to_firn*Options.timestep; firn_grav_change=(grav_new-grav)/Options.timestep; //assume deep snow is at 500 kg/m3 - grav=grav_new; + grav=grav_new; } double bottom_grav=(grav+0.5*DENS_GRADIENT*firn); @@ -152,7 +152,7 @@ double firn_old=firn; } //compact firn - firn_grav_change+=firn_compaction_rate; //linear compaction rate [1/d] + firn_grav_change+=firn_compaction_rate; //linear compaction rate [1/d] //cout<<" "<GetHRUID()<<" "<FIRN diff --git a/src/GlacierProcesses.h b/src/GlacierProcesses.h index 986bfb4..7d1781c 100644 --- a/src/GlacierProcesses.h +++ b/src/GlacierProcesses.h @@ -143,7 +143,7 @@ class CmvGlacierInfil: public CHydroProcessABC /// \brief Methods of modeling firn evolution // enum firn_evolution_type{ - FIRNEVOL_SIMPLE + FIRNEVOL_SIMPLE }; //////////////////////////////////////////////////////////////////// /// \brief Data abstraction for transition from snow to firn to glacier diff --git a/src/HydroUnits.cpp b/src/HydroUnits.cpp index 2344282..c027f27 100644 --- a/src/HydroUnits.cpp +++ b/src/HydroUnits.cpp @@ -390,7 +390,7 @@ void CHydroUnit::Initialize (const int UTM_zone) /// \param len [in] - flow length, in meters // void CHydroUnit::SetFlowLength (const double &len) -{ +{ if (len<0){ string warn="Negative or zero flow length set for HRU "+to_string(_ID); ExitGracefully(warn.c_str(),BAD_DATA_WARN); return; diff --git a/src/HydroUnits.h b/src/HydroUnits.h index 81b0663..bc1b469 100644 --- a/src/HydroUnits.h +++ b/src/HydroUnits.h @@ -31,7 +31,7 @@ class CHydroUnit location _Centroid; ///< centroid of HRU HRU_type _HRUType; ///< Standard, Lake, Rock, Glacier, etc... bool _Disabled; ///< true if processes are not simulated for this HRU - bool _res_linked; ///> true if HRU is linked to Reservoir + bool _res_linked; ///> true if HRU is linked to Reservoir //Model State variables: double *_aStateVar; ///< Array of *current value* of state variable i with size CModel::nStateVars [mm] for water storage, permafrost depth, snow depth, [MJ/m^2] for energy storage diff --git a/src/Infiltration.cpp b/src/Infiltration.cpp index 871ff36..1681ff0 100644 --- a/src/Infiltration.cpp +++ b/src/Infiltration.cpp @@ -513,7 +513,7 @@ void CmvInfiltration::GetRatesOfChange (const double *state_vars, rates[3]=delayed; //PONDED->CONVOL[1] } else if (type==INF_XINANXIANG) - { //from Xinanxiang model + { //from Xinanxiang model double stor =state_vars[iTopSoil]; double max_stor =pHRU->GetSoilCapacity(0); double b=0.0;//pHRU->GetSoilProps(0)->xinanxiang_b; @@ -523,7 +523,7 @@ void CmvInfiltration::GetRatesOfChange (const double *state_vars, double wmm=max_stor*(1.0+b);//mm double a=(1.0 - pow((1.0 - stor / max_stor),1.0 / (1.0 + b)));//mm - + runoff=direct-(max_stor - stor)+ max_stor * pow(1.0 - min(direct+a, wmm) / wmm,1.0 + b); runoff=max(runoff,0.0); diff --git a/src/LatIceFlow.cpp b/src/LatIceFlow.cpp index b73ae97..b74a62a 100644 --- a/src/LatIceFlow.cpp +++ b/src/LatIceFlow.cpp @@ -78,7 +78,7 @@ void CmvLatIceFlow::Initialize() sortPointerArray(sortHRUs,nHRUs,sortByElevation); for (int k=0;kGetGlobalIndex(); _kTo [q] = sortHRUs[k+1]->GetGlobalIndex(); @@ -137,7 +137,7 @@ void CmvLatIceFlow::GetLateralExchange(const double *const *state_vars, const time_struct &tt, double *exchange_rates) const { - //because HRUs are sorted from high elev to low, 'from' and 'to' are directed downhill, not necessarily in flow direction + //because HRUs are sorted from high elev to low, 'from' and 'to' are directed downhill, not necessarily in flow direction double stor_from,stor_to,Afrom,Ato; double elev_from,elev_to; //elevation is actually *initial* elevation, including glacier cover, as consistent with most DEMs double gelev_from,gelev_to; //ground elevation, [masl] @@ -171,12 +171,12 @@ void CmvLatIceFlow::GetLateralExchange(const double *const *state_vars, //slope=(gelev_from-gelev_to)/distance; //bottom surface slope slope=surf_grad; //if interpreted as surface gradient (JRC: I think this is appropriate interpretation) - if (surf_grad<0){H=Hfrom;} + if (surf_grad<0){H=Hfrom;} else {H=Hto; } //H=0.5*(Hfrom+Hto); //alternative option width=0.5*(Afrom/len_from+Ato/len_to); - + velocity = ((2*A)/(n+2))*pow(DENSITY_ICE*GRAVITY*fabs(slope),n)*pow(H,n+1); //[m/s] velocity*=SEC_PER_DAY; //[m/d] diff --git a/src/MassRouting.cpp b/src/MassRouting.cpp index ad42145..1501fa6 100644 --- a/src/MassRouting.cpp +++ b/src/MassRouting.cpp @@ -351,7 +351,7 @@ void CConstituentModel::RouteMassInReservoir(const int p, // /// /// \param p [in] subbasin index /// \param **aMoutnew [in] Array of new mass outflows [mg/d] [size: nsegments x _nConstituents] -/// \param Mlat_new [in] new lateral mass transport from in-catchment routing +/// \param Mlat_new [in] new lateral mass transport from in-catchment routing /// \param ResMass [in] new reservoir mass [mg] /// \param ResMass [in] new reservoir sediment mass [mg] /// \param MassOutflow [out] new mass outflow [mg/d] from last segment or reservoir diff --git a/src/Model.cpp b/src/Model.cpp index a3c8018..ca92b36 100644 --- a/src/Model.cpp +++ b/src/Model.cpp @@ -2940,8 +2940,8 @@ void CModel::UpdateDiagnostics(const optStruct &Options, value= RAV_BLANK_DATA; } - - if (_pObservedTS[i]->GetType()==CTimeSeriesABC::TS_REGULAR) + + if (_pObservedTS[i]->GetType()==CTimeSeriesABC::TS_REGULAR) { _pModeledTS[i]->SetValue(n,value); _pModeledTS[i]->SetSampledValue(n,value); //Handles blank value issue in final time step diff --git a/src/ModelInitialize.cpp b/src/ModelInitialize.cpp index f247f75..8deaffa 100644 --- a/src/ModelInitialize.cpp +++ b/src/ModelInitialize.cpp @@ -1100,7 +1100,7 @@ void CModel::GenerateGaugeWeights(double **&aWts, const forcing_type forcing, co delete[] has_data; } ////////////////////////////////////////////////////////////////// -/// \brief reboots all necessary variables for ensemble mode +/// \brief reboots all necessary variables for ensemble mode // void CModel::RebootTimeVariables(const optStruct &Options) { @@ -1127,4 +1127,4 @@ void CModel::RebootTimeVariables(const optStruct &Options) } _CumulInput =_CumulOutput =0.0; -} \ No newline at end of file +} diff --git a/src/ParseHRUFile.cpp b/src/ParseHRUFile.cpp index d285fb6..bd04d31 100644 --- a/src/ParseHRUFile.cpp +++ b/src/ParseHRUFile.cpp @@ -1184,7 +1184,7 @@ bool ParseHRUPropsFile(CModel *&pModel, const optStruct &Options, bool terrain_r break; } case(22): //---------------------------------------------- - {/* :HRUFlowLengths + {/* :HRUFlowLengths {HRUID} {value} x nHRUs (or less) :EndHRUFlowLengths */ @@ -1205,7 +1205,7 @@ bool ParseHRUPropsFile(CModel *&pModel, const optStruct &Options, bool terrain_r CHydroUnit *pHRU=pModel->GetHRUByID(HRUID); if (pHRU==NULL){ WriteWarning("Parsing RVH file: Bad HRU index in :HRUFlowLengths command. Will be ignored",Options.noisy); - } + } else{ pHRU->SetFlowLength(s_to_d(s[1])); } diff --git a/src/ParseInitialConditionFile.cpp b/src/ParseInitialConditionFile.cpp index 55cd560..511d418 100644 --- a/src/ParseInitialConditionFile.cpp +++ b/src/ParseInitialConditionFile.cpp @@ -377,7 +377,7 @@ bool ParseInitialConditionsFile(CModel *&pModel, const optStruct &Options) WriteWarning("Initial conditions specified for state variable not in model ("+to_string(s[i+1])+")",Options.noisy); } - if ((typ==ATMOS_PRECIP) || (typ==ATMOSPHERE) || + if ((typ==ATMOS_PRECIP) || (typ==ATMOSPHERE) || ((typ==GLACIER_ICE) && (!Options.glacier_model_on))){//initial conditions of cumulative precip, evap, and glacier loss ignored, left at zero SVinds[i]=DOESNT_EXIST; } diff --git a/src/RavenInclude.h b/src/RavenInclude.h index 0a43f7e..4d4ac5e 100644 --- a/src/RavenInclude.h +++ b/src/RavenInclude.h @@ -886,7 +886,7 @@ enum sv_type WETLAND, ///< [mm] deep wetland depression storage GLACIER, ///< [mm] Glacier melt/reservoir storage GLACIER_ICE, ///< [mm] Glacier ice - typically assumed to be infinite reservoir. - FIRN, ///< [mm] Firn atop glacier + FIRN, ///< [mm] Firn atop glacier LAKE_STORAGE, ///< [mm] Net lake storage - relative to equilibrium datum - can go negative GLACIER_MB, ///< [mm] equivalent to GLACIER_ICE+GLACIER+FIRN+SNOW (diagnostic variable) @@ -914,7 +914,7 @@ enum sv_type // Snow/Glacier variables SNOW_DEPTH, ///< [mm] Snow depth - surrogate for density - FIRN_GRAVITY, ///< [0..1] Firn specific gravity (relative to water=1) + FIRN_GRAVITY, ///< [0..1] Firn specific gravity (relative to water=1) PERMAFROST_DEPTH, ///< [mm] depth of permafrost THAW_DEPTH, ///< [mm] depth of thaw SNOW_DEPTH_STDDEV, ///< log([mm]) Snow depth standard deviation diff --git a/src/RavenProcessConnections.dat b/src/RavenProcessConnections.dat index 1ad7b0c..6350c5c 100644 --- a/src/RavenProcessConnections.dat +++ b/src/RavenProcessConnections.dat @@ -220,4 +220,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/SnowBalance.cpp b/src/SnowBalance.cpp index 515e011..b7af80b 100644 --- a/src/SnowBalance.cpp +++ b/src/SnowBalance.cpp @@ -709,7 +709,7 @@ void CmvSnowBalance::GetRatesOfChange(const double *state_var, double firn_melt_corr=pHRU->GetSurfaceProps()->firn_melt_corr; double potmelt=pHRU->GetForcingFunctions()->potential_melt; - + rates[_nConnections-1]=(1.0-SC)*firn_melt_corr*potmelt; } }; diff --git a/src/Solvers.cpp b/src/Solvers.cpp index e7f4426..fd4378e 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,iGlacierMB; //total SWE index, glacier MB index - + int maxLatConns=0; int maxConns=0; int maxTotConns=0; diff --git a/src/SubBasin.cpp b/src/SubBasin.cpp index 3f5eb61..7eb44ae 100644 --- a/src/SubBasin.cpp +++ b/src/SubBasin.cpp @@ -1972,7 +1972,7 @@ void CSubBasin::InitializeFlowStates(const double& Qin_avg,const double& Qlat_av //Calculate Initial Channel Storage from flowrate //------------------------------------------------------------------------ _channel_storage=0.0; - + if ((Options.routing==ROUTE_NONE) || (Options.routing==ROUTE_EXTERNAL)) { _channel_storage=0.0; @@ -2015,7 +2015,7 @@ void CSubBasin::InitializeFlowStates(const double& Qin_avg,const double& Qlat_av sum+=_aUnitHydro[n]; _rivulet_storage+=sum*Qlat_avg*(Options.timestep*SEC_PER_DAY);//[m3]; } - _rivulet_storage+=Qlat_avg*Options.timestep*(Options.timestep*SEC_PER_DAY); + _rivulet_storage+=Qlat_avg*Options.timestep*(Options.timestep*SEC_PER_DAY); } //end if disabled } ///////////////////////////////////////////////////////////////// diff --git a/src/TimeSeries.h b/src/TimeSeries.h index fcffe7b..a3a9238 100644 --- a/src/TimeSeries.h +++ b/src/TimeSeries.h @@ -110,7 +110,7 @@ class CTimeSeries: public CTimeSeriesABC double GetModelledValue(const double &t,const ts_type type) const; void SetValue (const int n, const double &val); - + void ShiftInTime (const double t, const optStruct &Options); static CTimeSeries *ReadTimeSeriesFromNetCDF(const optStruct &Options, // model options (such as simulation period)