I am having some difficulty running parfor loops on a cluster. The parfor loop is within a while loop. When I run the script on the cluster, the parallel pool is restarted at each iteration of the for loop. However when I run the code on my machine, the parallel pool is only initialized a single time. Some example code is below. The output from the below code shows "Starting parallel pool (parpool) using the 'local' profile ..." at each iteration of the while loop when run on the cluster. Any thoughts why the parallel pool is being restarted over and over?
while it<=maxit & diff>tol;
it=it+1;
Prev_It=S_e_vfun;
parfor k=1:(2*nsearch+1)^3
for i=1:nz
for ii=1:nw
S_e_vfun(ii,:,i,k)= MATRIX CALCULATIONS..
end
end
end
diff=max(max(max(max(abs(S_e_vfun(:,:,:,:)-Prev_It(:,:,:,:))))))
end