I wrote a function that counts valid samples in an array. It declares integer :: count = 0, loops over the data and returns count. The first call returns 3 as expected, but calling it again with the same array returns 6, then 9.
In C the same line would reset the variable on every call. What is Fortran doing here, is this related to the save attribute I see in older code, and how should a local variable be initialised on each call?




