source: issm/trunk-jpl/src/m/model/solveparallel.m@ 11729

Last change on this file since 11729 was 11729, checked in by Eric.Larour, 13 years ago

Detect presence of petsc for solving in parallel. Otherwise, run with 1 cpu only

File size: 1.6 KB
Line 
1function 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)
8cluster=md.cluster;
9
10if options.loadonly,
11 md=loadresultsfromcluster(md);
12else
13
14 %In parallel mode, we need to make sure we have PETSC support, otherwise, we run with only one cpu:
15 if ~ispetsc,
16 disp('PETSC support not included, running on 1 cpu only!');
17 cluster.np=1;
18 end
19
20 %First, build a runtime name that is unique, that we will use to create
21 %directories, name jobs, etc ...
22 c=clock; md.private.runtimename=sprintf('%s-%02i-%02i-%04i-%02i-%02i-%02i-%i',md.miscellaneous.name,c(2),c(3),c(1),c(4),c(5),floor(c(6)),feature('GetPid'));
23
24 if verLessThan('matlab', '7.6')
25 BuildQueueScript(cluster,md);
26 LaunchQueueJob(cluster,md,options);
27 else
28 cluster.BuildQueueScript(md);
29 cluster.LaunchQueueJob(md,options);
30 end
31
32 if ~strcmpi(options.upload,'on'), %did we even try to run? if so, wait on lock
33
34 %Do we return, or just wait for results?
35 if (md.settings.waitonlock>0 & ~strcmpi(options.batch,'yes')),
36 %we wait for the done file
37 islock=waitonlock(md);
38 if islock==0,
39 %no results to be loaded
40 disp('The results must be loaded manually with md=loadresultsfromcluster(md).');
41 else
42 %load results
43 disp('loading results from cluster');
44 md=loadresultsfromcluster(md);
45 end
46 end
47
48 %post processes qmu results if necessary
49 if md.qmu.isdakota,
50 if ~strncmpi(options.keep,'y',1)
51 system(['rm -rf qmu' num2str(feature('GetPid'))]);
52 end
53 end
54 else
55 error('solveparallel done uploading test decks');
56 end
57
58end
Note: See TracBrowser for help on using the repository browser.