1 | function [B E]=pkriging(x,y,observations,x_interp,y_interp,varargin)
|
---|
2 | %PKRIGING - parallel Kriging
|
---|
3 | %
|
---|
4 | % Usage:
|
---|
5 | % [B E]=pkriging(x,y,observations,x_interp,y_interp,varargin);
|
---|
6 |
|
---|
7 | options=pairoptions(varargin{:});
|
---|
8 | cluster=getfieldvalue(options,'cluster',generic('np',1));
|
---|
9 | options=removefield(options,'cluster',0);
|
---|
10 | name = ['krig' num2str(feature('GetPid'))];
|
---|
11 |
|
---|
12 | % ========================================= MARSHALL.m =================================================
|
---|
13 | disp(['marshalling file ' name '.bin']);
|
---|
14 | fid=fopen([name '.bin'],'wb');
|
---|
15 | if fid==-1,
|
---|
16 | error(['marshall error message: could not open ' name '.bin file for binary writing']);
|
---|
17 | end
|
---|
18 |
|
---|
19 | %First, write MaximumNumberOfDefinitionsEnum to make sure that the Enums are synchronized
|
---|
20 | WriteData(fid,'enum',MaximumNumberOfDefinitionsEnum(),'data',true,'format','Boolean');
|
---|
21 |
|
---|
22 | %Write all data
|
---|
23 | WriteData(fid,'enum',0,'data',x,'format','DoubleMat');
|
---|
24 | WriteData(fid,'enum',1,'data',y,'format','DoubleMat');
|
---|
25 | WriteData(fid,'enum',2,'data',observations,'format','DoubleMat');
|
---|
26 | WriteData(fid,'enum',3,'data',x_interp,'format','DoubleMat');
|
---|
27 | WriteData(fid,'enum',4,'data',y_interp,'format','DoubleMat');
|
---|
28 |
|
---|
29 | %Last, write MaximumNumberOfEnum+1 to make sure that the binary file is not corrupt
|
---|
30 | WriteData(fid,'enum',MaximumNumberOfDefinitionsEnum()+1,'data',true,'format','Boolean');
|
---|
31 |
|
---|
32 | %Now, write number of options
|
---|
33 | options.marshall(fid,5);
|
---|
34 | st=fclose(fid);
|
---|
35 | if st==-1,
|
---|
36 | error(['marshall error message: could not close file ' name '.bin']);
|
---|
37 | end
|
---|
38 | % ========================================= MARSHALL.m =================================================
|
---|
39 |
|
---|
40 | %Launch job on remote cluster
|
---|
41 | BuildKrigingQueueScript(cluster,name,'',1,0,0); %gather, valgrind, gprof
|
---|
42 | LaunchQueueJob(cluster,name,name,{[name '.bin'] [name '.queue']});
|
---|
43 |
|
---|
44 | %Call waitonlock
|
---|
45 | md=model; md.cluster=cluster; md.settings.waitonlock=Inf; md.private.runtimename=name;md.miscellaneous.name=name;
|
---|
46 | waitonlock(md);
|
---|
47 |
|
---|
48 | %Download
|
---|
49 | Download(cluster,name,{[name '.outbin']});
|
---|
50 | structure=parseresultsfromdisk([name '.outbin'],0);
|
---|
51 | delete([name '.outlog']);
|
---|
52 | delete([name '.errlog']);
|
---|
53 | delete([name '.outbin']);
|
---|
54 | delete([name '.bin']);
|
---|
55 | if ~ispc(),
|
---|
56 | delete([name '.tar.gz']);
|
---|
57 | end
|
---|
58 |
|
---|
59 | %Process results
|
---|
60 | B=structure.(EnumToString(0));
|
---|
61 | B=reshape(B,size(x_interp,2),size(x_interp,1))';
|
---|
62 | E=structure.(EnumToString(1));
|
---|
63 | E=reshape(E,size(x_interp,2),size(x_interp,1))';
|
---|