Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Re: ParrallelDo and set::noval

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102706] Re: [mg102697] Re: ParrallelDo and set::noval
  • From: Mark McClure <mcmcclur at unca.edu>
  • Date: Thu, 20 Aug 2009 04:55:51 -0400 (EDT)
  • References: <h63cgg$1b6$1@smc.vnet.net> <h6duf8$h1c$1@smc.vnet.net>

On Wed, Aug 19, 2009 at 7:02 AM, guerom00 <guerom00 at gmail.com> 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];
DistributeDefinitions[grid];
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];
DistributeDefinitions[grid];
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
instead.

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