MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: ParrallelDo and set::noval

On Wed, Aug 19, 2009 at 7:02 AM, guerom00 <guerom00 at> wrote:

> grid = Range[4, 50, 0.5];
> testArray = Array[Null, {Length[grid]}];
> DistributeDefinitions[grid,testArray];
> ParallelDo[ iroot = 0;
>  rr = grid[[i]];
>  Which[4 <= rr <= 50, iroot = 1 ];
>  testArray[[i]] = {i, iroot};
>  , {i, 1, Length[grid]}]
> returns "Set::noval: Symbol testArray in part assignment does not have
> an immediate value." Somehow the DistributeDefinitions[] is not
> sufficient to indicate to each kernel that I have initialized the list
> testArray.

You're distributing the definition of testArray across
several kernels and then trying to write to the global
value of testArray.  That seems potentially problematic
to me.  Here's a much simpler example that shows this
kind of thing might be an issue:

(* This works fine. *)
grid = Range[10];
ParallelTable[grid[[i]]^2, {i, 1, Length[grid]}]

(* As does this. *)
grid = Range[10];
Table[grid[[i]] = grid[[i]]^2, {i, 1, Length[grid]}]

(* But the following yields an error. *)
grid = Range[10];
ParallelTable[grid[[i]] = grid[[i]]^2,
  {i, 1, Length[grid]}]

Thus, we can read from the distributed definitions, but
we can't write to them.  Writing to a list term by term
is inefficient in Mathematica anyway.  You should
probably try to reimplement with Table/ParallelTable

Good luck,
Mark McClure

  • Prev by Date: Re: Re: ParrallelDo and set::noval
  • Next by Date: Re: Re: ParrallelDo and set::noval
  • Previous by thread: Re: Re: ParrallelDo and set::noval
  • Next by thread: Re: Re: ParrallelDo and set::noval