Wednesday 14 January 2015

How to run WRF driven by ERA-Interim data

Get data

Download data as explained here:
http://conorsweeneyucd.blogspot.com/2015/01/download-era-interim-data.html

Test run on gaia

Working directory:
/gaia/home/sweeneyc/Code/WRF/ERAI

- load the WPS module:
module load WPS

- Edit namelist.wps:
Notes:
- For domain 2, set end time = start time in namelist.wps if you don't want updating. We do want to update surface fields (SST), so start and end dates should be the same for both domains.
&share
 wrf_core = 'ARW',
 max_dom = 1,
 start_date = '1979-01-01_00:00:00','2006-08-16_12:00:00',
 end_date   = '1979-01-01_06:00:00','2006-08-16_12:00:00',
 interval_seconds = 21600
 io_form_geogrid = 2,
/

&geogrid
 parent_id         =   1,   1,
 parent_grid_ratio =   1,   3,
 i_parent_start    =   1,  31,
 j_parent_start    =   1,  17,
 e_we              =  74, 112,
 e_sn              =  61,  97,
 geog_data_res     = '10m','2m',
 dx = 27000,
 dy = 27000,
 map_proj = 'lambert',
 ref_lat   =  52.,
 ref_lon   = -23.5,
 truelat1  =  50.0,
 truelat2  =  55.0,
 stand_lon = -20.0,
 geog_data_path = '/gaia/software/src/WPS_geog/'
/

&ungrib
 out_format = 'WPS',
 prefix = 'FILE',
/

&metgrid
 fg_name = 'FILE'
 io_form_metgrid = 2, 
/

- Check the domain:
module load ncl_ncarg
export NCARG_ROOT=/gaia/software/src/ncl_ncarg-6.2.1
ncl util/plotgrids_new.ncl

- Make sure you have geogrid/GEOGRID.TBL then run geogrid.exe

- Copy in the Vtable for ERA-Interim:
cp /gaia/software/src/WPS-3.6.1/ungrib/Variable_Tables/Vtable.ERA-interim.ml .
cp Vtable.ERA-interim.ml Vtable

- Link in the grib data:
link_grib.csh ~/DATA/ERAI/1979/ERAI-

- Run ungrib.exe
This should produce the files:
FILE:1979-01-01_00
FILE:1979-01-01_06

- create ecmwf_coeffs file:

    0         0.000000    0.00000000
    1        20.000000    0.00000000
    2        38.425343    0.00000000
    3        63.647804    0.00000000
    4        95.636963    0.00000000
    5       134.483307    0.00000000
    6       180.584351    0.00000000
    7       234.779053    0.00000000
    8       298.495789    0.00000000
    9       373.971924    0.00000000
   10       464.618134    0.00000000
   11       575.651001    0.00000000
   12       713.218079    0.00000000
   13       883.660522    0.00000000
   14      1094.834717    0.00000000
   15      1356.474609    0.00000000
   16      1680.640259    0.00000000
   17      2082.273926    0.00000000
   18      2579.888672    0.00000000
   19      3196.421631    0.00000000
   20      3960.291504    0.00000000
   21      4906.708496    0.00000000
   22      6018.019531    0.00000000
   23      7306.631348    0.00000000
   24      8765.053711    0.00007582
   25     10376.126953    0.00046139
   26     12077.446289    0.00181516
   27     13775.325195    0.00508112
   28     15379.805664    0.01114291
   29     16819.474609    0.02067788
   30     18045.183594    0.03412116
   31     19027.695313    0.05169041
   32     19755.109375    0.07353383
   33     20222.205078    0.09967469
   34     20429.863281    0.13002251
   35     20384.480469    0.16438432
   36     20097.402344    0.20247594
   37     19584.330078    0.24393314
   38     18864.750000    0.28832296
   39     17961.357422    0.33515489
   40     16899.468750    0.38389215
   41     15706.447266    0.43396294
   42     14411.124023    0.48477158
   43     13043.218750    0.53570992
   44     11632.758789    0.58616841
   45     10209.500977    0.63554746
   46      8802.356445    0.68326861
   47      7438.803223    0.72878581
   48      6144.314941    0.77159661
   49      4941.778320    0.81125343
   50      3850.913330    0.84737492
   51      2887.696533    0.87965691
   52      2063.779785    0.90788388
   53      1385.912598    0.93194032
   54       855.361755    0.95182151
   55       467.333588    0.96764523
   56       210.393890    0.97966272
   57        65.889244    0.98827010
   58         7.367743    0.99401945
   59         0.000000    0.99763012
   60         0.000000    1.00000000

