# Initializing the WRF model with ECMWF ERA-Interim reanalysis

## Summarization

To summarise, you need three separate data files from the reanalysis data:

1. Pressure level data (or model levels)
2. Surface variable data
3. Fixed data.

You’ll be required to select which surface varibles you want to download, as well as which pressure levels, too. The land-sea mask is just a single file. According to 夏朗的芒果, we just need to download UNGRIB - Required Fields

The details of the Python API are here, it’s well explained so I will only summarise here what you need to do:

1. Register on the ECMWF site
3. Install the ecmwfapi Python module.
4. Either write your own python script using the API documentation above, or have the ECMWF web interface generate one for you. (Click the ‘view MARS request’ after making your selections, and then copy the Python script that is displayed. An example python script looks like this:

### fix.py

ECMWF provide the data in two different file formats, GRIB (gridded-binary) and netCDF (.nc files). WPS comes with the ungribber tool (ungrib.exe) so I’ve gone for the grib data format here. (Selected by default in the Python download script).

## Ungribbing the data

Now we need to ‘ungrib’ data to convert into the WPS intermediate file format, before running metgrid. This has to be done in two stages - one for the surface and pressure level data, and one for the land-sea mask. This is because the land-sea mask has a ‘start date’ of 1989-01-01 if you try to run ungrib with the date of your case study, ungrib will fail, complaining that the dates specified could not be found.

Link the correct Vtable to the file name “Vtable” in the directory. The Vtable can be found inWPS/ungrib/Variable_Tables/Vtable.ECMWF

1. Link GRIB files to the correct file names in the run directory.

2. Ungribbing the pressure level data.In the namelist.wps file, I set the the &ungrib section to the following:

3. Repeat again for the surface data:

4. Repeat again for the fixed data:

5. You should have these files now:

## Metgrid

If you are using the sea surface temparatures field from the ECMWF data, you’ll need to make a few changes to the METGRID.TBL file for it to correctly interpolate and mask the sea surface temparatures around land. In the METGRID.TBL file (located in WPS/metgrid/), change the entry of the SST field to the following:

The changes are to make the interp_mask use the LANDMASK mask instead of LANDSEA (the default), and to change the interpolation option slightly. Without the changes, Declan found that for his inner domain the sea surface temperatures were incorrectly masked, and had been interpolated over land as well. Although metgrid.exe did not complain when run, the met files generated caused an error when real.exe was run - generating an error message saying:

The changes to METGRID.TBL should remedy this error message.

Before running metgrid, there is one last change to make to the namelist.wps file:

Declan:

Hopefully it will produce all the input met files needed, and correctly interpolated. It’s a good idea before running real.exe and wrf.exe to check that the fields look reasonable. In particular, check the SST field if you are using sea-surface temperatures. Check the nested domains as well - I found that my SST field had been incorrectly interpolated in the inner domain, which required the change to the METGRID.TBL file above. Ncview is a useful utility for checking the met files generated by metgrid.