Hi,
this comes up quite often in variants, so I’m repeating my answer from here:
https://www.listarc.bham.ac.uk/lists/sc-users-2019/msg66280.html
see the data sharing chapter of the Practical Guide
http://doc.sccode.org/Tutorials/A-Practical-Guide/PG_06g_Data_Sharing.html
here a more recent example from the list
https://www.listarc.bham.ac.uk/lists/sc-users-2019/msg65459.html
and three threads on the forum with related examples
There are countless other examples in the old archive if you search “data sharing”
https://www.listarc.bham.ac.uk/lists/sc-users-old/search/
In any case note the time-shift, which is necessary in most examples for order of execution.