Skip to content

Floating point roundoff errors in model time #76

Open
@szy21

Description

@szy21

When using float32, there may be roundoff errors in model time, which could cause problems. For example:

julia> t=Float32(390*24*60*60)
3.3696f7

julia> tt = t+150
3.369615f7

julia> tt-t
152.0f0

Potential solution:
use a different mechanism for internally storing current time, either

  • a higher-precision Float64
  • an integer, either number of time steps or number of seconds (or equivalently using a DateTime object, which internally uses milliseconds since an epoch)

From Tapio: Standard solution is to use an integer step counter j, then write output every n steps. Of course, this only works with constant dt, but every climate model I know has that anyway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions