1 | function md=solveparallel(md,options)
|
---|
2 | %SOLVEPARALLEL - solution sequence using a cluster in parallel mode
|
---|
3 | %
|
---|
4 | % Usage:
|
---|
5 | % md=solveparallel(md);
|
---|
6 |
|
---|
7 | %retrieve cluster: otherwise, we can't call its methods (subsref bug)
|
---|
8 | cluster=md.cluster;
|
---|
9 |
|
---|
10 | if options.loadonly,
|
---|
11 | md=loadresultsfromcluster(md);
|
---|
12 | else
|
---|
13 |
|
---|
14 | %First, build a runtime name that is unique, that we will use to create
|
---|
15 | %directories, name jobs, etc ...
|
---|
16 | c=clock; md.private.runtimename=sprintf('%s-%i-%i-%i-%i-%i-%i-%i',md.miscellaneous.name,c(2),c(3),c(1),c(4),c(5),floor(c(6)),feature('GetPid'));
|
---|
17 |
|
---|
18 | if verLessThan('matlab', '7.6')
|
---|
19 | BuildQueueScript(cluster,md);
|
---|
20 | LaunchQueueJob(cluster,md,options);
|
---|
21 | else
|
---|
22 | cluster.BuildQueueScript(md);
|
---|
23 | cluster.LaunchQueueJob(md,options);
|
---|
24 | end
|
---|
25 |
|
---|
26 | if ~strcmpi(options.upload,'on'), %did we even try to run? if so, wait on lock
|
---|
27 |
|
---|
28 | %Do we return, or just wait for results?
|
---|
29 | if (md.settings.waitonlock>0 & ~strcmpi(options.batch,'yes')),
|
---|
30 | %we wait for the done file
|
---|
31 | islock=waitonlock(md);
|
---|
32 | if islock==0,
|
---|
33 | %no results to be loaded
|
---|
34 | disp('The results must be loaded manually with md=loadresultsfromcluster(md).');
|
---|
35 | else
|
---|
36 | %load results
|
---|
37 | disp('loading results from cluster');
|
---|
38 | md=loadresultsfromcluster(md);
|
---|
39 | end
|
---|
40 | end
|
---|
41 |
|
---|
42 | %post processes qmu results if necessary
|
---|
43 | if md.qmu.isdakota,
|
---|
44 | if ~strncmpi(options.keep,'y',1)
|
---|
45 | system(['rm -rf qmu' num2str(feature('GetPid'))]);
|
---|
46 | end
|
---|
47 | end
|
---|
48 | else
|
---|
49 | error('solveparallel done uploading test decks');
|
---|
50 | end
|
---|
51 |
|
---|
52 | end
|
---|