Index: /issm/trunk/src/m/classes/model.m
===================================================================
--- /issm/trunk/src/m/classes/model.m	(revision 8371)
+++ /issm/trunk/src/m/classes/model.m	(revision 8372)
@@ -5,5 +5,5 @@
 
 classdef model
-    properties (SetAccess=public) 
+    properties (SetAccess=public) %Model fields
 		 % {{{1
 		 %Careful here: no other class should be used as default value
@@ -24,5 +24,5 @@
 
 		 %Mesh
-		 bamg=NaN;
+		 bamg=struct();
 		 dim=0;
 		 numberofelements=0;
@@ -183,5 +183,5 @@
 
 		 %Forcings
-		 forcings=NaN;
+		 forcings=struct();
 
 		 %Statics parameters
@@ -358,4 +358,108 @@
 		 vwgt=[];
 		 %}}}
+	 end
+	 properties(Dependent,Hidden) %Deprecated property
+		 % {{{
+		 % We must keep here ALL deprecated properties
+		 % This ensures that when a model object from a previous version
+		 % all fields are recovered.
+		 % loadobj is then used to assign old properties to new properties
+		 % But if we don't keep the old properties here, they would not be
+		 % recovered when the model is loaded
+		 drag;
+		 p;
+		 q;
+		 B;
+		 n;
+		 melting;
+		 accumulation;
+		 type;
+		 numberofgrids;
+		 numberofgrids2d;
+		 gridonhutter;
+		 gridonmacayeal;
+		 gridonpattyn;
+		 gridonstokes;
+		 uppergrids;
+		 lowergrids;
+		 gridonbed;
+		 gridonsurface;
+		 extractedgrids;
+		 gridoniceshelf;
+		 gridonicesheet;
+		 gridonwater;
+		 gridonnuna;
+		 gridonboundary;
+		 % }}}
+	 end
+	 methods (Static)
+		 function md = loadobjk(md) % {{{
+			 % This function is directly called by matlab when
+			 % a model object is loaded. If the input is a struct
+			 % it is an old version of model and old fields must be 
+			 % recovered (make sure they are in the deprecated
+			 % model properties)
+
+			 if isstruct(md)
+				 disp('Recovering model object from a previous version');
+
+				 %Ok the loaded model is a struct, initialize output and recover all fields
+				 structmd=md;
+				 md=model;
+
+				 structfields=fields(structmd);
+				 modelprops  =properties(md);
+
+				 for i=1:length(structfields),
+					 fieldname =structfields{i};
+					 fieldvalue=getfield(structmd,fieldname);
+					 if ismember(fieldname,modelprops),
+						 md=setfield(md,fieldname,fieldvalue);
+					 end
+				 end
+
+				 %Field name change
+				 if isfield(structmd,'drag'), md.drag_coefficient=structmd.drag; end
+				 if isfield(structmd,'p'), md.drag_p=structmd.p; end
+				 if isfield(structmd,'q'), md.drag_q=structmd.p; end
+				 if isfield(structmd,'B'), md.rheology_B=structmd.B; end
+				 if isfield(structmd,'n'), md.rheology_n=structmd.n; end
+				 if isfield(structmd,'melting'), md.melting_rate=structmd.melting; end
+				 if isfield(structmd,'accumulation'), md.accumulation_rate=structmd.accumulation; end
+				 if isfield(structmd,'numberofgrids'), md.numberofnodes=structmd.numberofgrids; end
+				 if isfield(structmd,'numberofgrids2d'), md.numberofnodes2d=structmd.numberofgrids2d; end
+				 if isfield(structmd,'gridonhutter'), md.nodeonhutter=structmd.gridonhutter; end
+				 if isfield(structmd,'gridonmacayeal'), md.nodeonmacayeal=structmd.gridonmacayeal; end
+				 if isfield(structmd,'gridonpattyn'), md.nodeonpattyn=structmd.gridonpattyn; end
+				 if isfield(structmd,'gridonstokes'), md.nodeonstokes=structmd.gridonstokes; end
+				 if isfield(structmd,'uppergrids'), md.uppernodes=structmd.uppergrids; end
+				 if isfield(structmd,'lowergrids'), md.lowernodes=structmd.lowergrids; end
+				 if isfield(structmd,'gridonbed'), md.nodeonbed=structmd.gridonbed; end
+				 if isfield(structmd,'gridonsurface'), md.nodeonsurface=structmd.gridonsurface; end
+				 if isfield(structmd,'extractedgrids'), md.extractednodes=structmd.extractedgrids; end
+				 if isfield(structmd,'gridoniceshelf'), md.nodeoniceshelf=structmd.gridoniceshelf; end
+				 if isfield(structmd,'gridonicesheet'), md.nodeonicesheet=structmd.gridonicesheet; end
+				 if isfield(structmd,'gridonwater'), md.nodeonwater=structmd.gridonwater; end
+				 if isfield(structmd,'gridonnuna'), md.nodeonnuna=structmd.gridonnuna; end
+				 if isfield(structmd,'gridonboundary'), md.nodeonboundary=structmd.gridonboundary; end
+
+				 %Field class change
+				 if (isfield(structmd,'type') & ischar(structmd.type)), 
+					 if strcmpi(structmd.type,'2d'), md.dim=2; end
+					 if strcmpi(structmd.type,'3d'), md.dim=3; end
+				 end
+				 if isnumeric(md.verbose), md.verbose=verbose; end
+
+				 %New fields
+				 if ~isfield(structmd,'upperelements');
+					 md.upperelements=transpose(1:md.numberofelements)+md.numberofelements2d;
+					 md.upperelements(end-md.numberofelements2d+1:end)=NaN;
+				 end
+				 if ~isfield(structmd,'lowerelements');
+					 md.lowerelements=transpose(1:md.numberofelements)-md.numberofelements2d;
+					 md.lowerelements(1:md.numberofelements2d)=NaN;
+				 end
+			 end
+		 end% }}}
 	 end
 	 methods
Index: /issm/trunk/src/m/classes/plotoptions.m
===================================================================
--- /issm/trunk/src/m/classes/plotoptions.m	(revision 8371)
+++ /issm/trunk/src/m/classes/plotoptions.m	(revision 8372)
@@ -109,4 +109,7 @@
 							 nums=strsplit(plotnum,'-');
 							 if length(nums)~=2, continue; end
+							 if ~isnumeric(nums)
+								 error(['the option #i-j is not set properly for ' field]);
+							 end
 							 for j=nums(1):nums(2),
 								 opt.list{j}=addfield(opt.list{j},field,rawoptions.list{i,2});
Index: /issm/trunk/src/m/model/marshall.m
===================================================================
--- /issm/trunk/src/m/model/marshall.m	(revision 8371)
+++ /issm/trunk/src/m/model/marshall.m	(revision 8372)
@@ -114,5 +114,5 @@
 	for i=1:numforcings,
 		forcing=md.forcings.(forcingnames{i});
-		forcingname=forcingnames{i};
+		forcingname=EnumToString(forcingtypes(i));
 
 		WriteData(fid,size(forcing,2),'Integer',['forcing_' forcingname '_num_time_steps']);
