Skip to content

time:units set inconsistently in the nuopc interface #17

@anton-seaice

Description

@anton-seaice

Describe the bug
In the netcdf output, when using a restart file, then time:units attribute is set in a way that is inconsistent with the time variable.

For an initial run of one day long, in the netcdf output:

time:units = "seconds since 1900-01-01 00:00:00" ; 
time = 86400 ;

Which is correct

If another day is run, the time variable in netcdf output is:

time:units = "seconds since 1900-01-02 00:00:00" ;
time = 172800 ;

This is inconsistent, as both the time and the time origin have stepped forward one day.

Interestingly the file name has the correct date (i.e. the end of the time period):
GMOM_JRA_WD.ww3.hi.1900-01-03-00000.nc

To Reproduce
Start the model from a restart file, with netcdf output turned on.

Expected behavior
Time:units should be set from the model start time, not the restart time.

Additional context

The time_origin is set based on the 'Current Time' before the model is time stepped:

time_origin = 'seconds since '//time_origin(1:10)//' '//time_origin(12:19)

   call ESMF_ClockGet( clock, currTime=esmfTime, rc=rc )
      if (ChkErr(rc,__LINE__,u_FILE_u)) return
    endif
    ! Determine time attributes for history output
    call ESMF_TimeGet( esmfTime, timeString=time_origin, calendar=calendar, rc=rc )
    if (ChkErr(rc,__LINE__,u_FILE_u)) return
    time_origin = 'seconds since '//time_origin(1:10)//' '//time_origin(12:19)

But then the 'elapsed_secs' is set from the 'Start Time'

elapsedTime = nextTime - startTime

elapsedTime = nextTime - startTime
    call ESMF_TimeIntervalGet(elapsedTime, s_i8=elapsed_secs,rc=rc)

I think setting time_origin based on Start Time would make sense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions