Fixing two time-related problems in ARWpost

Discussions related to the use of ARWPost

Fixing two time-related problems in ARWpost

Postby Gadian » Mon Aug 27, 2018 3:45 am

BUGS/problems I met:

For a restart run, the output file of WRF may have some overlapped data, for example in my recent runs.
Due to some limitations of supercomputers, I ran the wrf with several restart runs. As a result,
I got four files for one month simulation. Because the data for restart are not identical to the model output, four wrfout files are like:
wrfout_d01_A covers 2014-06-30_00:00:00 to 2014-07-03_00:00:00
wrfout_d01_A covers 2014-07-02_00:00:00 to 2014-07-05_00:00:00
wrfout_d01_B covers 2014-07-04_03:00:00 to 2014-07-26_00:00:00
wrfout_d01_C covers 2014-07-24_00:00:00 to 2014-07-31_00:00:00

In this case, my ARWpostV3.1 can't find the correct time, and I got some strange output, like:

Processing time --- 2014-07-06_12:00:00
Date not in this file - see if there are more files
Found 2014-07-26_12:00:00
Date is close enough - continue

I confirmed the "Times" variable in the wrfout files and the data actually existed. Furthermore, it's strange to see the 'Date is close enough' for such great time difference. Obviously, the program did not recognize the time correctly, and the parameter "tacc" in the namelist.ARWpost did not work well.


HOW TO FIX:
It's very easy to fix such kind of problems by modifying the codes in two sources files:
input_module.f90
module_date_pack.f90

First, for the parameter "tacc" that didn't work:
"tacc" is set to do the comparison between actually time difference between "Found time" and "Expected Time". The comparison is by an "IF" judgment and works well. The bug comes from the calculation of two times, which is done by the subroutine:"get_seconds" in module_date_pack.f90.
just change the code
Code: Select all
seconds = second + 60*minute

by adding the day, month, and year into the calculation, as
Code: Select all
 seconds = second + 60*minute + 60*60*hour + 60*60*24*day + 60*60*24*31*month
 + 60*60*24*365*century_year

Then, the "tacc" will work, because the time difference is calculated correctly.

Second, for the program that can't find the correct time.
This part is mainly done by the subroutine "arw_get_next_time" in input_module.f90.

The problem occurs, because the program can't get the correct max time step of the file.
So, to fix it, just change:
Code: Select all
 
          get_times : DO ii=1,ncDims(ishape(2))
          file_time = ii
          istart(2) = ii
          istatus = NF_GET_VARA_TEXT (ncid,iloc,istart,iend,datestr)
          IF ( istatus /= 0 ) EXIT get_times
          call get_diff_dates (datestr, valid_date, isec_diff)
          !IF ( TRIM(datestr) == TRIM(valid_date) ) EXIT get_times
          IF ( abs(isec_diff) .LE. tacc ) EXIT get_times
        END DO get_times

to
Code: Select all
 
          ii = 1
          get_times : DO
          file_time = ii
          istart(2) = ii
          istatus = NF_GET_VARA_TEXT (ncid,iloc,istart,iend,datestr)
          IF ( istatus /= 0 ) EXIT get_times
          call get_diff_dates (datestr, valid_date, isec_diff)
          !IF ( TRIM(datestr) == TRIM(valid_date) ) EXIT get_times
          IF ( abs(isec_diff) .LE. tacc ) EXIT get_times
          ii = ii + 1
        END DO get_times


Although it may not be the best solution, these two modifications worked for me.
Gadian
 
Posts: 2
Joined: Mon Oct 30, 2017 10:58 pm

Return to ARWPost

Who is online

Users browsing this forum: No registered users and 2 guests