I have a Do[] loop that references a few global variables but doesn't modify anything. The only output is appending data to an external file. The order of appending doesn't matter, I just can't have duplicates. How can I make this run in parallel? I've tried ParallelDo and Parallelize but for the life of me I can't figure out the syntax and they give errors. Here are the relevant parts of my code:
List1 = [*list one stuff*];
List2 = [*list two stuff*];
Table1 = [*table one stuff*];
max = Length[List2];
Do[
[a whole bunch of stuff using data from both lists and the table];
data >>> "output.txt";,
{i,max}];
The code runs perfectly fine this way but if I change Do to ParallelDo it gives a ton of errors such as:
Part::partd : Part specification ComputationalGeometry`List2[[1]] is longer than depth of object.
Part::pkspec1 : The expression ComputationalGeometry`List2 cannot be used as a part specification.
General::stop : Further output of Part::partd will be suppressed during this calculation.
Part::partw : Part 3 of ComputationalGeometry`List2[[1]] does not exist.
These were occuring for each kernel running.
I couldn't figure out the syntax for Parallelize at all. My data files are huge so I need all parallel processing to use the same global variables. I can't just start another notebook instance and run them manually, I already have to buy more RAM as is.
Is there any way to manually specify what I want run on each kernel? It would be so easy if I could just write:
calc[n_,m_] := Do[
[*a whole bunch of stuff using data from both lists and the table*];
data >>> "output.txt";,
{i,n,m}];
RunParallel[calc[1,250],calc[251,500],calc[501,750],calc[751,1000]];
Parallelwork. – rhermans May 26 '22 at 08:49