%Start defining model parameters here

%Geometry
hmin=300;
hmax=1000;
ymin=min(md.mesh.y);
ymax=max(md.mesh.y);
md.geometry.thickness=hmax+(hmin-hmax)*(md.mesh.y-ymin)/(ymax-ymin);
md.geometry.bed=-md.materials.rho_ice/md.materials.rho_water*md.geometry.thickness;
md.geometry.surface=md.geometry.bed+md.geometry.thickness;

%Initial velocity and pressure
x     = transpose(ncread('SquareShelf.nc','x'));
y     = transpose(ncread('SquareShelf.nc','y'));
vx    = transpose(ncread('SquareShelf.nc','vx'));
vy    = transpose(ncread('SquareShelf.nc','vy'));
index = transpose(ncread('SquareShelf.nc','index'));
md.initialization.vx=InterpFromMeshToMesh2d(index,x,y,vx,md.mesh.x,md.mesh.y);
md.initialization.vy=InterpFromMeshToMesh2d(index,x,y,vy,md.mesh.x,md.mesh.y);
clear vx vy x y index;
md.initialization.vz=zeros(md.mesh.numberofvertices,1);
md.initialization.pressure=zeros(md.mesh.numberofvertices,1);

%Materials
md.initialization.temperature=(273-20)*ones(md.mesh.numberofvertices,1);
md.materials.rheology_B=paterson(md.initialization.temperature);
md.materials.rheology_n=3*ones(md.mesh.numberofelements,1);

%Friction
pos=find(md.mask.elementonfloatingice);
md.friction.coefficient=20*ones(md.mesh.numberofvertices,1);
md.friction.coefficient(md.mesh.elements(pos,:))=0;
md.friction.p=ones(md.mesh.numberofelements,1);
md.friction.q=ones(md.mesh.numberofelements,1);

%Numerical parameters
md.diagnostic.viscosity_overshoot=0.3;
md.prognostic.stabilization=1;
md.thermal.stabilization=1;
md.settings.waitonlock=30;
md.verbose=verbose(0);
md.diagnostic.restol=0.10;
md.steadystate.reltol=0.02;
md.diagnostic.reltol=0.02;
md.diagnostic.abstol=NaN;
md.timestepping.time_step=1;
md.timestepping.final_time=3;

%Boundary conditions:
...

%Change name so that no test have the same name
A=dbstack;
if (length(A)>2), md.miscellaneous.name=A(3).file(1:end-2); end
