Skip to content

time handling in single precision#3161

Open
wiersema1 wants to merge 2 commits into
erf-model:developmentfrom
wiersema1:time-tracking-precision
Open

time handling in single precision#3161
wiersema1 wants to merge 2 commits into
erf-model:developmentfrom
wiersema1:time-tracking-precision

Conversation

@wiersema1
Copy link
Copy Markdown
Contributor

When compiled in single precision, small rounding errors in the time step and current time can accumulate. For Bomex (6 hours with dt=0.3) the single precision run completes 20 time steps (6 seconds) earlier than the double precision run. This PR changes some times to doubles when in single precision and also syncs the current time after each time step so that it does not drift for the I/O and physics routines. These changes shouldn't change anything when compiled in double precision.

Tested by compiling in single and double precision and running Bomex. No change to behavior of the double precision simulation. Single precision simulation now tracks and reports time identical to the double precision simulation.

wiersema1 added 2 commits May 8, 2026 12:26
…le precision. When compiling in single precision, the time step and current time were float32, which could lead to some unintended behavior when the number of time steps is large. For 6 hour Bomex simulations with fixed_dt=0.3, the actual dt is 0.29980469 until time 16384, after which dt=0.30078125. This causes the single precision run to reach 6 hrs in 20 less time steps relative to the double precision run.
…rue elapsed time due to representation of the time step as float32. This change assigns t_new[0] using the double cur_time after each time step, which avoids the accumulation of float32 quantization error. The correct timestamp is now provided to physics routines and the plt and chk Header files. There should be no change when compiled in double precision since t_new[0] is already a double, so the static_cast<Real> does nothing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant