Julia pmap how to write each worker into separate index using parallel computing

Hi Pedro — please check out Please read: make it easier to help you for some guidance on how to format and present your posts in a more readable manner. Importantly, it can be very useful to use “code fences” (blocks of code surrounded by triple-backticks ```) to make your code more readable.

Your initial error —

ERROR: On worker 6:

ArgumentError: invalid index: 1.0 of type Float64
Stacktrace:
[1] to_index
@ ./indices.jl:300
[2] to_index
@ ./indices.jl:277
[3] to_indices

Is not that a worker is trying to write into a “wrong” index, but rather, that you’re doing some floating point computation for an index and haven’t converted it to an integer. Note that N/nworkers() will return a floating point number — I’m betting you want N ÷ nworkers() instead.