Select a part of a function's result

The associate construct works as if you are making a subroutine call where f is the dummy argument associated with the actual argument get_series(n) evaluated as an expression. So the compiler is evaluating that expression and making a temporary copy for you. That temporary copy dissappears after the end of the block, just like a dummy argument disappears after the procedure returns. I think the same thing could be done with a block statement with the declaration integer :: f(n). I’m not sure if the allocatable attribute is required (in either the procedure or the block) – maybe the temporary array is in the heap with it but on the stack without it?