Index: /issm/trunk/test/NightlyRun/Id2Name.m
===================================================================
--- /issm/trunk/test/NightlyRun/Id2Name.m	(revision 5048)
+++ /issm/trunk/test/NightlyRun/Id2Name.m	(revision 5049)
@@ -201,3 +201,7 @@
 elseif (id==1202), name='EISMINTDiag1';
 elseif (id==1203), name='EISMINTDiag2';
+elseif (id==1301), name='ThermalMelting';
+elseif (id==1302), name='ThermalAdvection';
+elseif (id==1303), name='ThermalConduction';
+elseif (id==1304), name='ThermalGeothermalFlux';
 else name='N/A'; end
Index: /issm/trunk/test/NightlyRun/test1101.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1101.m	(revision 5049)
+++ /issm/trunk/test/NightlyRun/test1101.m	(revision 5049)
@@ -0,0 +1,43 @@
+%This test is a test from the ISMP-HOM Intercomparison project
+%Pattyn and Payne 2006
+
+L_list={5000,10000,20000,40000,80000,160000};
+results={};
+
+for i=1:length(L_list),
+	L=L_list{i};
+	nx=20; %numberof nodes in x direction
+	ny=20;
+	md=model;
+	md=squaremesh(md,L,L,nx,ny);
+	md=geography(md,'',''); %ice sheet test
+	md=parameterize(md,'../Par/ISMIPA.par');
+	md=extrude(md,9,1);
+
+	md=setelementstype(md,'pattyn','all');
+
+	%Create dirichlet on the bed only
+	md.spcvelocity=zeros(md.numberofgrids,6);
+	pos=find(md.gridonbed);
+	md.spcvelocity(pos,1:2)=1;
+
+	%Create MPCs to have periodic boundary conditions
+	posx=find(md.x==0);
+	posx2=find(md.x==max(md.x));
+
+	posy=find(md.y==0 & md.x~=0 & md.x~=max(md.x)); %Don't take the same grids two times
+	posy2=find(md.y==max(md.y) & md.x~=0 & md.x~=max(md.x));
+
+	md.penalties=[posx,posx2;posy,posy2];
+
+	%Compute the diagnostic
+	md=solve(md,'analysis_type',DiagnosticSolutionEnum);
+
+	%Plot the results and save them
+	vx=PatchToVec(md.results.DiagnosticSolution.Vx);
+	vy=PatchToVec(md.results.DiagnosticSolution.Vy);
+	vz=PatchToVec(md.results.DiagnosticSolution.Vz);
+	results{i}=md.results.DiagnosticSolution;
+
+	plotmodel(md,'data',vx,'data',vy,'data',vz,'layer#all',md.numlayers)
+end
Index: /issm/trunk/test/NightlyRun/test1101_nightly.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1101_nightly.m	(revision 5049)
+++ /issm/trunk/test/NightlyRun/test1101_nightly.m	(revision 5049)
@@ -0,0 +1,25 @@
+field_names     ={...
+	'Vx5km','Vy5km','Vz5km',...
+	'Vx10km','Vy10km','Vz10km',...
+	'Vx20km','Vy20km','Vz20km',...
+	'Vx40km','Vy40km','Vz40km',...
+	'Vx80km','Vy80km','Vz80km'
+	'Vx160km','Vy160km','Vz160km'
+}
+field_tolerances={...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+};
+field_values={};
+for i=1:6,
+	result=results{i}
+	field_values={field_values,...
+		PatchToVec(result.DiagnosticSolution.Vx),...
+		PatchToVec(result.DiagnosticSolution.Vy),...
+		PatchToVec(result.DiagnosticSolution.Vz),...
+		};
+end
Index: /issm/trunk/test/NightlyRun/test1102.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1102.m	(revision 5049)
+++ /issm/trunk/test/NightlyRun/test1102.m	(revision 5049)
@@ -0,0 +1,44 @@
+%This test is a test from the ISMP-HOM Intercomparison project
+%Pattyn and Payne 2006
+
+L_list={5000,10000,20000,40000,80000,160000}
+results={};
+
+for i=1:length(L_list),
+	L=L_list{i};
+	nx=20; %numberof nodes in x direction
+	ny=20;
+	md=model;
+	md=squaremesh(md,L,L,nx,ny);
+	md=geography(md,'',''); %ice sheet test
+	md=parameterize(md,'../Par/ISMIPA.par');
+	md=extrude(md,9,1);
+
+	md=setelementstype(md,'pattyn','all','stokes','all');
+
+	%Create dirichlet on the bed only
+	md.spcvelocity=zeros(md.numberofgrids,6);
+	pos=find(md.gridonbed);
+	md.spcvelocity(pos,1:2)=1;
+
+	%Create MPCs to have periodic boundary conditions
+	posx=find(md.x==0);
+	posx2=find(md.x==max(md.x));
+
+	posy=find(md.y==0 & md.x~=0 & md.x~=max(md.x)); %Don't take the same grids two times
+	posy2=find(md.y==max(md.y) & md.x~=0 & md.x~=max(md.x));
+
+	md.penalties=[posx,posx2;posy,posy2];
+
+	%Compute the diagnostic
+	md=solve(md,'analysis_type',DiagnosticSolutionEnum);
+
+	%Plot the results and save them
+	vx=PatchToVec(md.results.DiagnosticSolution.Vx);
+	vy=PatchToVec(md.results.DiagnosticSolution.Vy);
+	vz=PatchToVec(md.results.DiagnosticSolution.Vz);
+	results{i}=md.results.DiagnosticSolution;
+
+	plotmodel(md,'data',vx,'data',vy,'data',vz,'layer#all',md.numlayers)
+
+end
Index: /issm/trunk/test/NightlyRun/test1102_nightly.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1102_nightly.m	(revision 5049)
+++ /issm/trunk/test/NightlyRun/test1102_nightly.m	(revision 5049)
@@ -0,0 +1,25 @@
+field_names     ={...
+	'Vx5km','Vy5km','Vz5km',...
+	'Vx10km','Vy10km','Vz10km',...
+	'Vx20km','Vy20km','Vz20km',...
+	'Vx40km','Vy40km','Vz40km',...
+	'Vx80km','Vy80km','Vz80km'
+	'Vx160km','Vy160km','Vz160km'
+}
+field_tolerances={...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+};
+field_values={};
+for i=1:6,
+	result=results{i}
+	field_values={field_values,...
+		PatchToVec(result.DiagnosticSolution.Vx),...
+		PatchToVec(result.DiagnosticSolution.Vy),...
+		PatchToVec(result.DiagnosticSolution.Vz),...
+		};
+end
Index: /issm/trunk/test/NightlyRun/test1103.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1103.m	(revision 5049)
+++ /issm/trunk/test/NightlyRun/test1103.m	(revision 5049)
@@ -0,0 +1,43 @@
+%This test is a test from the ISMP-HOM Intercomparison project
+%Pattyn and Payne 2006
+
+L_list={5000,10000,20000,40000,80000,160000};
+results={};
+
+for i=1:length(L_list),
+	L=L_list{i};
+	nx=20; %numberof nodes in x direction
+	ny=20;
+	md=model;
+	md=squaremesh(md,L,L,nx,ny);
+	md=geography(md,'',''); %ice sheet test
+	md=parameterize(md,'../Par/ISMIPB.par');
+	md=extrude(md,10,1);
+
+	md=setelementstype(md,'pattyn','all');
+
+	%Create dirichlet on the bed only
+	md.spcvelocity=zeros(md.numberofgrids,6);
+	pos=find(md.gridonbed);
+	md.spcvelocity(pos,1:2)=1;
+
+	%Create MPCs to have periodic boundary conditions
+	posx=find(md.x==0);
+	posx2=find(md.x==max(md.x));
+
+	posy=find(md.y==0 & md.x~=0 & md.x~=max(md.x)); %Don't take the same grids two times
+	posy2=find(md.y==max(md.y) & md.x~=0 & md.x~=max(md.x));
+
+	md.penalties=[posx,posx2;posy,posy2];
+
+	%Compute the diagnostic
+	md=solve(md,'analysis_type',DiagnosticSolutionEnum);
+
+	%Plot the results and save them
+	vx=PatchToVec(md.results.DiagnosticSolution.Vx);
+	vy=PatchToVec(md.results.DiagnosticSolution.Vy);
+	vz=PatchToVec(md.results.DiagnosticSolution.Vz);
+	results{i}=md.results.DiagnosticSolution;
+
+	plotmodel(md,'data',vx,'data',vy,'data',vz,'layer#all',md.numlayers)
+end
Index: /issm/trunk/test/NightlyRun/test1103_nightly.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1103_nightly.m	(revision 5049)
+++ /issm/trunk/test/NightlyRun/test1103_nightly.m	(revision 5049)
@@ -0,0 +1,25 @@
+field_names     ={...
+	'Vx5km','Vy5km','Vz5km',...
+	'Vx10km','Vy10km','Vz10km',...
+	'Vx20km','Vy20km','Vz20km',...
+	'Vx40km','Vy40km','Vz40km',...
+	'Vx80km','Vy80km','Vz80km'
+	'Vx160km','Vy160km','Vz160km'
+}
+field_tolerances={...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+};
+field_values={};
+for i=1:6,
+	result=results{i}
+	field_values={field_values,...
+		PatchToVec(result.DiagnosticSolution.Vx),...
+		PatchToVec(result.DiagnosticSolution.Vy),...
+		PatchToVec(result.DiagnosticSolution.Vz),...
+		};
+end
Index: /issm/trunk/test/NightlyRun/test1104.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1104.m	(revision 5049)
+++ /issm/trunk/test/NightlyRun/test1104.m	(revision 5049)
@@ -0,0 +1,43 @@
+%This test is a test from the ISMP-HOM Intercomparison project
+%Pattyn and Payne 2006
+
+L_list={5000,10000,20000,40000,80000,160000};
+results={};
+
+for i=1:length(L_list),
+	L=L_list{i};
+	nx=20; %numberof nodes in x direction
+	ny=20;
+	md=model;
+	md=squaremesh(md,L,L,nx,ny);
+	md=geography(md,'',''); %ice sheet test
+	md=parameterize(md,'../Par/ISMIPB.par');
+	md=extrude(md,10,1);
+
+	md=setelementstype(md,'pattyn','all','stokes','all');
+
+	%Create dirichlet on the bed only
+	md.spcvelocity=zeros(md.numberofgrids,6);
+	pos=find(md.gridonbed);
+	md.spcvelocity(pos,1:2)=1;
+
+	%Create MPCs to have periodic boundary conditions
+	posx=find(md.x==0);
+	posx2=find(md.x==max(md.x));
+
+	posy=find(md.y==0 & md.x~=0 & md.x~=max(md.x)); %Don't take the same grids two times
+	posy2=find(md.y==max(md.y) & md.x~=0 & md.x~=max(md.x));
+
+	md.penalties=[posx,posx2;posy,posy2];
+
+	%Compute the diagnostic
+	md=solve(md,'analysis_type',DiagnosticSolutionEnum);
+
+	%Plot the results and save them
+	vx=PatchToVec(md.results.DiagnosticSolution.Vx);
+	vy=PatchToVec(md.results.DiagnosticSolution.Vy);
+	vz=PatchToVec(md.results.DiagnosticSolution.Vz);
+	results{i}=md.results.DiagnosticSolution;
+
+	plotmodel(md,'data',vx,'data',vy,'data',vz,'layer#all',md.numlayers)
+end
Index: /issm/trunk/test/NightlyRun/test1104_nightly.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1104_nightly.m	(revision 5049)
+++ /issm/trunk/test/NightlyRun/test1104_nightly.m	(revision 5049)
@@ -0,0 +1,25 @@
+field_names     ={...
+	'Vx5km','Vy5km','Vz5km',...
+	'Vx10km','Vy10km','Vz10km',...
+	'Vx20km','Vy20km','Vz20km',...
+	'Vx40km','Vy40km','Vz40km',...
+	'Vx80km','Vy80km','Vz80km'
+	'Vx160km','Vy160km','Vz160km'
+}
+field_tolerances={...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+};
+field_values={};
+for i=1:6,
+	result=results{i}
+	field_values={field_values,...
+		PatchToVec(result.DiagnosticSolution.Vx),...
+		PatchToVec(result.DiagnosticSolution.Vy),...
+		PatchToVec(result.DiagnosticSolution.Vz),...
+		};
+end
Index: /issm/trunk/test/NightlyRun/test1105.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1105.m	(revision 5049)
+++ /issm/trunk/test/NightlyRun/test1105.m	(revision 5049)
@@ -0,0 +1,40 @@
+%This test is a test from the ISMP-HOM Intercomparison project
+%Pattyn and Payne 2006
+
+L_list={5000,10000,20000,40000,80000,160000};
+results={};
+
+for i=1:length(L_list),
+	L=3*L_list{i};  %in m (3 times the desired lenght for BC problems)  
+	nx=60; %number of nodes in x direction
+	ny=60;
+	md=model;
+	md=squaremesh(md,L,L,nx,ny);
+	md=geography(md,'',''); %ice sheet test
+	md=parameterize(md,'../Par/ISMIPC.par');
+	md=extrude(md,6,1);
+
+	md=setelementstype(md,'pattyn','all'); 
+
+	%Create MPCs to have periodic boundary conditions
+	%md.spcvelocity=zeros(md.numberofgrids,6);
+
+	%posx=find(md.x==0);
+	%posx2=find(md.x==L);
+
+	%posy=find(md.y==0 & md.x~=0 & md.x~=L); %Don't take the same grids two times
+	%posy2=find(md.y==L & md.x~=0 & md.x~=L);
+
+	%md.penalties=[posx,posx2;posy,posy2];
+
+	%Compute the diagnostic
+	md=solve(md,'analysis_type',DiagnosticSolutionEnum);
+
+	%Plot the results and save them
+	vx=PatchToVec(md.results.DiagnosticSolution.Vx);
+	vy=PatchToVec(md.results.DiagnosticSolution.Vy);
+	vz=PatchToVec(md.results.DiagnosticSolution.Vz);
+	results{i}=md.results.DiagnosticSolution;
+
+	plotmodel(md,'data',vx,'data',vy,'data',vz,'layer#all',md.numlayers)
+end
Index: /issm/trunk/test/NightlyRun/test1105_nightly.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1105_nightly.m	(revision 5049)
+++ /issm/trunk/test/NightlyRun/test1105_nightly.m	(revision 5049)
@@ -0,0 +1,25 @@
+field_names     ={...
+	'Vx5km','Vy5km','Vz5km',...
+	'Vx10km','Vy10km','Vz10km',...
+	'Vx20km','Vy20km','Vz20km',...
+	'Vx40km','Vy40km','Vz40km',...
+	'Vx80km','Vy80km','Vz80km'
+	'Vx160km','Vy160km','Vz160km'
+}
+field_tolerances={...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+};
+field_values={};
+for i=1:6,
+	result=results{i}
+	field_values={field_values,...
+		PatchToVec(result.DiagnosticSolution.Vx),...
+		PatchToVec(result.DiagnosticSolution.Vy),...
+		PatchToVec(result.DiagnosticSolution.Vz),...
+		};
+end
Index: /issm/trunk/test/NightlyRun/test1106.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1106.m	(revision 5049)
+++ /issm/trunk/test/NightlyRun/test1106.m	(revision 5049)
@@ -0,0 +1,40 @@
+%This test is a test from the ISMP-HOM Intercomparison project
+%Pattyn and Payne 2006
+
+L_list={5000,10000,20000,40000,80000,160000};
+results{};
+
+for i=1:length(L_list),
+	L=3*L_list{i};  %in m (3 times the desired lenght for BC problems)  
+	nx=60; %number of nodes in x direction
+	ny=60;
+	md=model;
+	md=squaremesh(md,L,L,nx,ny);
+	md=geography(md,'',''); %ice sheet test
+	md=parameterize(md,'../Par/ISMIPC.par');
+	md=extrude(md,6,1);
+
+	md=setelementstype(md,'pattyn','all','stokes','all'); 
+
+	%Create MPCs to have periodic boundary conditions
+	%md.spcvelocity=zeros(md.numberofgrids,6);
+
+	%posx=find(md.x==0);
+	%posx2=find(md.x==L);
+
+	%posy=find(md.y==0 & md.x~=0 & md.x~=L); %Don't take the same grids two times
+	%posy2=find(md.y==L & md.x~=0 & md.x~=L);
+
+	%md.penalties=[posx,posx2;posy,posy2];
+
+	%Compute the diagnostic
+	md=solve(md,'analysis_type',DiagnosticSolutionEnum);
+
+	%Plot the results and save them
+	vx=PatchToVec(md.results.DiagnosticSolution.Vx);
+	vy=PatchToVec(md.results.DiagnosticSolution.Vy);
+	vz=PatchToVec(md.results.DiagnosticSolution.Vz);
+	results{i}=md.results.DiagnosticSolution;
+
+	plotmodel(md,'data',vx,'data',vy,'data',vz,'layer#all',md.numlayers)
+end
Index: /issm/trunk/test/NightlyRun/test1106_nightly.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1106_nightly.m	(revision 5049)
+++ /issm/trunk/test/NightlyRun/test1106_nightly.m	(revision 5049)
@@ -0,0 +1,25 @@
+field_names     ={...
+	'Vx5km','Vy5km','Vz5km',...
+	'Vx10km','Vy10km','Vz10km',...
+	'Vx20km','Vy20km','Vz20km',...
+	'Vx40km','Vy40km','Vz40km',...
+	'Vx80km','Vy80km','Vz80km'
+	'Vx160km','Vy160km','Vz160km'
+}
+field_tolerances={...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+};
+field_values={};
+for i=1:6,
+	result=results{i}
+	field_values={field_values,...
+		PatchToVec(result.DiagnosticSolution.Vx),...
+		PatchToVec(result.DiagnosticSolution.Vy),...
+		PatchToVec(result.DiagnosticSolution.Vz),...
+		};
+end
Index: /issm/trunk/test/NightlyRun/test1107.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1107.m	(revision 5049)
+++ /issm/trunk/test/NightlyRun/test1107.m	(revision 5049)
@@ -0,0 +1,43 @@
+%This test is a test from the ISMP-HOM Intercomparison project
+%Pattyn and Payne 2006
+
+L_list={5000,10000,20000,40000,80000,160000};
+results={};
+
+for i=1:length(L_list),
+	L=3*L_list{i};
+	nx=60; %numberof nodes in x direction
+	ny=60;
+	md=model;
+	md=squaremesh(md,L,L,nx,ny);
+	md=geography(md,'',''); %ice sheet test
+	md=parameterize(md,'../Par/ISMIPD.par');
+	md=extrude(md,6,1);
+
+	md=setelementstype(md,'pattyn','all');
+
+	%We need one grd on dirichlet: the 4 corners are set to zero
+	md.spcvelocity=zeros(md.numberofgrids,6);
+	pos=find((md.x==0 | md.x==max(md.x)) & (md.y==0 | md.y==max(md.y)));
+	md.spcvelocity(pos,1:3)=1;
+
+	%Create MPCs to have periodic boundary conditions
+	posx=find(md.x==0);
+	posx2=find(md.x==max(md.x));
+
+	posy=find(md.y==0 & md.x~=0 & md.x~=max(md.x)); %Don't take the same grids two times
+	posy2=find(md.y==max(md.y) & md.x~=0 & md.x~=max(md.x));
+
+	md.penalties=[posx,posx2;posy,posy2];
+
+	%Compute the diagnostic
+	md=solve(md,'analysis_type',DiagnosticSolutionEnum);
+
+	%Plot the results and save them
+	vx=PatchToVec(md.results.DiagnosticSolution.Vx);
+	vy=PatchToVec(md.results.DiagnosticSolution.Vy);
+	vz=PatchToVec(md.results.DiagnosticSolution.Vz);
+	results{i}=md.results.DiagnosticSolution;
+
+	plotmodel(md,'data',vx,'data',vy,'data',vz,'layer#all',md.numlayers)
+end
Index: /issm/trunk/test/NightlyRun/test1107_nightly.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1107_nightly.m	(revision 5049)
+++ /issm/trunk/test/NightlyRun/test1107_nightly.m	(revision 5049)
@@ -0,0 +1,25 @@
+field_names     ={...
+	'Vx5km','Vy5km','Vz5km',...
+	'Vx10km','Vy10km','Vz10km',...
+	'Vx20km','Vy20km','Vz20km',...
+	'Vx40km','Vy40km','Vz40km',...
+	'Vx80km','Vy80km','Vz80km'
+	'Vx160km','Vy160km','Vz160km'
+}
+field_tolerances={...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+};
+field_values={};
+for i=1:6,
+	result=results{i}
+	field_values={field_values,...
+		PatchToVec(result.DiagnosticSolution.Vx),...
+		PatchToVec(result.DiagnosticSolution.Vy),...
+		PatchToVec(result.DiagnosticSolution.Vz),...
+		};
+end
Index: /issm/trunk/test/NightlyRun/test1108.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1108.m	(revision 5049)
+++ /issm/trunk/test/NightlyRun/test1108.m	(revision 5049)
@@ -0,0 +1,43 @@
+%This test is a test from the ISMP-HOM Intercomparison project
+%Pattyn and Payne 2006
+
+L_list={5000,10000,20000,40000,80000,160000};
+results={};
+
+for i=1:length(L_list),
+	L=3*L_list{i};
+	nx=60; %numberof nodes in x direction
+	ny=60;
+	md=model;
+	md=squaremesh(md,L,L,nx,ny);
+	md=geography(md,'',''); %ice sheet test
+	md=parameterize(md,'../Par/ISMIPD.par');
+	md=extrude(md,6,1);
+
+	md=setelementstype(md,'pattyn','all','stokes','all');
+
+	%We need one grd on dirichlet: the 4 corners are set to zero
+	md.spcvelocity=zeros(md.numberofgrids,6);
+	pos=find((md.x==0 | md.x==max(md.x)) & (md.y==0 | md.y==max(md.y)));
+	md.spcvelocity(pos,1:3)=1;
+
+	%Create MPCs to have periodic boundary conditions
+	posx=find(md.x==0);
+	posx2=find(md.x==max(md.x));
+
+	posy=find(md.y==0 & md.x~=0 & md.x~=max(md.x)); %Don't take the same grids two times
+	posy2=find(md.y==max(md.y) & md.x~=0 & md.x~=max(md.x));
+
+	md.penalties=[posx,posx2;posy,posy2];
+
+	%Compute the diagnostic
+	md=solve(md,'analysis_type',DiagnosticSolutionEnum);
+
+	%Plot the results and save them
+	vx=PatchToVec(md.results.DiagnosticSolution.Vx);
+	vy=PatchToVec(md.results.DiagnosticSolution.Vy);
+	vz=PatchToVec(md.results.DiagnosticSolution.Vz);
+	results{i}=md.results.DiagnosticSolution;
+
+	plotmodel(md,'data',vx,'data',vy,'data',vz,'layer#all',md.numlayers)
+end
Index: /issm/trunk/test/NightlyRun/test1108_nightly.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1108_nightly.m	(revision 5049)
+++ /issm/trunk/test/NightlyRun/test1108_nightly.m	(revision 5049)
@@ -0,0 +1,25 @@
+field_names     ={...
+	'Vx5km','Vy5km','Vz5km',...
+	'Vx10km','Vy10km','Vz10km',...
+	'Vx20km','Vy20km','Vz20km',...
+	'Vx40km','Vy40km','Vz40km',...
+	'Vx80km','Vy80km','Vz80km'
+	'Vx160km','Vy160km','Vz160km'
+}
+field_tolerances={...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,...
+};
+field_values={};
+for i=1:6,
+	result=results{i}
+	field_values={field_values,...
+		PatchToVec(result.DiagnosticSolution.Vx),...
+		PatchToVec(result.DiagnosticSolution.Vy),...
+		PatchToVec(result.DiagnosticSolution.Vz),...
+		};
+end
Index: /issm/trunk/test/Par/ISMIPA.par
===================================================================
--- /issm/trunk/test/Par/ISMIPA.par	(revision 5049)
+++ /issm/trunk/test/Par/ISMIPA.par	(revision 5049)
@@ -0,0 +1,27 @@
+%Ok, start defining model parameters here
+
+disp('      creating thickness');
+md.surface=-md.x*tan(0.5*pi/180);
+md.bed=md.surface-1000+500*sin(md.x*2*pi/max(md.x)).*sin(md.y*2*pi/max(md.x));
+md.thickness=md.surface-md.bed;
+md.firn_layer=0*ones(md.numberofgrids,1);
+
+disp('      creating drag');
+md.drag_type=2; %0 none 1 plastic 2 viscous
+md.drag_coefficient=200*ones(md.numberofgrids,1); %q=1.
+%Take care of iceshelves: no basal drag
+pos=find(md.elementoniceshelf);
+md.drag_coefficient(md.elements(pos,:))=0;
+md.drag_p=ones(md.numberofelements,1);
+md.drag_q=ones(md.numberofelements,1);
+
+disp('      creating flow law paramter');
+md.rheology_B=6.8067*10^7*ones(md.numberofgrids,1);
+md.rheology_n=3*ones(md.numberofelements,1);
+
+disp('      boundary conditions for diagnostic model');
+%Create grid on boundary fist (because we cannot use mesh)
+md=SetIceSheetBC(md);
+
+md.np=8;
+md.cluster=oshostname();
Index: /issm/trunk/test/Par/ISMIPB.par
===================================================================
--- /issm/trunk/test/Par/ISMIPB.par	(revision 5049)
+++ /issm/trunk/test/Par/ISMIPB.par	(revision 5049)
@@ -0,0 +1,27 @@
+%Ok, start defining model parameters here
+
+disp('      creating thickness');
+md.surface=-md.x*tan(0.5*pi/180);
+md.bed=md.surface-1000+500*sin(md.x*2*pi/max(md.x));
+md.thickness=md.surface-md.bed;
+md.firn_layer=0*ones(md.numberofgrids,1);
+
+disp('      creating drag');
+md.drag_type=2; %0 none 1 plastic 2 viscous
+md.drag_coefficient=200*ones(md.numberofgrids,1); %q=1.
+%Take care of iceshelves: no basal drag
+pos=find(md.elementoniceshelf);
+md.drag_coefficient(md.elements(pos,:))=0;
+md.drag_p=ones(md.numberofelements,1);
+md.drag_q=ones(md.numberofelements,1);
+
+disp('      creating flow law paramter');
+md.rheology_B=6.8067*10^7*ones(md.numberofgrids,1);
+md.rheology_n=3*ones(md.numberofelements,1);
+
+disp('      boundary conditions for diagnostic model');
+%Create grid on boundary fist (because we cannot use mesh)
+md=SetIceSheetBC(md);
+
+md.np=8;
+md.cluster=oshostname();
Index: /issm/trunk/test/Par/ISMIPC.par
===================================================================
--- /issm/trunk/test/Par/ISMIPC.par	(revision 5049)
+++ /issm/trunk/test/Par/ISMIPC.par	(revision 5049)
@@ -0,0 +1,28 @@
+%Ok, start defining model parameters here
+
+disp('      creating thickness');
+md.surface=2000-md.x*tan(0.1*pi/180); %to have z>0
+md.bed=md.surface-1000;
+md.thickness=md.surface-md.bed;
+md.firn_layer=0*ones(md.numberofgrids,1);
+
+disp('      creating drag');
+md.drag_type=2; %0 none 1 plastic 2 viscous
+md.drag_coefficient=sqrt(md.yts.*(1000+1000*sin(md.x*2*pi/max(md.x/3)).*sin(md.y*2*pi/max(md.x/3)))./(md.g*(md.rho_ice*md.thickness+md.rho_water*md.bed)));
+%md.drag_coefficient=sqrt(md.yts.*(1000+1000*sin(md.x*2*pi/max(md.x)).*sin(md.y*2*pi/max(md.x)))./(md.g*(md.rho_ice*md.thickness+md.rho_water*md.bed)));
+%Take care of iceshelves: no basal drag
+pos=find(md.elementoniceshelf);
+md.drag_coefficient(md.elements(pos,:))=0;
+md.drag_p=ones(md.numberofelements,1);
+md.drag_q=ones(md.numberofelements,1);
+
+disp('      creating flow law paramter');
+md.rheology_B=6.8067*10^7*ones(md.numberofgrids,1);
+md.rheology_n=3*ones(md.numberofelements,1);
+
+disp('      boundary conditions for diagnostic model: ');
+%Create grid on boundary fist (because wi can not use mesh)
+md=SetIceSheetBC(md);
+
+md.np=8;
+md.cluster=oshostname();
Index: /issm/trunk/test/Par/ISMIPD.par
===================================================================
--- /issm/trunk/test/Par/ISMIPD.par	(revision 5049)
+++ /issm/trunk/test/Par/ISMIPD.par	(revision 5049)
@@ -0,0 +1,27 @@
+%Ok, start defining model parameters here
+
+disp('      creating thickness');
+md.surface=2000-md.x*tan(0.1*pi/180); %to have z>0
+md.bed=md.surface-1000;
+md.thickness=md.surface-md.bed;
+md.firn_layer=0*ones(md.numberofgrids,1);
+
+disp('      creating drag');
+md.drag_type=2; %0 none 1 plastic 2 viscous
+md.drag_coefficient=sqrt(md.yts.*(1000+1000*sin(md.x*2*pi/max(md.x)))./(md.g*(md.rho_ice*md.thickness+md.rho_water*md.bed)));
+%Take care of iceshelves: no basal drag
+pos=find(md.elementoniceshelf);
+md.drag_coefficient(md.elements(pos,:))=0;
+md.drag_p=ones(md.numberofelements,1);
+md.drag_q=ones(md.numberofelements,1);
+
+disp('      creating flow law paramter');
+md.rheology_B=6.8067*10^7*ones(md.numberofgrids,1);
+md.rheology_n=3*ones(md.numberofelements,1);
+
+disp('      boundary conditions for diagnostic model: ');
+%Create grid on boundary fist (because wi can not use mesh)
+md=SetIceSheetBC(md);
+
+md.np=8;
+md.cluster=oshostname();
