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

IOOUTPUT is skipping times that would round to the next day #326

Open
mrjohnston opened this issue Mar 22, 2021 · 4 comments
Open

IOOUTPUT is skipping times that would round to the next day #326

mrjohnston opened this issue Mar 22, 2021 · 4 comments

Comments

@mrjohnston
Copy link
Contributor

When the observation outputs are requested in ED2IN (IOOUTPUT = 3), the model should output fast timescale files within 10 minutes of the time requested in the input timelist (a text file).

It skips outputting files requested at times that would round to the next day, for example:
2018-08-01 23:54:08
2019-06-16 23:57:34
2020-02-13 23:51:48

@xiangtaoxu
Copy link
Contributor

@mrjohnston It seems it is because when we wrote the codes, we always round the input observational time up (always use a later time, see below code chunk). So these times will be converted to a time value of 86400 (seconds).

ED2/ED/src/init/ed_init.F90

Lines 1262 to 1279 in fa80dab

! FIND ANALYSIS TIME: record the second of day of the closest analysis time
! note that we always round upward because the analysis file would
! include the average state/flux over the previous analysis period.
obstime_list(time_idx)%time = real(ceiling(( &
real(obstime_list(time_idx)%hour) * hr_sec &
+ real(obstime_list(time_idx)%min) * min_sec &
+ real(obstime_list(time_idx)%sec)) / frqfast)) * frqfast
! QUALITY CONTROL: Remove the entry if
! (1) it is outside the range of the simulation
! (2) it is the same as the last entry
! auxiliary variables to determine whether the observation time is
! within the range of simulation periods
time_hms = obstime_list(time_idx)%hour * 10000 &
+ obstime_list(time_idx)%min * 100 &
+ obstime_list(time_idx)%sec

Meanwhile, the model timer will automatically add one day and change time to zero when the time of day is greater or equal than 86400 (see below). So 86400 will never be reached in the model.

if (ctime%time >= day_sec)then
!----- If time is greater than one day, update the day. --------------------------!
ctime%time = ctime%time - day_sec
ctime%date = ctime%date + 1

One way to fix this is to similarly add one day and convert time to zero in read_obstime.

@mpaiao
Copy link
Contributor

mpaiao commented Mar 24, 2021

You may be able to fix this by using some of the existing subroutines in ED2. Without thinking too much (so likely to have errors), you could try the following:

           ! FIND ANALYSIS TIME: record the second of day of the closest analysis time
           ! note that we always round upward because the analysis file would
           ! include the average state/flux over the previous analysis period.
           tadd = real(ceiling((                                                           &
                        real(obstime_list(time_idx)%hour) * hr_sec                         &
                      + real(obstime_list(time_idx)%min)  * min_sec                        &
                      + real(obstime_list(time_idx)%sec)) / frqfast)) * frqfast
           !-------------------------------------------------------------------------------!


           !---- Add time to the date, so it can update time to the next day if needed. ---!
           call date_add_to(obstime_list(time_idx)%year,obstime_list(time_idx)%month       &
                           ,obstime_list(time_idx)%date,0,tadd,'s'                         &
                           ,iyearo,imontho,idateo,ihouro)
           !-------------------------------------------------------------------------------!


           !---- Update observation time. -------------------------------------------------!
           obstime_list(time_idx)%year  = iyearo
           obstime_list(time_idx)%month = imontho
           obstime_list(time_idx)%date  = idateo
           obstime_list(time_idx)%hour  = floor(ihouro/10000)
           obstime_list(time_idx)%min   = floor(mod(ihouro,10000)/100)
           obstime_list(time_idx)%sec   = mod(ihouro,100)
           !-------------------------------------------------------------------------------!

           ! Obstime - start time should be positive
           call date_2_seconds(obstime_list(time_idx)%year,obstime_list(time_idx)%month    &
                              ,obstime_list(time_idx)%date,ihouro                          &
                              ,iyeara,imontha,idatea,itimea*100                            &
                              ,sec_2_start)

           ! Obstime - end time should be negative
           call date_2_seconds(obstime_list(time_idx)%year,obstime_list(time_idx)%month    &
                              ,obstime_list(time_idx)%date,ihouro                          &
                              ,iyearz,imonthz,idatez,itimez*100                            &
                              ,sec_2_end)

@xiangtaoxu
Copy link
Contributor

@mpaiao Thanks! It is always good to use existing utilities...

@mrjohnston
Copy link
Contributor Author

@xiangtaoxu @mpaiao Thanks both! Fixing this is on my to-do list (feel free to assign me!), but it may take me a little while to get to.

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

No branches or pull requests

3 participants