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