Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time:units set inconsistently in the nuopc interface #17

Open
anton-seaice opened this issue Jan 17, 2024 · 2 comments
Open

time:units set inconsistently in the nuopc interface #17

anton-seaice opened this issue Jan 17, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@anton-seaice
Copy link

anton-seaice commented Jan 17, 2024

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.

@DeniseWorthen
Copy link

@anton-seaice I have made this fix in some work I'm doing in WW3 for the Coastal application in UFS. I'll be making a PR which will include this fix in the coming weeks.

index c7bb14ef..f2d4a4f8 100644
--- a/model/src/wav_comp_nuopc.F90
+++ b/model/src/wav_comp_nuopc.F90
@@ -623,7 +623,7 @@ contains
       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 )
+    call ESMF_TimeGet( startTime, 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)
     !call ESMF_ClockGet(clock, calendar=calendar)

@anton-seaice
Copy link
Author

Thankyou!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants