Changeset 6096


Ignore:
Timestamp:
09/30/10 07:59:03 (15 years ago)
Author:
Mathieu Morlighem
Message:

readded branching

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/m/classes/runsteps.m

    r6076 r6096  
    88%      rs = runsteps('../Models/');               %build an empty runsteps object with a given repository
    99%      rs = runsteps('../Models/','models.AGU.'); %build an empty runsteps object with a given repository and a prefix
     10%      rs = runsteps('../Models/','models.AGU.','model.init'); %repository, prefix, and initial trunk prefix
    1011
    1112classdef runsteps
    1213    properties (SetAccess=public)
    1314                 % {{{1
    14                  repository='./';
    15                  prefix    ='model.';
    16                  steps     =[];
     15                 repository  ='./';
     16                 prefix      ='model.';
     17                 trunkprefix ='';
     18                 steps       =[];
    1719                 %}}}
    1820         end
    1921         methods
    2022                 function rs=runsteps(varargin) % {{{1
    21                          if nargin>2,
     23                         if nargin>3,
    2224                                 help runsteps
    2325                                 error('runsteps constructor error message: bad usage');
     26                         end
     27                         if nargin>2,
     28                                 trunkprefix=varargin{3};
     29                                 if ~ischar(trunkprefix),                                 error('trunkprefix is not a string'); end
     30                                 if ~strcmp(regexprep(trunkprefix,'\s+',''),trunkprefix), error('trunkprefix should not have any white space'); end
     31                                 rs.trunkprefix=trunkprefix;
    2432                         end
    2533                         if nargin>1,
     
    96104                 function md=loadmodel(rs,string),% {{{1
    97105
    98                          %Some checks
     106                         %Get model path
    99107                         if ~ischar(string), error('argument provided is not a string'); end
    100 
    101                          %Get model path
    102                          id=GetId(rs,string);
    103                          path=[rs.repository '/' rs.prefix rs.steps(id).string];
     108                         path=[rs.repository '/' rs.prefix string];
    104109
    105110                         %figure out if the model is there, otherwise, we have to use the default path supplied by user.
    106                          if ~exist(path,'file'), error(['File ' path ' not found']); end
    107                          md=loadmodel(path);
     111                         if exist(path,'file'),
     112                                 md=loadmodel(path);
     113                                 return;
     114                         end
     115
     116                         %If we are here, the model has not been found. Try trunk prefix if provided
     117                         if ~isempty(rs.trunkprefix),
     118                                 path2=[rs.repository '/' rs.trunkprefix string];
     119                                 if ~exist(path2,'file'),
     120                                         error(['Could neither find ' path ', nor ' path2]);
     121                                 else
     122                                         disp(['--> Branching ' rs.prefix ' from trunk ' rs.trunkprefix]);
     123                                         md=loadmodel(path2);
     124                                         return;
     125                                 end
     126                         else
     127                                 error(['Could not find ' path ]);
     128                         end
    108129                 end%}}}
    109130                 function message(rs,num) % {{{1
Note: See TracChangeset for help on using the changeset viewer.