Index: /issm/trunk-jpl/src/m/solve/parseresultsfromdisk.m
===================================================================
--- /issm/trunk-jpl/src/m/solve/parseresultsfromdisk.m	(revision 25560)
+++ /issm/trunk-jpl/src/m/solve/parseresultsfromdisk.m	(revision 25561)
@@ -7,5 +7,4 @@
 end
 
-
 function results=parseresultsfromdiskioserial(md,filename) % {{{
 
@@ -15,44 +14,9 @@
 	error(['loadresultsfromdisk error message: could not open ',filename,' for binary reading']);
 end
-results=struct();
-
-%Read fields until the end of the file.
-result  = ReadData(fid,md);
-if isempty(result), error(['no results found in binary file ' filename]); end
-check_nomoresteps=0;
-counter = 1;
-step    = result.step;
-while ~isempty(result),
-
-	if check_nomoresteps,
-		%check that the new result does not add a step, which would be an error:
-		if result.step>=1,
-			error('parsing results for a steady-state core, which incorporates transient results!');
-		end
-	end
-
-	%Check step, increase counter if this is a new step
-	if(step~=result.step & result.step>1)
-		counter = counter + 1;
-		step    = result.step;
-	end
-
-	%Add result
-	if(result.step==0),
-		%if we have a step = 0, this is a steady state solution, don't expect more steps.
-		index = 1;
-		check_nomoresteps=1;
-	elseif(result.step==1),
-		index = 1;
-	else
-		index = counter;
-	end
-	if(result.step~=-9999),
-		results(index).step=result.step;
-	end
-	if(result.time~=-9999),
-		results(index).time=result.time;
-	end
-	results(index).(result.fieldname)=result.field;
+
+%Collect all results in a cell array
+allresults = {};
+counter    = 1;
+while(true)
 
 	%read next result
@@ -61,10 +25,45 @@
 	catch me,
 		disp('WARNING: file corrupted, trying partial recovery');
-		result=[];
-	end
-
-end
-
+		continue;
+	end
+
+	%Have we reached the end of the file?
+	if isempty(result),
+		if counter==1
+			error(['no results found in binary file ' filename]);
+		else
+			break;
+		end
+	end
+
+	%Add result to cell array
+	allresults{counter} = result;
+	counter = counter+1;
+end
 fclose(fid);
+
+%Now, process all results and find how many steps we have
+numresults = numel(allresults);
+allsteps   = zeros(numresults,1);
+for i=1:numresults
+	allsteps(i) = allresults{i}.step;
+end
+pos = find(allsteps~=-9999);
+allsteps = sort(unique(allsteps(pos)));
+
+%Ok, now construct structure
+results=struct();
+for i=1:numresults
+	result = allresults{i};
+
+	index = 1;
+	if result.step ~= -9999
+		index = find(result.step == allsteps);
+	end
+
+	if(result.step~=-9999) results(index).step=result.step; end
+	if(result.time~=-9999) results(index).time=result.time; end
+	results(index).(result.fieldname)=result.field;
+end
 % }}}
 function results=parseresultsfromdiskiosplit(md,filename) % {{{
