Error accessing global variables inside parfor. (addAttachedFiles ??)
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dear,
I have a code that defines some global vectors (X, Y, Z) and 3D arrays (U, V, W).
At some point I'm doing the following parfor loop:
parfor plab = 1: N_particles;
[i, j, k] = R2voxel(X(plab),Y(plab), Z(plab), resolution);
[uip, vip, wip] = V2part(X(plab),Y(plab), Z(plab), i,j,k);
if ( U(i+1,j,k) > 0.0 )
Flag_Average_u = Flag_Average_u + 1;
Total_u = Total_u + uip
end
end
where V2part is a simple linear interpolation between two grid points:
function [uip,vip,wip] = V2part(X,Y,Z,x2i,y2j,z2k)
hx=( U(x2i+1,y2j,z2k) - U(x2i,y2j,z2k))/deltax;
uip= U(x2i,y2j,z2k) + hx*(X -( x2i-1)* deltax)
hy=(V(x2i,y2j + 1,z2k) - V(x2i,y2j,z2k))/deltay;
vip=( V(x2i,y2j,z2k) + hy *(Y -(y2j-1) * deltay));
hz=( W(x2i,y2j,z2k+ 1) - W(x2i,y2j,z2k))/deltaz;
wip=( W(x2i,y2j,z2k)+ hz*(Z-(z2k -1)* deltaz));
and then I get the error:
Error using V2part (line 4) An UndefinedFunction error was thrown on the workers for 'U'. This may be because the file containing 'U' is not accessible on the workers. Specify the required files to this MATLAB pool using the matlabpool addAttachedFiles command. See the documentation for matlabpool for more details.
Any ideas ? Why is parfor complaining about accessing an array previously defined as Global ?
many thanks !
p.s I guess there are better ways of writing this in Matlab, but I'm just starting now to migrate some old fortran code I have.
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Parallel for-Loops (parfor) dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!