- Run calc_ecmwf_p.exe
This should produce the files:
PRES:1979-01-01_00
PRES:1979-01-01_06

- Make sure you have your metgrid/METGRID.TBL pointing to METGRID.TBL.ARW

- Run metgrid.exe
This should produce the files:
met_em.d01.1979-01-01_00:00:00.nc
met_em.d01.1979-01-01_06:00:00.nc

Notes:
- I have checked, and the met files to contain varying values for SST and SEAICE.
- metgrid.exe failed at first because my ERAI data didn't cover my WRF domain!

- Change into WRF/run directory
/gaia/home/sweeneyc/Code/WRF/WRFV3/run.test

- module load WRF

- link in the met_em files:
ln -s ../../../WRF/ERAI/met_em.d01.1979-01-01_0* .

- edit namelist.input
It should agree with namelist.wps.
Use ncdump -h to check NUM_MET levels:
num_metgrid_levels = 61
NUM_METGRID_SOIL_LEVELS = 4

- Run real.exe
This should produce:
wrfinput_d01
wrfbdy_d01

- Run WRF
mpirun -np 4 wrf.exe


- >>>>STOPPED HERE<<<<

calc_ecmwf_p.exe

In the course of vertically interpolating meteorological fields, the real program requires 3-d pressure and geopotential height fields on the same levels as the other atmospheric fields. The calc_ecmwf_p.exe utility may be used to create such these fields for use with ECMWF sigma-level data sets. Given a surface pressure field (or log of surface pressure field) and a list of coefficients A and B, calc_ecmwf_p.exe computes the pressure at an ECMWF sigma level $k$ at grid point $(i,j)$ as $P_{ijk} = A_k + B_k*Psfc_{ij}$. The list of coefficients used in the pressure computation can be copied from a table appropriate to the number of sigma levels in the data set from http://www.ecmwf.int/products/data/technical/model_levels/index.html. This table should be written in plain text to a file, ecmwf_coeffs, in the current working directory.

If soil height (or soil geopotential), 3-d temperature, and 3-d specific humidity fields are available, calc_ecmwf_p.exe computes a 3-d geopotential height field, which is required to obtain an accurate vertical interpolation in the real program. Given a set of intermediate files produced by ungrib and the file ecmwf_coeffs, calc_ecmwf_p loops over all time periods in namelist.wps, and produces an additional intermediate file, PRES:YYYY-MM-DD_HH, for each time, which contains pressure and geopotential height data for each full sigma level, as well as a 3-d relative humidity field. This intermediate file should be specified to metgrid, along with the intermediate data produced by ungrib, by adding 'PRES' to the list of prefixes in the fg_name namelist variable.

