%% Condor question: "Poor man's spmd" using Condor
% Matlab scriptfile:  .../MatOhjelmistot/2016_2_syksySCI/Lectures/CondorQ.m
%
%% Example: Nlabs svd's, bring results to client
Nlabs=2;   % Laptop
% Nlabs=4; % taisto@aalto.fi
% Nlabs=24 % Triton
%
n=5;  % for small demo
for k=1:Nlabs
    A{k}=rand(n,n);
end    
%%
spmd(Nlabs)
  [U,V,W]=svd(A{labindex});
end  
  
A{1}, U{1}*V{1}*W{1}'
%% How about Condor, try files.

save('Afile.mat','A')  % Works but can't use here
% load('Afile.mat')

for k=1:Nlabs
    Atemp=A{k};
    save(['A',num2str(k),'file.mat'],'Atemp')
end    
% Include variables U,V,W in the same loop

%%
delete(gcp)
