The function works and gives the output. Checked the output and they are...

... correct. The problem with dimension of matrix is solved in general form so it can read in files with different time step.