My PDE simulation program written in Fortran has to make about 2 million variable time steps. But with each time step it slows down more and more, so that if it initially makes 1000 time steps per second, then when it reaches time step 600k and above, it makes 1000 time steps in as many as several minutes. And the slow down continues the further the simulation runs.
As far as I have established and understood, the problem is related to bufferization. There is enough memory and it does not get filled completely as the simulation progresses, but it does slow down quite a bit as the time steps progress. It looks like some caches get filled so that more and more latency occurs.
The solution would be to free up memory after every certain number of time steps, thus running the simulation in chunks. However, I don't yet know how to do that in Fortran. Does one have to use something like
call Malloc() to dynamically allocate each arrays in Fortran, and then use
call Free() to deallocate memory after a certain number of time steps has been done? Or is there a better approach toward this problem?
Would appreciate some advice.