To avoid that somebody might miss the reference in my comment, I would like to rephrase the solution which is given in this answer by @David.
Basically, one sets up a list - currentStep
- which holds the current value of the iterators on every kernel (or some combination that gives the desired output) and is printed temporarily as a Dynamic
construct. By this, one avoids huge amounts of Print
cells in the notebook that need to be deleted afterwards.
Mainly, the correct assignment in the body needs to be like currentStep[[$KernelID /. kernels]] = i
where i
is the iterator. For the example given in the OP (where the iterator of the inner For
loop needs to be monitored) we can proceed like this:
kernels = ParallelTable[$KernelID -> i, {i, $KernelCount}];
currentStep = ConstantArray[0, Length@kernels];
SetSharedVariable[kernels, currentStep];
PrintTemporary["Current computation on each kernel:"];
PrintTemporary@Dynamic[currentStep//Column];
ParallelDo[For[i = 1, i <= 5, i++, Pause[.25]; currentStep[[$KernelID/.kernels]] = "Kernel: " <> ToString[$KernelID] <> " -> i=" <> ToString[i]], {k, 1, 20, 1}]