Index: /issm/trunk/src/m/classes/runsteps.m
===================================================================
--- /issm/trunk/src/m/classes/runsteps.m	(revision 6095)
+++ /issm/trunk/src/m/classes/runsteps.m	(revision 6096)
@@ -8,18 +8,26 @@
 %      rs = runsteps('../Models/');               %build an empty runsteps object with a given repository
 %      rs = runsteps('../Models/','models.AGU.'); %build an empty runsteps object with a given repository and a prefix
+%      rs = runsteps('../Models/','models.AGU.','model.init'); %repository, prefix, and initial trunk prefix
 
 classdef runsteps
     properties (SetAccess=public) 
 		 % {{{1
-		 repository='./';
-		 prefix    ='model.';
-		 steps     =[];
+		 repository  ='./';
+		 prefix      ='model.';
+		 trunkprefix ='';
+		 steps       =[];
 		 %}}}
 	 end
 	 methods
 		 function rs=runsteps(varargin) % {{{1
-			 if nargin>2,
+			 if nargin>3,
 				 help runsteps
 				 error('runsteps constructor error message: bad usage');
+			 end
+			 if nargin>2,
+				 trunkprefix=varargin{3};
+				 if ~ischar(trunkprefix),                                 error('trunkprefix is not a string'); end
+				 if ~strcmp(regexprep(trunkprefix,'\s+',''),trunkprefix), error('trunkprefix should not have any white space'); end
+				 rs.trunkprefix=trunkprefix;
 			 end
 			 if nargin>1,
@@ -96,14 +104,27 @@
 		 function md=loadmodel(rs,string),% {{{1
 
-			 %Some checks
+			 %Get model path
 			 if ~ischar(string), error('argument provided is not a string'); end
-
-			 %Get model path
-			 id=GetId(rs,string);
-			 path=[rs.repository '/' rs.prefix rs.steps(id).string];
+			 path=[rs.repository '/' rs.prefix string];
 
 			 %figure out if the model is there, otherwise, we have to use the default path supplied by user.
-			 if ~exist(path,'file'), error(['File ' path ' not found']); end
-			 md=loadmodel(path);
+			 if exist(path,'file'),
+				 md=loadmodel(path);
+				 return;
+			 end
+
+			 %If we are here, the model has not been found. Try trunk prefix if provided
+			 if ~isempty(rs.trunkprefix),
+				 path2=[rs.repository '/' rs.trunkprefix string];
+				 if ~exist(path2,'file'),
+					 error(['Could neither find ' path ', nor ' path2]);
+				 else
+					 disp(['--> Branching ' rs.prefix ' from trunk ' rs.trunkprefix]);
+					 md=loadmodel(path2);
+					 return;
+				 end
+			 else
+				 error(['Could not find ' path ]);
+			 end
 		 end%}}}
 		 function message(rs,num) % {{{1
