1 | function mds=solve(mds,varargin)
|
---|
2 | %SOLVE - apply solution sequence for a list of models. Used in batch mode.
|
---|
3 | %
|
---|
4 | % Usage:
|
---|
5 | % mds=solve(mds,varargin)
|
---|
6 | % where varargin is a lit of paired arguments.
|
---|
7 | % arguments can be: 'analysis_type': 'diagnostic','thermal','prognostic','transient'
|
---|
8 | %
|
---|
9 | % Examples:
|
---|
10 | % mds=solve(mds,'analysis_type','diagnostic');
|
---|
11 |
|
---|
12 | %recover options
|
---|
13 | options=pairoptions(varargin{:});
|
---|
14 |
|
---|
15 | %add default options
|
---|
16 | options=process_solve_options(options);
|
---|
17 |
|
---|
18 | %length of list
|
---|
19 | nummodels=length(mds.models);
|
---|
20 |
|
---|
21 | %name of queue: to make it unique, add a time stamp
|
---|
22 | name=[mds.name '-' datestr(now,1) '-' datestr(now,'HH-MM-SS') ];
|
---|
23 |
|
---|
24 | %name of cluster will be first name of list
|
---|
25 | cluster=mds.cluster;
|
---|
26 |
|
---|
27 | %Figure out parameters for this particular cluster
|
---|
28 | cluster_rc_location=which('cluster.rc');
|
---|
29 | [codepath,executionpath]=ClusterParameters(cluster,cluster_rc_location);
|
---|
30 |
|
---|
31 | %solve in batch mode:
|
---|
32 | for i=1:nummodels,
|
---|
33 |
|
---|
34 | %model
|
---|
35 | mdex=mds.models{i};
|
---|
36 |
|
---|
37 | %recover some fields
|
---|
38 | mdex.analysis_type=options.analysis_type;
|
---|
39 |
|
---|
40 | mdex.name=[name '-' num2str(i) 'vs' num2str(nummodels)];
|
---|
41 | mdex.time=mds.time;
|
---|
42 | mdex.queue=mds.queue;
|
---|
43 | mdex.cluster=mds.cluster;
|
---|
44 | if ~isnan(mds.np),
|
---|
45 | mdex.np=mds.np;
|
---|
46 | end
|
---|
47 |
|
---|
48 | %call solve in batch mode:
|
---|
49 | if strcmpi(cluster,oshostname),
|
---|
50 | mdex=solve(mdex,varargin{:});
|
---|
51 | else
|
---|
52 | mdex=solve(mdex,varargin{:},'batch','yes','directory',name);
|
---|
53 | end
|
---|
54 |
|
---|
55 | %feed back
|
---|
56 | mds.models{i}=mdex;
|
---|
57 | end
|
---|
58 |
|
---|
59 | %locally, we are done.
|
---|
60 | if strcmpi(cluster,oshostname),
|
---|
61 | return
|
---|
62 | end
|
---|
63 |
|
---|
64 |
|
---|
65 | %now, tar all the files and then erase them.
|
---|
66 | eval(['!find -iname ''' name '-*'' > file_list.txt']);
|
---|
67 | !tar zcvf ModelList.tar.gz --files-from file_list.txt
|
---|
68 | !rm -rf *.bin *.queue file_list.txt
|
---|
69 |
|
---|
70 | %still have to build a launching script.
|
---|
71 | BuildMultipleQueueingScript(cluster,name,executionpath,codepath);
|
---|
72 |
|
---|
73 | %launch jobs on remote cluster
|
---|
74 | LaunchMultipleQueueJob(cluster,name,executionpath);
|
---|
75 |
|
---|
76 | %erase files:
|
---|
77 | delete([name '.queue']);
|
---|
78 | delete('ModelList.tar.gz');
|
---|
79 |
|
---|
80 | %save name:
|
---|
81 | mds.name=name;
|
---|