Index: /issm/trunk/src/m/classes/public/tres.m
===================================================================
--- /issm/trunk/src/m/classes/public/tres.m	(revision 5298)
+++ /issm/trunk/src/m/classes/public/tres.m	(revision 5299)
@@ -9,12 +9,26 @@
 
 if strcmpi(string,'diagnostic'),
-	md.vx=PatchToVec(md.results.DiagnosticSolution.Vx);
-	md.vy=PatchToVec(md.results.DiagnosticSolution.Vy);
-	if isfield(md.results.DiagnosticSolution,'Vz'),
-		md.vz=PatchToVec(md.results.DiagnosticSolution.Vz);
-	else
-		md.vz=zeros(md.numberofgrids,1);
+	if md.dim==2,
+		if isfield(md.results.DiagnosticSolution,'VxAverage'),
+			md.vx=PatchToVec(md.results.DiagnosticSolution.VxAverage);
+		else
+			md.vx=PatchToVec(md.results.DiagnosticSolution.Vx);
+		end
+		if isfield(md.results.DiagnosticSolution,'VyAverage'),
+			md.vy=PatchToVec(md.results.DiagnosticSolution.VyAverage);
+		else
+			md.vy=PatchToVec(md.results.DiagnosticSolution.Vy);
+		end
+	else 
+		md.vx=PatchToVec(md.results.DiagnosticSolution.Vx);
+		md.vy=PatchToVec(md.results.DiagnosticSolution.Vy);
+		if isfield(md.results.DiagnosticSolution,'Vz'),
+			md.vz=PatchToVec(md.results.DiagnosticSolution.Vz);
+		else
+			md.vz=zeros(md.numberofgrids,1);
+		end
+		md.vel=PatchToVec(md.results.DiagnosticSolution.Vel);
 	end
-	md.vel=PatchToVec(md.results.DiagnosticSolution.Vel);
+
 	if isfield(md.results.DiagnosticSolution,'Pressure'),
 		md.pressure=PatchToVec(md.results.DiagnosticSolution.Pressure);
@@ -26,5 +40,5 @@
 	end
 	if md.control_analysis==1,
-		md.(md.control_type)=PatchToVec(md.results.DiagnosticSolution.(md.results.DiagnosticSolution.ControlType))
+		md.(md.control_type)=PatchToVec(md.results.DiagnosticSolution.(md.results.DiagnosticSolution.ControlType));
 	end
 elseif strcmpi(string,'dakota'),
Index: /issm/trunk/src/m/classes/public/waitonlock.m
===================================================================
--- /issm/trunk/src/m/classes/public/waitonlock.m	(revision 5298)
+++ /issm/trunk/src/m/classes/public/waitonlock.m	(revision 5299)
@@ -23,5 +23,13 @@
 		while (ispresent==0 & time<timelimit)
 			[status, result]=system(['ssh -q -p ' num2str(port) ' ' login '@localhost "if ( -e ' executionpath '/' md.name '.lock ) echo 1"']);
-			ispresent=~isempty(result);
+			if ~isempty(result),
+				if ismember('1',result),
+					ispresent=1;
+				else
+					ispresent=0;
+				end
+			else
+				ispresent=0;
+			end
 			pause(10); %tunnel can be unstable, let's not use it too much
 			time=time+1/60;
