Help! "Parfor" error: Subscripted assignment dimension mismatch
Show older comments
Hi. I'm converting some sequential codes into parallel codes. The former works well. But I came across the following errors when running the parallel codes. Can anyone help me? Thanks.
??? Error using ==> parallel_function>make_general_channel/channel_general at 843 Subscripted assignment dimension mismatch.
Error in ==> parallel_function>distributed_execution at 752 [tags, out] = P.getCompleteIntervals(chunkSize);
Error in ==> parallel_function at 564 R = distributed_execution(...
Error in ==> SensitivityForNaturalBreachFreqParfor3 at 8 SANaturalBreachFreq = zeros(4,14);
??? Operation terminated by user during ==> NormalFlow
In ==> NaturalBreachFreq at 275 [h_begin, u_begin] = NormalFlow(Q_begin,B_prtC,s_prtC,n_prtC);
In ==> parallel_function>make_general_channel/channel_general at 843 O = F(C{:});
In ==> remoteParallelFunction at 28 out = distcompMakeByteBufferHandle(distcompserialize(feval(channel, channelArgs{:})));
****************The parallel codes:
SANaturalBreachFreq = zeros(4,14); % The outputs
parfor i=1:4 % Test four iterations
V = zeros(1,14);
V(i,1:3) = SA3Parameters(i,1:3); % All inputs loaded into the workspace
[Z_prtC,Z_levee] = ChnlElevations(H_prtC,V(i,1),rDep_chnl,rDep_bsn);
E_weak = 0.2*V(i,2)^(-0.5)*1e-6;
Lweak = 0.05*L_prtC/V(i,3);
[BreachYearNo,BigBreachYearNo,BreachNo,BigBreachNo,AvulsionNo,AllBreachNo,MajorBreachW,MajorBreachQout_pct,...
Avulsion,AllBreachYearNo]...
= NaturalBreachFreq(Qd,Qsd,Qpct_overtop,Qpct_bifur,Qpct_avlsn,yBifur,Big_pct,H_prtC,Z_prtC,Z_levee,...
B_prtC,s_prtC,n_prtC,tauCr,V(i,2),nDcr,V(i,3),Lweak,E,E_weak,D_breach0,B_breach0,dL,n_star,...
n_breach,dL_outfl,p_wash,d50,ws_m,rho_s,rho_m,p,dt);
V(i,4) = AvulsionNo;
if ~isempty(Avulsion)
V(i,5) = Avulsion(1);
V(i,6) = Z_levee(Avulsion(3))/Hbar;
end
V(i,7) = AllBreachYearNo;
V(i,8) = BreachYearNo;
V(i,9) = BigBreachYearNo;
V(i,10) = AllBreachNo;
V(i,11) = BreachNo;
V(i,12) = BigBreachNo;
V(i,13) = MajorBreachW;
V(i,14) = MajorBreachQout_pct;
SANaturalBreachFreq(i,:) = V;
end
Accepted Answer
More Answers (1)
Jan
on 23 Oct 2012
Please use the debugger to find the source of the problems:
dbstop if error
Now Matlab stops when the error occurres - at least I hope this concerns your parallel parts of the code also.
Then you can inspect the dimensions of the local variables to find out, what's going on. At least you can post the corresponding line only, instead of a bunch of correctly working lines.
Remark:
0.2*V(i,2)^(-0.5)*1e-6;
can be written more efficient as:
0.2e-6 / sqrt(V(i, 2));
3 Comments
Edric Ellis
on 23 Oct 2012
Unfortunately, MATLAB's debugger cannot debug problems on the matlabpool workers. However, the debugger will work if the OP runs the problematic code including PARFOR with matlabpool closed.
Jan
on 23 Oct 2012
Thanks, Edric. There is a chance that replacing PARFOR by FOR might reveal the cause or the error also.
Yunzhen Chen
on 24 Oct 2012
Categories
Find more on Parallel for-Loops (parfor) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!