[13730] | 1 | function [B E]=pkriging(x,y,observations,x_interp,y_interp,varargin)
|
---|
[12378] | 2 | %PKRIGING - parallel Kriging
|
---|
| 3 | %
|
---|
| 4 | % Usage:
|
---|
| 5 | % [B E]=pkriging(x,y,observations,x_interp,y_interp,varargin);
|
---|
| 6 |
|
---|
| 7 | options=pairoptions(varargin{:});
|
---|
[15229] | 8 | cluster=getfieldvalue(options,'cluster',generic('np',1));
|
---|
[12384] | 9 | options=removefield(options,'cluster',0);
|
---|
[12662] | 10 | name = ['krig' num2str(feature('GetPid'))];
|
---|
[12378] | 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 |
|
---|
[16250] | 19 | %First, write MaximumNumberOfDefinitionsEnum to make sure that the Enums are synchronized
|
---|
| 20 | WriteData(fid,'enum',MaximumNumberOfDefinitionsEnum(),'data',true,'format','Boolean');
|
---|
[12378] | 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');
|
---|
[16515] | 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
|
---|
[12384] | 33 | options.marshall(fid,5);
|
---|
[12378] | 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']});
|
---|
[15229] | 43 |
|
---|
| 44 | %Call waitonlock
|
---|
[15572] | 45 | md=model; md.cluster=cluster; md.settings.waitonlock=Inf; md.private.runtimename=name;md.miscellaneous.name=name;
|
---|
| 46 | waitonlock(md);
|
---|
[15229] | 47 |
|
---|
| 48 | %Download
|
---|
[12378] | 49 | Download(cluster,name,{[name '.outbin']});
|
---|
[12662] | 50 | structure=parseresultsfromdisk([name '.outbin'],0);
|
---|
| 51 | delete([name '.outlog']);
|
---|
| 52 | delete([name '.errlog']);
|
---|
| 53 | delete([name '.outbin']);
|
---|
| 54 | delete([name '.bin']);
|
---|
[13170] | 55 | if ~ispc(),
|
---|
[12662] | 56 | delete([name '.tar.gz']);
|
---|
| 57 | end
|
---|
[12378] | 58 |
|
---|
| 59 | %Process results
|
---|
[15229] | 60 | B=structure.(EnumToString(0));
|
---|
[12662] | 61 | B=reshape(B,size(x_interp,2),size(x_interp,1))';
|
---|
[15229] | 62 | E=structure.(EnumToString(1));
|
---|
[12662] | 63 | E=reshape(E,size(x_interp,2),size(x_interp,1))';
|
---|