1

I have some codes like this:

LaunchKernels[$ProcessorCount];
ParallelDo[
 result=myFunction[i];
 WriteString[ToString[$KernelID]<>".txt",result,"\n"]
 ,
 {i,k}
]

For some reason I'm only getting one output file from this code (I use 5 processors and it's always 5.txt). Why is that? The code seems to be parallelizing properly in multiple threads based on cpu usage data. Also this is only happening on our 64-bit computing cluster with Mathematica 10.0.2, but not happening on my local 32-bit computer with 2 cores and Mathematica 10.0.1.

Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263
J Yeh
  • 105
  • 4
  • What does ParallelTable[{Directory[], $KernelID}, {k}] return? Just in case: does it work with Export instead of WriteString? – Szabolcs Sep 16 '16 at 10:07
  • Works for me with MMA10.1 Linux. Perhaps this would be some additional help Writing data to a common file during parallel processing. – Sumit Sep 16 '16 at 10:22
  • Okay this is awkward... It turns out I had a stupid mistake in myFunction. There was a parameter undefined in there, which lead to super high recursion depth. For some reason one of the kernels on the cluster and both kernels my local computer managed to fill in a value for that parameter. Still a mystery but at least now I fixed the problem. – J Yeh Sep 19 '16 at 20:27

0 Answers0