Input variables
WRF comers with a variable table for ERA-Interim model level data: Vtable.ERA-interim.ml:
GRIB | Level| Level| Level| metgrid  |  metgrid | metgrid                                  |
Code | Code |   1  |   2  | Name     |  Units   | Description                              |
-----+------+------+------+----------+----------+------------------------------------------+
 130 | 109  |   *  |      | TT       | K        | Temperature                              |
 131 | 109  |   *  |      | UU       | m s-1    | U                                        |
 132 | 109  |   *  |      | VV       | m s-1    | V                                        |
 133 | 109  |   *  |      | SPECHUMD | kg kg-1  | Specific humidity                        |
 165 |  1   |   0  |      | UU       | m s-1    | U                                        | At 10 m
 166 |  1   |   0  |      | VV       | m s-1    | V                                        | At 10 m
 167 |  1   |   0  |      | TT       | K        | Temperature                              | At 2 m
 168 |  1   |   0  |      | DEWPT    | K        |                                          | At 2 m
     |  1   |   0  |      | RH       | %        | Relative Humidity at 2 m                 | At 2 m
 172 |  1   |   0  |      | LANDSEA  | 0/1 Flag | Land/Sea flag                            |
 129 |  1   |   0  |      | SOILGEO  | m2 s-2   |                                          |
     |  1   |   0  |      | SOILHGT  | m        | Terrain field of source analysis         |
 134 |  1   |   0  |      | PSFC     | Pa       | Surface Pressure                         |
 151 |  1   |   0  |      | PMSL     | Pa       | Sea-level Pressure                       |
 235 |  1   |   0  |      | SKINTEMP | K        | Sea-Surface Temperature                  |
  31 |  1   |   0  |      | SEAICE   | fraction | Sea-Ice-Fraction                         |
  34 |  1   |   0  |      | SST      | K        | Sea-Surface Temperature                  |
  33 |  1   |   0  |      | SNOW_DEN | kg m-3   |                                          |
 141 |  1   |   0  |      | SNOW_EC  | m        |                                          |
     |  1   |   0  |      | SNOW     | kg m-2   |Water Equivalent of Accumulated Snow Depth|
     |  1   |   0  |      | SNOWH    | m        | Physical Snow Depth                      |
 139 | 112  |   0  |   7  | ST000007 | K        | T of 0-7 cm ground layer                 |
 170 | 112  |   7  |  28  | ST007028 | K        | T of 7-28 cm ground layer                |
 183 | 112  |  28  | 100  | ST028100 | K        | T of 28-100 cm ground layer              |
 236 | 112  | 100  | 255  | ST100255 | K        | T of 100-255 cm ground layer             |
  39 | 112  |   0  |   7  | SM000007 | m3 m-3   | Soil moisture of 0-7 cm ground layer     |
  40 | 112  |   7  |  28  | SM007028 | m3 m-3   | Soil moisture of 7-28 cm ground layer    |
  41 | 112  |  28  | 100  | SM028100 | m3 m-3   | Soil moisture of 28-100 cm ground layer  |
  42 | 112  | 100  | 255  | SM100255 | m3 m-3   | Soil moisture of 100-255 cm ground layer |
-----+------+------+------+----------+----------+------------------------------------------+

Lines which have a metgrid name but no GRIB codes are generated by ungrib.exe.

namelist.input

parent_grid_ratio: integer parent-to-nest domain grid size ratio. Typically an odd number ratio is used in real-data applications.

feedback: To define a two-way nested run, feedback is on. The values of the coarse domain are overwritten by the values of the variables in the nest at the coincident points.

Sea Surface Temperature
The WRF model physics does not predict sea-surface temperature, vegetation fraction, albedo and sea ice. For long simulations, the model provides an alternative to read-in the time-varying data and update these fields. In order to use this option, one must have access to time-varying SST and sea ice fields. Twelve monthly values of vegetation fraction and albedo are available from the geogrid program. Once these fields are processed via WPS, one may activate the following options in the namelist record &time_control before running the program real.exe and wrf.exe:

io_form_auxinput4 = 2
auxinput4_inname = “wrflowinp_d<domain>” (created by real.exe)
auxinput4_interval = 360, 360, 360,

and in &physics

sst_update = 1

Note that this option doesn’t work with sf_ocean_physics options.

Restart Run

