Thanks for all the explanations.
Should have mentioned it's not actually my code! I've fixed it up, but just wanted to understand why it's doing what it's doing.
I get the fact that the compile time of the subroutine means it will use the initial variable. But does the localised variable not use the same location as the my variable?