source: issm/trunk/src/m/classes/@modellist/modellist.m@ 11527

Last change on this file since 11527 was 2912, checked in by Eric.Larour, 15 years ago

Created modellist class, with its own methods, made out of lists of models
that need to be solved for on a cluster.

File size: 1.5 KB
Line 
1function mds = modellist(varargin)
2%MODEL - constructor for a list of models
3%
4% Usage:
5% mds = modellist(varargin)
6
7switch nargin
8
9case 0
10
11 % if no input arguments, create a default object
12 mds.models=cell(0,1);
13
14 %fields:
15 mds.name='';
16 mds.cluster='';
17 mds.queue='';
18 mds.time=0;
19 mds.np=0;
20
21 %output
22 mds=class(mds,'modellist');
23
24 %set default parameters
25 mds=setdefaultparameters(mds);
26
27case 1
28
29 %If single argument of class model, we have a copy constructor.
30 if (isa(varargin{1},'modellist'))
31 mds = varargin{1};
32 elseif (isa(varargin{1},'cell'))
33 celllist=varargin{1};
34
35 %user gave us a list of models, plug them in mds.models, and do some set up
36 mds=modellist;
37
38 %check on size of cell list:
39 if (size(celllist,2)~=1),
40 error('modellist constructor error message: list of models should be a cell list of column size 1');
41 end
42
43 %check that only models are in the celllist:
44 for i=1:size(celllist,1),
45 md=celllist{i};
46 if ~isa(md,'model')
47 error(['modellist constructor error message: element ' num2str(i) ' of cell list is not a model!']);
48 end
49 end
50
51 %initialize
52 mds.models=celllist;
53
54 %set some default parameters:
55 if size(celllist,1),
56 %pick up 1st model for default parameters
57 mds.cluster=mds.models{1}.cluster;
58 mds.name=mds.models{1}.name;
59 mds.queue=mds.models{1}.queue;
60 mds.time=mds.models{1}.time;
61 end
62 else
63 error('model constructor error message: copy constructor called on a non ''model'' class object');
64 end
65otherwise
66 error('model constructor error message: 0 of 1 argument only in input.');
67end
Note: See TracBrowser for help on using the repository browser.