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',10));
|
---|
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 MaximumNumberOfEnum to make sure that the Enums are synchronized
|
---|
20 | WriteData(fid,'enum',MaximumNumberOfEnums(),'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 | options.marshall(fid,5);
|
---|
29 | st=fclose(fid);
|
---|
30 | if st==-1,
|
---|
31 | error(['marshall error message: could not close file ' name '.bin']);
|
---|
32 | end
|
---|
33 | % ========================================= MARSHALL.m =================================================
|
---|
34 |
|
---|
35 | %Launch job on remote cluster
|
---|
36 | BuildKrigingQueueScript(cluster,name,'',1,0,0); %gather, valgrind, gprof
|
---|
37 | tic
|
---|
38 | LaunchQueueJob(cluster,name,name,{[name '.bin'] [name '.queue']});
|
---|
39 | toc
|
---|
40 | choice=input('Is the job successfully completed? (y/n)','s');
|
---|
41 | Download(cluster,name,{[name '.outbin']});
|
---|
42 | structure=parseresultsfromdisk([name '.outbin'],0);
|
---|
43 | delete([name '.outlog']);
|
---|
44 | delete([name '.errlog']);
|
---|
45 | delete([name '.outbin']);
|
---|
46 | delete([name '.bin']);
|
---|
47 | if ~ispc,
|
---|
48 | delete([name '.tar.gz']);
|
---|
49 | end
|
---|
50 |
|
---|
51 | %Process results
|
---|
52 | B=structure.AutodiffForward;
|
---|
53 | B=reshape(B,size(x_interp,2),size(x_interp,1))';
|
---|
54 | E=structure.AutodiffIsautodiff;
|
---|
55 | E=reshape(E,size(x_interp,2),size(x_interp,1))';
|
---|