I implement Runge--Kutta method for time integration of the system of nonlinear conservation laws
$$ u_t + f(u)_x = 0. $$
As the system is nonlinear, we have to recompute time step
dt on each time step. Then we have to find new current time by using code like this:
cur_time = cur_time + dt
However, if we want to integrate to a very large time, then
cur_time will be large while time step
dt will be small, therefore, the error due to the floating-point arithmetics can accumulate significantly.
Is there a way to avoid this? If time step were constant, I could handle it, but what to do with the nonconstant time step?
UPDATE 2016-04-17. I add an example to demonstrate that the floating-point arithmetics introduce significant error even for a small number of step and small ratio
cur_time/dt. For simplicity, I use constant time step
dt here, nevertheless, the issue with nonconstant time step should be similar. Code is in Python programming language:
dt = 0.2 n = 100 cur_time =  for i in range(n): cur_time.append(cur_time[-1] + dt) cur_time[-5:] # Shows last five time points.
which leads to
19.199999999999964, 19.399999999999963, 19.599999999999962, 19.79999999999996, 19.99999999999996
Therefore, even with small time of integration and small number of time steps, the time points are slightly corrupted by accumulation of error due to the floating-point arithmetics.