I am sorry for this confusion. I posted now an excecutable script as an example (see above). Array_b provides the information of the time lag for determining a simple moving average. The subroutine is supposed to give three arrays back. Does that makes sense now? Anyhow, something is wrong with it and basically I have issues to get the three arrays into my main program. Finally, is there a way for threading the calculations of such a subroutine?