The results at the end of one or more restart runs should be identical to a single run without any restart. In order to do a restart run, one must first create a restart file. This is done by setting the namelist variable restart_interval (unit is in minutes) to be equal to or less than the simulation length in the first model run, as specified by run_* variables or start_* and end_* times. When the model reaches the time to write a restart file, a restart file named wrfrst_d_ will be written. The date string represents the time when the restart file is valid.
When one starts the restart run, edit the namelist.input file, so that your start_* time will be set to the restart time (which is the time the restart file is written). The other namelist variable one must set is restart, this variable should be set to .true. for a restart run.

WRF may fail to write a restart file. This is because the basic netCDF file support is only 2Gb. One solution is to simply set the namelist option io_form_restart = 102 (instead of 2), and this will force the restart file to be written into multiple pieces, one per processor.

One-way Nested Run

Step 1: Make a coarse grid run. Hourly output.

Step 2: Run geogrid.exe and metgrid.exe for two domains (as if you are making a 2-way nested run).

Step 3.
- Edit the namelist.input file, changing ‘max_dom = 2’, and making sure columns 1 and 2 are set-up for a 2 domain run, editing the correct start time and grid dimensions.
- Run real.exe for 2 domains.
- Rename the wrfinput_d02 file to wrfndi_d02.

Step 4.
- add io_form_auxinput2 = 2 in the &time_control section of namelist.input to run ndown.exe
- Set namelist variable interval_seconds to reflect the history output interval from the coarse domain model run.
- Do not change physics options until after running ndown program.
- Run ndown.exe, which uses input from the coarse grid wrfout file(s), and the wrfndi_d02 file generated from Step 3 above. This will produce a wrfinput_d02 and wrfbdy_d02 file.

Step 5.
- Rename wrfinput_d02 and wrfbdy_d02 to wrfinput_d01 and wrfbdy_d01, respectively.
- Rename (or move) the original wrfout_d01* files to something else (or another directory) so as to not overwrite them.
- Edit namelist.input,moving all of the fine-grid domain data from column 2 to column 1 so that this run will be for the fine-grid domain only. Make sure that the time_step is set to comply with the fine-grid domain (typically 6*DX). It may be beneficial to save namelist.input to something else prior to this step in case you need to repeat this process in the future.
- Users may take advantage of a feature that allows both the initial and lateral boundaries to use the moist and scalar arrays (have_bcs_moist and have_bcs_scalar, respectively). This option is only to be used during the WRF model run which follows the ndown processing. With this option, a user must keep the microphysics options the same between forecasts. The advantage is that the previous WRF model provides realistic lateral boundary tendencies for all of the microphysical variables, instead of a simple “zero inflow” or “zero gradient outflow”.
- Run WRF for this grid.

Time Series Output
Time series output. To activate the option, a file called “tslist” must be present in the WRF run directory. The tslist file contains a list of locations defined by their latitude and longitude along with a short description and an abbreviation for each location. A sample file looks something like this:

#-----------------------------------------------#
# 24 characters for name | pfx | LAT | LON |
#-----------------------------------------------#
Cape Hallett hallt -72.330 170.250
McMurdo Station mcm -77.851 166.713

The maximum number of time series locations is controlled by the namelist variable max_ts_locs in the namelist record &domains. The default value is 5. The time series output contains selected variables at the surface, including 2-m temperature, vapor mixing ratio, 10-m wind components, u and v, rotated to the earth coordinate, etc.. More information for time series output can be found in WRFV3/run/README.tslist.

Starting in V3.5, in addtion to surface variables, vertical profiles of earth-relative U and V, potential temperature, water vapor, and geopotential height will also be output. The default number of levels in the output is 15, but can be changed with namelist variable max_ts_level.

Examples of namelists for various applications

a. 1 to 4 km grid distances, convection-permitting runs for a 1- 3 day run: Page 5-30
b. 10 to 20 km grid distances: Page 5-31
e. Regional climate case at 10 to 30 km grid sizes: Page 5-32