Home Agenda Lectures Virtual Mtg. Etiquette



  Quick Links
Run with Adaptive Time Stepping

In this example you will use the Adaptive Time Stepping option, rather than running with a fixed time step. Adaptive time stepping is a way to maximize the time step when, in order to maintain model stability, it is necessary to reduce the time step. This will help the model to run faster, overall. It is typically used in real-time or climate model runs.

There is no data pre-processing necessary. If you still have wrfinput_d01 and wrfbdy_d01 files from a previous case, you can continue. If not, please return to the Single Domain case and generate these again.

  1. Edit the namelist.input file.

    Use the Single Domain case namelist, and add the following to the &domains record. To ensure that the model runs quickly, make sure "max_dom=1"



  2. use_adaptive_time_step  = .true.,
    step_to_output_time     = .true.,
    target_cfl              = 1.2, 1.2,
    target_hcfl             = .84, .84,
    max_step_increase_pct   = 5, 51,
    starting_time_step      = -1, -1,
    max_time_step           = 240, 240,
    min_time_step           = 120, 120,
    adaptation_domain       = 1,






    Note

    • Recommended min and max time steps are 3*dx and 8*dx, respectively. For this case, you should typically set these to 120 and 240.

    • For real-time runs or research, the max time step can be set a bit higher than 8*dx, but not too high. It's also important to ensure the min and max are not so far apart that the model time steps vary drastically, so take care when picking optimal time steps!

    • Since max_dom = 1, the model will only pay attention to the first column in the namelist settings above. We have provided information for multiple columns just to show you which variables require a setting for each column, if running with more than 1 domain.


  3. No need to run real.exe again, just run wrf.exe.


Check your output:


When running WRF with fixed time steps you would have information like this in the rsl.out.0000, showing the elapsed time for each fixed model time step:

Timing for main: time 2023-03-31_00:03:00 on domain 1: 3.43441 elapsed seconds
Timing for main: time 2023-03-31_00:06:00 on domain 1: 2.11485 elapsed seconds
Timing for main: time 2023-03-31_00:09:00 on domain 1: 2.05235 elapsed seconds
Timing for main: time 2023-03-31_00:12:00 on domain 1: 2.16914 elapsed seconds
Timing for main: time 2023-03-31_00:15:00 on domain 1: 2.05815 elapsed seconds
Timing for main: time 2023-03-31_00:18:00 on domain 1: 2.17894 elapsed seconds
Timing for main: time 2023-03-31_00:21:00 on domain 1: 2.07029 elapsed seconds
Timing for main: time 2023-03-31_00:24:00 on domain 1: 2.18028 elapsed seconds
Timing for main: time 2023-03-31_00:27:00 on domain 1: 2.09054 elapsed seconds
Timing for main: time 2023-03-31_00:30:00 on domain 1: 2.19225 elapsed seconds



When running with adaptive time step, information regarding the length of the time step is added to the output. Notice the actual time steps the model takes are written to the log file, and that although they start lower, they quickly become longer than the original dt=150 you used for the fixed time step runs. You may also notice the model still outputs every 3 hours, on the hour. This is ensured by setting step_to_output_time=.true.

Timing for main (dt=120.00): time 2023-03-31_00:02:00 on domain 1: 1.43449 elapsed seconds
Timing for main (dt=126.00): time 2023-03-31_00:04:06 on domain 1: 0.07998 elapsed seconds
Timing for main (dt=132.30): time 2023-03-31_00:06:18 on domain 1: 0.08054 elapsed seconds
Timing for main (dt=138.91): time 2023-03-31_00:08:37 on domain 1: 0.08064 elapsed seconds
Timing for main (dt=145.86): time 2023-03-31_00:11:03 on domain 1: 0.08072 elapsed seconds
Timing for main (dt=153.15): time 2023-03-31_00:13:36 on domain 1: 0.08088 elapsed seconds
Timing for main (dt=160.81): time 2023-03-31_00:16:17 on domain 1: 0.08190 elapsed seconds
Timing for main (dt=168.85): time 2023-03-31_00:19:05 on domain 1: 0.43627 elapsed seconds
Timing for main (dt=177.29): time 2023-03-31_00:22:03 on domain 1: 0.08504 elapsed seconds
Timing for main (dt=186.15): time 2023-03-31_00:25:09 on domain 1: 0.08125 elapsed seconds
Timing for main (dt=195.46): time 2023-03-31_00:28:24 on domain 1: 0.08498 elapsed seconds
Timing for main (dt=205.23): time 2023-03-31_00:31:50 on domain 1: 0.08544 elapsed seconds



 

Let's see the time steps the model took. Copy /glade/campaign/mmm/wmr/wrf_tutorial/WRF_NCL_scripts/wrf_AdaptiveTime.ncl to your test/em_real directory. This script has been edited for this case, so all you need to do is get the time steps from the rsl.out.0000 file and run the script:

grep "Timing for main" rsl.out.0000 > adaptive_times.txt
ncl wrf_AdaptiveTime.ncl

This will produce the following plot. Note, this plot may vary, depending on how the steps were adapted.

The red line represents a constant time of 180 seconds. The blue line represents the actual time steps the model took. It is clear the model mostly took time steps larger than 180 seconds. Notice the occasional big drops in time steps. This is not desirable. For this case we could easily set the minimum time step to 200 seconds, as the model takes bigger time steps the entire time. We want to prevent big drops and large differences in time steps, so setting the maximum time step to no more than 360 would be more sensible than our test setting of 420.

 

What is in the NCL script?

    1. Reading data:
      To read and use the data from text files, you need to know a bit about the file.
      The data are a mix between characters and numbers and not simple to interpret.
      So we are going to read the data with "systemfunc" rather than with typical NCL read commands.
         tmp = systemfunc("cut -c21-26 adaptive_times.txt") 
      Note that we need to read characters 21-26 (so some counting is in order).


    2. Plotting the data
      We need three pieces of information for plotting.
      a. An x coordinate, which is created as a simple 0 to n array (steps)
      b. A constant 180 second line, which we place in data(0,:)
      c. The actual time steps the model took, which we place in data(1,:)
          Note the tmp array we read consists of characters. We need to convert this to floats before plotting (stringtofloat)
          plot = gsn_csm_xy(wks,steps,data,res)


WRF Tutorial Exercises



Continue to More Exercises

If you plan to attempt more exercises right now, you can access the cases studies menu by clicking here.