…or, how to change your history interval mid-run for WRF.

Here is a funny problem: I’m running a rather long WRF (or WRF-GC) case where I have to spin-up chemistry for about a month before I run the remaining time in the simulation.

The spin-up period history output is no use to me, but as a sanity check I want to output every 12 hours to see if things are going OK. Then for the main simulation period I want hourly output.

The reason I do this is because (1) storage is constrained and I don’t want to hog the server with useless output (and wake up in the middle of the night to delete useless data) and (2) core hours are constrained and I might get kicked out of the queue, so it’s better to do this in a few restart runs in WRF.

How can I do this? The logical thinking is to run the spin-up first with namelist.input option:

 &time_control
 ...
 history_interval                    = 720, 720, 720,
 frames_per_outfile                  = 1, 1, 1,
 restart                             = .false.,
 restart_interval                    = 10080,

The 10080 is number of minutes between restart files being written (24 x 7 x 60 = 10,080). Then once I am done with the spin-up, I can simply restart by killing the job, and modifying the namelist like so:

 &time_control
 ...
 history_interval                    = 60, 60, 60,
 frames_per_outfile                  = 1, 1, 1,
 restart                             = .true.,
 restart_interval                    = 10080,

Nope! This won’t work. Apparently, WRF stores the history alarm (WRF jargon for “when is history going to be written next?") inside the wrfrst restart files generated. How do I know this?

Because I ran about a week into my simulation and realized I had no hourly output.

Oops! Let’s poke into wrfrst and see what we can find:

$ ncdump -h wrfrst_d01 > reset.txt
...
// global attributes:
                :TITLE = " OUTPUT FROM WRF V3.9.1.1 MODEL" ;
                :START_DATE = "2019-04-02_00:00:00" ;
                :SIMULATION_START_DATE = "2019-04-02_00:00:00" ;
                :MAX_WRF_ALARMS = 55 ;
                :WRF_ALARM_ISRINGING_01 = 0 ;
                :WRF_ALARM_SECS_TIL_NEXT_RING_01 = 43200 ;

Yes! 43200 just so happens to be 720 minutes (720 x 60 = 43,200 seconds) and checking the WRF source confirms this somewhat: 01 is the history alarm.

Can I do something sneaky and change history_interval in the restart file? Luckily, yes - it would be kind of stupid to re-run the whole spin-up because of a namelist issue. NCO to the rescue. Copy your restart files, prefix them with old_ for backup and do this for each domain:

ncatted -O -h -a WRF_ALARM_SECS_TIL_NEXT_RING_01,global,m,i,3600 old_wrfrst_d01_2019-04-30_00\:00\:00 wrfrst_d01_2019-04-30_00\:00\:00

The modifier m means modify the global attribute, i is integer, and 3600 is the desired history_interval in minutes.

All done! Core hours and storage are both saved by this little trick.

hplin