Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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
72 changes: 72 additions & 0 deletions .github/workflows/auto-approve-dependabot.yml
Original file line number Diff line number Diff line change
@@ -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 }}
8 changes: 4 additions & 4 deletions src/FirnEvolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand All @@ -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<<" "<<pHRU->GetHRUID()<<" "<<snow_to_firn<<" "<<firn_to_glacier<<" "<<firn_grav_change<<" firn new/old: "<<firn<<" "<<firn_old<<" grav: "<<grav<<" "<<bottom_grav<<" "<<top_grav<<endl;
rates[0]=snow_to_firn; //SNOW->FIRN
Expand Down
2 changes: 1 addition & 1 deletion src/GlacierProcesses.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/HydroUnits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/HydroUnits.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Infiltration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/LatIceFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void CmvLatIceFlow::Initialize()
sortPointerArray<CHydroUnit>(sortHRUs,nHRUs,sortByElevation);

for (int k=0;k<nHRUs-1;k++)
{
{
_kFrom [q] = sortHRUs[k ]->GetGlobalIndex();
_kTo [q] = sortHRUs[k+1]->GetGlobalIndex();

Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]

Expand Down
2 changes: 1 addition & 1 deletion src/MassRouting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/ModelInitialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -1127,4 +1127,4 @@ void CModel::RebootTimeVariables(const optStruct &Options)
}
_CumulInput =_CumulOutput =0.0;

}
}
4 changes: 2 additions & 2 deletions src/ParseHRUFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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]));
}
Expand Down
2 changes: 1 addition & 1 deletion src/ParseInitialConditionFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/RavenInclude.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/RavenProcessConnections.dat
Original file line number Diff line number Diff line change
Expand Up @@ -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
LAKEREL_LINEAR LakeRelease LAKE SURFACE_WATER
2 changes: 1 addition & 1 deletion src/SnowBalance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/Solvers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/SubBasin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
}
/////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion src/TimeSeries.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down