This document contains information about the files and variables necessary to run the model from tc2016_74y.mat on Matlab.
for further clarification please contact Dr. Sasha Carter at sasha.ase.carter@gmail.com

As the development of this code and and its input variables represents 100's of hours of work and a substantial degree 
of trial there do exist some legacy elements that should be rational numbers, but are no longer important to the actual operation of the code itself anymore  these will be labelled as "legacy"

%files included in tc2016_74.mat
filling_flood_mod4U_tM.m is the model interface  
filling_flood_mod6UH.m  is the core of the model
filling_flood_mod3_SLWWA is the R-channel model 
isfucked.m is a program that stops running the model if any variables are either Inf, negative Inf or Nan, and attempts to identify where the error began
overhead52.m is a program that makes your plots bold
gttrack.m is an analogue to gmt's gridtrack, takes a file of the form (x,y, . . . .) a grid file, a vector of x values for said grid file corresponding to the columns, 
	a vector of y values for said grid file corresponding to the rows, and outputs (x,y, . . ., grd(x,y))
rmrept.m removes repeated values from a list
webcolor100.txt is a table of RGB values for plotting lines of differing color
tc2016_74.mat contains all the input variables

In a number of the files I use numerical codes to represent each lake
SLW =72308111
SLE = 70514111
SLC = 70215111
SLM = 71305111
L78 = 71208111
Input variables:
files starting with "ohs" are the flowpath data for the model.  Columns are as follows:
(distance upstream (m), x coord (m), y coord (m), bed elev (m above wgs84, corrected for geoid),  pressure head (m w.e.), hydraulic potential (m w.e.) (a.k.a.) Theta_0, . . .
legacy, cross valley distance (y) (m), legacy, bedrock elevation (m), legacy, lakenumber (0 for no lake, 1 or multiple of 1111 for ice shelf), legacy, legacy, legacy, baseflow (m3 s-2), legacy) 
srfslp_1kf, is a grid of ice surface slope gridded to 1 km,
xax1k, is the the x values for the columns of said grid (km)
yax1k is the y values for the rows of aforementioned grid (km)
Qlk_toC is the lake inflow values with respect to time, also 
wc100 is s a table of RGB values for plotting lines of differing color
"levarmatC2"  is  a matrix of all the various variables for the model columns are as follows:
(Q_onset, Q_shutdown, legacy, significant grain size (d15, (m)), N_infinity,  R1 (m), max # timesteps, lake number, h', legacy, alpha)
SLC_obs, SLM_V_t,SLW_obs, SLE_obs, and L78_obs, are the observed values for lake volume from Siegfried et al., 2016
ohs_Dom01_00,srfslpDom,xdom,ydom,Qlk_toCD([17,19],:) all correspond to the idealized domain

Output variables:
ih . . . is the state of the flowpath at the end of the model run columns are as follows
(distance upstream (m), x coord (m), y coord (m), bed elev (m above wgs84, corrected for geoid),  pressure head (m w.e.), hydraulic potential (m w.e.) (a.k.a.) Theta_0, . . .
legacy, cross valley distance (y) (m), legacy, bedrock elevation (m), legacy, lakenumber (0 for no lake, 1 or multiple of 1111 for ice shelf), legacy, legacy, legacy, baseflow (m3 s-2), legacy . . .
ice thickness (m), ice surface elevation (m), S_s (m), h_s (m), N_S (Pas), overburden pressure (pas), Theta_S (pas), E_S, velocity of distributed system (m s-1),  lake status (0=not a lake, 1 filling, 2 draining), . . .
is cell a lake edge, Tau_b (pas), ice surface slope, legacy, legacy, legacy, Transfer coefficient (TS_CC),  Radius of canal (R_CC), Tau_CC, Deposition rate (D_CC), Creep closure rate, Erosion, Q_CC (m3 s-1), N_CC (pas), . . .
S_cc (m2), Sed concentration, u_cc (m s-1), p_CC (pas), Theta_CC, legacy, legacy, m_CC, legacy, legacy)
ilk . . . is the state of the lakes in the model
sh. . . is the variables from ih on the staggered grid,
Nt is the values for N_S alogn the flowpath vs time with rows corresponding the rows in the "ohs" file and columns of time,  The top row is time in years since Y2k
TSRt is the values for TS_CC along the flowpath vs time with rows corresponding the rows in the "ohs" file and columns of time,  The top row is time in years since Y2k
SSt . . .  is the values for S_S along the flowpath vs time with rows corresponding the rows in the "ohs" file and columns of time,  The top row is time in years since Y2k
SRt . . .is the values for S_CC along the flowpath vs time with rows corresponding the rows in the "ohs" file and columns of time,  The top row is time in years since Y2k
hhSt . . .is the values for theta_S along the flowpath vs time with rows corresponding the rows in the "ohs" file and columns of time,  The top row is time in years since Y2k
hhRt . . .is the values for theta_CC along the flowpath vs time with rows corresponding the rows in the "ohs" file and columns of time,  The top row is time in years since Y2k
V... is the time series for volume, time is the first row,  lake volume may be anywhere between ros 2 and rows 4 (maybe deeper depending on your "ohs" input)
Q ... is the time series for lake outflow, time is the first row,  Q_S is the second row, Q_CC is the third row
%Commands to run the constant inflow model
[ihSLC_C,ilkSLC_C,shSLC_C,NtCSLC,TSRtCSLC,SStCSLC,SRtCSLC,hhStCSLC,hhRtCSLC,VSLC_C,QSLCt_C]=filling_flood_mod4U_tM(ohs_SLC5,srfslp_1kf,xax1k,yax1k,Qlk_toC,wc100,[4,14],levarmatC2(1,:),SLC_obs);
[ihSLM_C,ilkSLM_C,shSLM_C,NtCSLM,TSRtCSLM,SStCSLM,SRtCSLM,hhStCSLM,hhRtCSLM,VSLM_C,QSLMt_C]=filling_flood_mod4U_tM(ohs_SLMf3,srfslp_1kf,xax1k,yax1k,Qlk_toC,wc100,[4.15,14],levarmatC2(4,:),SLM_V_t);
[ihSLWt_C,ilkSLWt_C,shSLW_C,NtCSLW,TSRtCSLW,SStCSLW,SRtCSLW,hhStCSLW,hhRtCSLW,VSLWt_C,QSLWt_C]=filling_flood_mod4U_tM(ohs_SLWf2,srfslp_1kf,xax1k,yax1k,Qlk_toC,wc100,[5,14],levarmatC2(3,:),SLW_obs);
[ihSLEt_C,ilkSLEt_C,shSLE_C,NtCSLE,TSRtCSLE,SStCSLE,SRtCSLE,hhStCSLE,hhRtCSLE,VSLEt_C,QSLEt_C]=filling_flood_mod4U_tM(ohs_SLEf,srfslp_1kf,xax1k,yax1k,Qlk_toC,wc100,[0,16],levarmatC2(2,:),SLE_obs);
[ihL78t_C,ilkL78t_C,shL78_C,NtCSL78,TSRtCSL78,SStCSL78,SRtCSL78,hhStCSL78,hhRtCSL78,VL78t_C,QL78t_C]=filling_flood_mod4U_tM(ohs_L78b,srfslp_1kf,xax1k,yax1k,Qlk_toC,wc100,[5.4,14],levarmatC2(6,:),L78_obs);

%this is the idealized domain
[ihDOM_C,ilkDOM_C,shDOM_C,NtCDOM,tCDOM,SStCDOM,SRtCDOM,hhStCDOM,hhRtCDOM,VDOMt_C,QDOMt_C]=filling_flood_mod4U_tM(ohs_Dom01_00,srfslpDom,xdom,ydom,Qlk_toCD([17,19],:),wc100,[5,14],levarmatC2(8,:),SLW_obs);
%this is the R_channel model 
[ihR1_1,~,mRt1_1,CVRt1_1,SRt1_1,NR_t1_1,VR_1_1,QR_1_1]=filling_flood_mod3_SLWWA(ohs_SLWf2,srfslp_1kf,xax1k,yax1k,Qlk_toC,wc100,1e-4,[5,14],1,1);

