Index: /issm/trunk-jpl/src/m/classes/model.m
===================================================================
--- /issm/trunk-jpl/src/m/classes/model.m	(revision 27029)
+++ /issm/trunk-jpl/src/m/classes/model.m	(revision 27030)
@@ -1752,52 +1752,67 @@
 
 		end % }}}
-		function savemodeljs(md,modelname,websiteroot,varargin) % {{{
-		
-			%the goal of this routine is to save the model as a javascript array that can be included in any html 
-			%file: 
-
-			options=pairoptions(varargin{:});
-			optimization=getfieldvalue(options,'optimize',0);
-
-			
-			%disp: 
-			disp(['saving model ''' modelname ''' in file ' websiteroot '/js/' modelname '.js']);
-
-			%open file for writing and declare the model:
-			fid=fopen([websiteroot '/js/' modelname '.js'],'w');
-			fprintf(fid,'var %s=new model();\n',modelname);
-
-			%now go through all the classes and fwrite all the corresponding fields: 
-			
-			fields=properties('model');
+		function saveasstruct(md,filename) % {{{
+
+			fields=sort(properties('model')); %sort fields so that comparison of binary files is easier
+			disp('Converting all model fields to struct...');
+			warning off MATLAB:structOnObject
 			for i=1:length(fields),
 				field=fields{i};
-
-				%Some properties do not need to be saved
-				if ismember(field,{'results','cluster' }),
-					continue;
-				end
-
-				%some optimization: 
-				if optimization==1,
-					%optimize for plotting only:
-					if ~ismember(field,{'geometry','mesh','mask'}),
-						continue;
-					end
-				end
-
-				%Check that current field is an object
-				if ~isobject(md.(field))
-					error(['field ''' char(field) ''' is not an object']);
-				end
-
-				%savemodeljs for current object
-				%disp(['javascript saving ' field '...']);
-				savemodeljs(md.(field),fid,modelname);
-			end
-
-			%done, close file:
-			fclose(fid);
+				md.(field) = struct(md.(field));
+			end
+			disp('Converting model to struct...');
+			md=struct(md);
+			warning on MATLAB:structOnObject
+			disp(['Saving as ' filename '...']);
+			save(filename,'md','-v7.3')
+		end % }}}
+function savemodeljs(md,modelname,websiteroot,varargin) % {{{
+
+	%the goal of this routine is to save the model as a javascript array that can be included in any html 
+	%file: 
+
+	options=pairoptions(varargin{:});
+	optimization=getfieldvalue(options,'optimize',0);
+
+
+	%disp: 
+	disp(['saving model ''' modelname ''' in file ' websiteroot '/js/' modelname '.js']);
+
+	%open file for writing and declare the model:
+	fid=fopen([websiteroot '/js/' modelname '.js'],'w');
+	fprintf(fid,'var %s=new model();\n',modelname);
+
+	%now go through all the classes and fwrite all the corresponding fields: 
+
+	fields=properties('model');
+	for i=1:length(fields),
+		field=fields{i};
+
+		%Some properties do not need to be saved
+		if ismember(field,{'results','cluster' }),
+			continue;
 		end
+
+		%some optimization: 
+		if optimization==1,
+			%optimize for plotting only:
+			if ~ismember(field,{'geometry','mesh','mask'}),
+				continue;
+			end
+		end
+
+		%Check that current field is an object
+		if ~isobject(md.(field))
+			error(['field ''' char(field) ''' is not an object']);
+		end
+
+		%savemodeljs for current object
+		%disp(['javascript saving ' field '...']);
+		savemodeljs(md.(field),fid,modelname);
 	end
- end
+
+	%done, close file:
+	fclose(fid);
+end
+	end
+end
