Model mass balance

There are two methods to calculate the mass balance within the model;
 * degree day method
 * simple energy balance model.

Degree day method
The degree day method is the simplest method to calculate the ablation.

function rainorsnw
This function determines whether precipitation falls as rain or snow using air temperature(it returns amount of rainfall). If it is called with the flag not equal to 1, a simple comparison between the daily mean temperature and a prescribed rain-snow transition temperature is made: if the daily mean air temperature is above the threshold then all precipitation on that day falls as rain, otherwise it is assumed that all the precipitation is snow, so the function returns zero. If the function is called with flag set to 1, it estimates the rainfall by assuming a cosine for the diurnal variation of temperature about its mean ($$\bar{T}$$) with prescribed range ( from mean to peak NOT peak to peak) which can be rearranged to give time of day  (in radians) at which the threshold  is equaled . The proportion of the day for which temperatures exceed the threshold is therefore. If we assume that there is an equal probability of the precipitation falling at any time during the day then we simply need to multiply by the daily precipitation total to get the amount of rainfall.

function finddegdays
This function finds the number of positive day degrees during a day using air temperature. If it is called with the flag not equal to 1, the number of day degrees is simply the daily mean temperature if its is above zero otherwise nothing. If the function is called with flag set to 1, it estimates the number of positive day degrees by assuming a cosine for the diurnal variation of temperature about its mean with prescribed range ( from mean to peak NOT peak to peak) which can be rearranged to give time of day  (in radians) at which the temperature equals zero . We now need to integrate  from the this time to midday  and scale from radians into fractions of a day

function lapsecalc
This function simply applies the prescribed lapse rate to what ever variable is given. This is usually done for air temperature (daily means but not amplitudes) and precipitation. In the latter case, there is a guard in the calling routine that avoids creating precipitation if there was none in the base met. data. The lapse rate is applied relative to the prescribed elevation of the met. data and everything is done in scaled units.

function surfacemodel
This function takes the estimated daily precipitation (total), rainfall and meltwater depths and evolves the accumulated snow, super-imposed ice and glacier ice stores. We call firn the combined depths of snow and super-imposed ice. The logic of the process is as follows.
 * 1) The depth of snow is increased by snowfall (total precipitation minus rainfall).
 * 2) The depth of super-imposed ice is increased by rainfall (assumed to refreeze).
 * 3) Use the total potential melt to melt snow. If there is snow left then set melt to zero, otherwise reduce it by amount of snow melted.  Any melted snow is assumed to refreeze and become super-imposed ice.
 * 4) Estimate the depth of super-imposed ice that would result in the firn reaching its capacity. Here firn is assumed to be the sum of the snow (s) and super-imposed ice (i) depths.  We assume that only a fixed proportion (w or wmax) of the firn can be super-imposed ice and estimate this depth as
 * 5) Any super-imposed ice above this capacity is assumed to have run off – or more accurately the melt water that would have formed super-imposed ice is rejected before it gets a chance to freeze.
 * 6) If any melt potential remains then proceed to melt super-imposed ice (reducing potential and increasing runoff accordingly). If the melt potential exceeds the amount of super-imposed ice, remove all of and amend runoff and potential melt figures accordingly. Note that in the case of the degree day model, this requires a re-determination of the appropriate degree-day factor from that of snow to ice.
 * 7) If any melt potential remains then proceed to melt glacier ice ice (reducing potential and increasing runoff accordingly).

Energy balance model
subroutine initialstart_ebm Sets up a number of parameters that are used in the energy balance calculation of surface melt. Points to note include: scaling of time from second in day to radians. subroutine initial4day_ebm Calculate energy-budget parameters that vary daily. In this case, this is the solar declination which is then used later on with the latitude  to calculate the solar zenith (z) and azimuth where  is the julian day expressed in radians, and

the primes indicates that these are parameters used in the final calculation of zenith and azimuths. subroutine nexttimestep_ebm This is the main solver for the energy-balance model and steps both the surface temperature (T) and the accumulated melt forward in time. The equation being solved is

where  is the surface’s aspect and   its slope (in radians);   is the fraction of the day expressed in radians and relative to midday; A, B and C are free parameters;  is the co-albedo of the surface; d is the depth of the thermally-active layer,  its density and c its specific heat capacity (we currently assume snow throughout); the 2-m air temperature (T2m) is based on the daily mean and amplitude value supplied; and temperatures are in K.  Appropriate sets are taken to ensure that the sun does not sun when it is below the horizon.

We use an implicit time-marching scheme

In these subroutines, time through the day is in radians. If the new temperature is above the melt point then we estimate an amount of melt by converting energy with active layer into an equivalent melt depth. We use the trapezium rule to do this. There are two cases. The first is where the preceeding temperature is at the melt point also; this is easy. The second in when the preceeding temperature is below the melt point, in which case we need to estimate the fraction of the time step during which temperature was above the melt point (using linear interpolation).